fern-api 0.56.17 → 0.56.18

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 +4 -4
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -1692,7 +1692,7 @@ ${c.indent}`:""}${uWf(o)}:${l.indent?" ":""}`;return u=!1,s=!0,l.objectItem=void
1692
1692
  `}),r.replaceAll(/\n$/g,"")}function nNS(e){return e?k_.green(l7.radioOn):l7.radioOff}var rOo=yi(gSe(),1);function $rp(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var rsa=class extends y2{_run(t){this.done=t;let r=ZU(this.rl),i=r.line.pipe((0,rOo.map)(this.filterInput.bind(this))),n=this.handleSubmitEvents(i);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),r.keypress.pipe((0,rOo.takeUntil)(n.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),i="";r+=this.status==="answered"?this.getMaskedValue(this.answer):this.getMaskedValue(this.rl.line||""),t&&(i=`
1693
1693
  `+k_.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?k_.cyan($rp(t,this.opt.mask)):k_.italic.dim("[hidden]"):this.opt.mask?$rp(t,this.opt.mask):k_.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 ynp=yi(vTs(),1),vnp=yi(gSe(),1);var dsa=class extends y2{_run(t){this.done=t,this.editorResult=new vnp.Subject;let r=ZU(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let i=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,n=this.handleSubmitEvents(this.editorResult);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,i?this.render():this.startExternalEditor(),this}render(t){let r="",i=this.getQuestion();i+=this.status==="answered"?k_.dim("Received"):k_.dim("Press <enter> to launch your preferred editor."),t&&(r=k_.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),(0,ynp.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 Snp=yi(Onp(),1);var jnp=yi(require("readline"),1),wnp=yi(Pnp(),1),Yxi=class{constructor(t){this.rl||=jnp.default.createInterface(JNS(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 JNS(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let n=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw n.isTtyError=!0,n}let r=new wnp.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var psa=class extends Yxi{constructor(t={}){super(t),this.log=(0,Snp.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return Jua(this.rl,this.bottomBar.split(`
1694
1694
  `).length),this}updateBottomBar(t){return Jua(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+`
1695
- `}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&&Zgo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var Inp=yi(Mnp(),1),znp=yi(SAs(),1),Rnp=yi(Bnp(),1),LA=yi(gSe(),1),Nnp=yi(iua(),1);var POo=yi(gSe(),1),xnp=yi(iua(),1),jOo=function(e,t,r){return typeof e[t]!="function"?(0,POo.of)(e):(0,POo.from)((0,xnp.default)(e[t])(r).then(i=>(e[t]=i,e)))};var _sa={isPlainObject:Inp.default,set:Rnp.default,get:znp.default},zOn=class extends Yxi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=_sa.isPlainObject(r)?{...r}:{},_sa.isPlainObject(t)&&(t=Object.values(t).every(n=>_sa.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,LA.from)(t):t;return this.process=i.pipe((0,LA.concatMap)(this.processQuestion.bind(this)),(0,LA.publish)()),this.process.connect(),this.process.pipe((0,LA.reduce)((n,a)=>(_sa.set(n,a.name,a.answer),n),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,LA.defer)(()=>(0,LA.of)(t).pipe((0,LA.concatMap)(this.setDefaultType.bind(this)),(0,LA.concatMap)(this.filterIfRunnable.bind(this)),(0,LA.concatMap)(()=>jOo(t,"message",this.answers)),(0,LA.concatMap)(()=>jOo(t,"default",this.answers)),(0,LA.concatMap)(()=>jOo(t,"choices",this.answers)),(0,LA.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,LA.defer)(()=>(0,LA.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,LA.defer)(()=>(0,LA.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&_sa.get(this.answers,t.name)!==void 0)return(0,LA.empty)();if(t.when===!1)return(0,LA.empty)();if(typeof t.when!="function")return(0,LA.of)(t);let{answers:r}=this;return(0,LA.defer)(()=>(0,LA.from)((0,Nnp.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,LA.filter)(i=>i!=null)))}};function Fnp(e){let t=function(r,i){let n;try{n=new zOn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",Yua),this.registerPrompt("input",Vxi),this.registerPrompt("number",Xua),this.registerPrompt("confirm",Zua),this.registerPrompt("rawlist",kua),this.registerPrompt("expand",esa),this.registerPrompt("checkbox",tsa),this.registerPrompt("password",rsa),this.registerPrompt("editor",dsa)},t.restoreDefaultPrompts(),t}var OTs=Fnp();function dFS(e,t){OTs.registerPrompt(e,t)}function pFS(){OTs.restoreDefaultPrompts()}var _FS={prompt:OTs,ui:{BottomBar:psa,Prompt:zOn},createPromptModule:Fnp,registerPrompt:dFS,restoreDefaultPrompts:pFS,Separator:oie},wOo=_FS;var Yap=yi(Lnp()),U7S="4.2.1",$8t;(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"})($8t||($8t={}));function V7S(e,t){if(!e)throw new Error(t)}function W7S(e){return e?.replace(/\/+$/,"")}async function H7S(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function $7S(){return new Date().getTime()}function Vap(){return new Date().toISOString()}function Xap(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var Ssa=String.fromCharCode,Wap="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",FOo={};function G7S(e,t){if(!FOo[e]){FOo[e]={};for(let r=0;r<e.length;r++)FOo[e][e.charAt(r)]=r}return FOo[e][t]}var Dsa={compressToBase64:function(e){if(e==null)return"";let t=Dsa._compress(e,6,function(r){return Wap.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:Dsa._decompress(e.length,32,function(t){return G7S(Wap,e.charAt(t))})},compress:function(e){return Dsa._compress(e,16,function(t){return Ssa(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,d="",s="",o="",c=2,b=3,g=2,O=0,m=0,w;for(w=0;w<e.length;w+=1)if(d=e.charAt(w),Object.prototype.hasOwnProperty.call(i,d)||(i[d]=b++,n[d]=!0),s=o+d,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:Dsa._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,d=3,s="",o,c,b,g,O,m,w;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=Ssa(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=Ssa(b);break;case 2:return""}for(i[3]=w,c=w,n.push(w);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,d),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(w=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=Ssa(b),w=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=Ssa(b),w=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,d),d++),i[w])s=i[w];else if(w===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,d),d++)}}},nCs=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(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}};var LOo="0123456789abcdef",UOo=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,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>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|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,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 i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=LOo.charAt(this.bytes[r]>>>4),t+=LOo.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+=LOo.charAt(this.bytes[r]>>>4),t+=LOo.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 i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},aCs=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??Q7S()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}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 UOo.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,UOo.ofInner(t)}},Q7S=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Hap,$ap=()=>J7S().toString(),J7S=()=>(Hap||(Hap=new aCs)).generate(),VOo=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},Esa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function Gap(e){return typeof e=="object"&&(e instanceof VOo||e instanceof Esa)}var oCs=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new nCs,this._isInitialized=!1,V7S(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=W7S(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:Gap},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($8t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty($8t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty($8t.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));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=$ap();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let l=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",l,n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.fetchWithRetry(u,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(d=>d.json()).catch(d=>{this._events.emit("error",d)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagsStateless(r,i,n,a,u);if(!l)return;let d=l[t];return d===void 0&&(d=!1),d}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u);if(!l)return;let d=l[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let l=await this.getDecide(t,r,i,n,u),d=l?.featureFlags,s=l?.featureFlagPayloads,o=s;return s&&(o=Object.fromEntries(Object.entries(s).map(([c,b])=>[c,this._parsePayload(b)]))),{flags:d,payloads:o}}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:Vap(),uuid:i?.uuid?i.uuid:$ap()};(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId);let u=this.getPersistedProperty($8t.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:n}),this.setPersistedProperty($8t.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=Xap(()=>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($8t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty($8t.Queue)||[];this.setPersistedProperty($8t.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:Vap()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${$7S()}&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(Dsa.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(l,d)}catch(s){throw s instanceof Esa||n(),this._events.emit("error",s),s}return n(),this._events.emit("flush",i),i}async fetchWithRetry(t,r,i,n){var a;return(a=AbortSignal).timeout??(a.timeout=function(l){let d=new AbortController;return setTimeout(()=>d.abort(),l),d.signal}),await H7S(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(d){throw new Esa(d)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new VOo(u);return u},{...this._retryOptions,...i})}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($8t.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!Gap(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},uCs=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},sCs=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!sCs){let e=Uap();sCs=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var Zap=sCs,K7S=1152921504606847e3,Y7S=["is_not"],WOo=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},v2=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},cCs=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...l}){this.debugMode=!1,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=l.fetch||Zap,this.onError=l.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,l;if(!this.loadedSuccessfullyOnce)return u;for(let d of this.featureFlags)if(t===d.key){l=d;break}if(l!==void 0)try{u=this.computeFlagLocally(l,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(d){d instanceof v2?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 i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return this.featureFlags.map(async d=>{try{let s=this.computeFlagLocally(d,t,r,i,n);a[d.key]=s;let o=await this.computeFeatureFlagPayloadLocally(d.key,s);o&&(u[d.key]=o)}catch(s){s instanceof v2||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${s}`)),l=!0}}),{response:a,payloads:u,fallbackToDecide:l}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new v2("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let d=this.groupTypeMapping[String(l)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new v2("Flag has unknown group type index");if(!(d in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[d];return this.matchFeatureFlagProperties(t,i[d],s)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,d=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of d)try{if(this.isConditionMatch(t,r,s,i)){let o=s.variant,c=n.multivariate?.variants||[];o&&c.some(b=>b.key===o)?l=o:l=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof v2)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new v2("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=l=>{this.logMsgIfDebug(()=>console.warn(l))};if((i.properties||[]).length>0){for(let l of i.properties){let d=l.type,s=!1;if(d==="cohort"?s=eop(l,n,this.cohorts,this.debugMode):s=kap(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&Qap(t.key,r)>a/100)}getMatchingVariant(t,r){let i=Qap(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(l=>{n=i+l.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:l.key}),i=n}),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 WOo("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((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0}catch(t){t instanceof WOo&&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}`}},i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=Xap(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function Qap(e,t,r=""){let i=(0,Yap.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/K7S}function kap(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new v2("Operator is_not_set is not supported")}else throw new v2(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!Y7S.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function d(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return Jap(String(n))&&String(u).match(String(n))!==null;case"not_regex":return Jap(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?d(u,String(n),a):d(u,s,a):d(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=X7S(String(n));if(s==null&&(s=Kap(n)),s==null)throw new v2(`Invalid date: ${n}`);let o=Kap(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new v2(`Unknown operator: ${a}`)}}function eop(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new v2("can't match cohort without a given cohort property value");let a=r[n];return top(a,t,r,i)}function top(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let d=top(l,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof v2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new v2("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let d;l.type==="cohort"?d=eop(l,t,r,i):d=kap(l,t);let s=l.negation||!1;if(n==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof v2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new v2("can't match cohort without a given cohort property value");return n==="AND"}}function Jap(e){try{return new RegExp(e),!0}catch{return!1}}function Kap(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 v2(`${e} is in an invalid date format`)}else throw new v2(`The date provided ${e} must be a string, number, or date object`)}function X7S(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var Z7S=30*1e3,k7S=50*1e3,WOn=class extends oCs{constructor(t,r={}){super(t,r),this._memoryStorage=new uCs,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new cCs({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:Z7S,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||k7S}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):Zap(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return U7S}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:i,groups:n,sendFeatureFlags:a,timestamp:u,disableGeoip:l,uuid:d}){let s=b=>{super.captureStateless(t,r,b,{timestamp:u,disableGeoip:l,uuid:d})},o=(b,g,O)=>super.getFeatureFlagsStateless(b,g,void 0,void 0,O),c=Promise.resolve().then(async()=>{if(a)return await o(t,n,l);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let b={};for(let[g,O]of Object.entries(n||{}))b[g]=String(O);return await this.getAllFlags(t,{groups:b,disableGeoip:l,onlyEvaluateLocally:!0})}return{}}).then(b=>{let g={};if(b)for(let[m,w]of Object.entries(b))g[`$feature/${m}`]=w;let O=Object.keys(b||{}).filter(m=>b?.[m]!==!1);return O.length>0&&(g.$active_feature_flags=O),g}).catch(()=>({})).then(b=>{s({...b,...i,$groups:n})});this.addPendingPromise(c)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties:d,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,d,s);d=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,d,s),b=c!==void 0;!b&&!u&&(c=await super.getFeatureFlagStateless(t,r,n,d,s,a));let g=`${t}_${c}`;return l&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(g))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(g):this.distinctIdHasSentFlagCalls[r]=[g],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:c,locally_evaluated:b,[`$feature/${t}`]:c},groups:n,disableGeoip:a})),c}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:l,sendFeatureFlagEvents:d,personProperties:s,groupProperties:o}=n||{},c=this.addLocalPersonAndGroupProperties(r,a,s,o);s=c.allPersonProperties,o=c.allGroupProperties;let b;return i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i)),l==null&&(l=!1),d==null&&(d=!0),l==null&&(l=!1),!(b!==void 0)&&!l&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:l}=r||{},d=this.addLocalPersonAndGroupProperties(t,i,u,l);u=d.allPersonProperties,l=d.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}},lCs=class e{constructor(t,r,i,n){this.posthog=t,this.posthogHost=r,this.organization=i,this.prefix=n,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(i=>{if(i.exception?.values===void 0||i.exception.values.length===0)return i;i.tags||(i.tags={});let n=r(),a=i.tags[e.POSTHOG_ID_TAG];if(a===void 0)return i;i.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:i.exception.values[0]?.value,$exception_type:i.exception.values[0]?.type,$exception_personURL:i.tags["PostHog Person URL"],$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:i.exception.values[0]?.value,$sentry_exception_type:i.exception.values[0]?.type,$sentry_tags:i.tags},l=n.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&l!==void 0&&i.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${l}&query=${i.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),i})}};lCs.POSTHOG_ID_TAG="posthog_distinct_id";var HOo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new WOn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.56.17",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var Msa=class{async sendEvent(){}async identify(){}async flush(){}};var HOn=require("fs/promises"),aop=require("os"),oop=require("path");var rop=yi(require("crypto")),GOo=new Uint8Array(256),$Oo=GOo.length;function fCs(){return $Oo>GOo.length-16&&(rop.default.randomFillSync(GOo),$Oo=0),GOo.slice($Oo,$Oo+=16)}var tV=[];for(let e=0;e<256;++e)tV.push((e+256).toString(16).slice(1));function iop(e,t=0){return tV[e[t+0]]+tV[e[t+1]]+tV[e[t+2]]+tV[e[t+3]]+"-"+tV[e[t+4]]+tV[e[t+5]]+"-"+tV[e[t+6]]+tV[e[t+7]]+"-"+tV[e[t+8]]+tV[e[t+9]]+"-"+tV[e[t+10]]+tV[e[t+11]]+tV[e[t+12]]+tV[e[t+13]]+tV[e[t+14]]+tV[e[t+15]]}var nop=yi(require("crypto")),dCs={randomUUID:nop.default.randomUUID};function e6S(e,t,r){if(dCs.randomUUID&&!t&&!e)return dCs.randomUUID();e=e||{};let i=e.random||(e.rng||fCs)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return iop(i)}var fie=e6S;var t6S="id",r6S=".fern",Asa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new WOn(r),this.userId=t==null?void 0:M1s(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.56.17",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Xu(Wl.of((0,aop.homedir)()),Xa.of(r6S),Xa.of(t6S));await Cf(t)||(await(0,HOn.mkdir)((0,oop.dirname)(t),{recursive:!0}),await(0,HOn.writeFile)(t,fie())),this.persistedDistinctId=(await(0,HOn.readFile)(t)).toString()}return this.persistedDistinctId}};var pCs;async function $On(){return pCs==null&&(pCs=await i6S()),pCs}async function i6S(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Msa;let r=await Z_o();return r!=null?new Asa({token:r,posthogApiKey:e}):await X_o()!=null?new HOo({posthogApiKey:e}):new Asa({token:void 0,posthogApiKey:e})}catch{return new Msa}}function qsa(e,t){return function(){return e.apply(t,arguments)}}var{toString:n6S}=Object.prototype,{getPrototypeOf:hCs}=Object,JOo=(e=>t=>{let r=n6S.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),G8t=e=>(e=e.toLowerCase(),t=>JOo(t)===e),KOo=e=>t=>typeof t===e,{isArray:GOn}=Array,Tsa=KOo("undefined");function a6S(e){return e!==null&&!Tsa(e)&&e.constructor!==null&&!Tsa(e.constructor)&&mSe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var sop=G8t("ArrayBuffer");function o6S(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&sop(e.buffer),t}var u6S=KOo("string"),mSe=KOo("function"),cop=KOo("number"),YOo=e=>e!==null&&typeof e=="object",s6S=e=>e===!0||e===!1,QOo=e=>{if(JOo(e)!=="object")return!1;let t=hCs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},c6S=G8t("Date"),l6S=G8t("File"),f6S=G8t("Blob"),d6S=G8t("FileList"),p6S=e=>YOo(e)&&mSe(e.pipe),_6S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||mSe(e.append)&&((t=JOo(e))==="formdata"||t==="object"&&mSe(e.toString)&&e.toString()==="[object FormData]"))},h6S=G8t("URLSearchParams"),[y6S,v6S,b6S,g6S]=["ReadableStream","Request","Response","Headers"].map(G8t),O6S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Csa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),GOn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,l;for(i=0;i<u;i++)l=a[i],t.call(null,e[l],l,e)}}function lop(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var tIi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,fop=e=>!Tsa(e)&&e!==tIi;function _Cs(){let{caseless:e}=fop(this)&&this||{},t={},r=(i,n)=>{let a=e&&lop(t,n)||n;QOo(t[a])&&QOo(i)?t[a]=_Cs(t[a],i):QOo(i)?t[a]=_Cs({},i):GOn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&Csa(arguments[i],r);return t}var m6S=(e,t,r,{allOwnKeys:i}={})=>(Csa(t,(n,a)=>{r&&mSe(n)?e[a]=qsa(n,r):e[a]=n},{allOwnKeys:i}),e),P6S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),j6S=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},w6S=(e,t,r,i)=>{let n,a,u,l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!l[u]&&(t[u]=e[u],l[u]=!0);e=r!==!1&&hCs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},S6S=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},D6S=e=>{if(!e)return null;if(GOn(e))return e;let t=e.length;if(!cop(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},E6S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&hCs(Uint8Array)),M6S=(e,t)=>{let i=(e&&e[Symbol.iterator]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},A6S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},q6S=G8t("HTMLFormElement"),T6S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),uop=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),C6S=G8t("RegExp"),dop=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};Csa(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},B6S=e=>{dop(e,(t,r)=>{if(mSe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(mSe(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},x6S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return GOn(e)?i(e):i(String(e).split(t)),r},I6S=()=>{},z6S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function R6S(e){return!!(e&&mSe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var N6S=e=>{let t=new Array(10),r=(i,n)=>{if(YOo(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=GOn(i)?[]:{};return Csa(i,(u,l)=>{let d=r(u,n+1);!Tsa(d)&&(a[l]=d)}),t[n]=void 0,a}}return i};return r(e,0)},F6S=G8t("AsyncFunction"),L6S=e=>e&&(YOo(e)||mSe(e))&&mSe(e.then)&&mSe(e.catch),pop=((e,t)=>e?setImmediate:t?((r,i)=>(tIi.addEventListener("message",({source:n,data:a})=>{n===tIi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),tIi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",mSe(tIi.postMessage)),U6S=typeof queueMicrotask<"u"?queueMicrotask.bind(tIi):typeof process<"u"&&process.nextTick||pop,ds={isArray:GOn,isArrayBuffer:sop,isBuffer:a6S,isFormData:_6S,isArrayBufferView:o6S,isString:u6S,isNumber:cop,isBoolean:s6S,isObject:YOo,isPlainObject:QOo,isReadableStream:y6S,isRequest:v6S,isResponse:b6S,isHeaders:g6S,isUndefined:Tsa,isDate:c6S,isFile:l6S,isBlob:f6S,isRegExp:C6S,isFunction:mSe,isStream:p6S,isURLSearchParams:h6S,isTypedArray:E6S,isFileList:d6S,forEach:Csa,merge:_Cs,extend:m6S,trim:O6S,stripBOM:P6S,inherits:j6S,toFlatObject:w6S,kindOf:JOo,kindOfTest:G8t,endsWith:S6S,toArray:D6S,forEachEntry:M6S,matchAll:A6S,isHTMLForm:q6S,hasOwnProperty:uop,hasOwnProp:uop,reduceDescriptors:dop,freezeMethods:B6S,toObjectSet:x6S,toCamelCase:T6S,noop:I6S,toFiniteNumber:z6S,findKey:lop,global:tIi,isContextDefined:fop,isSpecCompliantForm:R6S,toJSONObject:N6S,isAsyncFn:F6S,isThenable:L6S,setImmediate:pop,asap:U6S};function QOn(e,t,r,i,n){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),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}ds.inherits(QOn,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:ds.toJSONObject(this.config),code:this.code,status:this.status}}});var _op=QOn.prototype,hop={};["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=>{hop[e]={value:e}});Object.defineProperties(QOn,hop);Object.defineProperty(_op,"isAxiosError",{value:!0});QOn.from=(e,t,r,i,n,a)=>{let u=Object.create(_op);return ds.toFlatObject(e,u,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),QOn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var wp=QOn;var yop=yi(ora(),1),XOo=yop.default;function yCs(e){return ds.isPlainObject(e)||ds.isArray(e)}function bop(e){return ds.endsWith(e,"[]")?e.slice(0,-2):e}function vop(e,t,r){return e?e.concat(t).map(function(n,a){return n=bop(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function V6S(e){return ds.isArray(e)&&!e.some(yCs)}var W6S=ds.toFlatObject(ds,{},null,function(t){return/^is[A-Z]/.test(t)});function H6S(e,t,r){if(!ds.isObject(e))throw new TypeError("target must be an object");t=t||new(XOo||FormData),r=ds.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,w){return!ds.isUndefined(w[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&ds.isSpecCompliantForm(t);if(!ds.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(ds.isDate(O))return O.toISOString();if(!d&&ds.isBlob(O))throw new wp("Blob is not supported. Use a Buffer instead.");return ds.isArrayBuffer(O)||ds.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,w){let E=O;if(O&&!w&&typeof O=="object"){if(ds.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(ds.isArray(O)&&V6S(O)||(ds.isFileList(O)||ds.endsWith(m,"[]"))&&(E=ds.toArray(O)))return m=bop(m),E.forEach(function(q,D){!(ds.isUndefined(q)||q===null)&&t.append(u===!0?vop([m],D,a):u===null?m:m+"[]",s(q))}),!1}return yCs(O)?!0:(t.append(vop(w,m,a),s(O)),!1)}let c=[],b=Object.assign(W6S,{defaultVisitor:o,convertValue:s,isVisitable:yCs});function g(O,m){if(!ds.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),ds.forEach(O,function(E,A){(!(ds.isUndefined(E)||E===null)&&n.call(t,E,ds.isString(A)?A.trim():A,m,b))===!0&&g(E,m?m.concat(A):[A])}),c.pop()}}if(!ds.isObject(e))throw new TypeError("data must be an object");return g(e),t}var xli=H6S;function gop(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function Oop(e,t){this._pairs=[],e&&xli(e,this,t)}var mop=Oop.prototype;mop.append=function(t,r){this._pairs.push([t,r])};mop.toString=function(t){let r=t?function(i){return t.call(this,i,gop)}:gop;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var Pop=Oop;function $6S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function rIi(e,t,r){if(!t)return e;let i=r&&r.encode||$6S;ds.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=ds.isURLSearchParams(t)?t.toString():new Pop(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var vCs=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){ds.forEach(this.handlers,function(i){i!==null&&t(i)})}},bCs=vCs;var JOn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var Dop=yi(require("crypto"),1);var jop=yi(require("url"),1),wop=jop.default.URLSearchParams;var gCs="abcdefghijklmnopqrstuvwxyz",Sop="0123456789",Eop={DIGIT:Sop,ALPHA:gCs,ALPHA_DIGIT:gCs+gCs.toUpperCase()+Sop},G6S=(e=16,t=Eop.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);Dop.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},Mop={isNode:!0,classes:{URLSearchParams:wop,FormData:XOo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:Eop,generateString:G6S,protocols:["http","https","file","data"]};var PCs={};Co(PCs,{hasBrowserEnv:()=>mCs,hasStandardBrowserEnv:()=>Q6S,hasStandardBrowserWebWorkerEnv:()=>J6S,navigator:()=>OCs,origin:()=>K6S});var mCs=typeof window<"u"&&typeof document<"u",OCs=typeof navigator=="object"&&navigator||void 0,Q6S=mCs&&(!OCs||["ReactNative","NativeScript","NS"].indexOf(OCs.product)<0),J6S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",K6S=mCs&&window.location.href||"http://localhost";var PM={...PCs,...Mop};function jCs(e,t){return xli(e,new PM.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return PM.isNode&&ds.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function Y6S(e){return ds.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function X6S(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function Z6S(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),d=a>=r.length;return u=!u&&ds.isArray(n)?n.length:u,d?(ds.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!ds.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&ds.isArray(n[u])&&(n[u]=X6S(n[u])),!l)}if(ds.isFormData(e)&&ds.isFunction(e.entries)){let r={};return ds.forEachEntry(e,(i,n)=>{t(Y6S(i),n,r,0)}),r}return null}var ZOo=Z6S;function k6S(e,t,r){if(ds.isString(e))try{return(t||JSON.parse)(e),ds.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var wCs={transitional:JOn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=ds.isObject(t);if(a&&ds.isHTMLForm(t)&&(t=new FormData(t)),ds.isFormData(t))return n?JSON.stringify(ZOo(t)):t;if(ds.isArrayBuffer(t)||ds.isBuffer(t)||ds.isStream(t)||ds.isFile(t)||ds.isBlob(t)||ds.isReadableStream(t))return t;if(ds.isArrayBufferView(t))return t.buffer;if(ds.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return jCs(t,this.formSerializer).toString();if((l=ds.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return xli(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),k6S(t)):t}],transformResponse:[function(t){let r=this.transitional||wCs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(ds.isResponse(t)||ds.isReadableStream(t))return t;if(t&&ds.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?wp.from(l,wp.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:PM.classes.FormData,Blob:PM.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ds.forEach(["delete","get","head","post","put","patch"],e=>{wCs.headers[e]={}});var KOn=wCs;var e2S=ds.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"]),Aop=e=>{let t={},r,i,n;return e&&e.split(`
1695
+ `}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&&Zgo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var Inp=yi(Mnp(),1),znp=yi(SAs(),1),Rnp=yi(Bnp(),1),LA=yi(gSe(),1),Nnp=yi(iua(),1);var POo=yi(gSe(),1),xnp=yi(iua(),1),jOo=function(e,t,r){return typeof e[t]!="function"?(0,POo.of)(e):(0,POo.from)((0,xnp.default)(e[t])(r).then(i=>(e[t]=i,e)))};var _sa={isPlainObject:Inp.default,set:Rnp.default,get:znp.default},zOn=class extends Yxi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=_sa.isPlainObject(r)?{...r}:{},_sa.isPlainObject(t)&&(t=Object.values(t).every(n=>_sa.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,LA.from)(t):t;return this.process=i.pipe((0,LA.concatMap)(this.processQuestion.bind(this)),(0,LA.publish)()),this.process.connect(),this.process.pipe((0,LA.reduce)((n,a)=>(_sa.set(n,a.name,a.answer),n),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,LA.defer)(()=>(0,LA.of)(t).pipe((0,LA.concatMap)(this.setDefaultType.bind(this)),(0,LA.concatMap)(this.filterIfRunnable.bind(this)),(0,LA.concatMap)(()=>jOo(t,"message",this.answers)),(0,LA.concatMap)(()=>jOo(t,"default",this.answers)),(0,LA.concatMap)(()=>jOo(t,"choices",this.answers)),(0,LA.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,LA.defer)(()=>(0,LA.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,LA.defer)(()=>(0,LA.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&_sa.get(this.answers,t.name)!==void 0)return(0,LA.empty)();if(t.when===!1)return(0,LA.empty)();if(typeof t.when!="function")return(0,LA.of)(t);let{answers:r}=this;return(0,LA.defer)(()=>(0,LA.from)((0,Nnp.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,LA.filter)(i=>i!=null)))}};function Fnp(e){let t=function(r,i){let n;try{n=new zOn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",Yua),this.registerPrompt("input",Vxi),this.registerPrompt("number",Xua),this.registerPrompt("confirm",Zua),this.registerPrompt("rawlist",kua),this.registerPrompt("expand",esa),this.registerPrompt("checkbox",tsa),this.registerPrompt("password",rsa),this.registerPrompt("editor",dsa)},t.restoreDefaultPrompts(),t}var OTs=Fnp();function dFS(e,t){OTs.registerPrompt(e,t)}function pFS(){OTs.restoreDefaultPrompts()}var _FS={prompt:OTs,ui:{BottomBar:psa,Prompt:zOn},createPromptModule:Fnp,registerPrompt:dFS,restoreDefaultPrompts:pFS,Separator:oie},wOo=_FS;var Yap=yi(Lnp()),U7S="4.2.1",$8t;(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"})($8t||($8t={}));function V7S(e,t){if(!e)throw new Error(t)}function W7S(e){return e?.replace(/\/+$/,"")}async function H7S(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function $7S(){return new Date().getTime()}function Vap(){return new Date().toISOString()}function Xap(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var Ssa=String.fromCharCode,Wap="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",FOo={};function G7S(e,t){if(!FOo[e]){FOo[e]={};for(let r=0;r<e.length;r++)FOo[e][e.charAt(r)]=r}return FOo[e][t]}var Dsa={compressToBase64:function(e){if(e==null)return"";let t=Dsa._compress(e,6,function(r){return Wap.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:Dsa._decompress(e.length,32,function(t){return G7S(Wap,e.charAt(t))})},compress:function(e){return Dsa._compress(e,16,function(t){return Ssa(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,d="",s="",o="",c=2,b=3,g=2,O=0,m=0,w;for(w=0;w<e.length;w+=1)if(d=e.charAt(w),Object.prototype.hasOwnProperty.call(i,d)||(i[d]=b++,n[d]=!0),s=o+d,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:Dsa._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,d=3,s="",o,c,b,g,O,m,w;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=Ssa(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=Ssa(b);break;case 2:return""}for(i[3]=w,c=w,n.push(w);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,d),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(w=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=Ssa(b),w=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=Ssa(b),w=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,d),d++),i[w])s=i[w];else if(w===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,d),d++)}}},nCs=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(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}};var LOo="0123456789abcdef",UOo=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,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>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|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,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 i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=LOo.charAt(this.bytes[r]>>>4),t+=LOo.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+=LOo.charAt(this.bytes[r]>>>4),t+=LOo.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 i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},aCs=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??Q7S()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}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 UOo.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,UOo.ofInner(t)}},Q7S=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Hap,$ap=()=>J7S().toString(),J7S=()=>(Hap||(Hap=new aCs)).generate(),VOo=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},Esa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function Gap(e){return typeof e=="object"&&(e instanceof VOo||e instanceof Esa)}var oCs=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new nCs,this._isInitialized=!1,V7S(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=W7S(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:Gap},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($8t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty($8t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty($8t.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));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=$ap();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let l=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",l,n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.fetchWithRetry(u,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(d=>d.json()).catch(d=>{this._events.emit("error",d)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagsStateless(r,i,n,a,u);if(!l)return;let d=l[t];return d===void 0&&(d=!1),d}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u);if(!l)return;let d=l[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let l=await this.getDecide(t,r,i,n,u),d=l?.featureFlags,s=l?.featureFlagPayloads,o=s;return s&&(o=Object.fromEntries(Object.entries(s).map(([c,b])=>[c,this._parsePayload(b)]))),{flags:d,payloads:o}}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:Vap(),uuid:i?.uuid?i.uuid:$ap()};(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId);let u=this.getPersistedProperty($8t.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:n}),this.setPersistedProperty($8t.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=Xap(()=>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($8t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty($8t.Queue)||[];this.setPersistedProperty($8t.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:Vap()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${$7S()}&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(Dsa.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(l,d)}catch(s){throw s instanceof Esa||n(),this._events.emit("error",s),s}return n(),this._events.emit("flush",i),i}async fetchWithRetry(t,r,i,n){var a;return(a=AbortSignal).timeout??(a.timeout=function(l){let d=new AbortController;return setTimeout(()=>d.abort(),l),d.signal}),await H7S(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(d){throw new Esa(d)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new VOo(u);return u},{...this._retryOptions,...i})}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($8t.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!Gap(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},uCs=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},sCs=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!sCs){let e=Uap();sCs=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var Zap=sCs,K7S=1152921504606847e3,Y7S=["is_not"],WOo=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},v2=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},cCs=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...l}){this.debugMode=!1,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=l.fetch||Zap,this.onError=l.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,l;if(!this.loadedSuccessfullyOnce)return u;for(let d of this.featureFlags)if(t===d.key){l=d;break}if(l!==void 0)try{u=this.computeFlagLocally(l,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(d){d instanceof v2?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 i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return this.featureFlags.map(async d=>{try{let s=this.computeFlagLocally(d,t,r,i,n);a[d.key]=s;let o=await this.computeFeatureFlagPayloadLocally(d.key,s);o&&(u[d.key]=o)}catch(s){s instanceof v2||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${s}`)),l=!0}}),{response:a,payloads:u,fallbackToDecide:l}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new v2("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let d=this.groupTypeMapping[String(l)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new v2("Flag has unknown group type index");if(!(d in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[d];return this.matchFeatureFlagProperties(t,i[d],s)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,d=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of d)try{if(this.isConditionMatch(t,r,s,i)){let o=s.variant,c=n.multivariate?.variants||[];o&&c.some(b=>b.key===o)?l=o:l=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof v2)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new v2("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=l=>{this.logMsgIfDebug(()=>console.warn(l))};if((i.properties||[]).length>0){for(let l of i.properties){let d=l.type,s=!1;if(d==="cohort"?s=eop(l,n,this.cohorts,this.debugMode):s=kap(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&Qap(t.key,r)>a/100)}getMatchingVariant(t,r){let i=Qap(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(l=>{n=i+l.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:l.key}),i=n}),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 WOo("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((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0}catch(t){t instanceof WOo&&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}`}},i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=Xap(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function Qap(e,t,r=""){let i=(0,Yap.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/K7S}function kap(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new v2("Operator is_not_set is not supported")}else throw new v2(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!Y7S.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function d(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return Jap(String(n))&&String(u).match(String(n))!==null;case"not_regex":return Jap(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?d(u,String(n),a):d(u,s,a):d(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=X7S(String(n));if(s==null&&(s=Kap(n)),s==null)throw new v2(`Invalid date: ${n}`);let o=Kap(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new v2(`Unknown operator: ${a}`)}}function eop(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new v2("can't match cohort without a given cohort property value");let a=r[n];return top(a,t,r,i)}function top(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let d=top(l,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof v2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new v2("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let d;l.type==="cohort"?d=eop(l,t,r,i):d=kap(l,t);let s=l.negation||!1;if(n==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof v2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new v2("can't match cohort without a given cohort property value");return n==="AND"}}function Jap(e){try{return new RegExp(e),!0}catch{return!1}}function Kap(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 v2(`${e} is in an invalid date format`)}else throw new v2(`The date provided ${e} must be a string, number, or date object`)}function X7S(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var Z7S=30*1e3,k7S=50*1e3,WOn=class extends oCs{constructor(t,r={}){super(t,r),this._memoryStorage=new uCs,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new cCs({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:Z7S,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||k7S}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):Zap(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return U7S}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:i,groups:n,sendFeatureFlags:a,timestamp:u,disableGeoip:l,uuid:d}){let s=b=>{super.captureStateless(t,r,b,{timestamp:u,disableGeoip:l,uuid:d})},o=(b,g,O)=>super.getFeatureFlagsStateless(b,g,void 0,void 0,O),c=Promise.resolve().then(async()=>{if(a)return await o(t,n,l);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let b={};for(let[g,O]of Object.entries(n||{}))b[g]=String(O);return await this.getAllFlags(t,{groups:b,disableGeoip:l,onlyEvaluateLocally:!0})}return{}}).then(b=>{let g={};if(b)for(let[m,w]of Object.entries(b))g[`$feature/${m}`]=w;let O=Object.keys(b||{}).filter(m=>b?.[m]!==!1);return O.length>0&&(g.$active_feature_flags=O),g}).catch(()=>({})).then(b=>{s({...b,...i,$groups:n})});this.addPendingPromise(c)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties:d,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,d,s);d=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,d,s),b=c!==void 0;!b&&!u&&(c=await super.getFeatureFlagStateless(t,r,n,d,s,a));let g=`${t}_${c}`;return l&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(g))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(g):this.distinctIdHasSentFlagCalls[r]=[g],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:c,locally_evaluated:b,[`$feature/${t}`]:c},groups:n,disableGeoip:a})),c}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:l,sendFeatureFlagEvents:d,personProperties:s,groupProperties:o}=n||{},c=this.addLocalPersonAndGroupProperties(r,a,s,o);s=c.allPersonProperties,o=c.allGroupProperties;let b;return i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i)),l==null&&(l=!1),d==null&&(d=!0),l==null&&(l=!1),!(b!==void 0)&&!l&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:l}=r||{},d=this.addLocalPersonAndGroupProperties(t,i,u,l);u=d.allPersonProperties,l=d.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}},lCs=class e{constructor(t,r,i,n){this.posthog=t,this.posthogHost=r,this.organization=i,this.prefix=n,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(i=>{if(i.exception?.values===void 0||i.exception.values.length===0)return i;i.tags||(i.tags={});let n=r(),a=i.tags[e.POSTHOG_ID_TAG];if(a===void 0)return i;i.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:i.exception.values[0]?.value,$exception_type:i.exception.values[0]?.type,$exception_personURL:i.tags["PostHog Person URL"],$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:i.exception.values[0]?.value,$sentry_exception_type:i.exception.values[0]?.type,$sentry_tags:i.tags},l=n.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&l!==void 0&&i.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${l}&query=${i.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),i})}};lCs.POSTHOG_ID_TAG="posthog_distinct_id";var HOo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new WOn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.56.18",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var Msa=class{async sendEvent(){}async identify(){}async flush(){}};var HOn=require("fs/promises"),aop=require("os"),oop=require("path");var rop=yi(require("crypto")),GOo=new Uint8Array(256),$Oo=GOo.length;function fCs(){return $Oo>GOo.length-16&&(rop.default.randomFillSync(GOo),$Oo=0),GOo.slice($Oo,$Oo+=16)}var tV=[];for(let e=0;e<256;++e)tV.push((e+256).toString(16).slice(1));function iop(e,t=0){return tV[e[t+0]]+tV[e[t+1]]+tV[e[t+2]]+tV[e[t+3]]+"-"+tV[e[t+4]]+tV[e[t+5]]+"-"+tV[e[t+6]]+tV[e[t+7]]+"-"+tV[e[t+8]]+tV[e[t+9]]+"-"+tV[e[t+10]]+tV[e[t+11]]+tV[e[t+12]]+tV[e[t+13]]+tV[e[t+14]]+tV[e[t+15]]}var nop=yi(require("crypto")),dCs={randomUUID:nop.default.randomUUID};function e6S(e,t,r){if(dCs.randomUUID&&!t&&!e)return dCs.randomUUID();e=e||{};let i=e.random||(e.rng||fCs)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return iop(i)}var fie=e6S;var t6S="id",r6S=".fern",Asa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new WOn(r),this.userId=t==null?void 0:M1s(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.56.18",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Xu(Wl.of((0,aop.homedir)()),Xa.of(r6S),Xa.of(t6S));await Cf(t)||(await(0,HOn.mkdir)((0,oop.dirname)(t),{recursive:!0}),await(0,HOn.writeFile)(t,fie())),this.persistedDistinctId=(await(0,HOn.readFile)(t)).toString()}return this.persistedDistinctId}};var pCs;async function $On(){return pCs==null&&(pCs=await i6S()),pCs}async function i6S(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Msa;let r=await Z_o();return r!=null?new Asa({token:r,posthogApiKey:e}):await X_o()!=null?new HOo({posthogApiKey:e}):new Asa({token:void 0,posthogApiKey:e})}catch{return new Msa}}function qsa(e,t){return function(){return e.apply(t,arguments)}}var{toString:n6S}=Object.prototype,{getPrototypeOf:hCs}=Object,JOo=(e=>t=>{let r=n6S.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),G8t=e=>(e=e.toLowerCase(),t=>JOo(t)===e),KOo=e=>t=>typeof t===e,{isArray:GOn}=Array,Tsa=KOo("undefined");function a6S(e){return e!==null&&!Tsa(e)&&e.constructor!==null&&!Tsa(e.constructor)&&mSe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var sop=G8t("ArrayBuffer");function o6S(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&sop(e.buffer),t}var u6S=KOo("string"),mSe=KOo("function"),cop=KOo("number"),YOo=e=>e!==null&&typeof e=="object",s6S=e=>e===!0||e===!1,QOo=e=>{if(JOo(e)!=="object")return!1;let t=hCs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},c6S=G8t("Date"),l6S=G8t("File"),f6S=G8t("Blob"),d6S=G8t("FileList"),p6S=e=>YOo(e)&&mSe(e.pipe),_6S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||mSe(e.append)&&((t=JOo(e))==="formdata"||t==="object"&&mSe(e.toString)&&e.toString()==="[object FormData]"))},h6S=G8t("URLSearchParams"),[y6S,v6S,b6S,g6S]=["ReadableStream","Request","Response","Headers"].map(G8t),O6S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Csa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),GOn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,l;for(i=0;i<u;i++)l=a[i],t.call(null,e[l],l,e)}}function lop(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var tIi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,fop=e=>!Tsa(e)&&e!==tIi;function _Cs(){let{caseless:e}=fop(this)&&this||{},t={},r=(i,n)=>{let a=e&&lop(t,n)||n;QOo(t[a])&&QOo(i)?t[a]=_Cs(t[a],i):QOo(i)?t[a]=_Cs({},i):GOn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&Csa(arguments[i],r);return t}var m6S=(e,t,r,{allOwnKeys:i}={})=>(Csa(t,(n,a)=>{r&&mSe(n)?e[a]=qsa(n,r):e[a]=n},{allOwnKeys:i}),e),P6S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),j6S=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},w6S=(e,t,r,i)=>{let n,a,u,l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!l[u]&&(t[u]=e[u],l[u]=!0);e=r!==!1&&hCs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},S6S=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},D6S=e=>{if(!e)return null;if(GOn(e))return e;let t=e.length;if(!cop(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},E6S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&hCs(Uint8Array)),M6S=(e,t)=>{let i=(e&&e[Symbol.iterator]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},A6S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},q6S=G8t("HTMLFormElement"),T6S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),uop=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),C6S=G8t("RegExp"),dop=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};Csa(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},B6S=e=>{dop(e,(t,r)=>{if(mSe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(mSe(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},x6S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return GOn(e)?i(e):i(String(e).split(t)),r},I6S=()=>{},z6S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function R6S(e){return!!(e&&mSe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var N6S=e=>{let t=new Array(10),r=(i,n)=>{if(YOo(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=GOn(i)?[]:{};return Csa(i,(u,l)=>{let d=r(u,n+1);!Tsa(d)&&(a[l]=d)}),t[n]=void 0,a}}return i};return r(e,0)},F6S=G8t("AsyncFunction"),L6S=e=>e&&(YOo(e)||mSe(e))&&mSe(e.then)&&mSe(e.catch),pop=((e,t)=>e?setImmediate:t?((r,i)=>(tIi.addEventListener("message",({source:n,data:a})=>{n===tIi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),tIi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",mSe(tIi.postMessage)),U6S=typeof queueMicrotask<"u"?queueMicrotask.bind(tIi):typeof process<"u"&&process.nextTick||pop,ds={isArray:GOn,isArrayBuffer:sop,isBuffer:a6S,isFormData:_6S,isArrayBufferView:o6S,isString:u6S,isNumber:cop,isBoolean:s6S,isObject:YOo,isPlainObject:QOo,isReadableStream:y6S,isRequest:v6S,isResponse:b6S,isHeaders:g6S,isUndefined:Tsa,isDate:c6S,isFile:l6S,isBlob:f6S,isRegExp:C6S,isFunction:mSe,isStream:p6S,isURLSearchParams:h6S,isTypedArray:E6S,isFileList:d6S,forEach:Csa,merge:_Cs,extend:m6S,trim:O6S,stripBOM:P6S,inherits:j6S,toFlatObject:w6S,kindOf:JOo,kindOfTest:G8t,endsWith:S6S,toArray:D6S,forEachEntry:M6S,matchAll:A6S,isHTMLForm:q6S,hasOwnProperty:uop,hasOwnProp:uop,reduceDescriptors:dop,freezeMethods:B6S,toObjectSet:x6S,toCamelCase:T6S,noop:I6S,toFiniteNumber:z6S,findKey:lop,global:tIi,isContextDefined:fop,isSpecCompliantForm:R6S,toJSONObject:N6S,isAsyncFn:F6S,isThenable:L6S,setImmediate:pop,asap:U6S};function QOn(e,t,r,i,n){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),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}ds.inherits(QOn,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:ds.toJSONObject(this.config),code:this.code,status:this.status}}});var _op=QOn.prototype,hop={};["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=>{hop[e]={value:e}});Object.defineProperties(QOn,hop);Object.defineProperty(_op,"isAxiosError",{value:!0});QOn.from=(e,t,r,i,n,a)=>{let u=Object.create(_op);return ds.toFlatObject(e,u,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),QOn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var wp=QOn;var yop=yi(ora(),1),XOo=yop.default;function yCs(e){return ds.isPlainObject(e)||ds.isArray(e)}function bop(e){return ds.endsWith(e,"[]")?e.slice(0,-2):e}function vop(e,t,r){return e?e.concat(t).map(function(n,a){return n=bop(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function V6S(e){return ds.isArray(e)&&!e.some(yCs)}var W6S=ds.toFlatObject(ds,{},null,function(t){return/^is[A-Z]/.test(t)});function H6S(e,t,r){if(!ds.isObject(e))throw new TypeError("target must be an object");t=t||new(XOo||FormData),r=ds.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,w){return!ds.isUndefined(w[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&ds.isSpecCompliantForm(t);if(!ds.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(ds.isDate(O))return O.toISOString();if(!d&&ds.isBlob(O))throw new wp("Blob is not supported. Use a Buffer instead.");return ds.isArrayBuffer(O)||ds.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,w){let E=O;if(O&&!w&&typeof O=="object"){if(ds.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(ds.isArray(O)&&V6S(O)||(ds.isFileList(O)||ds.endsWith(m,"[]"))&&(E=ds.toArray(O)))return m=bop(m),E.forEach(function(q,D){!(ds.isUndefined(q)||q===null)&&t.append(u===!0?vop([m],D,a):u===null?m:m+"[]",s(q))}),!1}return yCs(O)?!0:(t.append(vop(w,m,a),s(O)),!1)}let c=[],b=Object.assign(W6S,{defaultVisitor:o,convertValue:s,isVisitable:yCs});function g(O,m){if(!ds.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),ds.forEach(O,function(E,A){(!(ds.isUndefined(E)||E===null)&&n.call(t,E,ds.isString(A)?A.trim():A,m,b))===!0&&g(E,m?m.concat(A):[A])}),c.pop()}}if(!ds.isObject(e))throw new TypeError("data must be an object");return g(e),t}var xli=H6S;function gop(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function Oop(e,t){this._pairs=[],e&&xli(e,this,t)}var mop=Oop.prototype;mop.append=function(t,r){this._pairs.push([t,r])};mop.toString=function(t){let r=t?function(i){return t.call(this,i,gop)}:gop;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var Pop=Oop;function $6S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function rIi(e,t,r){if(!t)return e;let i=r&&r.encode||$6S;ds.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=ds.isURLSearchParams(t)?t.toString():new Pop(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var vCs=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){ds.forEach(this.handlers,function(i){i!==null&&t(i)})}},bCs=vCs;var JOn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var Dop=yi(require("crypto"),1);var jop=yi(require("url"),1),wop=jop.default.URLSearchParams;var gCs="abcdefghijklmnopqrstuvwxyz",Sop="0123456789",Eop={DIGIT:Sop,ALPHA:gCs,ALPHA_DIGIT:gCs+gCs.toUpperCase()+Sop},G6S=(e=16,t=Eop.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);Dop.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},Mop={isNode:!0,classes:{URLSearchParams:wop,FormData:XOo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:Eop,generateString:G6S,protocols:["http","https","file","data"]};var PCs={};Co(PCs,{hasBrowserEnv:()=>mCs,hasStandardBrowserEnv:()=>Q6S,hasStandardBrowserWebWorkerEnv:()=>J6S,navigator:()=>OCs,origin:()=>K6S});var mCs=typeof window<"u"&&typeof document<"u",OCs=typeof navigator=="object"&&navigator||void 0,Q6S=mCs&&(!OCs||["ReactNative","NativeScript","NS"].indexOf(OCs.product)<0),J6S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",K6S=mCs&&window.location.href||"http://localhost";var PM={...PCs,...Mop};function jCs(e,t){return xli(e,new PM.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return PM.isNode&&ds.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function Y6S(e){return ds.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function X6S(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function Z6S(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),d=a>=r.length;return u=!u&&ds.isArray(n)?n.length:u,d?(ds.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!ds.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&ds.isArray(n[u])&&(n[u]=X6S(n[u])),!l)}if(ds.isFormData(e)&&ds.isFunction(e.entries)){let r={};return ds.forEachEntry(e,(i,n)=>{t(Y6S(i),n,r,0)}),r}return null}var ZOo=Z6S;function k6S(e,t,r){if(ds.isString(e))try{return(t||JSON.parse)(e),ds.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var wCs={transitional:JOn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=ds.isObject(t);if(a&&ds.isHTMLForm(t)&&(t=new FormData(t)),ds.isFormData(t))return n?JSON.stringify(ZOo(t)):t;if(ds.isArrayBuffer(t)||ds.isBuffer(t)||ds.isStream(t)||ds.isFile(t)||ds.isBlob(t)||ds.isReadableStream(t))return t;if(ds.isArrayBufferView(t))return t.buffer;if(ds.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return jCs(t,this.formSerializer).toString();if((l=ds.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return xli(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),k6S(t)):t}],transformResponse:[function(t){let r=this.transitional||wCs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(ds.isResponse(t)||ds.isReadableStream(t))return t;if(t&&ds.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?wp.from(l,wp.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:PM.classes.FormData,Blob:PM.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ds.forEach(["delete","get","head","post","put","patch"],e=>{wCs.headers[e]={}});var KOn=wCs;var e2S=ds.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"]),Aop=e=>{let t={},r,i,n;return e&&e.split(`
1696
1696
  `).forEach(function(u){n=u.indexOf(":"),r=u.substring(0,n).trim().toLowerCase(),i=u.substring(n+1).trim(),!(!r||t[r]&&e2S[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var qop=Symbol("internals");function Bsa(e){return e&&String(e).trim().toLowerCase()}function kOo(e){return e===!1||e==null?e:ds.isArray(e)?e.map(kOo):String(e)}function t2S(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,i;for(;i=r.exec(e);)t[i[1]]=i[2];return t}var r2S=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function SCs(e,t,r,i,n){if(ds.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!ds.isString(t)){if(ds.isString(i))return t.indexOf(i)!==-1;if(ds.isRegExp(i))return i.test(t)}}function i2S(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function n2S(e,t){let r=ds.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,u){return this[i].call(this,t,n,a,u)},configurable:!0})})}var YOn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(l,d,s){let o=Bsa(d);if(!o)throw new Error("header name must be a non-empty string");let c=ds.findKey(n,o);(!c||n[c]===void 0||s===!0||s===void 0&&n[c]!==!1)&&(n[c||d]=kOo(l))}let u=(l,d)=>ds.forEach(l,(s,o)=>a(s,o,d));if(ds.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(ds.isString(t)&&(t=t.trim())&&!r2S(t))u(Aop(t),r);else if(ds.isHeaders(t))for(let[l,d]of t.entries())a(d,l,i);else t!=null&&a(r,t,i);return this}get(t,r){if(t=Bsa(t),t){let i=ds.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return t2S(n);if(ds.isFunction(r))return r.call(this,n,i);if(ds.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=Bsa(t),t){let i=ds.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||SCs(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(u){if(u=Bsa(u),u){let l=ds.findKey(i,u);l&&(!r||SCs(i,i[l],l,r))&&(delete i[l],n=!0)}}return ds.isArray(t)?t.forEach(a):a(t),n}clear(t){let r=Object.keys(this),i=r.length,n=!1;for(;i--;){let a=r[i];(!t||SCs(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return ds.forEach(this,(n,a)=>{let u=ds.findKey(i,a);if(u){r[u]=kOo(n),delete r[a];return}let l=t?i2S(a):String(a).trim();l!==a&&delete r[a],r[l]=kOo(n),i[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return ds.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&ds.isArray(i)?i.join(", "):i)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
1697
1697
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let i=new this(t);return r.forEach(n=>i.set(n)),i}static accessor(t){let i=(this[qop]=this[qop]={accessors:{}}).accessors,n=this.prototype;function a(u){let l=Bsa(u);i[l]||(n2S(n,u),i[l]=!0)}return ds.isArray(t)?t.forEach(a):a(t),this}};YOn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ds.reduceDescriptors(YOn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});ds.freezeMethods(YOn);var ez=YOn;function xsa(e,t){let r=this||KOn,i=t||r,n=ez.from(i.headers),a=i.data;return ds.forEach(e,function(l){a=l.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function Isa(e){return!!(e&&e.__CANCEL__)}function Top(e,t,r){wp.call(this,e??"canceled",wp.ERR_CANCELED,t,r),this.name="CanceledError"}ds.inherits(Top,wp,{__CANCEL__:!0});var PSe=Top;function pYt(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new wp("Request failed with status code "+r.status,[wp.ERR_BAD_REQUEST,wp.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function DCs(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function ECs(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function iIi(e,t,r){let i=!DCs(t);return e&&i||r==!1?ECs(e,t):t}var Qop=yi(ysa(),1),Jop=yi(require("http"),1),Kop=yi(require("https"),1),Yop=yi(require("util"),1),Xop=yi(xTs(),1),oJr=yi(require("zlib"),1);var nIi="1.8.2";function zsa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var a2S=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function MCs(e,t,r){let i=r&&r.Blob||PM.classes.Blob,n=zsa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=a2S.exec(e);if(!a)throw new wp("Invalid URL",wp.ERR_INVALID_URL);let u=a[1],l=a[2],d=a[3],s=Buffer.from(decodeURIComponent(d),l?"base64":"utf8");if(t){if(!i)throw new wp("Blob is not supported",wp.ERR_NOT_SUPPORT);return new i([s],{type:u})}return s}throw new wp("Unsupported protocol "+n,wp.ERR_NOT_SUPPORT)}var aIi=yi(require("stream"),1);var Cop=yi(require("stream"),1);var ACs=Symbol("internals"),qCs=class extends Cop.default.Transform{constructor(t){t=ds.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!ds.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[ACs]={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",i=>{i==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[ACs];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[ACs],a=n.maxRate,u=this.readableHighWaterMark,l=n.timeWindow,d=1e3/l,s=a/d,o=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,c=(g,O)=>{let m=Buffer.byteLength(g);n.bytesSeen+=m,n.bytes+=m,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(g)?process.nextTick(O):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(O)}},b=(g,O)=>{let m=Buffer.byteLength(g),w=null,E=u,A,q=0;if(a){let D=Date.now();(!n.ts||(q=D-n.ts)>=l)&&(n.ts=D,A=s-n.bytes,n.bytes=A<0?-A:0,q=0),A=s-n.bytes}if(a){if(A<=0)return setTimeout(()=>{O(null,g)},l-q);A<E&&(E=A)}E&&m>E&&m-E>o&&(w=g.subarray(E),g=g.subarray(0,E)),c(g,w?()=>{process.nextTick(O,null,w)}:O)};b(t,function g(O,m){if(O)return i(O);m?b(m,g):i(null)})}},TCs=qCs;var Zop=require("events");var xop=yi(require("util"),1),Iop=require("stream");var{asyncIterator:Bop}=Symbol,o2S=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[Bop]?yield*e[Bop]():yield e},emo=o2S;var u2S=PM.ALPHABET.ALPHA_DIGIT+"-_",Rsa=typeof TextEncoder=="function"?new TextEncoder:new xop.default.TextEncoder,Ili=`\r
1698
1698
  `,s2S=Rsa.encode(Ili),c2S=2,CCs=class{constructor(t,r){let{escapeName:i}=this.constructor,n=ds.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${Ili}`;n?r=Rsa.encode(String(r).replace(/\r?\n|\r\n?/g,Ili)):a+=`Content-Type: ${r.type||"application/octet-stream"}${Ili}`,this.headers=Rsa.encode(a+Ili),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+c2S,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;ds.isTypedArray(t)?yield t:yield*emo(t),yield s2S}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},l2S=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+PM.generateString(n,u2S)}=r||{};if(!ds.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=Rsa.encode("--"+a+Ili),l=Rsa.encode("--"+a+"--"+Ili+Ili),d=l.byteLength,s=Array.from(e.entries()).map(([c,b])=>{let g=new CCs(c,b);return d+=g.size,g});d+=u.byteLength*s.length,d=ds.toFiniteNumber(d);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(o["Content-Length"]=d),t&&t(o),Iop.Readable.from(async function*(){for(let c of s)yield u,yield*c.encode();yield l}())},zop=l2S;var Rop=yi(require("stream"),1),BCs=class extends Rop.default.Transform{__transform(t,r,i){this.push(t),i()}_transform(t,r,i){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let n=Buffer.alloc(2);n[0]=120,n[1]=156,this.push(n,r)}this.__transform(t,r,i)}},Nop=BCs;var f2S=(e,t)=>ds.isAsyncFn(e)?function(...r){let i=r.pop();e.apply(this,r).then(n=>{try{t?i(null,...t(n)):i(null,n)}catch(a){i(a)}},i)}:e,Fop=f2S;function d2S(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,u;return t=t!==void 0?t:1e3,function(d){let s=Date.now(),o=i[a];u||(u=s),r[n]=d,i[n]=s;let c=a,b=0;for(;c!==n;)b+=r[c++],c=c%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-u<t)return;let g=o&&s-o;return g?Math.round(b*1e3/g):void 0}}var Lop=d2S;function p2S(e,t){let r=0,i=1e3/t,n,a,u=(s,o=Date.now())=>{r=o,n=null,a&&(clearTimeout(a),a=null),e.apply(null,s)};return[(...s)=>{let o=Date.now(),c=o-r;c>=i?u(s,o):(n=s,a||(a=setTimeout(()=>{a=null,u(n)},i-c)))},()=>n&&u(n)]}var Uop=p2S;var aJr=(e,t,r=3)=>{let i=0,n=Lop(50,250);return Uop(a=>{let u=a.loaded,l=a.lengthComputable?a.total:void 0,d=u-i,s=n(d),o=u<=l;i=u;let c={loaded:u,total:l,progress:l?u/l:void 0,bytes:d,rate:s||void 0,estimated:s&&l&&o?(l-u)/s:void 0,event:a,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(c)},r)},XOn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},ZOn=e=>(...t)=>ds.asap(()=>e(...t));var Vop={flush:oJr.default.constants.Z_SYNC_FLUSH,finishFlush:oJr.default.constants.Z_SYNC_FLUSH},_2S={flush:oJr.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:oJr.default.constants.BROTLI_OPERATION_FLUSH},Wop=ds.isFunction(oJr.default.createBrotliDecompress),{http:h2S,https:y2S}=Xop.default,v2S=/https:?/,Hop=PM.protocols.map(e=>e+":"),$op=(e,[t,r])=>(e.on("end",r).on("error",r),t);function b2S(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function kop(e,t,r){let i=t;if(!i&&i!==!1){let n=Qop.default.getProxyForUrl(r);n&&(i=new URL(n))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let a=Buffer.from(i.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let n=i.hostname||i.host;e.hostname=n,e.host=n,e.port=i.port,e.path=r,i.protocol&&(e.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}e.beforeRedirects.proxy=function(a){kop(a,t,a.href)}}var g2S=typeof process<"u"&&ds.kindOf(process)==="process",O2S=e=>new Promise((t,r)=>{let i,n,a=(d,s)=>{n||(n=!0,i&&i(d,s))},u=d=>{a(d),t(d)},l=d=>{a(d,!0),r(d)};e(u,l,d=>i=d).catch(l)}),m2S=({address:e,family:t})=>{if(!ds.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},Gop=(e,t)=>m2S(ds.isObject(e)?e:{address:e,family:t}),eup=g2S&&function(t){return O2S(async function(i,n,a){let{data:u,lookup:l,family:d}=t,{responseType:s,responseEncoding:o}=t,c=t.method.toUpperCase(),b,g=!1,O;if(l){let we=Fop(l,Ze=>ds.isArray(Ze)?Ze:[Ze]);l=(Ze,Mt,De)=>{we(Ze,Mt,(Te,xt,Ee)=>{if(Te)return De(Te);let It=ds.isArray(xt)?xt.map(st=>Gop(st)):[Gop(xt,Ee)];Mt.all?De(Te,It):De(Te,It[0].address,It[0].family)})}}let m=new Zop.EventEmitter,w=()=>{t.cancelToken&&t.cancelToken.unsubscribe(E),t.signal&&t.signal.removeEventListener("abort",E),m.removeAllListeners()};a((we,Ze)=>{b=!0,Ze&&(g=!0,w())});function E(we){m.emit("abort",!we||we.type?new PSe(null,t,O):we)}m.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(E),t.signal&&(t.signal.aborted?E():t.signal.addEventListener("abort",E)));let A=iIi(t.baseURL,t.url,t.allowAbsoluteUrls),q=new URL(A,PM.hasBrowserEnv?PM.origin:void 0),D=q.protocol||Hop[0];if(D==="data:"){let we;if(c!=="GET")return pYt(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{we=MCs(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(Ze){throw wp.from(Ze,wp.ERR_BAD_REQUEST,t)}return s==="text"?(we=we.toString(o),(!o||o==="utf8")&&(we=ds.stripBOM(we))):s==="stream"&&(we=aIi.default.Readable.from(we)),pYt(i,n,{data:we,status:200,statusText:"OK",headers:new ez,config:t})}if(Hop.indexOf(D)===-1)return n(new wp("Unsupported protocol "+D,wp.ERR_BAD_REQUEST,t));let C=ez.from(t.headers).normalize();C.set("User-Agent","axios/"+nIi,!1);let{onUploadProgress:R,onDownloadProgress:$}=t,I=t.maxRate,U,H;if(ds.isSpecCompliantForm(u)){let we=C.getContentType(/boundary=([-_\w\d]{10,70})/i);u=zop(u,Ze=>{C.set(Ze)},{tag:`axios-${nIi}-boundary`,boundary:we&&we[1]||void 0})}else if(ds.isFormData(u)&&ds.isFunction(u.getHeaders)){if(C.set(u.getHeaders()),!C.hasContentLength())try{let we=await Yop.default.promisify(u.getLength).call(u);Number.isFinite(we)&&we>=0&&C.setContentLength(we)}catch{}}else if(ds.isBlob(u)||ds.isFile(u))u.size&&C.setContentType(u.type||"application/octet-stream"),C.setContentLength(u.size||0),u=aIi.default.Readable.from(emo(u));else if(u&&!ds.isStream(u)){if(!Buffer.isBuffer(u))if(ds.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(ds.isString(u))u=Buffer.from(u,"utf-8");else return n(new wp("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",wp.ERR_BAD_REQUEST,t));if(C.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return n(new wp("Request body larger than maxBodyLength limit",wp.ERR_BAD_REQUEST,t))}let k=ds.toFiniteNumber(C.getContentLength());ds.isArray(I)?(U=I[0],H=I[1]):U=H=I,u&&(R||U)&&(ds.isStream(u)||(u=aIi.default.Readable.from(u,{objectMode:!1})),u=aIi.default.pipeline([u,new TCs({maxRate:ds.toFiniteNumber(U)})],ds.noop),R&&u.on("progress",$op(u,XOn(k,aJr(ZOn(R),!1,3)))));let K;if(t.auth){let we=t.auth.username||"",Ze=t.auth.password||"";K=we+":"+Ze}if(!K&&q.username){let we=q.username,Ze=q.password;K=we+":"+Ze}K&&C.delete("authorization");let ee;try{ee=rIi(q.pathname+q.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(we){let Ze=new Error(we.message);return Ze.config=t,Ze.url=t.url,Ze.exists=!0,n(Ze)}C.set("Accept-Encoding","gzip, compress, deflate"+(Wop?", br":""),!1);let fe={path:ee,method:c,headers:C.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:K,protocol:D,family:d,beforeRedirect:b2S,beforeRedirects:{}};!ds.isUndefined(l)&&(fe.lookup=l),t.socketPath?fe.socketPath=t.socketPath:(fe.hostname=q.hostname.startsWith("[")?q.hostname.slice(1,-1):q.hostname,fe.port=q.port,kop(fe,t.proxy,D+"//"+q.hostname+(q.port?":"+q.port:"")+fe.path));let me,ge=v2S.test(fe.protocol);if(fe.agent=ge?t.httpsAgent:t.httpAgent,t.transport?me=t.transport:t.maxRedirects===0?me=ge?Kop.default:Jop.default:(t.maxRedirects&&(fe.maxRedirects=t.maxRedirects),t.beforeRedirect&&(fe.beforeRedirects.config=t.beforeRedirect),me=ge?y2S:h2S),t.maxBodyLength>-1?fe.maxBodyLength=t.maxBodyLength:fe.maxBodyLength=1/0,t.insecureHTTPParser&&(fe.insecureHTTPParser=t.insecureHTTPParser),O=me.request(fe,function(Ze){if(O.destroyed)return;let Mt=[Ze],De=+Ze.headers["content-length"];if($||H){let st=new TCs({maxRate:ds.toFiniteNumber(H)});$&&st.on("progress",$op(st,XOn(De,aJr(ZOn($),!0,3)))),Mt.push(st)}let Te=Ze,xt=Ze.req||O;if(t.decompress!==!1&&Ze.headers["content-encoding"])switch((c==="HEAD"||Ze.statusCode===204)&&delete Ze.headers["content-encoding"],(Ze.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":Mt.push(oJr.default.createUnzip(Vop)),delete Ze.headers["content-encoding"];break;case"deflate":Mt.push(new Nop),Mt.push(oJr.default.createUnzip(Vop)),delete Ze.headers["content-encoding"];break;case"br":Wop&&(Mt.push(oJr.default.createBrotliDecompress(_2S)),delete Ze.headers["content-encoding"])}Te=Mt.length>1?aIi.default.pipeline(Mt,ds.noop):Mt[0];let Ee=aIi.default.finished(Te,()=>{Ee(),w()}),It={status:Ze.statusCode,statusText:Ze.statusMessage,headers:new ez(Ze.headers),config:t,request:xt};if(s==="stream")It.data=Te,pYt(i,n,It);else{let st=[],ve=0;Te.on("data",function(Ot){st.push(Ot),ve+=Ot.length,t.maxContentLength>-1&&ve>t.maxContentLength&&(g=!0,Te.destroy(),n(new wp("maxContentLength size of "+t.maxContentLength+" exceeded",wp.ERR_BAD_RESPONSE,t,xt)))}),Te.on("aborted",function(){if(g)return;let Ot=new wp("stream has been aborted",wp.ERR_BAD_RESPONSE,t,xt);Te.destroy(Ot),n(Ot)}),Te.on("error",function(Ot){O.destroyed||n(wp.from(Ot,null,t,xt))}),Te.on("end",function(){try{let Ot=st.length===1?st[0]:Buffer.concat(st);s!=="arraybuffer"&&(Ot=Ot.toString(o),(!o||o==="utf8")&&(Ot=ds.stripBOM(Ot))),It.data=Ot}catch(Ot){return n(wp.from(Ot,null,t,It.request,It))}pYt(i,n,It)})}m.once("abort",st=>{Te.destroyed||(Te.emit("error",st),Te.destroy())})}),m.once("abort",we=>{n(we),O.destroy(we)}),O.on("error",function(Ze){n(wp.from(Ze,null,t,O))}),O.on("socket",function(Ze){Ze.setKeepAlive(!0,1e3*60)}),t.timeout){let we=parseInt(t.timeout,10);if(Number.isNaN(we)){n(new wp("error trying to parse `config.timeout` to int",wp.ERR_BAD_OPTION_VALUE,t,O));return}O.setTimeout(we,function(){if(b)return;let Mt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",De=t.transitional||JOn;t.timeoutErrorMessage&&(Mt=t.timeoutErrorMessage),n(new wp(Mt,De.clarifyTimeoutError?wp.ETIMEDOUT:wp.ECONNABORTED,t,O)),E()})}if(ds.isStream(u)){let we=!1,Ze=!1;u.on("end",()=>{we=!0}),u.once("error",Mt=>{Ze=!0,O.destroy(Mt)}),u.on("close",()=>{!we&&!Ze&&E(new PSe("Request stream has been aborted",t,O))}),u.pipe(O)}else O.end(u)})};var tup=PM.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,PM.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(PM.origin),PM.navigator&&/(msie|trident)/i.test(PM.navigator.userAgent)):()=>!0;var rup=PM.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let u=[e+"="+encodeURIComponent(t)];ds.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),ds.isString(i)&&u.push("path="+i),ds.isString(n)&&u.push("domain="+n),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 iup=e=>e instanceof ez?{...e}:e;function Q8t(e,t){t=t||{};let r={};function i(s,o,c,b){return ds.isPlainObject(s)&&ds.isPlainObject(o)?ds.merge.call({caseless:b},s,o):ds.isPlainObject(o)?ds.merge({},o):ds.isArray(o)?o.slice():o}function n(s,o,c,b){if(ds.isUndefined(o)){if(!ds.isUndefined(s))return i(void 0,s,c,b)}else return i(s,o,c,b)}function a(s,o){if(!ds.isUndefined(o))return i(void 0,o)}function u(s,o){if(ds.isUndefined(o)){if(!ds.isUndefined(s))return i(void 0,s)}else return i(void 0,o)}function l(s,o,c){if(c in t)return i(s,o);if(c in e)return i(void 0,s)}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:l,headers:(s,o,c)=>n(iup(s),iup(o),c,!0)};return ds.forEach(Object.keys(Object.assign({},e,t)),function(o){let c=d[o]||n,b=c(e[o],t[o],o);ds.isUndefined(b)&&c!==l||(r[o]=b)}),r}var tmo=e=>{let t=Q8t({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:u,auth:l}=t;t.headers=u=ez.from(u),t.url=rIi(iIi(t.baseURL,t.url),e.params,e.paramsSerializer),l&&u.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let d;if(ds.isFormData(r)){if(PM.hasStandardBrowserEnv||PM.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((d=u.getContentType())!==!1){let[s,...o]=d?d.split(";").map(c=>c.trim()).filter(Boolean):[];u.setContentType([s||"multipart/form-data",...o].join("; "))}}if(PM.hasStandardBrowserEnv&&(i&&ds.isFunction(i)&&(i=i(t)),i||i!==!1&&tup(t.url))){let s=n&&a&&rup.read(a);s&&u.set(n,s)}return t};var P2S=typeof XMLHttpRequest<"u",nup=P2S&&function(e){return new Promise(function(r,i){let n=tmo(e),a=n.data,u=ez.from(n.headers).normalize(),{responseType:l,onUploadProgress:d,onDownloadProgress:s}=n,o,c,b,g,O;function m(){g&&g(),O&&O(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let w=new XMLHttpRequest;w.open(n.method.toUpperCase(),n.url,!0),w.timeout=n.timeout;function E(){if(!w)return;let q=ez.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),C={data:!l||l==="text"||l==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:q,config:e,request:w};pYt(function($){r($),m()},function($){i($),m()},C),w=null}"onloadend"in w?w.onloadend=E:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(E)},w.onabort=function(){w&&(i(new wp("Request aborted",wp.ECONNABORTED,e,w)),w=null)},w.onerror=function(){i(new wp("Network Error",wp.ERR_NETWORK,e,w)),w=null},w.ontimeout=function(){let D=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",C=n.transitional||JOn;n.timeoutErrorMessage&&(D=n.timeoutErrorMessage),i(new wp(D,C.clarifyTimeoutError?wp.ETIMEDOUT:wp.ECONNABORTED,e,w)),w=null},a===void 0&&u.setContentType(null),"setRequestHeader"in w&&ds.forEach(u.toJSON(),function(D,C){w.setRequestHeader(C,D)}),ds.isUndefined(n.withCredentials)||(w.withCredentials=!!n.withCredentials),l&&l!=="json"&&(w.responseType=n.responseType),s&&([b,O]=aJr(s,!0),w.addEventListener("progress",b)),d&&w.upload&&([c,g]=aJr(d),w.upload.addEventListener("progress",c),w.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(o=q=>{w&&(i(!q||q.type?new PSe(null,e,w):q),w.abort(),w=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));let A=zsa(n.url);if(A&&PM.protocols.indexOf(A)===-1){i(new wp("Unsupported protocol "+A+":",wp.ERR_BAD_REQUEST,e));return}w.send(a||null)})};var j2S=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let i=new AbortController,n,a=function(s){if(!n){n=!0,l();let o=s instanceof Error?s:this.reason;i.abort(o instanceof wp?o:new PSe(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new wp(`timeout ${t} of ms exceeded`,wp.ETIMEDOUT))},t),l=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:d}=i;return d.unsubscribe=()=>ds.asap(l),d}},aup=j2S;var w2S=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let i=0,n;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},S2S=async function*(e,t){for await(let r of D2S(e))yield*w2S(r,t)},D2S=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:i}=await t.read();if(r)break;yield i}}finally{await t.cancel()}},xCs=(e,t,r,i)=>{let n=S2S(e,t),a=0,u,l=d=>{u||(u=!0,i&&i(d))};return new ReadableStream({async pull(d){try{let{done:s,value:o}=await n.next();if(s){l(),d.close();return}let c=o.byteLength;if(r){let b=a+=c;r(b)}d.enqueue(new Uint8Array(o))}catch(s){throw l(s),s}},cancel(d){return l(d),n.return()}},{highWaterMark:2})};var imo=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",uup=imo&&typeof ReadableStream=="function",E2S=imo&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),sup=(e,...t)=>{try{return!!e(...t)}catch{return!1}},M2S=uup&&sup(()=>{let e=!1,t=new Request(PM.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),oup=64*1024,ICs=uup&&sup(()=>ds.isReadableStream(new Response("").body)),rmo={stream:ICs&&(e=>e.body)};imo&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!rmo[t]&&(rmo[t]=ds.isFunction(e[t])?r=>r[t]():(r,i)=>{throw new wp(`Response type '${t}' is not supported`,wp.ERR_NOT_SUPPORT,i)})})})(new Response);var A2S=async e=>{if(e==null)return 0;if(ds.isBlob(e))return e.size;if(ds.isSpecCompliantForm(e))return(await new Request(PM.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(ds.isArrayBufferView(e)||ds.isArrayBuffer(e))return e.byteLength;if(ds.isURLSearchParams(e)&&(e=e+""),ds.isString(e))return(await E2S(e)).byteLength},q2S=async(e,t)=>{let r=ds.toFiniteNumber(e.getContentLength());return r??A2S(t)},cup=imo&&(async e=>{let{url:t,method:r,data:i,signal:n,cancelToken:a,timeout:u,onDownloadProgress:l,onUploadProgress:d,responseType:s,headers:o,withCredentials:c="same-origin",fetchOptions:b}=tmo(e);s=s?(s+"").toLowerCase():"text";let g=aup([n,a&&a.toAbortSignal()],u),O,m=g&&g.unsubscribe&&(()=>{g.unsubscribe()}),w;try{if(d&&M2S&&r!=="get"&&r!=="head"&&(w=await q2S(o,i))!==0){let C=new Request(t,{method:"POST",body:i,duplex:"half"}),R;if(ds.isFormData(i)&&(R=C.headers.get("content-type"))&&o.setContentType(R),C.body){let[$,I]=XOn(w,aJr(ZOn(d)));i=xCs(C.body,oup,$,I)}}ds.isString(c)||(c=c?"include":"omit");let E="credentials"in Request.prototype;O=new Request(t,{...b,signal:g,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:i,duplex:"half",credentials:E?c:void 0});let A=await fetch(O),q=ICs&&(s==="stream"||s==="response");if(ICs&&(l||q&&m)){let C={};["status","statusText","headers"].forEach(U=>{C[U]=A[U]});let R=ds.toFiniteNumber(A.headers.get("content-length")),[$,I]=l&&XOn(R,aJr(ZOn(l),!0))||[];A=new Response(xCs(A.body,oup,$,()=>{I&&I(),m&&m()}),C)}s=s||"text";let D=await rmo[ds.findKey(rmo,s)||"text"](A,e);return!q&&m&&m(),await new Promise((C,R)=>{pYt(C,R,{data:D,headers:ez.from(A.headers),status:A.status,statusText:A.statusText,config:e,request:O})})}catch(E){throw m&&m(),E&&E.name==="TypeError"&&/fetch/i.test(E.message)?Object.assign(new wp("Network Error",wp.ERR_NETWORK,e,O),{cause:E.cause||E}):wp.from(E,E&&E.code,e,O)}});var zCs={http:eup,xhr:nup,fetch:cup};ds.forEach(zCs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var lup=e=>`- ${e}`,T2S=e=>ds.isFunction(e)||e===null||e===!1,nmo={getAdapter:e=>{e=ds.isArray(e)?e:[e];let{length:t}=e,r,i,n={};for(let a=0;a<t;a++){r=e[a];let u;if(i=r,!T2S(r)&&(i=zCs[(u=String(r)).toLowerCase()],i===void 0))throw new wp(`Unknown adapter '${u}'`);if(i)break;n[u||"#"+a]=i}if(!i){let a=Object.entries(n).map(([l,d])=>`adapter ${l} `+(d===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
@@ -1930,11 +1930,11 @@ ${q}${A}${D}${Zxp.default.cursorHide}`});var Tpa=yi(lBi(),1);function q8s(e,t){i
1930
1930
  Run ${Js.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
1931
1931
  Run ${Js.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),emn(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function U8s({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!PIp(e))return;let n=t??"",a=e.filter(l=>l.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((l,d)=>l.generatorName.localeCompare(d.generatorName)||l.currentVersion.localeCompare(d.currentVersion));for(let l of u)n+=`
1932
1932
  ${await BmD(l.generatorName)} (${l.apiName!=null?"API: "+l.apiName+", ":""}Group: ${l.generatorGroup}) `+Js.dim(l.currentVersion)+Js.reset(" \u2192 ")+Js.green(l.latestVersion);return n+=`
1933
- `,i?emn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function BmD(e){let r=await new mIp.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 xmD({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await wIp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=lsi(o.name,c),g=await MQt({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:c});g!=null&&(l.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),l}let u={type:"multiApi",versions:{}};return await wIp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,d,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][d]==null&&(u.versions[l][d]={});let c=lsi(s.name,o),b=await MQt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function wIp({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let l=await v8t({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let d of l.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function SIp(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let d=Pie(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function oAo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await xmD({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[d,s]of Object.entries(l.versions))u.push(...SIp(s,d,t.logger));else u.push(...SIp(l.versions,void 0,t.logger))}return u}var Fpa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),l=u?`status code ${u}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var Qwn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Jwn=e=>e!==null&&typeof e=="object";var Lpa=(...e)=>{for(let t of e)if((!Jwn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return H8s({},...e)},V8s=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function uAo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:H8s(e[r]??[],t[r]??[])}var W8s=(e={},t={})=>({beforeRequest:uAo(e,t,"beforeRequest"),beforeRetry:uAo(e,t,"beforeRetry"),afterResponse:uAo(e,t,"afterResponse"),beforeError:uAo(e,t,"beforeError")}),H8s=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(Jwn(n)){for(let[a,u]of Object.entries(n))Jwn(u)&&a in t&&(u=H8s(t[a],u)),t={...t,[a]:u};Jwn(n.hooks)&&(i=W8s(i,n.hooks),t.hooks=i),Jwn(n.headers)&&(r=V8s(r,n.headers),t.headers=r)}return t};var DIp=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)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(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),EIp=typeof globalThis.AbortController=="function",MIp=typeof globalThis.ReadableStream=="function",AIp=typeof globalThis.FormData=="function",sAo=["get","post","put","patch","head","delete"],ImD=()=>{};ImD();var qIp={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},cAo=2147483647,lAo=Symbol("stop"),TIp={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},CIp={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 xIp=e=>sAo.includes(e)?e.toUpperCase():e,zmD=["get","put","head","delete","options","trace"],RmD=[408,413,429,500,502,503,504],NmD=[413,429,503],BIp={limit:2,methods:zmD,statusCodes:RmD,afterStatusCodes:NmD,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},IIp=(e={})=>{if(typeof e=="number")return{...BIp,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{...BIp,...e}};async function $8s(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new Qwn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function G8s(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var zIp=(e,t)=>{let r={};for(let i in t)!(i in CIp)&&!(i in TIp)&&!(i in e)&&(r[i]=t[i]);return r};var Upa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>cAo)throw new RangeError(`The \`timeout\` option cannot be greater than ${cAo}`);await Promise.resolve();let l=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let d=new Fpa(l,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!MIp)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return i._stream(l.clone(),i._options.onDownloadProgress)}return l},u=i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n();for(let[l,d]of Object.entries(qIp))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let o=(await u).clone();if(l==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:V8s(this._input.headers,r.headers),hooks:W8s({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:xIp(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:IIp(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(EIp){this.abortController=new globalThis.AbortController;let i=this._options.signal??this._input.signal;i?.addEventListener("abort",()=>{this.abortController.abort(i.reason)}),this._options.signal=this.abortController.signal}if(DIp&&(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 n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(AIp&&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 Qwn)throw t;if(t instanceof Fpa){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=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(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n: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 i=Math.min(this._calculateRetryDelay(r),cAo);if(this._retryCount<1)throw r;await G8s(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===lAo)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=zIp(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):$8s(r,t,this.abortController,this._options)}_stream(t,r){let i=Number(t.headers.get("content-length"))||0,n=0;return t.status===204?(r&&r({percent:1,totalBytes:i,transferredBytes:n},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:i},new Uint8Array);async function l(){let{done:d,value:s}=await u.read();if(d){a.close();return}if(r){n+=s.byteLength;let o=i===0?0:n/i;r({percent:o,transferredBytes:n,totalBytes:i},s)}a.enqueue(s),await l()}await l()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var Q8s=e=>{let t=(r,i)=>Upa.create(r,Lpa(e,i));for(let r of sAo)t[r]=(i,n)=>Upa.create(i,Lpa(e,n,{method:r}));return t.create=r=>Q8s(Lpa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Q8s(Lpa(e,r))),t.stop=lAo,t},FmD=Q8s(),RIp=FmD;var ozp=yi(azp(),1);function Z8s(e){let t=(0,ozp.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var eRp=yi(kzp(),1),tRp=yi(lBi(),1),d5s=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},p5s=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function _5s(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Z8s(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,eRp.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,l&&(d.authorization=`${l.type} ${l.token}`);let s;try{s=await RIp(u,{headers:d,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new d5s(e):c}if(t.allVersions)return s;let o=new p5s(e,r);if(s["dist-tags"][r]){let{time:c}=s;s=s.versions[s["dist-tags"][r]],s.time=c}else if(r){let c=!!s.versions[r];if(i&&!c)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!c){let g=Object.keys(s.versions);if(r=tRp.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function Qpa(e,t){let{version:r}=await _5s(e.toLowerCase(),t);return r}async function adi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:Qpa(e.packageName,{version:t?"prerelease":"latest"})}var rRp=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],PAo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=V0.Info;constructor(t){this.ttyAwareLogger=new aAo(t);let r=this.getPackageName(),i=this.getPackageVersion(),n=this.getCliName();(r==null||i==null||n==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:i,cliName:n}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.56.17"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Js.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Ute}failWithoutThrowing(t,r){this.didSucceed=!1,tAo({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await $On()).flush(),this.exitProgram()}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await jIp({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1933
+ `,i?emn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function BmD(e){let r=await new mIp.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 xmD({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await wIp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=lsi(o.name,c),g=await MQt({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:c});g!=null&&(l.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),l}let u={type:"multiApi",versions:{}};return await wIp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,d,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][d]==null&&(u.versions[l][d]={});let c=lsi(s.name,o),b=await MQt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function wIp({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let l=await v8t({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let d of l.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function SIp(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let d=Pie(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function oAo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await xmD({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[d,s]of Object.entries(l.versions))u.push(...SIp(s,d,t.logger));else u.push(...SIp(l.versions,void 0,t.logger))}return u}var Fpa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),l=u?`status code ${u}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var Qwn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Jwn=e=>e!==null&&typeof e=="object";var Lpa=(...e)=>{for(let t of e)if((!Jwn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return H8s({},...e)},V8s=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function uAo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:H8s(e[r]??[],t[r]??[])}var W8s=(e={},t={})=>({beforeRequest:uAo(e,t,"beforeRequest"),beforeRetry:uAo(e,t,"beforeRetry"),afterResponse:uAo(e,t,"afterResponse"),beforeError:uAo(e,t,"beforeError")}),H8s=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(Jwn(n)){for(let[a,u]of Object.entries(n))Jwn(u)&&a in t&&(u=H8s(t[a],u)),t={...t,[a]:u};Jwn(n.hooks)&&(i=W8s(i,n.hooks),t.hooks=i),Jwn(n.headers)&&(r=V8s(r,n.headers),t.headers=r)}return t};var DIp=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)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(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),EIp=typeof globalThis.AbortController=="function",MIp=typeof globalThis.ReadableStream=="function",AIp=typeof globalThis.FormData=="function",sAo=["get","post","put","patch","head","delete"],ImD=()=>{};ImD();var qIp={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},cAo=2147483647,lAo=Symbol("stop"),TIp={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},CIp={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 xIp=e=>sAo.includes(e)?e.toUpperCase():e,zmD=["get","put","head","delete","options","trace"],RmD=[408,413,429,500,502,503,504],NmD=[413,429,503],BIp={limit:2,methods:zmD,statusCodes:RmD,afterStatusCodes:NmD,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},IIp=(e={})=>{if(typeof e=="number")return{...BIp,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{...BIp,...e}};async function $8s(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new Qwn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function G8s(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var zIp=(e,t)=>{let r={};for(let i in t)!(i in CIp)&&!(i in TIp)&&!(i in e)&&(r[i]=t[i]);return r};var Upa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>cAo)throw new RangeError(`The \`timeout\` option cannot be greater than ${cAo}`);await Promise.resolve();let l=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let d=new Fpa(l,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!MIp)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return i._stream(l.clone(),i._options.onDownloadProgress)}return l},u=i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n();for(let[l,d]of Object.entries(qIp))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let o=(await u).clone();if(l==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:V8s(this._input.headers,r.headers),hooks:W8s({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:xIp(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:IIp(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(EIp){this.abortController=new globalThis.AbortController;let i=this._options.signal??this._input.signal;i?.addEventListener("abort",()=>{this.abortController.abort(i.reason)}),this._options.signal=this.abortController.signal}if(DIp&&(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 n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(AIp&&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 Qwn)throw t;if(t instanceof Fpa){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=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(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n: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 i=Math.min(this._calculateRetryDelay(r),cAo);if(this._retryCount<1)throw r;await G8s(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===lAo)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=zIp(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):$8s(r,t,this.abortController,this._options)}_stream(t,r){let i=Number(t.headers.get("content-length"))||0,n=0;return t.status===204?(r&&r({percent:1,totalBytes:i,transferredBytes:n},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:i},new Uint8Array);async function l(){let{done:d,value:s}=await u.read();if(d){a.close();return}if(r){n+=s.byteLength;let o=i===0?0:n/i;r({percent:o,transferredBytes:n,totalBytes:i},s)}a.enqueue(s),await l()}await l()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var Q8s=e=>{let t=(r,i)=>Upa.create(r,Lpa(e,i));for(let r of sAo)t[r]=(i,n)=>Upa.create(i,Lpa(e,n,{method:r}));return t.create=r=>Q8s(Lpa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Q8s(Lpa(e,r))),t.stop=lAo,t},FmD=Q8s(),RIp=FmD;var ozp=yi(azp(),1);function Z8s(e){let t=(0,ozp.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var eRp=yi(kzp(),1),tRp=yi(lBi(),1),d5s=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},p5s=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function _5s(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Z8s(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,eRp.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,l&&(d.authorization=`${l.type} ${l.token}`);let s;try{s=await RIp(u,{headers:d,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new d5s(e):c}if(t.allVersions)return s;let o=new p5s(e,r);if(s["dist-tags"][r]){let{time:c}=s;s=s.versions[s["dist-tags"][r]],s.time=c}else if(r){let c=!!s.versions[r];if(i&&!c)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!c){let g=Object.keys(s.versions);if(r=tRp.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function Qpa(e,t){let{version:r}=await _5s(e.toLowerCase(),t);return r}async function adi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:Qpa(e.packageName,{version:t?"prerelease":"latest"})}var rRp=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],PAo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=V0.Info;constructor(t){this.ttyAwareLogger=new aAo(t);let r=this.getPackageName(),i=this.getPackageVersion(),n=this.getCliName();(r==null||i==null||n==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:i,cliName:n}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.56.18"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Js.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Ute}failWithoutThrowing(t,r){this.didSucceed=!1,tAo({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await $On()).flush(),this.exitProgram()}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await jIp({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1934
1934
  `)||(r+=`
1935
1935
  `),this.logger.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram(){process.exit(this.didSucceed?0:1)}longestWorkspaceName;registerWorkspaces(t){let r=lds(t.map(i=>i.type==="docs"?"docs":i.workspaceName??"api"),i=>i.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 Cpa(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 i=this.addTaskWithInit(t).start(),n;try{n=await r(i)}catch(a){throw a.message.includes("globalThis")?(i.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),i.failWithoutThrowing()):i.failWithoutThrowing(void 0,a),new Ute}finally{i.finish()}return n}async instrumentPostHogEvent(t){(await $On()).sendEvent(t)}logger=FGr(this.log.bind(this));constructTaskInitForWorkspace(t){let r=iRp(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?iRp(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=rRp[this.numTasks++%rRp.length],u=Js.hex(a)(n);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===wC.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(i=>Dui.indexOf(i.level)>=Dui.indexOf(this.logLevel));this.ttyAwareLogger.log(r,{includeDebugInfo:this.logLevel===V0.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 adi({cliEnvironment:this.environment,includePreReleases:t}),i=Pie(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await oAo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await w8s({message:t,default:r})}async getInput(t){return await S8s({message:t.message,default:t.default})}};function iRp(e){return`[${e}]:`}var jYp=require("fs/promises");function jie({breadcrumbs:e=[],title:t,subtitle:r}){let i=[];return e.length>0&&i.push(Js.blue(e.join(" -> "))),i.push(t),r!=null&&i.push(Js.dim(r)),i.join(`
1936
1936
  `)}var xHp=require("fs/promises");var D5t=class e{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;type=e.Type;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};var USe=class extends D5t{definition;sources;constructor({definition:t,sources:r,...i}){super(i),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var Jpa=class{context;constructor(t){this.context=t}};var jAo=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[u,l]of Object.entries(i.files)){let d=n!=null?sy.of(`${n}${N4t}${u}`):sy.of(u);t[d]=l}let a=Object.keys(i.directories).sort();for(let u of a){let l=n!=null?`${n}${N4t}${u}`:u,d=i.directories[u];r(d,l)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(N4t))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[sy.of(t[0])]??={};let[r,...i]=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(i)}};var hRi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new jAo,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":i,"display-name":n,docs:a}){let u=this.getOrCreateFile(t);u.service==null&&(u.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(u.service.auth=r),i!=null&&(u.service["base-path"]=i),n!=null&&(u.service["display-name"]=n),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 pQr(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??{});if(this.rootApiFile["auth-schemes"]!=null)for(let i of Object.values(this.rootApiFile["auth-schemes"]))HPD(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===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:i}){if(t===r)return;let n=i??Dg((DBe(r)+"/"+_Ci(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===sy.of(Q3))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=Rka(DBe(Zhn.of(`/${t}`)),Zhn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=Rka(DBe(Zhn.of(`/${t}`)),Zhn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(l=>F1e(l,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=PR(n,r.path))}addChannelExample(t,{example:r}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.examples==null&&(i.channel.examples=[]),i.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:i}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.messages[r]=i}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(([n,a])=>[n,{...a,path:PR(r,a.path)}]))});for(let n of Object.values(t))n.service!=null&&(n.service={...n.service,endpoints:Object.fromEntries(Object.entries(n.service.endpoints).map(([a,u])=>[a,{...u,path:PR(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===X1?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}};function HPD(e){return e?.header!=null}var wie={openapi:e=>({...e,type:"openapi",_visit:function(t){return wie._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return wie._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 t1n={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return t1n._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var g5={basic:e=>({...e,type:"basic",_visit:function(t){return g5._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return g5._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return g5._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return g5._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return g5._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 rg={primitive:e=>({value:e,type:"primitive",_visit:function(t){return rg._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return rg._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return rg._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return rg._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return rg._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return rg._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return rg._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return rg._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 u_={int:e=>({value:e,type:"int",_visit:function(t){return u_._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return u_._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return u_._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return u_._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return u_._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return u_._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return u_._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return u_._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return u_._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return u_._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return u_._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 r1n={boolean:e=>({value:e,type:"boolean",_visit:function(t){return r1n._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return r1n._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 odi={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return odi._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return odi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undiscriminated":return t.undiscriminated(e.value);default:return t._other(e)}}};var pV={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case pV.GenerallyAvailable:return t.generallyAvailable();case pV.Beta:return t.beta();case pV.Deprecated:return t.deprecated();default:return t._other()}}};var hze={cursor:e=>({...e,type:"cursor",_visit(t){return hze._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit(t){return hze._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit(t){return hze._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var kJr={language:e=>({...e,type:"language",_visit:function(t){return kJr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return kJr._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 _V={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 _V.Curl:return t.curl();case _V.Python:return t.python();case _V.Javascript:return t.javascript();case _V.Typescript:return t.typescript();case _V.Go:return t.go();case _V.Ruby:return t.ruby();case _V.Csharp:return t.csharp();case _V.Java:return t.java();case _V.Js:return t.js();case _V.Node:return t.node();case _V.Ts:return t.ts();case _V.Nodets:return t.nodets();case _V.Golang:return t.golang();case _V.Dotnet:return t.dotnet();case _V.Jvm:return t.jvm();default:return t._other()}}};var E5t={unknown:e=>({value:e,type:"unknown",_visit:function(t){return E5t._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return E5t._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 yze={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return yze._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return yze._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var pG={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case pG.Get:return t.get();case pG.Post:return t.post();case pG.Put:return t.put();case pG.Patch:return t.patch();case pG.Delete:return t.delete();case pG.Head:return t.head();case pG.Options:return t.options();case pG.Trace:return t.trace();default:return t._other()}}};var udi={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return udi._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return udi._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return udi._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 vze={file:e=>({...e,type:"file",_visit:function(t){return vze._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return vze._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 Sie={file:e=>({...e,type:"file",_visit:function(t){return Sie._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Sie._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Sie._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return Sie._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return Sie._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return Sie._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 gy={primitive:e=>({...e,type:"primitive",_visit:function(t){return gy._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return gy._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return gy._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return gy._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return gy._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return gy._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return gy._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return gy._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return gy._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return gy._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return gy._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 vj={int:e=>({...e,type:"int",_visit:function(t){return vj._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return vj._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return vj._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return vj._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return vj._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return vj._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return vj._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return vj._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return vj._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return vj._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return vj._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 cx={boolean:e=>({value:e,type:"boolean",_visit:function(t){return cx._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return cx._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 eKr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return eKr._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return eKr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var VSe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return VSe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return VSe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return VSe._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 lx={file:e=>({...e,type:"file",_visit:function(t){return lx._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return lx._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return lx._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return lx._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return lx._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return lx._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 El={primitive:e=>({...e,type:"primitive",_visit:function(t){return El._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return El._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return El._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return El._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return El._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return El._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return El._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return El._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return El._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return El._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return El._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 QY={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return QY._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return QY._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var Xd={int:e=>({...e,type:"int",_visit:function(t){return Xd._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Xd._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return Xd._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return Xd._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return Xd._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return Xd._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Xd._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Xd._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return Xd._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return Xd._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Xd._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 uv={};Co(uv,{AllOfPropertyConflict:()=>w1n,ArraySchema:()=>Rqo,ArraySchemaWithExample:()=>fTo,Availability:()=>BAo,Base64WithExample:()=>oTo,BasicSecurityScheme:()=>zAo,BearerSecurityScheme:()=>RAo,BooleanSchema:()=>Tqo,BooleanWithExample:()=>uTo,CasingOverrides:()=>LAo,CommonProperty:()=>$qo,CommonPropertyWithExample:()=>OTo,CursorPagination:()=>yqo,CustomCodeSample:()=>_qo,CustomCodeSampleLanguage:()=>fqo,CustomCodeSampleSdk:()=>pqo,CustomPagination:()=>bqo,DateWithExample:()=>aTo,DatetimeWithExample:()=>nTo,DiscriminatedOneOfSchema:()=>Wqo,DiscriminatedOneOfSchemaWithExample:()=>bTo,DoubleSchema:()=>Aqo,DoubleWithExample:()=>rTo,Encoding:()=>CAo,Endpoint:()=>gqo,EndpointExample:()=>g1n,EndpointResponseExample:()=>lqo,EndpointSdkName:()=>nXt,EndpointWithExample:()=>BRp,EnumSchema:()=>o1n,EnumSchemaWithExample:()=>cTo,EnumValue:()=>ldi,ErrorExample:()=>aqo,FernExample:()=>uqo,FileResponse:()=>_1n,FileSchema:()=>ZAo,FloatWithExample:()=>tTo,FullEndpointExample:()=>hqo,FullExample:()=>WA,FullObjectExample:()=>QAo,FullOneOfExample:()=>KAo,GlobalHeader:()=>Bqo,Header:()=>ddi,HeaderExample:()=>b1n,HeaderSecurityScheme:()=>NAo,HeaderWithExample:()=>hdi,HttpEndpointServer:()=>y1n,HttpError:()=>oqo,HttpErrorWithExample:()=>Yqo,HttpMethod:()=>c1n,IdempotencyHeader:()=>xqo,Int64WithExample:()=>Zqo,IntSchema:()=>Eqo,IntWithExample:()=>Xqo,JsonRequest:()=>rqo,JsonRequestWithExample:()=>Qqo,JsonResponse:()=>h1n,JsonResponseWithExample:()=>E1n,KeyValuePair:()=>JAo,LiteralExample:()=>GAo,LiteralSchema:()=>j1n,LiteralSchemaValue:()=>Iqo,LongSchema:()=>Mqo,MapSchema:()=>Nqo,MapSchemaWithExample:()=>dTo,MultipartRequest:()=>p1n,MultipartRequestProperty:()=>tqo,MultipartRequestPropertyEncoding:()=>eqo,MultipartSchema:()=>kAo,NamedFullExample:()=>oXt,Namespace:()=>UAo,NamespaceId:()=>$Ao,NullableSchema:()=>Lqo,NullableSchemaWithExample:()=>_To,OauthSecurityScheme:()=>WAo,ObjectProperty:()=>Vqo,ObjectPropertyConflictInfo:()=>S1n,ObjectPropertyWithExample:()=>vTo,ObjectSchema:()=>zqo,ObjectSchemaWithExample:()=>hTo,OctetStreamRequest:()=>d1n,OffsetPagination:()=>vqo,OneOfSchema:()=>Uqo,OneOfSchemaWithExample:()=>yTo,OpenApiIntermediateRepresentation:()=>TRp,OpenApiSource:()=>MAo,OptionalSchema:()=>Fqo,OptionalSchemaWithExample:()=>pTo,Pagination:()=>O1n,PathParameter:()=>l1n,PathParameterExample:()=>sqo,PathParameterWithExample:()=>Gqo,PrimitiveExample:()=>s1n,PrimitiveSchema:()=>_di,PrimitiveSchemaValue:()=>Cqo,PrimitiveSchemaValueWithExample:()=>sTo,PrimitiveSchemaWithExample:()=>M1n,PropertyKey:()=>u1n,ProtobufEncoding:()=>TAo,ProtobufSource:()=>AAo,QueryParameter:()=>f1n,QueryParameterExample:()=>v1n,QueryParameterWithExample:()=>D1n,QuerySecurityScheme:()=>FAo,ReferencedSchema:()=>aXt,Request:()=>iqo,RequestWithExample:()=>Jqo,Response:()=>nqo,ResponseWithExample:()=>Kqo,Schema:()=>IO,SchemaId:()=>JY,SchemaWithExample:()=>EM,Schemas:()=>Dqo,SdkGroup:()=>VAo,SdkGroupInfo:()=>YAo,SdkGroupName:()=>fdi,SecurityScheme:()=>HAo,SecuritySchemeId:()=>IAo,Server:()=>Zpa,Source:()=>qAo,StatusCode:()=>tXt,StreamingResponseExample:()=>cqo,StringSchema:()=>qqo,StringSchemaWithExample:()=>iTo,SupportedSdkLanguage:()=>dqo,Tag:()=>xAo,TagId:()=>KY,Tags:()=>XAo,TextResponse:()=>pdi,Uint64WithExample:()=>eTo,UintWithExample:()=>kqo,UnDiscriminatedOneOfSchema:()=>Hqo,UnDiscriminatedOneOfSchemaWithExample:()=>gTo,UnknownSchemaWithExample:()=>lTo,Webhook:()=>Oqo,WebhookExampleCall:()=>P1n,WebhookHttpMethod:()=>m1n,WebhookWithExample:()=>xRp,WebsocketChannel:()=>Sqo,WebsocketHandshake:()=>mqo,WebsocketHandshakeWithExample:()=>CRp,WebsocketMessageExample:()=>jqo,WebsocketServer:()=>Pqo,WebsocketSessionExample:()=>wqo,WithAvailability:()=>dh,WithDescription:()=>_f,WithEncoding:()=>Die,WithInline:()=>uE,WithName:()=>s0,WithNamespace:()=>iXt,WithSdkGroupName:()=>xO,WithSource:()=>ly,WithStatusCode:()=>rXt,WithTitle:()=>BO,commons:()=>g5s,example:()=>O5s,finalIr:()=>m5s,parseIr:()=>P5s});var g5s={};Co(g5s,{BasicSecurityScheme:()=>zAo,BearerSecurityScheme:()=>RAo,Encoding:()=>CAo,HeaderSecurityScheme:()=>NAo,Namespace:()=>UAo,NamespaceId:()=>$Ao,OauthSecurityScheme:()=>WAo,OpenApiSource:()=>MAo,ProtobufEncoding:()=>TAo,ProtobufSource:()=>AAo,QuerySecurityScheme:()=>FAo,SchemaId:()=>JY,SdkGroup:()=>VAo,SdkGroupName:()=>fdi,SecurityScheme:()=>HAo,SecuritySchemeId:()=>IAo,Server:()=>Zpa,Source:()=>qAo,StatusCode:()=>tXt,Tag:()=>xAo,TagId:()=>KY,WithAvailability:()=>dh,WithDescription:()=>_f,WithEncoding:()=>Die,WithInline:()=>uE,WithName:()=>s0,WithNamespace:()=>iXt,WithSdkGroupName:()=>xO,WithSource:()=>ly,WithStatusCode:()=>rXt,WithTitle:()=>BO});var At={};Co(At,{JsonError:()=>i1n,ParseError:()=>n1n,any:()=>bRp,bigint:()=>aRp,boolean:()=>gRp,booleanLiteral:()=>vRp,date:()=>oRp,discriminant:()=>MRp,enum_:()=>SAo,getObjectLikeUtils:()=>M5t,getObjectUtils:()=>yRi,getSchemaUtils:()=>VA,isProperty:()=>cdi,lazy:()=>uRp,lazyObject:()=>_Rp,list:()=>EAo,number:()=>ORp,object:()=>DAo,objectWithoutOptionalProperties:()=>pRp,optional:()=>h5s,property:()=>cRp,record:()=>wRp,set:()=>SRp,string:()=>mRp,stringLiteral:()=>yRp,transform:()=>y5s,undiscriminatedUnion:()=>ERp,union:()=>qRp,unknown:()=>PRp,withParsedProperties:()=>b5s});var JP={BIGINT:"bigint",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 DM(e,t){return`Expected ${t}. Received ${$PD(e)}.`}function $PD(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function O5(e){return{...e,json:nRp(e.json),parse:nRp(e.parse)}}function nRp(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
1937
- `)),{ok:!0,value:t}):i}}function wAo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var i1n=class e extends Error{errors;constructor(t){super(t.map(wAo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var n1n=class e extends Error{errors;constructor(t){super(t.map(wAo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function VA(e){return{optional:()=>h5s(e),transform:t=>y5s(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new n1n(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new i1n(i.errors)}}}function h5s(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>JP.OPTIONAL};return{...t,...VA(t)}}function y5s(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...VA(r)}}function aRp(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:DM(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:DM(t,"bigint")}]},getType:()=>JP.BIGINT};return{...O5(e),...VA(e)}}var GPD=/^([+-]?\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 oRp(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:DM(t,"string")}]}:GPD.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:DM(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:DM(t,"Date object")}]},getType:()=>JP.DATE};return{...O5(e),...VA(e)}}function _G(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...O5(r),...VA(r)}}}function SAo(e){let t=new Set(e);return _G(JP.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:DM(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:DM(i,"enum")}]}:{ok:!0,value:i})()}function uRp(e){let t=v5s(e);return{...t,...VA(t)}}function v5s(e){return{parse:(t,r)=>a1n(e).parse(t,r),json:(t,r)=>a1n(e).json(t,r),getType:()=>a1n(e).getType()}}function a1n(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function Kpa(e){return Object.entries(e)}function Ypa(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function sdi(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 Xpa(e){return Object.keys(e)}function sRp(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function M5t(e){return{withParsedProperties:t=>b5s(e,t)}}function b5s(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((l,[d,s])=>({...l,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!sdi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:DM(i,"object")}]};let a=new Set(Object.keys(t)),u=Ypa(i,Object.keys(i).filter(l=>!a.has(l)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...VA(r),...M5t(r)}}function cRp(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function cdi(e){return e.isProperty}function DAo(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>cdi(i)?i.rawKey:r),_getParsedProperties:()=>Xpa(e),parse:(r,i)=>{let n={},a=[];for(let[u,l]of Kpa(e)){let d=cdi(l)?l.rawKey:u,s=cdi(l)?l.valueSchema:l,o={rawKey:d,parsedKey:u,valueSchema:s};n[d]=o,dRp(s)&&a.push(d)}return lRp({value:r,requiredKeys:a,getProperty:u=>{let l=n[u];if(l!=null)return{transformedKey:l.parsedKey,transform:d=>l.valueSchema.parse(d,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of Kpa(e)){let l=cdi(u)?u.valueSchema:u;dRp(l)&&n.push(a)}return lRp({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return cdi(u)?{transformedKey:u.rawKey,transform:l=>u.valueSchema.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:l=>u.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>JP.OBJECT};return{...O5(t),...VA(t),...M5t(t),...yRi(t)}}function lRp({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!sdi(e))return{ok:!1,errors:[{path:a,message:DM(e,"object")}]};let u=new Set(t),l=[],d={};for(let[s,o]of Object.entries(e)){let c=r(s);if(c!=null){u.delete(s);let b=c.transform(o);b.ok?d[c.transformedKey]=b.value:(d[s]=o,l.push(...b.errors))}else switch(i){case"fail":l.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=o;break}}return l.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),l.length===0||n?{ok:!0,value:d}:{ok:!1,errors:l}}function yRi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>fRp({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>fRp({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>JP.OBJECT};return{...r,...VA(r),...M5t(r),...yRi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>JP.OBJECT};return{...t,...VA(t),...M5t(t),...yRi(t)}}}}function fRp({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=sRp(Xpa(t),s=>n.has(s)),l=r(Ypa(t,u)),d=i(Ypa(t,a));return l.ok&&d.ok?{ok:!0,value:{...l.value,...d.value}}:{ok:!1,errors:[...l.ok?[]:l.errors,...d.ok?[]:d.errors]}}function dRp(e){return!QPD(e)}function QPD(e){switch(e.getType()){case JP.ANY:case JP.UNKNOWN:case JP.OPTIONAL:return!0;default:return!1}}function pRp(e){return DAo(e)}function _Rp(e){let t={...v5s(e),_getRawProperties:()=>a1n(e)._getRawProperties(),_getParsedProperties:()=>a1n(e)._getParsedProperties()};return{...t,...VA(t),...M5t(t),...yRi(t)}}function EAo(e){let t={parse:(r,i)=>hRp(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>hRp(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>JP.LIST};return{...O5(t),...VA(t)}}function hRp(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:DM(e,"list"),path:[]}]}}function yRp(e){return _G(JP.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:DM(r,`"${e}"`)}]})()}function vRp(e){return _G(JP.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:DM(r,`${e.toString()}`)}]})()}var bRp=_G(JP.ANY,e=>({ok:!0,value:e}));var gRp=_G(JP.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DM(e,"boolean")}]});var ORp=_G(JP.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DM(e,"number")}]});var mRp=_G(JP.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DM(e,"string")}]});var PRp=_G(JP.UNKNOWN,e=>({ok:!0,value:e}));function wRp(e,t){let r={parse:(i,n)=>jRp({value:i,isKeyNumeric:e.getType()===JP.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>jRp({value:i,isKeyNumeric:e.getType()===JP.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>JP.RECORD};return{...O5(r),...VA(r)}}function jRp({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return sdi(e)?Kpa(e).reduce((a,[u,l])=>{if(l==null)return a;let d=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),c=i(l,s);if(d.ok&&o.ok&&c.ok)return{ok:!0,value:{...d.value,[o.value]:c.value}};let b=[];return d.ok||b.push(...d.errors),o.ok||b.push(...o.errors),c.ok||b.push(...c.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:DM(e,"object")}]}}function SRp(e){let t=EAo(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:DM(i,"Set")}]},getType:()=>JP.SET};return{...O5(r),...VA(r)}}function ERp(e){let t={parse:(r,i)=>DRp((n,a)=>n.parse(r,a),e,i),json:(r,i)=>DRp((n,a)=>n.json(r,a),e,i),getType:()=>JP.UNDISCRIMINATED_UNION};return{...O5(t),...VA(t)}}function DRp(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let l of u.errors)i.push({path:l.path,message:`[Variant ${n}] ${l.message}`})}return{ok:!1,errors:i}}function MRp(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function qRp(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=SAo(Xpa(t)),a={parse:(u,l)=>ARp({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:d=>n.parse(d,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),json:(u,l)=>ARp({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:d=>n.json(d,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),getType:()=>JP.UNION};return{...O5(a),...VA(a),...M5t(a)}}function ARp({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:l=[]}){if(!sdi(e))return{ok:!1,errors:[{path:l,message:DM(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:l,message:`Missing discriminant ("${t}")`}]};let o=i(d);if(!o.ok)return{ok:!1,errors:o.errors};let c=n(o.value);if(c==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...l,t],message:"Unexpected discriminant value"}]};let b=u(s,c);return b.ok?{ok:!0,value:{[r]:d,...b.value}}:b}var BO=At.objectWithoutOptionalProperties({title:At.string().optional()});var MAo=At.objectWithoutOptionalProperties({file:At.string()});var AAo=At.objectWithoutOptionalProperties({file:At.string()});var qAo=At.union("type",{openapi:MAo,protobuf:AAo}).transform({transform:e=>{switch(e.type){case"openapi":return wie.openapi(e);case"protobuf":return wie.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var ly=At.objectWithoutOptionalProperties({source:qAo.optional()});var TAo=At.objectWithoutOptionalProperties({typeName:At.string()});var CAo=At.union("type",{protobuf:TAo}).transform({transform:e=>{switch(e.type){case"protobuf":return t1n.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Die=At.objectWithoutOptionalProperties({encoding:CAo.optional()});var _f=At.objectWithoutOptionalProperties({description:At.string().optional()});var BAo=At.enum_(["GenerallyAvailable","Beta","Deprecated"]);var dh=At.objectWithoutOptionalProperties({availability:BAo.optional()});var tXt=At.number();var rXt=At.objectWithoutOptionalProperties({statusCode:tXt.optional()});var s0=At.objectWithoutOptionalProperties({nameOverride:At.string().optional(),generatedName:At.string()});var uE=At.objectWithoutOptionalProperties({inline:At.boolean().optional()});var JY=At.string();var KY=At.string();var xAo=At.objectWithoutOptionalProperties({id:KY}).extend(_f);var IAo=At.string();var zAo=At.objectWithoutOptionalProperties({usernameVariableName:At.string().optional(),usernameEnvVar:At.string().optional(),passwordVariableName:At.string().optional(),passwordEnvVar:At.string().optional()});var RAo=At.objectWithoutOptionalProperties({tokenVariableName:At.string().optional(),tokenEnvVar:At.string().optional()});var NAo=At.objectWithoutOptionalProperties({headerName:At.string(),prefix:At.string().optional(),headerVariableName:At.string().optional(),headerEnvVar:At.string().optional()});var FAo=At.objectWithoutOptionalProperties({queryParameterName:At.string()});var LAo=At.objectWithoutOptionalProperties({snake:At.string().optional(),camel:At.string().optional(),screamingSnake:At.string().optional(),pascal:At.string().optional()});var ldi=At.objectWithoutOptionalProperties({nameOverride:At.string().optional(),generatedName:At.string(),value:At.string(),casing:LAo.optional()}).extend(_f).extend(dh);var UAo=At.objectWithoutOptionalProperties({type:At.stringLiteral("namespace"),name:At.string()});var VAo=At.undiscriminatedUnion([At.string(),UAo]);var fdi=At.list(VAo);var xO=At.objectWithoutOptionalProperties({groupName:fdi.optional()});var o1n=At.objectWithoutOptionalProperties({default:ldi.optional(),values:At.list(ldi)}).extend(_f).extend(s0).extend(xO).extend(dh).extend(ly).extend(BO).extend(uE);var WAo=At.objectWithoutOptionalProperties({scopesEnum:o1n.optional()});var HAo=At.union("type",{basic:zAo,bearer:RAo,header:NAo,query:FAo,oauth:WAo}).transform({transform:e=>{switch(e.type){case"basic":return g5.basic(e);case"bearer":return g5.bearer(e);case"header":return g5.header(e);case"query":return g5.query(e);case"oauth":return g5.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var Zpa=At.objectWithoutOptionalProperties({name:At.string().optional(),url:At.string(),audiences:At.list(At.string()).optional()}).extend(_f);var $Ao=At.string();var iXt=At.objectWithoutOptionalProperties({namespace:At.string().optional()});var O5s={};Co(O5s,{FullExample:()=>WA,FullObjectExample:()=>QAo,FullOneOfExample:()=>KAo,KeyValuePair:()=>JAo,LiteralExample:()=>GAo,PrimitiveExample:()=>s1n,PropertyKey:()=>u1n});var u1n=At.string();var s1n=At.union("type",{int:At.object({value:At.number()}),int64:At.object({value:At.number()}),uint:At.object({value:At.number()}),uint64:At.object({value:At.number()}),float:At.object({value:At.number()}),double:At.object({value:At.number()}),string:At.object({value:At.string()}),datetime:At.object({value:At.string()}),date:At.object({value:At.string()}),base64:At.object({value:At.string()}),boolean:At.object({value:At.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return u_.int(e.value);case"int64":return u_.int64(e.value);case"uint":return u_.uint(e.value);case"uint64":return u_.uint64(e.value);case"float":return u_.float(e.value);case"double":return u_.double(e.value);case"string":return u_.string(e.value);case"datetime":return u_.datetime(e.value);case"date":return u_.date(e.value);case"base64":return u_.base64(e.value);case"boolean":return u_.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var GAo=At.union("type",{boolean:At.object({value:At.boolean()}),string:At.object({value:At.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return r1n.boolean(e.value);case"string":return r1n.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var WA=At.union("type",{primitive:At.object({value:s1n}),object:At.lazyObject(()=>QAo),array:At.object({value:At.list(At.lazy(()=>WA))}),map:At.object({value:At.list(At.lazyObject(()=>JAo))}),enum:At.object({value:At.string()}),literal:At.object({value:GAo}),oneOf:At.object({value:At.lazy(()=>KAo)}),unknown:At.object({value:At.lazy(()=>WA)})}).transform({transform:e=>{switch(e.type){case"primitive":return rg.primitive(e.value);case"object":return rg.object(e);case"array":return rg.array(e.value);case"map":return rg.map(e.value);case"enum":return rg.enum(e.value);case"literal":return rg.literal(e.value);case"oneOf":return rg.oneOf(e.value);case"unknown":return rg.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var QAo=At.objectWithoutOptionalProperties({properties:At.record(u1n,At.lazy(()=>WA))});var JAo=At.objectWithoutOptionalProperties({key:s1n,value:At.lazy(()=>WA)});var KAo=At.union("type",{discriminated:At.object({value:At.record(u1n,At.lazy(()=>WA))}),undiscriminated:At.object({value:At.lazy(()=>WA)})}).transform({transform:e=>{switch(e.type){case"discriminated":return odi.discriminated(e.value);case"undiscriminated":return odi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var m5s={};Co(m5s,{AllOfPropertyConflict:()=>w1n,ArraySchema:()=>Rqo,Availability:()=>BAo,BooleanSchema:()=>Tqo,CasingOverrides:()=>LAo,CommonProperty:()=>$qo,CursorPagination:()=>yqo,CustomCodeSample:()=>_qo,CustomCodeSampleLanguage:()=>fqo,CustomCodeSampleSdk:()=>pqo,CustomPagination:()=>bqo,DiscriminatedOneOfSchema:()=>Wqo,DoubleSchema:()=>Aqo,Endpoint:()=>gqo,EndpointExample:()=>g1n,EndpointResponseExample:()=>lqo,EndpointSdkName:()=>nXt,EnumSchema:()=>o1n,EnumValue:()=>ldi,ErrorExample:()=>aqo,FernExample:()=>uqo,FileResponse:()=>_1n,FileSchema:()=>ZAo,FullEndpointExample:()=>hqo,GlobalHeader:()=>Bqo,Header:()=>ddi,HeaderExample:()=>b1n,HttpEndpointServer:()=>y1n,HttpError:()=>oqo,HttpMethod:()=>c1n,IdempotencyHeader:()=>xqo,IntSchema:()=>Eqo,JsonRequest:()=>rqo,JsonResponse:()=>h1n,LiteralSchema:()=>j1n,LiteralSchemaValue:()=>Iqo,LongSchema:()=>Mqo,MapSchema:()=>Nqo,MultipartRequest:()=>p1n,MultipartRequestProperty:()=>tqo,MultipartRequestPropertyEncoding:()=>eqo,MultipartSchema:()=>kAo,NullableSchema:()=>Lqo,ObjectProperty:()=>Vqo,ObjectPropertyConflictInfo:()=>S1n,ObjectSchema:()=>zqo,OctetStreamRequest:()=>d1n,OffsetPagination:()=>vqo,OneOfSchema:()=>Uqo,OpenApiIntermediateRepresentation:()=>TRp,OptionalSchema:()=>Fqo,Pagination:()=>O1n,PathParameter:()=>l1n,PathParameterExample:()=>sqo,PrimitiveSchema:()=>_di,PrimitiveSchemaValue:()=>Cqo,QueryParameter:()=>f1n,QueryParameterExample:()=>v1n,ReferencedSchema:()=>aXt,Request:()=>iqo,Response:()=>nqo,Schema:()=>IO,Schemas:()=>Dqo,SdkGroupInfo:()=>YAo,StreamingResponseExample:()=>cqo,StringSchema:()=>qqo,SupportedSdkLanguage:()=>dqo,Tags:()=>XAo,TextResponse:()=>pdi,UnDiscriminatedOneOfSchema:()=>Hqo,Webhook:()=>Oqo,WebhookExampleCall:()=>P1n,WebhookHttpMethod:()=>m1n,WebsocketChannel:()=>Sqo,WebsocketHandshake:()=>mqo,WebsocketMessageExample:()=>jqo,WebsocketServer:()=>Pqo,WebsocketSessionExample:()=>wqo});var YAo=At.objectWithoutOptionalProperties({summary:At.string().optional(),description:At.string().optional()});var XAo=At.objectWithoutOptionalProperties({tagsById:At.record(KY,xAo),orderedTagIds:At.list(KY).optional()});var c1n=At.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var l1n=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>IO),variableReference:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(_f).extend(dh).extend(ly);var f1n=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>IO),parameterNameOverride:At.string().optional()}).extend(_f).extend(dh).extend(ly);var ddi=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>IO),env:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(_f).extend(dh).extend(ly);var nXt=At.objectWithoutOptionalProperties({groupName:fdi,methodName:At.string()});var d1n=At.objectWithoutOptionalProperties({}).extend(_f).extend(ly);var ZAo=At.objectWithoutOptionalProperties({isOptional:At.boolean(),isArray:At.boolean()}).extend(_f);var kAo=At.union("type",{file:ZAo,json:At.object({value:At.lazy(()=>IO)})}).transform({transform:e=>{switch(e.type){case"file":return vze.file(e);case"json":return vze.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var eqo=At.enum_(["json","form"]);var tqo=At.objectWithoutOptionalProperties({key:At.string(),schema:kAo,contentType:At.string().optional(),exploded:At.boolean().optional(),encoding:eqo.optional()}).extend(_f);var p1n=At.objectWithoutOptionalProperties({name:At.string().optional(),properties:At.list(tqo)}).extend(_f).extend(ly);var rqo=At.objectWithoutOptionalProperties({schema:At.lazy(()=>IO),contentType:At.string().optional(),additionalProperties:At.boolean()}).extend(_f).extend(ly);var iqo=At.union("type",{octetStream:d1n,multipart:p1n,json:rqo}).transform({transform:e=>{switch(e.type){case"octetStream":return udi.octetStream(e);case"multipart":return udi.multipart(e);case"json":return udi.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var _1n=At.objectWithoutOptionalProperties({}).extend(_f).extend(ly).extend(rXt);var h1n=At.objectWithoutOptionalProperties({schema:At.lazy(()=>IO),responseProperty:At.string().optional()}).extend(_f).extend(ly).extend(rXt);var pdi=At.objectWithoutOptionalProperties({}).extend(_f).extend(ly).extend(rXt);var nqo=At.union("type",{file:_1n,json:h1n,text:pdi,streamingSse:h1n,streamingText:pdi,streamingJson:h1n}).transform({transform:e=>{switch(e.type){case"file":return Sie.file(e);case"json":return Sie.json(e);case"text":return Sie.text(e);case"streamingSse":return Sie.streamingSse(e);case"streamingText":return Sie.streamingText(e);case"streamingJson":return Sie.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var aqo=At.objectWithoutOptionalProperties({name:At.string().optional(),description:At.string().optional(),example:At.lazy(()=>WA)});var oqo=At.objectWithoutOptionalProperties({schema:At.lazy(()=>IO).optional(),examples:At.list(aqo).optional()}).extend(_f).extend(s0).extend(ly);var y1n=At.objectWithoutOptionalProperties({name:At.string().optional(),url:At.string().optional(),audiences:At.list(At.string()).optional()});var uqo=At.unknown();var sqo=At.objectWithoutOptionalProperties({name:At.string(),parameterNameOverride:At.string().optional(),value:At.lazy(()=>WA)});var v1n=At.objectWithoutOptionalProperties({name:At.string(),value:At.lazy(()=>WA)});var b1n=At.objectWithoutOptionalProperties({name:At.string(),value:At.lazy(()=>WA)});var cqo=At.objectWithoutOptionalProperties({sse:At.boolean(),events:At.list(At.lazy(()=>WA))});var lqo=At.union("type",{withStreaming:cqo,withoutStreaming:At.object({value:At.lazy(()=>WA)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return yze.withStreaming(e);case"withoutStreaming":return yze.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var fqo=At.objectWithoutOptionalProperties({name:At.string().optional(),language:At.string(),code:At.string(),install:At.string().optional()}).extend(_f);var dqo=At.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var pqo=At.objectWithoutOptionalProperties({name:At.string().optional(),sdk:dqo,code:At.string()}).extend(_f);var _qo=At.union("type",{language:fqo,sdk:pqo}).transform({transform:e=>{switch(e.type){case"language":return kJr.language(e);case"sdk":return kJr.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var hqo=At.objectWithoutOptionalProperties({name:At.string().optional(),pathParameters:At.list(sqo).optional(),queryParameters:At.list(v1n).optional(),headers:At.list(b1n).optional(),request:At.lazy(()=>WA).optional(),response:lqo.optional(),codeSamples:At.list(_qo)}).extend(_f);var g1n=At.union("type",{unknown:At.object({value:uqo}),full:hqo}).transform({transform:e=>{switch(e.type){case"unknown":return E5t.unknown(e.value);case"full":return E5t.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var yqo=At.objectWithoutOptionalProperties({cursor:At.string(),nextCursor:At.property("next_cursor",At.string()),results:At.string()});var vqo=At.objectWithoutOptionalProperties({offset:At.string(),results:At.string(),step:At.string().optional(),hasNextPage:At.string().optional()});var bqo=At.objectWithoutOptionalProperties({results:At.string()});var O1n=At.union("type",{cursor:yqo,offset:vqo,custom:bqo}).transform({transform:e=>{switch(e.type){case"cursor":return hze.cursor(e);case"offset":return hze.offset(e);case"custom":return hze.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var gqo=At.objectWithoutOptionalProperties({authed:At.boolean(),internal:At.boolean().optional(),idempotent:At.boolean().optional(),method:c1n,audiences:At.list(At.string()),path:At.string(),summary:At.string().optional(),operationId:At.string().optional(),tags:At.list(KY),pathParameters:At.list(l1n),queryParameters:At.list(f1n),headers:At.list(ddi),sdkName:nXt.optional(),generatedRequestName:At.string(),requestNameOverride:At.string().optional(),request:iqo.optional(),response:nqo.optional(),errors:At.record(tXt,oqo),servers:At.list(y1n),examples:At.list(g1n),pagination:O1n.optional()}).extend(_f).extend(dh).extend(ly).extend(iXt);var m1n=At.enum_(["GET","POST"]);var P1n=At.objectWithoutOptionalProperties({name:At.string().optional(),payload:At.lazy(()=>WA)}).extend(_f);var Oqo=At.objectWithoutOptionalProperties({sdkName:nXt.optional(),method:m1n,summary:At.string().optional(),operationId:At.string(),tags:At.list(KY),headers:At.list(ddi),generatedPayloadName:At.string(),payload:At.lazy(()=>IO),examples:At.list(P1n)}).extend(_f).extend(ly).extend(iXt);var mqo=At.objectWithoutOptionalProperties({queryParameters:At.list(f1n),headers:At.list(ddi),pathParameters:At.list(l1n)});var Pqo=At.objectWithoutOptionalProperties({name:At.string(),url:At.string()});var jqo=At.objectWithoutOptionalProperties({messageType:At.string(),payload:At.lazy(()=>WA)}).extend(_f);var wqo=At.objectWithoutOptionalProperties({name:At.string().optional(),queryParameters:At.list(v1n).optional(),headers:At.list(b1n).optional(),messages:At.list(jqo)}).extend(_f);var Sqo=At.objectWithoutOptionalProperties({audiences:At.list(At.string()),path:At.string(),groupName:fdi,summary:At.string().optional(),handshake:mqo,publish:At.lazy(()=>IO).optional(),subscribe:At.lazy(()=>IO).optional(),servers:At.list(Pqo),examples:At.list(wqo)}).extend(_f).extend(ly);var Dqo=At.objectWithoutOptionalProperties({rootSchemas:At.record(JY,At.lazy(()=>IO)),namespacedSchemas:At.record($Ao,At.record(JY,At.lazy(()=>IO)))});var Eqo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional()});var Mqo=At.objectWithoutOptionalProperties({default:At.number().optional()});var Aqo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional()});var qqo=At.objectWithoutOptionalProperties({default:At.string().optional(),pattern:At.string().optional(),format:At.string().optional(),minLength:At.number().optional(),maxLength:At.number().optional()});var Tqo=At.objectWithoutOptionalProperties({default:At.boolean().optional()});var Cqo=At.union("type",{int:Eqo,int64:Mqo,uint:At.object({}),uint64:At.object({}),float:At.object({}),double:Aqo,string:qqo,datetime:At.object({}),date:At.object({}),base64:At.object({}),boolean:Tqo}).transform({transform:e=>{switch(e.type){case"int":return vj.int(e);case"int64":return vj.int64(e);case"uint":return vj.uint();case"uint64":return vj.uint64();case"float":return vj.float();case"double":return vj.double(e);case"string":return vj.string(e);case"datetime":return vj.datetime();case"date":return vj.date();case"base64":return vj.base64();case"boolean":return vj.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var _di=At.objectWithoutOptionalProperties({schema:Cqo}).extend(_f).extend(s0).extend(xO).extend(dh).extend(BO);var Bqo=At.objectWithoutOptionalProperties({header:At.string(),name:At.string().optional(),optional:At.boolean().optional(),env:At.string().optional(),schema:At.lazy(()=>IO).optional()});var xqo=At.objectWithoutOptionalProperties({header:At.string(),name:At.string().optional(),env:At.string().optional(),schema:At.lazy(()=>IO).optional()});var TRp=At.objectWithoutOptionalProperties({apiVersion:At.unknown().optional(),title:At.string().optional(),description:At.string().optional(),basePath:At.string().optional(),servers:At.list(Zpa),websocketServers:At.list(Zpa),groups:At.record(At.string(),YAo),tags:XAo,hasEndpointsMarkedInternal:At.boolean(),endpoints:At.list(gqo),webhooks:At.list(Oqo),channels:At.record(At.string(),Sqo),groupedSchemas:Dqo,variables:At.record(At.string(),_di),nonRequestReferencedSchemas:At.set(JY),securitySchemes:At.record(IAo,HAo),globalHeaders:At.list(Bqo).optional(),idempotencyHeaders:At.list(xqo).optional()});var aXt=At.objectWithoutOptionalProperties({schema:JY}).extend(_f).extend(s0).extend(xO).extend(dh).extend(ly).extend(BO);var Iqo=At.union("type",{boolean:At.object({value:At.boolean()}),string:At.object({value:At.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return cx.boolean(e.value);case"string":return cx.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var j1n=At.objectWithoutOptionalProperties({value:Iqo}).extend(_f).extend(s0).extend(xO).extend(dh).extend(BO);var IO=At.union("type",{primitive:_di,object:At.lazyObject(()=>zqo),array:At.lazyObject(()=>Rqo),map:At.lazyObject(()=>Nqo),optional:At.lazyObject(()=>Fqo),enum:o1n,reference:aXt,literal:j1n,oneOf:At.object({value:At.lazy(()=>Uqo)}),nullable:At.lazyObject(()=>Lqo),unknown:s0}).transform({transform:e=>{switch(e.type){case"primitive":return gy.primitive(e);case"object":return gy.object(e);case"array":return gy.array(e);case"map":return gy.map(e);case"optional":return gy.optional(e);case"enum":return gy.enum(e);case"reference":return gy.reference(e);case"literal":return gy.literal(e);case"oneOf":return gy.oneOf(e.value);case"nullable":return gy.nullable(e);case"unknown":return gy.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var w1n=At.objectWithoutOptionalProperties({propertyKey:At.string(),allOfSchemaIds:At.list(JY),conflictingTypeSignatures:At.boolean()});var zqo=At.objectWithoutOptionalProperties({allOf:At.list(aXt),properties:At.list(At.lazyObject(()=>Vqo)),allOfPropertyConflicts:At.list(w1n),additionalProperties:At.boolean()}).extend(_f).extend(s0).extend(xO).extend(dh).extend(ly).extend(BO).extend(uE);var S1n=At.objectWithoutOptionalProperties({differentSchema:At.boolean()});var Vqo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>IO),readonly:At.boolean().optional(),writeonly:At.boolean().optional(),conflict:At.record(JY,S1n),generatedName:At.string(),nameOverride:At.string().optional(),audiences:At.list(At.string())}).extend(dh);var Rqo=At.objectWithoutOptionalProperties({value:At.lazy(()=>IO)}).extend(_f).extend(s0).extend(xO).extend(dh).extend(BO).extend(uE);var Nqo=At.objectWithoutOptionalProperties({key:_di,value:At.lazy(()=>IO)}).extend(_f).extend(s0).extend(xO).extend(dh).extend(Die).extend(BO).extend(uE);var Fqo=At.objectWithoutOptionalProperties({value:At.lazy(()=>IO)}).extend(_f).extend(s0).extend(xO).extend(dh).extend(BO).extend(uE);var Lqo=At.objectWithoutOptionalProperties({value:At.lazy(()=>IO)}).extend(_f).extend(s0).extend(xO).extend(dh).extend(BO).extend(uE);var Uqo=At.union("type",{discriminated:At.lazyObject(()=>Wqo),undiscriminated:At.lazyObject(()=>Hqo)}).transform({transform:e=>{switch(e.type){case"discriminated":return eKr.discriminated(e);case"undiscriminated":return eKr.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Wqo=At.objectWithoutOptionalProperties({discriminantProperty:At.string(),commonProperties:At.list(At.lazyObject(()=>$qo)),schemas:At.record(At.string(),At.lazy(()=>IO))}).extend(_f).extend(s0).extend(xO).extend(dh).extend(Die).extend(ly).extend(BO).extend(uE);var $qo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>IO)});var Hqo=At.objectWithoutOptionalProperties({schemas:At.list(At.lazy(()=>IO))}).extend(_f).extend(s0).extend(xO).extend(dh).extend(Die).extend(ly).extend(BO).extend(uE);var P5s={};Co(P5s,{ArraySchemaWithExample:()=>fTo,Base64WithExample:()=>oTo,BooleanWithExample:()=>uTo,CommonPropertyWithExample:()=>OTo,DateWithExample:()=>aTo,DatetimeWithExample:()=>nTo,DiscriminatedOneOfSchemaWithExample:()=>bTo,DoubleWithExample:()=>rTo,EndpointWithExample:()=>BRp,EnumSchemaWithExample:()=>cTo,FloatWithExample:()=>tTo,HeaderWithExample:()=>hdi,HttpErrorWithExample:()=>Yqo,Int64WithExample:()=>Zqo,IntWithExample:()=>Xqo,JsonRequestWithExample:()=>Qqo,JsonResponseWithExample:()=>E1n,MapSchemaWithExample:()=>dTo,NamedFullExample:()=>oXt,NullableSchemaWithExample:()=>_To,ObjectPropertyWithExample:()=>vTo,ObjectSchemaWithExample:()=>hTo,OneOfSchemaWithExample:()=>yTo,OptionalSchemaWithExample:()=>pTo,PathParameterWithExample:()=>Gqo,PrimitiveSchemaValueWithExample:()=>sTo,PrimitiveSchemaWithExample:()=>M1n,QueryParameterWithExample:()=>D1n,RequestWithExample:()=>Jqo,ResponseWithExample:()=>Kqo,SchemaWithExample:()=>EM,StringSchemaWithExample:()=>iTo,Uint64WithExample:()=>eTo,UintWithExample:()=>kqo,UnDiscriminatedOneOfSchemaWithExample:()=>gTo,UnknownSchemaWithExample:()=>lTo,WebhookWithExample:()=>xRp,WebsocketHandshakeWithExample:()=>CRp});var oXt=At.objectWithoutOptionalProperties({name:At.string().optional(),value:At.unknown()}).extend(_f);var D1n=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>EM),parameterNameOverride:At.string().optional()}).extend(_f).extend(dh).extend(ly);var hdi=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>EM),env:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(_f).extend(dh).extend(ly);var CRp=At.objectWithoutOptionalProperties({queryParameters:At.list(D1n),headers:At.list(hdi)});var Gqo=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>EM),variableReference:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(_f).extend(dh).extend(ly);var Qqo=At.objectWithoutOptionalProperties({schema:At.lazy(()=>EM),contentType:At.string().optional(),fullExamples:At.list(oXt).optional(),additionalProperties:At.boolean()}).extend(_f).extend(ly);var Jqo=At.union("type",{octetStream:d1n,multipart:p1n,json:Qqo}).transform({transform:e=>{switch(e.type){case"octetStream":return VSe.octetStream(e);case"multipart":return VSe.multipart(e);case"json":return VSe.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var E1n=At.objectWithoutOptionalProperties({schema:At.lazy(()=>EM),responseProperty:At.string().optional(),fullExamples:At.list(oXt).optional()}).extend(_f).extend(ly).extend(rXt);var Kqo=At.union("type",{file:_1n,json:E1n,text:pdi,streamingSse:E1n,streamingText:pdi,streamingJson:E1n}).transform({transform:e=>{switch(e.type){case"file":return lx.file(e);case"json":return lx.json(e);case"text":return lx.text(e);case"streamingSse":return lx.streamingSse(e);case"streamingText":return lx.streamingText(e);case"streamingJson":return lx.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Yqo=At.objectWithoutOptionalProperties({statusCode:tXt,schema:At.lazy(()=>EM),fullExamples:At.list(oXt).optional()}).extend(_f).extend(s0).extend(ly);var BRp=At.objectWithoutOptionalProperties({authed:At.boolean(),internal:At.boolean().optional(),idempotent:At.boolean().optional(),method:c1n,audiences:At.list(At.string()),path:At.string(),summary:At.string().optional(),operationId:At.string().optional(),tags:At.list(KY),pathParameters:At.list(Gqo),queryParameters:At.list(D1n),headers:At.list(hdi),sdkName:nXt.optional(),generatedRequestName:At.string(),requestNameOverride:At.string().optional(),request:Jqo.optional(),response:Kqo.optional(),errors:At.record(tXt,Yqo),servers:At.list(y1n),examples:At.list(g1n),pagination:O1n.optional()}).extend(_f).extend(dh).extend(ly).extend(iXt);var xRp=At.objectWithoutOptionalProperties({sdkName:nXt.optional(),method:m1n,summary:At.string().optional(),operationId:At.string(),tags:At.list(KY),headers:At.list(hdi),generatedPayloadName:At.string(),payload:At.lazy(()=>EM),examples:At.list(P1n)}).extend(_f).extend(ly).extend(iXt);var Xqo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional(),example:At.number().optional()});var Zqo=At.objectWithoutOptionalProperties({default:At.number().optional(),example:At.number().optional()});var kqo=At.objectWithoutOptionalProperties({default:At.number().optional(),example:At.number().optional()});var eTo=At.objectWithoutOptionalProperties({default:At.number().optional(),example:At.number().optional()});var tTo=At.objectWithoutOptionalProperties({example:At.number().optional()});var rTo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional(),example:At.number().optional()});var iTo=At.objectWithoutOptionalProperties({default:At.string().optional(),pattern:At.string().optional(),format:At.string().optional(),minLength:At.number().optional(),maxLength:At.number().optional(),example:At.string().optional()});var nTo=At.objectWithoutOptionalProperties({example:At.string().optional()});var aTo=At.objectWithoutOptionalProperties({example:At.string().optional()});var oTo=At.objectWithoutOptionalProperties({example:At.string().optional()});var uTo=At.objectWithoutOptionalProperties({default:At.boolean().optional(),example:At.boolean().optional()});var sTo=At.union("type",{int:Xqo,int64:Zqo,uint:kqo,uint64:eTo,float:tTo,double:rTo,string:iTo,datetime:nTo,date:aTo,base64:oTo,boolean:uTo}).transform({transform:e=>{switch(e.type){case"int":return Xd.int(e);case"int64":return Xd.int64(e);case"uint":return Xd.uint(e);case"uint64":return Xd.uint64(e);case"float":return Xd.float(e);case"double":return Xd.double(e);case"string":return Xd.string(e);case"datetime":return Xd.datetime(e);case"date":return Xd.date(e);case"base64":return Xd.base64(e);case"boolean":return Xd.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var M1n=At.objectWithoutOptionalProperties({schema:sTo}).extend(_f).extend(s0).extend(xO).extend(dh).extend(BO);var cTo=At.objectWithoutOptionalProperties({default:ldi.optional(),values:At.list(ldi),example:At.string().optional()}).extend(_f).extend(s0).extend(xO).extend(dh).extend(ly).extend(BO).extend(uE);var lTo=At.objectWithoutOptionalProperties({example:At.unknown()}).extend(xO).extend(s0).extend(_f).extend(dh).extend(BO);var EM=At.union("type",{primitive:M1n,object:At.lazyObject(()=>hTo),array:At.lazyObject(()=>fTo),map:At.lazyObject(()=>dTo),optional:At.lazyObject(()=>pTo),enum:cTo,reference:aXt,literal:j1n,oneOf:At.object({value:At.lazy(()=>yTo)}),nullable:At.lazyObject(()=>_To),unknown:lTo}).transform({transform:e=>{switch(e.type){case"primitive":return El.primitive(e);case"object":return El.object(e);case"array":return El.array(e);case"map":return El.map(e);case"optional":return El.optional(e);case"enum":return El.enum(e);case"reference":return El.reference(e);case"literal":return El.literal(e);case"oneOf":return El.oneOf(e.value);case"nullable":return El.nullable(e);case"unknown":return El.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var fTo=At.objectWithoutOptionalProperties({value:At.lazy(()=>EM),example:At.list(At.unknown()).optional()}).extend(xO).extend(s0).extend(_f).extend(dh).extend(BO).extend(uE);var dTo=At.objectWithoutOptionalProperties({key:M1n,value:At.lazy(()=>EM),example:At.unknown().optional()}).extend(xO).extend(s0).extend(_f).extend(dh).extend(Die).extend(BO).extend(uE);var pTo=At.objectWithoutOptionalProperties({value:At.lazy(()=>EM)}).extend(xO).extend(s0).extend(_f).extend(dh).extend(BO).extend(uE);var _To=At.objectWithoutOptionalProperties({value:At.lazy(()=>EM)}).extend(xO).extend(s0).extend(_f).extend(dh).extend(BO).extend(uE);var hTo=At.objectWithoutOptionalProperties({allOf:At.list(aXt),properties:At.list(At.lazyObject(()=>vTo)),allOfPropertyConflicts:At.list(w1n),fullExamples:At.list(oXt).optional(),additionalProperties:At.boolean()}).extend(_f).extend(s0).extend(xO).extend(dh).extend(ly).extend(BO).extend(uE);var vTo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>EM),readonly:At.boolean().optional(),writeonly:At.boolean().optional(),audiences:At.list(At.string()),conflict:At.record(JY,S1n),nameOverride:At.string().optional(),generatedName:At.string()}).extend(dh);var yTo=At.union("type",{discriminated:At.lazyObject(()=>bTo),undiscriminated:At.lazyObject(()=>gTo)}).transform({transform:e=>{switch(e.type){case"discriminated":return QY.discriminated(e);case"undiscriminated":return QY.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var bTo=At.objectWithoutOptionalProperties({discriminantProperty:At.string(),commonProperties:At.list(At.lazyObject(()=>OTo)),schemas:At.record(At.string(),At.lazy(()=>EM))}).extend(_f).extend(s0).extend(xO).extend(dh).extend(Die).extend(ly).extend(BO).extend(uE);var OTo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>EM)});var gTo=At.objectWithoutOptionalProperties({schemas:At.list(At.lazy(()=>EM))}).extend(_f).extend(s0).extend(xO).extend(dh).extend(Die).extend(ly).extend(BO).extend(uE);var IRp=/^(\d+)/,A1n=/^[a-zA-Z][a-zA-Z0-9_]*$/,zRp={"<":"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 ydi(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","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),l=e%10;return l===0?i[u]:`${i[u]}_${t[l]}`}if(e<1e3){let u=Math.floor(e/100),l=e%100;return l===0?`${t[u]}_hundred`:`${t[u]}_hundred_${ydi(l)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${ydi(a)}`}function kpa(e){let t=e.match(IRp);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=ydi(n);return i.length>0?`${a}_${i}`:a}}}function q1n(e){let t=kpa(e),r=zRp[e];return t!=null?G3(Dg(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":G3(Dg(e)))}function Eie(e,t){return e.type==="primitive"&&t.type==="primitive"?RRp(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?JPD(e.values,t.values):e.type==="array"&&t.type==="array"?Eie(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"?Eie(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?KPD(e.value,t.value):e.type==="object"&&t.type==="object"?YPD(e,t):e.type==="map"&&t.type==="map"?RRp(e.key.schema,t.key.schema)&&Eie(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function RRp(e,t){return e.type===t.type}function JPD(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return F1e(r,i)}function KPD(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,i])=>{let n=t.schemas[r];return n==null?!1:Eie(i,n)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,i)=>{let n=t.schemas[i];return n==null?!1:Eie(r,n)}):!1}function YPD(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(i=>[i.key,i.schema]));return Object.entries(t.properties).every(([i,n])=>{let a=r[i];return a==null?!1:Eie(a,n.schema)})}var j2;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(j2||(j2={}));var mTo=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;respectNullableSchemas;onlyIncludeReferencedSchemas;inlinePathParameters;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:u}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=u,this.globalHeaderOverrides=a,this.detectGlobalHeaders=i?.detectGlobalHeaders??!0,this.objectQueryParameters=i?.objectQueryParameters??!1,this.respectReadonlySchemas=i?.respectReadonlySchemas??!1,this.respectNullableSchemas=i?.respectNullableSchemas??!1,this.onlyIncludeReferencedSchemas=i?.onlyIncludeReferencedSchemas??!1,this.inlinePathParameters=i?.inlinePathParameters??!1,this.referencedSchemaIds=i?.onlyIncludeReferencedSchemas?new Set:void 0,this.enableUniqueErrorsPerEndpoint=i?.enableUniqueErrorsPerEndpoint??!1,this.builder=new hRi(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let l={};if(!this.enableUniqueErrorsPerEndpoint)for(let d of r.endpoints)for(let[s,o]of Object.entries(d.errors)){let c=parseInt(s),b=l[c];b==null&&o.schema!=null?l[c]=o.schema:b!=null&&o.schema!=null&&Eie(b,o.schema)||this.unknownSchema.add(c)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}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}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.onlyIncludeReferencedSchemas&&this.isInAnyState(j2.Channel,j2.Endpoint,j2.Webhook)}markSchemaAsReferenced(t,r){switch(t.type){case"primitive":return;case"object":this.markObjectSchemaAsReferenced(t,r);return;case"array":this.markSchemaAsReferenced(t.value,r);return;case"map":this.markSchemaAsReferenced(t.value,r);return;case"optional":this.markSchemaAsReferenced(t.value,r);return;case"reference":this.markSchemaIdAsReferenced(t.schema,r);return;case"oneOf":this.markOneofSchemaAsReferenced(t.value,r);return;case"nullable":this.markSchemaAsReferenced(t.value,r);return;case"enum":return;case"literal":return;case"unknown":return;default:Fo(t)}}markObjectSchemaAsReferenced(t,r){for(let i of t.allOf)this.markSchemaIdAsReferenced(i.schema,r);for(let i of t.properties)this.markSchemaAsReferenced(i.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let i of Object.values(t.schemas))this.markSchemaAsReferenced(i,r);return;case"undiscriminated":for(let i of t.schemas)this.markSchemaAsReferenced(i,r);return;default:Fo(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let i=this.getSchema(t,r);i!=null&&this.markSchemaAsReferenced(i,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function fI(e){switch(e){case pV.Deprecated:return"deprecated";case pV.Beta:return"pre-release";case pV.GenerallyAvailable:return"generally-available";default:return}}function XPD(e){let t=e.find(i=>typeof i=="object"&&i.type==="namespace"),r=e.filter(i=>typeof i=="string"||i.type!=="namespace");return t?[t,...r]:r}function NRp(e){let t=e?XPD(e):void 0;if(t==null||t.length===0)return JTi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(Dg(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(Dg(n.name)):r.push(n.name,JTi);break}default:Fo(n.type)}else Fo(n);return r.join("/")}function T1n(e){return sy.of(`${NRp(e)}.yml`)}function j5s({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?JTi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,NRp(r))}function FRp({sdkName:e,namespaceOverride:t}){return sy.of(`${j5s({sdkName:e,namespaceOverride:t})}.yml`)}function LRp({location:e,namespaceOverride:t}){return t!=null?PR(sy.of(t),e):e}function PTo(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:Fo(e.type)}}function C1n(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:Fo(e)}}function MM(e){return typeof e=="string"?e:e.type}function B1n(e){if(typeof e!="string")return e.docs}function e_a(e){if(typeof e!="string")return e.default}function w5s(e){if(typeof e!="string")return e.validation}var ZPD=-2147483648,kPD=2147483647,ejD=-17976931348623157e292,tjD=17976931348623157e292;function H0({schema:e,fileContainingReference:t,declarationFile:r=t,context:i,namespace:n,declarationDepth:a}){switch(i.shouldMarkSchemaAsReferenced()&&i.markSchemaAsReferenced(e,n),e.type){case"primitive":return jTo(e);case"array":return E5s({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return M5s({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return D5s({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return q5s();case"optional":return wTo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return A5s({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return ljD({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,T5s(e);case"object":return fjD({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return djD({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:Fo(e)}}function jTo(e){switch(e.schema.type){case"string":return njD({description:e.description,schema:e.schema});case"int":return ajD({description:e.description,schema:e.schema});case"float":return ojD({description:e.description,schema:e.schema});case"double":return ujD({description:e.description,schema:e.schema});case"boolean":return rjD({description:e.description,schema:e.schema});case"int64":return ijD({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:fI(e.availability)}:{}}}function rjD({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function ijD({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function njD({description:e,schema:t}){let r="string",i=sjD(t);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function ajD({description:e,schema:t}){let r="integer",i=VRp(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function ojD({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function ujD({description:e,schema:t}){let r="double",i=VRp(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function sjD(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=cjD(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function cjD(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 VRp(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=S5s(r,t),i=S5s(i,t),n=S5s(n,t),!(r==null&&i==null&&a==null&&u==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:u,multipleOf:n}}function S5s(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[ZPD,kPD]:[ejD,tjD];return e<r||e>i?void 0:e}function D5s({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=pjD(n)??e.schema,u=C1n(n),l=_jD(n),d=STo({context:r,fileContainingReference:t,declarationFile:T1n(u),type:a}),s=n.type==="nullable"?`optional<${d}>`:d;return e.description==null&&l==null?s:{type:n.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:fI(e.availability)}:{}}}function E5s({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=H0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=`list<${MM(u)}>`;return e.description==null&&e.title==null?l:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:fI(e.availability)}:{},type:l}}function M5s({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=jTo(e.key),l=H0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),d=e.encoding!=null?PTo(e.encoding):void 0,s=`map<${MM(u)}, ${MM(l)}>`;if(e.description==null&&d==null&&e.title==null)return s;let o={type:s};return e.description!=null&&(o.docs=e.description),e.encoding!=null&&(o.encoding=d),e.availability!=null&&(o.availability=fI(e.availability)),o}function A5s({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.respectNullableSchemas)return wTo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let u=H0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=MM(u),d=B1n(u),s=e_a(u),o=w5s(u),c=l.startsWith("nullable<")?l:`nullable<${l}>`;if(e.availability==null&&e.description==null&&d==null&&s==null&&o==null&&e.title==null)return URp({typeReference:c,itemType:l});let b={type:c};return(e.description!=null||d!=null)&&(b.docs=e.description??d),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=fI(e.availability)),URp({typeReference:b,itemType:l})}function wTo({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=H0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=MM(u),d=B1n(u),s=e_a(u),o=w5s(u),c=l.startsWith("optional<")?l:`optional<${l}>`;if(e.availability==null&&e.description==null&&d==null&&s==null&&o==null&&e.title==null)return c;let b={type:c};return(e.description!=null||d!=null)&&(b.docs=e.description??d),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=fI(e.availability)),b}function q5s(){return"unknown"}function T5s(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:Fo(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:fI(e.availability)}:{}}}function ljD({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=t_a(e,n),u=e.nameOverride??e.generatedName;i.builder.addType(r,{name:u,schema:a.schema});let l=STo({type:u,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return l;let d={type:l};return e.description!=null&&(d.docs=e.description),e.default!=null&&(d.default=e.default.value),e.availability!=null&&(d.availability=fI(e.availability)),d}function fjD({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=C5s({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=e.nameOverride??e.generatedName;i.builder.addType(r,{name:l,schema:u.schema});let d=STo({type:l,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:fI(e.availability)}:{}}}function djD({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=B5s({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=e.nameOverride??e.generatedName;i.builder.addType(r,{name:l,schema:u.schema});let d=STo({type:l,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{...e.title!=null?{"display-name":e.title}:{},type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:fI(e.availability)}:{}}}function STo({type:e,fileContainingReference:t,declarationFile:r,context:i}){if(r===t)return e;let n=i.builder.addImport({file:t,fileToImport:r});return n!=null?`${n}.${e}`:e}function pjD(e){return gy._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 _jD(e){return gy._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 URp({typeReference:e,itemType:t}){return t.startsWith("optional<")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}function tKr(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Fo(e)}}function HRp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=vjD(e);break;case"array":a=hjD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=yjD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=bjD({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=OjD(e.nameOverride,e.generatedName);break;case"optional":a=$Rp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=gjD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=t_a(e,n);break;case"literal":a=mjD(e,e.nameOverride,e.generatedName);break;case"object":a=C5s({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=B5s({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:Fo(e)}return a}function C5s({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(j2.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),u=!1,l={},d=new Set;for(let g of e.properties){if(g.readonly&&(u=!0),a&&g.readonly)continue;if(Object.keys(g.conflict).length>0){if(Object.entries(g.conflict).every(([D,C])=>!C.differentSchema))continue;Object.entries(g.conflict).forEach(([D])=>{x5s({property:g.key,schemaId:D,context:t,namespace:i}).forEach(R=>{d.add(R)})})}let O=H0({schema:g.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),m=g.audiences,w=g.nameOverride,E=fI(g.availability),A=SjD(g);l[g.key]=wjD({typeReference:O,audiences:m,name:w,availability:E,propertyAccess:A})}let s=new Set;for(let g of e.allOfPropertyConflicts)g.allOfSchemaIds.forEach(O=>d.add(O)),g.conflictingTypeSignatures&&s.add(g.propertyKey);let o=[];for(let g of e.allOf){let O=GRp({schema:g.schema,context:t,namespace:i});if(O==null||d.has(g.schema)||d.has(O))continue;let m=H0({schema:gy.reference(g),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(MM(m))}for(let g of d){let O=I5s(t,g,i);for(let m of O.properties)l[m.key]==null&&(s.has(m.key)&&(l[m.key]="unknown"),l[m.key]=H0({schema:m.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let m of O.allOf){if(d.has(m.schema))continue;let w=H0({schema:gy.reference(m),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(MM(w))}}let c={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(l).map(([g,O])=>jjD(g)?[g,typeof O=="string"?{type:O,name:`_${g}`}:{...O,name:`_${g}`}]:[g,O]))};o.length>0&&(c.extends=o),e.additionalProperties&&(c["extra-properties"]=!0),e.availability!=null&&(c.availability=fI(e.availability)),e.source!=null&&(c.source=tKr(e.source)),c.inline=z5s(e,n);let b=e.nameOverride??e.generatedName;return{name:u&&t.respectReadonlySchemas&&!a?`${b}Read`:b,schema:c}}function x5s({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return x5s({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:u}=I5s(r,t,i),l=a.some(s=>s.key===e),d=[...u.flatMap(s=>x5s({property:e,context:r,schemaId:s.schema,namespace:i}))];if(l||d.length>0)return[t,...d]}return[]}function I5s(e,t,r){let i=e.getSchema(t,r);if(i==null)return{properties:[],allOf:[]};if(i.type==="object")return{properties:i.properties,allOf:i.allOf};if(i.type==="reference")return I5s(e,i.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${i.type}`)}function hjD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:E5s({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function yjD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:M5s({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function vjD(e){let t=jTo(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...i}=t;return{name:e.nameOverride??e.generatedName,schema:{...i}}}function WRp(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function t_a(e,t){let r={enum:e.values.map(a=>{let u=a.nameOverride??a.generatedName,l=a.value;if(u===l&&a.description==null&&(a.casing==null||WRp(a.casing)))return u;let d={value:a.value};if(u!==l&&(d.name=u),a.description!=null&&(d.docs=a.description),a.casing!=null&&!WRp(a.casing)){let s={},o=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,o=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,o=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,o=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,o=!0),o&&(d.casing=s)}return d})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=z5s(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?tKr(e.source):void 0};for(let a of r.enum){let u=typeof a=="string"?a:a.name??a.value;i.has(u.toLowerCase())||(n.enum.push(a),i.add(u.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function bjD({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:D5s({schema:e,context:t,fileContainingReference:r,namespace:i})}}function gjD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:A5s({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:$Rp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function $Rp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:wTo({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function OjD(e,t){return{name:e??t,schema:q5s()}}function mjD(e,t,r){return{name:t??r,schema:T5s(e)}}function B5s({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?PTo(e.encoding):void 0;if(e.type==="discriminated"){let l={};for(let s of e.commonProperties)l[s.key]=H0({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let d={};for(let[s,o]of Object.entries(e.schemas))d[s]=H0({schema:o,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":l,docs:e.description??void 0,availability:e.availability!=null?fI(e.availability):void 0,union:d,encoding:a,source:e.source!=null?tKr(e.source):void 0}}}let u=[];for(let l of e.schemas)u.push(H0({schema:l,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:u,encoding:a,source:e.source!=null?tKr(e.source):void 0,inline:z5s(e,n)}}}var PjD=/^[0-9]/;function jjD(e){return PjD.test(e)}function GRp({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?GRp({context:t,schema:i.schema,namespace:r}):e}function wjD({typeReference:e,audiences:t,name:r,availability:i,propertyAccess:n}){return t.length===0&&r==null&&i==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{},...n!=null?{access:n}:{}}}function z5s(e,t){return e.inline===!0||t>0?!0:void 0}function SjD(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return l2.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return l2.ObjectPropertyAccess.WriteOnly}}function QRp(e){let t=e.replace(/^x-|^X-/,"");return Dg(t)}var JRp="BasicAuthScheme",DTo="BearerAuthScheme";function KRp(e){if(e.authOverrides!=null){for(let[r,i]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:i});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,i]of Object.entries(e.ir.securitySchemes))if(i.type==="basic"){let n={scheme:"basic"};i.usernameVariableName!=null&&(n.username===void 0?n.username={name:i.usernameVariableName}:n.username.name=i.usernameVariableName),i.usernameEnvVar!=null&&(n.username===void 0?n.username={env:i.usernameEnvVar}:n.username.env=i.usernameEnvVar),i.passwordVariableName!=null&&(n.password===void 0?n.password={name:i.passwordVariableName}:n.password.name=i.passwordVariableName),i.passwordEnvVar!=null&&(n.password===void 0?n.password={env:i.passwordEnvVar}:n.password.env=i.passwordEnvVar),e.builder.addAuthScheme({name:JRp,schema:n}),t||(e.builder.setAuth(JRp),t=!0)}else if(i.type==="bearer"){let n={scheme:"bearer"};i.tokenVariableName!=null&&(n.token===void 0?n.token={name:i.tokenVariableName}:n.token.name=i.tokenVariableName),i.tokenEnvVar!=null&&(n.token===void 0?n.token={env:i.tokenEnvVar}:n.token.env=i.tokenEnvVar),e.builder.addAuthScheme({name:DTo,schema:n}),t||(e.builder.setAuth(DTo),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??QRp(i.headerName),env:i.headerEnvVar}});else{let n={header:i.headerName,name:i.headerVariableName??"apiKey",type:"string"};i.headerEnvVar!=null&&(n.env=i.headerEnvVar),i.prefix!=null&&(n.prefix=i.prefix),e.builder.addAuthScheme({name:r,schema:n}),e.builder.setAuth(r),t=!0}else if(i.type==="oauth"){let n={scheme:"bearer"};e.builder.addAuthScheme({name:DTo,schema:n}),t||(e.builder.setAuth(DTo),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(sy.of("__package__.yml"),{name:"OauthScope",schema:t_a(i.scopesEnum,0).schema})}}function uXt({header:e,context:t,fileContainingReference:r,namespace:i}){let n=H0({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=MM(n),u=e.name.replace(/^x-|^X-/,""),l=e.parameterNameOverride!=null?e.parameterNameOverride:Dg(u);if(e.description==null&&e.name===l&&e.env==null&&e.availability==null)return a;let d={type:a};return l!==e.name&&(d.name=l),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=fI(e.availability)),d}function ETo({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=H0({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return MM(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:MM(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=fI(e.availability)),a}function ATo({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=R5s({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=MM(n.value),u=e_a(n.value);if(a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>"),e.description==null&&!n.allowMultiple&&u==null&&e.parameterNameOverride==null&&e.availability==null)return a;let l={type:a};return u!=null&&(l.default=u),n.allowMultiple&&(l["allow-multiple"]=!0),e.description!=null&&(l.docs=e.description),e.parameterNameOverride!=null&&(l.name=e.parameterNameOverride),e.availability!=null&&(l.availability=fI(e.availability)),DjD(n.value)&&n.value.validation!==void 0&&(l.validation=n.value.validation),l}function R5s({schema:e,context:t,fileContainingReference:r,namespace:i}){if(e.type==="reference"){let n=t.getSchema(e.schema,i);if(n==null)return;if(n.type==="array")return{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,groupName:void 0,inline:void 0}),context:t,declarationFile:sy.of(X1),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[];for(let[u,l]of Object.entries(n.value.schemas))l.type==="literal"&&l.value.type==="string"&&(A1n.test(l.value.value)?a.push(l.value.value):a.push({value:l.value.value,name:q1n(l.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[u,l]=n.value.schemas;if(u!=null&&l!=null&&MTo({array:u,primitive:l}))return{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:l,description:e.description,availability:e.availability,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(u!=null&&l!=null&&MTo({array:u,primitive:l}))return{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[u,l]of Object.entries(n.value.schemas))return R5s({schema:l,context:t,fileContainingReference:r,namespace:i})}else if(t.objectQueryParameters)return{value:H0({schema:e,context:t,fileContainingReference:r,declarationFile:sy.of(X1),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let n=t.getSchema(e.value.schema,i);if(n==null)return;if(n.type==="array")return{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:sy.of(X1),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.objectQueryParameters)return{value:H0({schema:e,context:t,fileContainingReference:r,declarationFile:sy.of(X1),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let n=[];for(let[a,u]of Object.entries(e.value.value.schemas))u.type==="literal"&&u.value.type==="string"&&(A1n.test(u.value.value)?n.push(u.value.value):n.push({value:u.value.value,name:q1n(u.value.value)}));if(n.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:n}}),{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&&MTo({array:a,primitive:u}))return{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(a!=null&&u!=null&&MTo({array:u,primitive:a}))return{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[a,u]of Object.entries(e.value.value.schemas))return R5s({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:void 0,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.objectQueryParameters?{value:H0({schema:e,context:t,fileContainingReference:r,declarationFile:sy.of(X1),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:H0({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:H0({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function MTo({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function DjD(e){return e.type!=null}function YRp({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"]=EjD(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=MjD({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=vdi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function EjD(e){let t={};return e.forEach(r=>{let i=vdi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function MjD({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=vdi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function vdi(e){switch(e.type){case"primitive":return XRp(e.value);case"object":return ZRp(e.properties);case"array":return AjD(e.value);case"map":return qjD(e.value);case"oneOf":return TjD(e.value);case"enum":return e.value;case"literal":return CjD(e.value);case"unknown":return vdi(e.value);default:Fo(e)}}function XRp(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:Fo(e)}}function ZRp(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,vdi(r)]))}function AjD(e){return e.map(t=>vdi(t))}function qjD(e){return Object.fromEntries(e.map(t=>[XRp(t.key),vdi(t.value)]))}function TjD(e){return e.type==="discriminated"?ZRp(e.value):vdi(e.value)}function CjD(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Fo(e)}}function rKr(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function qTo(e,t){return t??(e?.groupName!=null?rKr(e.groupName):void 0)}function kRp({channel:e,context:t,declarationFile:r}){let i={path:e.path,url:e.servers[0]?.name,auth:!1};e.audiences!=null&&e.audiences.length>0&&(i.audiences=e.audiences),e.summary!=null&&(i["display-name"]=e.summary),e.description!=null&&(i.docs=e.description);let n=rKr(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=ETo({pathParameter:d,context:t,fileContainingReference:r,namespace:n});Object.keys(a).length>0&&(i["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let s=ATo({queryParameter:d,context:t,fileContainingReference:r,namespace:n});s!=null&&(u[d.name]=s)}Object.keys(u).length>0&&(i["query-parameters"]=u);let l={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let s=uXt({header:d,context:t,fileContainingReference:r,namespace:n});l[d.name]=s}Object.keys(l).length>0&&(i.headers=l),t.builder.addChannel(r,{channel:i}),e.subscribe!=null&&t.builder.addChannelMessage(r,{messageId:"subscribe",message:{origin:"server",body:H0({schema:e.subscribe,context:t,fileContainingReference:r,namespace:n,declarationDepth:0})}}),e.publish!=null&&t.builder.addChannelMessage(r,{messageId:"publish",message:{origin:"client",body:H0({schema:e.publish,context:t,fileContainingReference:r,namespace:n,declarationDepth:0})}});for(let d of e.examples){let s=YRp({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:s})}}var iKr="Base",BjD="Default";function bdi(e){return Object.entries(e).reduce((t,[r,i])=>(Dbn(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function eNp(e){if(e.environmentOverrides!=null){for(let[g,O]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:g,schema:O});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 g of e.ir.servers){let O=g.audiences?{url:g.url,audiences:g.audiences}:g.url;if(g.name==null){r.push(O);continue}t[g.name]=O}let i={},n=[];for(let g of e.ir.endpoints)for(let O of g.servers){if(O.url==null)continue;let m=O.audiences?{url:O.url,audiences:O.audiences}:O.url;if(O.name==null){n.push(m);continue}i[O.name]=m}let a={},u=[];for(let g of e.ir.websocketServers){let O=g.audiences?{url:g.url,audiences:g.audiences}:g.url;if(g.name==null){u.push(O);continue}a[g.name]=O}let l=Object.keys(t).length,d=l>0,s=Object.keys(i).length>0,o=Object.keys(a).length>0;if(!d&&!s&&o&&e.ir.servers.length===0){for(let[g,O]of Object.entries(a))e.builder.addEnvironment({name:g,schema:O});e.builder.setDefaultEnvironment(Object.keys(a)[0]),e.builder.setDefaultUrl(iKr);return}if(n.length>0&&e.logger.error(`Skipping endpoint level servers ${n.map(g=>typeof g=="string"?g:g.url).join(", ")} because x-fern-server-name was not provided.`),!d){let g=e.ir.servers[0]?.url,O=e.ir.servers[0]?.audiences;if(g!=null){let m=O?{url:g,audiences:O}:g;t[BjD]=m}}let c=Object.values(t).map(g=>typeof g=="string"?g:g.url),b=r.filter(g=>{let O=typeof g=="string"?g:g.url;return!c.includes(O)});if(b.length>0&&e.logger.error(`Skipping top level servers ${b.map(g=>typeof g=="string"?g:g.url).join(", ")} because x-fern-server-name was not provided.`),s)if(l===1){let g=Object.keys(t)[0],O=Object.values(t)[0],m=typeof O=="string"?O:O.url;e.builder.addEnvironment({name:g,schema:{urls:{[iKr]:m,...bdi(i),...bdi(a)}}}),e.builder.setDefaultEnvironment(g),e.builder.setDefaultUrl(iKr)}else{let g=!0;for(let[O,m]of Object.entries(t))g?(e.builder.addEnvironment({name:O,schema:{urls:{[iKr]:typeof m=="string"?m:m.url,...bdi(i),...bdi(a)}}}),e.builder.setDefaultEnvironment(O),g=!1):e.builder.addEnvironment({name:O,schema:{urls:{[iKr]:typeof m=="string"?m:m.url,...bdi(i),...bdi(a)}}});e.builder.setDefaultUrl(iKr)}else{let g=!0;for(let[O,m]of Object.entries(t))g?(o?e.builder.addEnvironment({name:O,schema:{urls:{[iKr]:typeof m=="string"?m:m.url,...bdi(a)}}}):e.builder.addEnvironment({name:O,schema:m}),e.builder.setDefaultEnvironment(O),g=!1):o?e.builder.addEnvironment({name:O,schema:{urls:{[iKr]:typeof m=="string"?m:m.url,...bdi(a)}}}):e.builder.addEnvironment({name:O,schema:m});o&&e.builder.setDefaultUrl(iKr)}}function TTo(e){return MM(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var N5s=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},xjD=.75,IjD=new Set("authorization");function tNp(e){if(e.globalHeaderOverrides!=null){for(let[r,i]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:i});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,i]of Object.entries(t)){let n="optional<string>";if(i.name==null&&i.env==null&&typeof i.schema=="string")n=i.schema;else if(i!=null){let a=i.schema?C1n(i.schema):void 0,u=a!=null?rKr(a):void 0,l=sy.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?MM(H0({schema:i.schema,context:e,fileContainingReference:u?PR(sy.of(Dg(u)),l):l,namespace:u,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(IjD.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let l=t[a.name],d=uXt({header:{...a,schema:l?.schema??a.schema,name:l?.name??a.name},fileContainingReference:sy.of(Q3),context:e,namespace:void 0});u=new N5s(d),r[a.name]=u}u.increment()}let i=e.ir.endpoints.length*xjD;for(let[n,a]of Object.entries(r)){let u=t[n],l=a.count===e.ir.endpoints.length,d=a.count>=i;u==null&&(l?e.builder.addGlobalHeader({name:n,schema:a.schema}):d&&e.builder.addGlobalHeader({name:n,schema:TTo(a.schema)}))}}}function rNp(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?C1n(t.schema):void 0,i=r!=null?rKr(r):void 0,n=uXt({header:{...t,schema:t.schema??gy.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0,schema:vj.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:sy.of(Q3),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:TTo(n)})}}function hG(e){switch(e.type){case"primitive":return nNp(e.value);case"object":return aNp(e.properties);case"array":return oNp(e.value);case"map":return RjD(e.value);case"oneOf":return NjD(e.value);case"enum":return e.value;case"literal":return FjD(e.value);case"unknown":return hG(e.value);default:Fo(e)}}function iNp(e){switch(e.type){case"withStreaming":return e.sse?{stream:zjD(e.events)}:{stream:oNp(e.events)};case"withoutStreaming":return{body:hG(e.value)};default:Fo(e)}}function nNp(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:Fo(e)}}function aNp(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,hG(r)]))}function zjD(e){return e.map(t=>({event:"",data:hG(t)}))}function oNp(e){return e.map(t=>hG(t))}function RjD(e){return Object.fromEntries(e.map(t=>[nNp(t.key),hG(t.value)]))}function NjD(e){return e.type==="discriminated"?aNp(e.value):hG(e.value)}function FjD(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Fo(e)}}function uNp({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"]=LjD(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=UjD(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=VjD({context:t,namedFullExamples:e.headers})),e.request!=null&&(r.request=hG(e.request)),e.response!=null&&(r.response=iNp(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(i=>i.type==="language"?{name:i.name??void 0,docs:i.description??void 0,language:i.language,code:i.code,install:i.install??void 0}:{name:i.name??void 0,docs:i.description??void 0,sdk:i.sdk,code:i.code}).filter(Qb)),r)}function LjD(e){let t={};return e.forEach(r=>{let i=hG(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function UjD(e){let t={};return e.forEach(r=>{let i=hG(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function VjD({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=hG(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function sNp(e){return pG._visit(e,{get:()=>l2.HttpMethodSchema.Get,post:()=>l2.HttpMethodSchema.Post,put:()=>l2.HttpMethodSchema.Put,patch:()=>l2.HttpMethodSchema.Patch,delete:()=>l2.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("Unknown http method is unsupported")}})}function cNp(e){return e==="POST"||e==="PUT"||e==="PATCH"}function lNp({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,u=e.path,l=qTo(e.sdkName,e.namespace),d={};for(let m of e.pathParameters)m.parameterNameOverride&&(u=u.replace(m.name,m.parameterNameOverride)),d[m.parameterNameOverride??m.name]=ETo({pathParameter:m,context:r,fileContainingReference:t,namespace:l}),a.add(m.name);let s={};for(let m of e.queryParameters){let w=ATo({queryParameter:m,context:r,fileContainingReference:t,namespace:l});w!=null&&(s[m.name]=w,a.add(m.name))}let o;if(e.pagination!=null)switch(e.pagination.type){case"cursor":o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":o={type:"custom",results:e.pagination.results};break;default:Fo(e.pagination)}let c={path:u,method:sNp(e.method),auth:e.authed,docs:e.description??void 0,pagination:o,source:e.source!=null?tKr(e.source):void 0};!$jD({context:r,request:e.request})&&Object.keys(d).length>0&&(c["path-parameters"]=d),e.summary!=null&&(c["display-name"]=e.summary);let b={},g=r.builder.getGlobalHeaderNames(),O=e.headers.filter(m=>!g.has(m.name));for(let m of O){let w=uXt({header:m,context:r,fileContainingReference:t,namespace:l});b[m.name]=w,a.add(typeof w=="string"?m.name:w.name??m.name)}if(e.request!=null){r.setInState(j2.Request);let m=HjD({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.inlinePathParameters&&Object.keys(d).length>0?d:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(i),headers:Object.keys(b).length>0?b:void 0,usedNames:a,namespace:l});c.request=m.value,n=[...n,...m.schemaIdsToExclude??[]],r.unsetInState(j2.Request)}else{let m=r.inlinePathParameters&&Object.keys(d).length>0,w=Object.keys(s).length>0,E=Object.keys(b).length>0,A={};(m||w||E)&&(A.name=e.requestNameOverride??e.generatedRequestName),m&&(A["path-parameters"]=d),w&&(A["query-parameters"]=s),E&&(A.headers=b),Object.keys(A).length>0&&(c.request=A)}if(e.response!=null&&e.response._visit({json:m=>{let w=H0({schema:m.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c.response={docs:m.description??void 0,type:MM(w)},m.statusCode!=null&&(c.response["status-code"]=m.statusCode),m.responseProperty!=null&&(c.response.property=m.responseProperty)},streamingJson:m=>{let w=H0({schema:m.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c["response-stream"]={docs:m.description??void 0,type:MM(w),format:"json"}},streamingSse:m=>{let w=H0({schema:m.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c["response-stream"]={docs:m.description??void 0,type:MM(w),format:"sse"}},file:m=>{c.response={docs:m.description??void 0,type:"file","status-code":m.statusCode}},streamingText:m=>{c["response-stream"]={docs:m.description??void 0,type:"text"}},text:m=>{c.response={docs:m.description??void 0,type:"text","status-code":m.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let m=r.getDefaultServerName(),w=e.servers[0];w==null?m!=null&&(c.url=m):c.url=w.name??void 0}return e.idempotent&&(c.idempotent=!0),e.availability!=null&&(c.availability=fI(e.availability)),Object.entries(e.errors).forEach(([m,w])=>{let E=w.generatedName,A=sy.of(X1);r.builder.enableUniqueErrorsPerEndpoint&&(E=`${e.generatedRequestName}${w.generatedName}`,w.schema!=null&&(w.schema.type!=="reference"&&w.schema.type!=="oneOf"?w.schema.generatedName=`${e.generatedRequestName}${w.schema.generatedName}`:w.schema.type==="oneOf"&&(w.schema.value.generatedName=`${e.generatedRequestName}${w.schema.value.generatedName}`)));let q={"status-code":parseInt(m)},D=LRp({location:fNp,namespaceOverride:l});if(w.schema!=null){let $=H0({schema:w.schema,context:r,fileContainingReference:D,declarationFile:D,namespace:l,declarationDepth:0});q.type=MM($),q.docs=w.description}r.builder.addError(D,{name:E,schema:r.isErrorUnknownSchema(parseInt(m))?{...q,type:"unknown"}:q}),c.errors==null&&(c.errors=[]);let C=r.builder.addImport({file:t,fileToImport:D});c.errors.push(C!=null?`${C}.${E}`:E),q.type!=null&&w.examples?.forEach($=>{let I={value:hG($.example),name:$.name,docs:$.description};r.builder.addErrorExample(D,{name:E,example:I})})}),e.examples.length>0&&(c.examples=WjD({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?c.audiences=[F5s,...e.audiences]:e.audiences.length>0&&(c.audiences=e.audiences),{value:c,schemaIdsToExclude:n}}function WjD({endpointExamples:e,context:t}){return e.map(r=>{try{return uNp({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function HjD({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:u,queryParameters:l,nonRequestReferencedSchemas:d,headers:s,usedNames:o,namespace:c}){if(i.type==="json"){let b=i.schema.type==="reference"?i.schema.schema:void 0,g=i.schema.type==="reference"?r.getSchema(i.schema.schema,c):i.schema;if(g?.type!=="object"||b!=null&&d.includes(b)){let A=H0({schema:i.schema,fileContainingReference:t,context:r,namespace:c,declarationDepth:0}),q={schemaIdsToExclude:[],value:{body:A}},D=Object.keys(u??{}).length>0,C=Object.keys(l??{}).length>0,R=Object.keys(s??{}).length>0;return D&&(q.value["path-parameters"]=u),C&&(q.value["query-parameters"]=l),R&&(q.value.headers=s),(D||C||R)&&(q.value.name=n??a),i.contentType!=null&&(q.value["content-type"]=i.contentType),i.description!=null&&(q.value.docs=i.description),q}let O=Object.fromEntries(g.properties.filter(A=>A.readonly==null?!0:!(cNp(e.method)&&A.readonly)).map(A=>{let q=H0({schema:A.schema,fileContainingReference:t,context:r,namespace:c,declarationDepth:1}),D=A.nameOverride??A.key,C=fI(A.availability);if(!o.has(D)&&A.audiences.length<=0)return o.add(D),A.nameOverride!=null?[A.key,{type:MM(q),docs:B1n(q),name:A.nameOverride,availability:C}]:[A.key,C?{...typeof q=="string"?{type:q}:q,availability:C}:q];let R={type:MM(q),docs:B1n(q)};return o.has(D)&&(R.name=A.generatedName),A.audiences.length>0&&(R.audiences=A.audiences),C!=null&&(R.availability=C),o.add(D),[A.key,R]})),m=g.allOf.map(A=>{let q=H0({schema:gy.reference(A),fileContainingReference:t,context:r,namespace:c,declarationDepth:0});return MM(q)}),w={properties:O};m.length>0&&(w.extends=m),i.additionalProperties&&(w["extra-properties"]=!0);let E={name:n??g.nameOverride??g.generatedName,"path-parameters":u,"query-parameters":l,headers:s,body:w};return i.contentType!=null&&(E["content-type"]=i.contentType),i.description!=null&&(E.docs=i.description),{schemaIdsToExclude:b!=null?[b]:[],value:E}}else{if(i.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":JB.APPLICATION_OCTET_STREAM,...i.description?{docs:i.description}:{}}};if(i.type==="multipart"){let b=Object.fromEntries(i.properties.map(g=>{if(g.schema.type==="file"){let O=g.schema.isArray?"list<file>":"file";if(O=g.schema.isOptional?`optional<${O}>`:O,g.description!=null||g.contentType!=null){let m={type:O};if(g.description!=null&&(m.docs=g.description),g.contentType!=null){let w=g.contentType.split(",")[0];m["content-type"]=w}return[g.key,m]}return[g.key,O]}else{let O=H0({schema:g.schema.value,fileContainingReference:t,context:r,namespace:c,declarationDepth:1});if(g.contentType!=null||g.exploded||g.encoding==="form"){let m=typeof O=="string"?{type:O}:O;g.contentType!=null&&(m["content-type"]=g.contentType),g.encoding==="form"?m.style="form":g.exploded&&(m.style="exploded"),O=m}return[g.key,O]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":u,"query-parameters":l,headers:s,body:{properties:b},"content-type":JB.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else Fo(i)}}function $jD({context:e,request:t}){if(!e.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;default:Fo(t)}}function GjD({location:e,namespaceOverride:t}){return t!=null?{...e,file:PR(sy.of(t),e.file)}:e}function QjD(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:sy.of(`${Dg(r)}.yml`),endpointId:e.summary!=null?Dg(e.summary):Dg(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:sy.of(X1),endpointId:Dg(e.summary)}:{file:sy.of(X1),endpointId:Dg(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:sy.of(X1),endpointId:i};let n=r_a(r),a=r_a(i);if(F1e(n,a))return{file:sy.of("__package__.yml"),endpointId:r};let u=YjD({operationId:i,tag:r,path:e.path,method:e.method});if(u!=null)return u;let l=[];for(let d=0;d<n.length;++d){let s=n[d];if(s!=null&&s===a[d])l.push(s);else{let o=Dg(r);return{file:sy.of(`${o}.yml`),endpointId:i,tag:r}}}if(l.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:sy.of(Dg(l.join("_"))+".yml"),endpointId:Dg(a.slice(l.length).join("_")),tag:r}}function i_a(e){let t=e.tags[0];if(e.sdkName!=null){let r=j5s({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:sy.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return GjD({namespaceOverride:e.namespace,location:QjD(e)})}function r_a(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=vBe(t),t}var JjD=new RegExp("[^a-zA-Z0-9{}]+"),KjD=new RegExp("[{}]","g");function YjD({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(JjD).join("_").replaceAll(KjD,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:sy.of(Dg(t)+".yml"),endpointId:Dg(e.slice(0,-1*a.length)),tag:t}}function dNp(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:u,file:l,tag:d}=i_a(a),s=l.split(".")[0];s!=null&&t.add(s);let o;if(a.sdkName!=null){let g=e.ir.groups;for(let O of a.sdkName.groupName){let m=typeof O=="string"?O:O.name,w=g[m];if(w==null)break;if(w.summary!=null||w.description!=null){o=g[m];break}}}let c=d==null?void 0:i.tagsById[d];e.setInState(j2.Endpoint),e.setEndpointMethod(a.method);let b=lNp({context:e,endpoint:a,declarationFile:l});e.unsetEndpointMethod(),e.unsetInState(j2.Endpoint),n=[...n,...b.schemaIdsToExclude],e.builder.addEndpoint(l,{name:u,schema:b.value,source:a.source!=null?tKr(a.source):void 0}),(c?.id!=null||c?.description!=null)&&e.builder.setServiceInfo(l,{"display-name":o?.summary??c?.id,docs:o?.description??c?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function pNp(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?rKr(r.groupName):void 0,n=H0({schema:gy.primitive(r),context:e,fileContainingReference:sy.of(X1),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:MM(n),docs:r.description??void 0}})}}function _Np(e){for(let t of e.ir.webhooks){let r=kjD({webhook:t,context:e});if(r==null)continue;let i=qTo(t.sdkName,t.namespace),n={};for(let u of t.headers)n[u.name]=uXt({header:u,context:e,fileContainingReference:r.file,namespace:i});let a={method:t.method,"display-name":t.summary??void 0,headers:n,payload:H0({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:hG(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function XjD({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:PR(sy.of(t),e.file)}:e}function ZjD({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:sy.of(X1),endpointId:i};let n=r_a(r),a=r_a(i);if(F1e(n,a))return{file:sy.of("__package__.yml"),endpointId:r};let u=[];for(let l=0;l<n.length;++l){let d=n[l];if(d!=null&&d===a[l])u.push(d);else{let s=Dg(r);return{file:sy.of(`${s}.yml`),endpointId:i,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:sy.of(Dg(u.join("_"))+".yml"),endpointId:Dg(a.slice(u.length).join("_")),tag:r}}function kjD({webhook:e,context:t}){return e.sdkName!=null?{file:FRp({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:XjD({namespaceOverride:e.namespace,location:ZjD({webhook:e,context:t})})}var ewD=sy.of(X1);function hNp(e){switch(e.type){case"object":return sXt(e.groupName);case"enum":return sXt(e.groupName);case"oneOf":return sXt(e.value.groupName);case"array":return sXt(e.groupName);case"map":return sXt(e.groupName);case"reference":return sXt(e.groupName);case"literal":return sXt(e.groupName);case"optional":return sXt(e.groupName);case"nullable":return sXt(e.groupName);case"primitive":return sXt(e.groupName);case"unknown":return ewD;default:Fo(e)}}function sXt(e){return T1n(e)}var F5s="external",fNp=sy.of(X1);function yNp({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let u=hNp(a),l=HRp({schema:a,context:i,declarationFile:u,namespace:r,declarationDepth:0});if(Jsi(l.schema)){let d=MM(l.schema);if(d===(l.name??n)||d===`optional<${l.name??n}>`)continue}i.builder.addType(u,{name:l.name??n,schema:l.schema})}}function vNp(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),eNp(e),tNp(e),rNp(e),KRp(e),pNp(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(F5s);let t=dNp(e),r=t.sdkGroups;e.setInState(j2.Webhook),_Np(e),e.unsetInState(j2.Webhook),e.setInState(j2.Channel);for(let n of Object.values(e.ir.channels)){let a=T1n(n.groupName);kRp({channel:n,context:e,declarationFile:a})}e.unsetInState(j2.Channel);let i=twD({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});yNp({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))yNp({schemas:a,schemaIdsToExclude:i,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}function twD({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}function L5s(e){let t=new mTo(e);return vNp(t)}var vRi={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!1,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1};function U5s({options:e,overrides:t}){return{enableUniqueErrorsPerEndpoint:t?.enableUniqueErrorsPerEndpoint??e?.enableUniqueErrorsPerEndpoint??vRi.enableUniqueErrorsPerEndpoint,detectGlobalHeaders:t?.detectGlobalHeaders??e?.detectGlobalHeaders??vRi.detectGlobalHeaders,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??vRi.objectQueryParameters,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??vRi.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??vRi.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??vRi.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??vRi.inlinePathParameters}}var CTo=class{args;constructor(t){this.args=t}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=L5s({taskContext:t,ir:r,options:U5s({overrides:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.args.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.args.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.args.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.args.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.args.objectQueryParameters}}),authOverrides:this.args.generatorsConfiguration?.api?.auth!=null?{...this.args.generatorsConfiguration?.api}:void 0,environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:n??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:Kd.dump(a.rootApiFile)},namedDefinitionFiles:{...rd(a.definitionFiles,u=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Kd.dump(u),contents:u})),[sy.of(X1)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Kd.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var n_a=class extends D5t{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;exampleGeneration;converter;constructor(t){super(t),this.inlinePathParameters=t.inlinePathParameters,this.objectQueryParameters=t.objectQueryParameters,this.onlyIncludeReferencedSchemas=t.onlyIncludeReferencedSchemas,this.respectReadonlySchemas=t.respectReadonlySchemas,this.respectNullableSchemas=t.respectNullableSchemas,this.exampleGeneration=t.exampleGeneration,this.converter=new CTo(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:i},n){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:i},n);return this.converter.convert({context:t,ir:a,settings:n,absoluteFilePath:r})}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new USe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion})}};function x1n(e){if(e.settings==null)return;let t={detectGlobalHeaders:!0};return e.settings.unions==="v1"&&(t.discriminatedUnionV2=!0),t}var OLp=yi(Bxo(),1);var mV={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"};var nha={of(e){return e}};var W5p={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},TWs={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:W5p,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},fd={SOURCE:nha.of("source"),SDK_METHOD_NAME:nha.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:nha.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:nha.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"};var OG={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!0,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,preserveSchemaIds:!1,objectQueryParameters:!1,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!1,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json"};function CWs({options:e,overrides:t}){return{disableExamples:t?.disableExamples??OG.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.discriminatedUnionV2??OG.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.useTitlesAsName??OG.useTitlesAsName,audiences:t?.audiences??e?.audiences??OG.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??OG.optionalAdditionalProperties,coerceEnumsToLiterals:t?.coerceEnumsToLiterals??e?.coerceEnumsToLiterals??OG.coerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??OG.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??OG.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??OG.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??OG.inlinePathParameters,preserveSchemaIds:t?.preserveSchemaIds??OG.preserveSchemaIds,shouldUseUndiscriminatedUnionsWithLiterals:t?.shouldUseUndiscriminatedUnionsWithLiterals??e?.shouldUseUndiscriminatedUnionsWithLiterals??OG.shouldUseUndiscriminatedUnionsWithLiterals,shouldUseIdiomaticRequestNames:t?.shouldUseIdiomaticRequestNames??e?.shouldUseIdiomaticRequestNames??OG.shouldUseIdiomaticRequestNames,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??OG.objectQueryParameters,filter:t?.filter??e?.filter??OG.filter,asyncApiNaming:t?.asyncApiNaming??e?.asyncApiNaming??OG.asyncApiNaming,exampleGeneration:t?.exampleGeneration??e?.exampleGeneration??void 0,defaultFormParameterEncoding:t?.defaultFormParameterEncoding??e?.defaultFormParameterEncoding??void 0}}var H5p={naming:"v1"};function yf(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function aha(e,t,r,i,n=[]){try{let a=yf(e,t);if(a!=null)return r.parse(a)}catch{let u=vBe(n).join(" -> ");i.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}function QRi(e){let t=yf(e,"examples");return t!=null&&Array.isArray(t)?t:[]}function $5p({schema:e,logger:t}){return yf(e,fd.ENCODING)??void 0}function G5p(e){return yf(e,fd.FERN_ENUM)}function Q5p({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let u=yf(i,fd.SDK_GROUP_NAME),l=yf(i,fd.TYPE_DEFINITION);if(l!=null)return oha({fernType:l,nameOverride:e,generatedName:t,title:r,description:n,availability:a,groupName:typeof u=="string"?[u]:u})}function oha({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u}){return NU({type:e,_default:void 0,validation:void 0,visitor:{primitive:l=>{switch(l.v1){case"BASE_64":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.base64({example:void 0})});case"BOOLEAN":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.boolean({default:void 0,example:void 0})});case"DATE":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.date({example:void 0})});case"DATE_TIME":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.datetime({example:void 0})});case"FLOAT":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.float({example:void 0})});case"DOUBLE":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.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 El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.uint({default:void 0,example:void 0})});case"INTEGER":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.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 El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.uint64({default:void 0,example:void 0})});case"LONG":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:Fo(l.v1)}},unknown:()=>El.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,groupName:u}),map:({keyType:l,valueType:d})=>l?.type==="primitive"&&d!=null?El.map({nameOverride:t,generatedName:r,title:i,key:l,value:d,description:n,availability:a,groupName:u,encoding:void 0,example:void 0,inline:void 0}):void 0,list:l=>l!=null?El.array({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,example:void 0,inline:void 0}):void 0,optional:l=>l!=null?El.optional({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,inline:void 0}):void 0,nullable:l=>l!=null?El.nullable({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,inline:void 0}):void 0,set:l=>l!=null?El.array({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,example:void 0,inline:void 0}):void 0,literal:l=>El.literal({nameOverride:t,generatedName:r,title:i,value:l._visit({string:d=>cx.string(d),boolean:d=>cx.boolean(d),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,groupName:u}),named:()=>{}}})}function J5p(e){let t=yf(e,fd.SOURCE);if(t!=null)return t.endsWith(".proto")?wie.protobuf({file:t}):wie.openapi({file:t})}function JRi(e){if(e!=null&&typeof e=="boolean")return e}function Zd(e){return e.$ref!=null}function K5p({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:u,wrapAsNullable:l,context:d,groupName:s,example:o,encoding:c,source:b,namespace:g}){return typeof n=="boolean"||SSn(n)?xxo({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:El.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:void 0}),groupName:s,example:o,encoding:c}):xxo({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:Y5p(qb(n,d.options.optionalAdditionalProperties?l:!1,d,[...i,"Value"],b,g,void 0,void 0,void 0)),groupName:s,example:o,encoding:c})}function Y5p(e){switch(e.type){case"array":case"enum":case"map":case"object":e.inline=!0;break;case"literal":case"primitive":case"reference":case"unknown":break;case"nullable":case"optional":e.inline=!0,e.value=Y5p(e.value);break;case"oneOf":e.value.inline=!0;break;default:Fo(e)}return e}function xxo({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsNullable:a,description:u,availability:l,groupName:d,example:s,encoding:o}){return a?El.nullable({nameOverride:e,generatedName:t,title:r,value:El.map({nameOverride:e,generatedName:t,title:r,description:u,availability:i.availability,key:i,value:n,groupName:d,encoding:o,example:s,inline:void 0}),description:u,availability:l,groupName:d,inline:void 0}):El.map({nameOverride:e,generatedName:t,title:r,description:u,availability:l,key:i,value:n,groupName:d,encoding:o,example:s,inline:void 0})}function SSn(e){return e==null?!1:typeof e=="boolean"?e:!Zd(e)&&Object.keys(e).length===0}function X5p({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:u,wrapAsNullable:l,context:d,groupName:s,example:o,source:c,namespace:b}){let g=n==null?El.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,groupName:s}):qb(n,!1,d,[...i,"Item"],c,b);return k4D({nameOverride:e,generatedName:t,title:r,groupName:s,itemSchema:g,wrapAsNullable:l,description:a,availability:u,example:o})}function k4D({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsNullable:n,description:a,availability:u,groupName:l,example:d}){return n?El.nullable({nameOverride:e,generatedName:t,title:r,value:El.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,groupName:l,example:d,inline:void 0}),description:a,availability:u,groupName:l,inline:void 0}):El.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,groupName:l,example:d,inline:void 0})}function Bie(e){switch(yf(e,fd.AVAILABILITY)){case"deprecated":return pV.Deprecated;case"beta":return pV.Beta;case"generally-available":return pV.GenerallyAvailable;default:break}if(!Zd(e)&&e.deprecated)return pV.Deprecated}function BWs({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:l,wrapAsNullable:d,discriminator:s,context:o,groupName:c,encoding:b,source:g,namespace:O}){let m=s.propertyName,w=Object.fromEntries(Object.entries(s.mapping??{}).map(([A,q])=>{let D=DSn({$ref:q},!1,o,[q],b,g,O);return o.markReferencedByDiscriminatedUnion({$ref:q},m,1),[A,D]})),E=Object.entries(n).filter(([A])=>A!==m).map(([A,q])=>{let D=l!=null&&l.includes(A),C=qb(q,!D,o,[...i,A],g,O);return{key:A,schema:C}});return Z5p({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:E,description:a,availability:u,discriminant:m,subtypes:w,groupName:c,source:g})}function xWs({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:l,wrapAsNullable:d,discriminant:s,variants:o,context:c,groupName:b,encoding:g,source:O,namespace:m}){let w=Object.fromEntries(Object.entries(o).map(([A,q])=>{if(Zd(q)){let D=DSn(q,!1,c,[q.$ref],g,O,m);return c.markReferencedByDiscriminatedUnion(q,s,1),[A,D]}else{let D=ESn(q,!1,c,[...i,A],g,O,m,new Set([s]));return[A,D]}})),E=Object.entries(n).filter(([A])=>A!==s).map(([A,q])=>{let D=l!=null&&l.includes(A),C=qb(q,!D,c,[...i,A],O,m);return{key:A,schema:C}});return Z5p({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:E,description:a,availability:u,discriminant:s,subtypes:w,groupName:b,source:O})}function Z5p({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,availability:u,discriminant:l,subtypes:d,groupName:s,source:o}){return i?El.nullable({nameOverride:e,generatedName:t,title:r,value:El.oneOf(QY.discriminated({description:a,availability:u,discriminantProperty:l,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:n,groupName:s,encoding:void 0,source:o,inline:void 0})),groupName:s,description:a,availability:u,inline:void 0}):El.oneOf(QY.discriminated({description:a,availability:u,discriminantProperty:l,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:n,groupName:s,encoding:void 0,source:o,inline:void 0}))}function k5p(e){if(e.proto!=null)return t1n.protobuf({typeName:e.proto.type})}function bXt({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:u,description:l,availability:d,wrapAsNullable:s,groupName:o,context:c,source:b,inline:g}){let O=t8D(n??[]),m=new Set(a),w=Array.from(m).map((A,q)=>{let D=i?.[A],C=O[q],R=A1n.test(A),$=D?.name??C,I=R?A:q1n(A);return $!=null&&!A1n.test($)&&(c?.logger.warn(`Enum name override ${$} is not a valid name. Falling back on ${I}.`),$=void 0),{nameOverride:$,generatedName:I,value:A,description:D?.description,availability:d,casing:{snake:D?.casing?.snake??void 0,pascal:D?.casing?.pascal??void 0,screamingSnake:D?.casing?.screamingSnake??void 0,camel:D?.casing?.camel??void 0}}}),E=u!=null?w.find(A=>A.value===u):void 0;return e8D({wrapAsNullable:s,nameOverride:e,generatedName:t,title:r,values:w,_default:E,description:l,availability:d,groupName:o,source:b,inline:g})}function e8D({wrapAsNullable:e,nameOverride:t,generatedName:r,title:i,values:n,_default:a,description:u,availability:l,groupName:d,source:s,inline:o}){return e?El.nullable({nameOverride:t,generatedName:r,title:i,value:El.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,default:a,availability:l,example:void 0,groupName:d,source:s,inline:o}),description:u,availability:l,groupName:d,inline:o}):El.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,availability:l,default:a,example:void 0,groupName:d,source:s,inline:o})}function t8D(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(i=>i[r]===t[r]);)r++;return e.map(i=>i.substring(r))}function e9p({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,description:o,availability:c,wrapAsNullable:b,example:g,groupName:O}){return i==="int64"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint32"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint64"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.int({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O})}function t9p(e){return typeof e=="string"?cx.string(e):typeof e=="boolean"?cx.boolean(e):cx.string(`${e}`)}function r9p({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,value:n,description:a,availability:u,groupName:l}){return i?El.nullable({nameOverride:e,generatedName:t,title:r,value:El.literal({nameOverride:e,generatedName:t,title:r,value:t9p(n),description:a,availability:u,groupName:l}),description:a,availability:u,groupName:l,inline:void 0}):El.literal({nameOverride:e,generatedName:t,title:r,value:t9p(n),description:a,availability:u,groupName:l})}function IWs({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,description:o,availability:c,wrapAsNullable:b,example:g,groupName:O}){return i==null||i==="double"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.double({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="float"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.float({example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="int32"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.int({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="int64"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint32"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint64"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="time-delta"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.float({example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.float({example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O})}var r8D={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},i8D={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}}},n8D={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}}},a8D={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},o8D={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},u8D={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},s8D={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},c8D={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function Ixo(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[r8D,i8D,n8D,a8D,o8D,u8D,s8D,c8D],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:l}=a.applyStrategy(t);t=u,r=[...r,...l]}}while(t.join("")!==n.join(""));return r}function D2(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:G3(Dg(n))).join("");return/^\d/.test(i)?kpa(i)??i:i}function zWs(e){let t=e.join("_");return Dg(t)}function cE(e){switch(e.type){case"object":return gy.object({allOf:e.allOf,properties:e.properties.map(t=>f8D(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,inline:e.inline});case"array":return gy.array({description:e.description,availability:e.availability,value:cE(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,inline:e.inline});case"enum":return gy.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,inline:e.inline});case"literal":return gy.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 gy.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:cE(e.value),groupName:e.groupName,inline:e.inline});case"optional":return gy.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:cE(e.value),groupName:e.groupName,inline:e.inline});case"primitive":return gy.primitive({description:e.description,availability:e.availability,schema:i9p(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return gy.map({description:e.description,availability:e.availability,key:gy.primitive({description:e.key.description,availability:e.key.availability,schema:i9p(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,groupName:e.groupName}),value:cE(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return gy.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 gy.oneOf(l8D(e.value));case"unknown":return gy.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:Fo(e)}}function l8D(e){switch(e.type){case"discriminated":return eKr.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:cE(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,cE(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return eKr.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>cE(t)),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:Fo(e)}}function i9p(e){switch(e.type){case"string":return vj.string(e);case"base64":return vj.base64();case"boolean":return vj.boolean(e);case"date":return vj.date();case"datetime":return vj.datetime();case"double":return vj.double(e);case"float":return vj.float();case"int":return vj.int(e);case"int64":return vj.int64(e);case"uint":return vj.uint();case"uint64":return vj.uint64();default:Fo(e)}}function f8D(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:cE(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function zxo(e,t){return Eie(cE(e),cE(t))}function n9p({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:u,wrapAsNullable:l,allOf:d,context:s,propertiesToExclude:o,groupName:c,fullExamples:b,additionalProperties:g,availability:O,encoding:m,source:w,namespace:E}){let A=[...u??[]],q={...n},D=[],C=[];for(let U of d)if(Zd(U)){let H=s.resolveSchemaReference(U);if(H.discriminator!=null&&H.discriminator.mapping!=null)continue;if(H.oneOf!=null){for(let K of H.oneOf){let ee=Zd(K)?s.resolveSchemaReference(K):K,fe=qb(ee,!1,s.DUMMY,i,w,E);fe.type==="object"&&D.push(...fe.properties.map(me=>me.schema.type!=="optional"&&me.schema.type!=="nullable"?{...me,schema:El.optional({nameOverride:void 0,generatedName:"",title:void 0,value:me.schema,description:void 0,availability:me.availability,groupName:void 0,inline:void 0})}:me))}continue}let k=Wdi(U);if(k==null)continue;C.push({schemaId:k,convertedSchema:RWs(U,[k],w,s.options.preserveSchemaIds),properties:a9p({schema:U,context:s,breadcrumbs:i,source:w,namespace:E})}),s.markSchemaAsReferencedByNonRequest(k)}else{let H=qb(U,!1,s,i,w,E);H.type==="object"&&D.push(...H.properties)}let R={};for(let U of C)for(let[H,k]of Object.entries(U.properties)){let K=R[H];K!=null?(K.schemaIds.push(U.schemaId),K.schemas.some(fe=>zxo(fe,k))||K.schemas.push(k)):R[H]={schemaIds:[U.schemaId],schemas:[k]}}let $=[];for(let[U,H]of Object.entries(R))H.schemaIds.length>1&&$.push({propertyKey:U,allOfSchemaIds:H.schemaIds,conflictingTypeSignatures:H.schemas.length>1});let I=Object.entries(q).map(([U,H])=>{let k=A.includes(U),K=yf(H,fd.AUDIENCES)??[],ee=Bie(H),fe=Zd(H)?!1:H.readOnly,me=Zd(H)?!1:H.writeOnly,ge=yf(H,fd.FERN_PROPERTY_NAME),we=[...i,U],Ze=zWs(we),Mt=k?qb(H,!1,s,we,w,E):El.optional({nameOverride:e,generatedName:Ze,title:r,description:void 0,availability:ee,value:qb(H,!1,s,we,w,E),groupName:c,inline:void 0}),De={};for(let Te of C){let xt=Te.properties[U];xt!=null&&!zxo(Mt,xt)?De[Te.schemaId]={differentSchema:!0}:xt!=null&&(De[Te.schemaId]={differentSchema:!1})}return{key:U,schema:Mt,nameOverride:ge,audiences:K,conflict:De,generatedName:zWs([...i,U]),availability:ee,readonly:fe,writeonly:me}});return I.push(...D.map(U=>{let H=U.conflict;for(let k of C){let K=k.properties[U.key];K!=null&&!zxo(U.schema,K)?H[k.schemaId]={differentSchema:!0}:K!=null&&(H[k.schemaId]={differentSchema:!1})}return{...U,conflict:H}})),d8D({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,properties:I.filter(U=>!o.has(U.key)),description:a,allOf:C.map(U=>U.convertedSchema),allOfPropertyConflicts:$,groupName:c,fullExamples:b,additionalProperties:g,availability:O,source:w})}function d8D({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,allOf:u,allOfPropertyConflicts:l,groupName:d,fullExamples:s,additionalProperties:o,availability:c,source:b}){return i?El.nullable({nameOverride:e,generatedName:t,title:r,value:El.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:l,groupName:d,fullExamples:s,additionalProperties:SSn(o),availability:void 0,source:b,inline:void 0}),description:a,availability:c,groupName:d,inline:void 0}):El.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:l,groupName:d,fullExamples:s,additionalProperties:SSn(o),availability:c,source:b,inline:void 0})}function a9p({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[u,l]=Zd(e)?[t.resolveSchemaReference(e),Ixo(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...a9p({schema:d,context:t,breadcrumbs:l,source:i,namespace:n})};for(let[d,s]of Object.entries(u.properties??{})){let o=qb(s,!1,t,[...l,d],i,n);a[d]=o}return a}function o9p({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsNullable:u,context:l,subtypes:d,groupName:s,encoding:o,source:c,subtypePrefixOverrides:b,namespace:g}){let O=u9p(d);return s9p({uniqueSubtypes:O,nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:n,availability:a,groupName:s,context:l,encoding:o,source:c})}function MSn({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsNullable:u,context:l,subtypes:d,groupName:s,encoding:o,source:c,subtypePrefixOverrides:b,namespace:g}){let O=p8D({schemas:d}),m=d.flatMap((E,A)=>{if(!Zd(E)&&E.enum!=null&&l.options.coerceEnumsToLiterals&&E.type==="string")return E.enum.map(D=>El.literal({nameOverride:void 0,generatedName:D2([t,D],l.options.preserveSchemaIds),title:void 0,value:cx.string(String(D)),groupName:void 0,description:void 0,availability:D.availability}));let q=O[A];if(b!=null){let D=b[A];D!=null&&"name"in D&&(q=D.name)}return[qb(E,!1,l,[...i,q??`${A}`],c,g)]}),w=u9p(m);return s9p({uniqueSubtypes:w,nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:n,availability:a,groupName:s,context:l,encoding:o,source:c})}function u9p(e){let t=[];for(let r=0;r<e.length;++r){let i=e[r],n=!1;for(let a=r+1;a<e.length;++a){let u=e[a];if(i!=null&&u!=null&&Eie(i,u)){n=!0;break}}i!=null&&!n&&t.push(i)}return t}function s9p({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,groupName:l,context:d,encoding:s,source:o}){if(Object.entries(e).every(([b,g])=>g.type==="literal")){let b={},g=[];return Object.entries(e).forEach(([O,m])=>{m.type==="literal"&&m.value.type==="string"&&(g.push(m.value.value),m.description!=null&&(b[m.value.value]={description:m.description}))}),bXt({nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,fernEnum:b,enumVarNames:void 0,enumValues:g,_default:void 0,groupName:l,context:d,source:o,inline:void 0})}return e.length===1&&e[0]!=null?e[0]:c9p({nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,subtypes:e,groupName:l,encoding:s,source:o})}function NWs({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsNullable:a,context:u,groupName:l,discriminator:d,encoding:s,source:o,namespace:c}){let b=Object.entries(d.mapping??{}).map(([m,w],E)=>{let A={$ref:w},q=DSn(A,!1,u,[w],s,o,c);return u.markSchemaWithDiscriminantValue(A,d.propertyName,m),q.type==="object"&&(q.properties={[d.propertyName]:El.literal({nameOverride:void 0,generatedName:D2([t,m],u.options.preserveSchemaIds),title:void 0,value:cx.string(m),groupName:void 0,description:void 0,availability:void 0}),...q.properties.filter(D=>D.key!==d.propertyName)}),q}),g=[];for(let m=0;m<b.length;++m){let w=b[m],E=!1;for(let A=m+1;A<b.length;++A){let q=b[A];if(w!=null&&q!=null&&Eie(w,q)){E=!0;break}}w!=null&&!E&&g.push(w)}if(Object.entries(g).every(([m,w])=>w.type==="literal")){let m={},w=[];return Object.entries(g).forEach(([E,A])=>{A.type==="literal"&&A.value.type==="string"&&(w.push(A.value.value),A.description!=null&&(m[A.value.value]={description:A.description}))}),bXt({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,fernEnum:m,enumVarNames:void 0,enumValues:w,_default:void 0,groupName:l,context:u,source:o,inline:void 0})}return g.length===1&&g[0]!=null?g[0]:c9p({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,subtypes:g,groupName:l,encoding:s,source:o})}function p8D({schemas:e}){let t={},r=0;for(let a of e){if(!Zd(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),l={},d=u;for(let[s,o]of Object.entries(t)){let c=nYa(o,u);d=nYa(d,o),l[s]=c}l[r]=d,t=l}}r++}let i=[],n=0;for(let a of e){let u=t[n];if(u!=null&&u.length>0){let l=u.sort();if(l[0]!=null){i.push(l[0]),++n;continue}}Zd(a)?i.push(ydi(n)??`${n}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?i.push(""):i.push(ydi(n)??`${n}`),++n}return i}function c9p({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,description:n,availability:a,subtypes:u,groupName:l,encoding:d,source:s}){return i?El.nullable({nameOverride:e,generatedName:t,title:r,value:El.oneOf(QY.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:l,encoding:d,source:s,inline:void 0})),description:n,availability:a,groupName:l,inline:void 0}):El.oneOf(QY.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:l,encoding:d,source:s,inline:void 0}))}function ASn(e){if(e.default!=null&&typeof e.default=="string")return e.default}function Rxo({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=QRi(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function l9p({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=QRi(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function _Kr({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=QRi(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function f9p({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=QRi(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var KRi="#/components/schemas/";function qb(e,t,r,i,n,a,u=!1,l=new Set,d){let s=J5p(e)??n,o=m8D({schema:e,logger:r.logger});if(Zd(e)){let c=Wdi(e);return c!=null?(u?r.markSchemaAsReferencedByRequest(c):r.markSchemaAsReferencedByNonRequest(c),DSn(e,t,r,i,o,s,a)):ESn(r.resolveSchemaReference(e),t,r,Ixo(e.$ref),o,s,a,l,u,d)}return ESn(e,t,r,i,o,s,a,l,u,d)}function DSn(e,t,r,i,n,a,u){let l=e.$ref.includes("properties")?ESn(r.resolveSchemaReference(e),t,r,i,n,a,u,new Set):El.reference(RWs(e,i,a,r.options.preserveSchemaIds));return t?El.nullable({title:void 0,nameOverride:void 0,generatedName:D2(i,r.options.preserveSchemaIds),value:l,description:void 0,availability:void 0,groupName:void 0,inline:void 0}):l}function _8D(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function ESn(e,t,r,i,n,a,u,l=new Set,d=!1,s){typeof e=="string"&&(e={type:e});let o=yf(e,fd.TYPE_NAME)??(r.options.useTitlesAsName?_8D(e.title):void 0),c=yf(e,fd.SDK_GROUP_NAME)??yf(e,mV.TAGS)?.[0],b=(typeof c=="string"?[c]:c)??[];b=r.resolveGroupName(b);let g=D2(i,r.options.preserveSchemaIds),O=e.title,m=e.description,w=Bie(e),E=[];e.example!=null&&E.push({name:void 0,value:e.example,description:void 0});let A=yf(e,mV.EXAMPLES);A!=null&&Object.keys(A).length>0&&E.push(...Object.entries(A).map(([C,R])=>({name:R?.summary??C,value:R.value,description:R.description})));let q=QRi(e);q!=null&&Object.keys(q).length>0&&E.push(...q.map(C=>({name:void 0,value:C,description:void 0})));let D=Q5p({schema:e,description:m,title:O,nameOverride:o,generatedName:g,availability:w});if(D!=null)return D;if(Array.isArray(e.type)){let C=e.type.indexOf("null"),R=C!==-1;e.type.length===1?e.type=e.type[0]:e.type.length===2&&R?(e.type.splice(C,1),e.type=e.type[0],e.nullable=!0):(R&&(e.type.splice(C,1),e.nullable=!0),e.oneOf==null?e.oneOf=e.type:e.oneOf.push(...e.type))}if(!t&&e.nullable===!0)return ESn(e,!0,r,i,n,a,u,l,d,s);if(e.enum!=null&&(e.type==="string"||e.type==null)){if(!Lxo(e.enum))return w5({nameOverride:o,generatedName:g,title:O,primitive:Xd.string({default:ASn(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:_Kr({schema:e,logger:r.logger,fallback:s})}),groupName:b,wrapAsNullable:t,description:m,availability:w});let C=G5p(e);return e.enum.length===1&&e.enum[0]!=null&&C==null?r9p({nameOverride:o,generatedName:g,title:O,wrapAsNullable:t,value:e.enum[0],description:m,availability:w,groupName:b}):bXt({nameOverride:o,generatedName:g,title:O,fernEnum:C,enumVarNames:yf(e,[mV.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:m,availability:w,wrapAsNullable:t,groupName:b,context:r,source:a,inline:void 0})}if(Lxo(e.type)&&e.type.length>1){let C=e.type.includes("null"),R=e.type.filter($=>$!=="null").map($=>({type:$,nullable:C}));return MSn({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,wrapAsNullable:t,context:r,subtypes:R,groupName:b,encoding:n,source:a,namespace:u})}if(e.type==="boolean"){let C=yf(e,fd.BOOLEAN_LITERAL);return C!=null?d9p({nameOverride:o,generatedName:g,title:O,literal:cx.boolean(C),wrapAsNullable:t,description:m,availability:w,groupName:b}):w5({nameOverride:o,generatedName:g,title:O,primitive:Xd.boolean({default:h8D(e.default),example:l9p({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:w,groupName:b})}if(e.type==="number")return IWs({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:JRi(e.exclusiveMinimum),exclusiveMaximum:JRi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:w,wrapAsNullable:t,example:Rxo({schema:e,logger:r.logger,fallback:s}),groupName:b});if(e.type==="integer")return e9p({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:JRi(e.exclusiveMinimum),exclusiveMaximum:JRi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:w,wrapAsNullable:t,example:Rxo({schema:e,logger:r.logger,fallback:s}),groupName:b});if(e.type==="float")return IWs({nameOverride:o,generatedName:g,title:O,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:JRi(e.exclusiveMinimum),exclusiveMaximum:JRi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:w,wrapAsNullable:t,example:Rxo({schema:e,logger:r.logger,fallback:s}),groupName:b});if(e.type==="string"){if(e.format==="date-time")return w5({nameOverride:o,generatedName:g,title:O,primitive:Xd.datetime({example:_Kr({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:w,groupName:b});if(e.format==="json-string")return El.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:w,groupName:b,example:void 0});let C=h9p(e,"const");return C!=null?d9p({nameOverride:o,generatedName:g,title:O,literal:cx.string(C),wrapAsNullable:t,description:m,availability:w,groupName:b}):w5({nameOverride:o,generatedName:g,title:O,primitive:Xd.string({default:ASn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:_Kr({schema:e,logger:r.logger,fallback:s})}),groupName:b,wrapAsNullable:t,description:m,availability:w})}if(e.type==="array")return X5p({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,item:e.items,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,example:f9p({schema:e,logger:r.logger,fallback:s}),source:a,namespace:u});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&Nxo(e))return K5p({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,additionalProperties:e.additionalProperties,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,encoding:n,example:e.example,source:a,namespace:u});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?NWs({nameOverride:o,generatedName:g,title:O,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,discriminator:e.discriminator,encoding:n,source:a,namespace:u}):BWs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:b,encoding:n,source:a,namespace:u});if(e.oneOf!=null&&e.oneOf.length>0){let C=yf(e,fd.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||C?NWs({nameOverride:o,generatedName:g,title:O,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,discriminator:e.discriminator,encoding:n,source:a,namespace:u}):BWs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:b,encoding:n,source:a,namespace:u});if(e.oneOf.length===1&&e.oneOf[0]!=null){let R=qb(e.oneOf[0],t,r,i,a,u,d);return qSn(R,m,b)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let U=e.oneOf[0],H=e.oneOf[1];if(!Zd(U)&&U.type==="null")return qb(H,!0,r,i,a,u);if(!Zd(H)&&H.type==="null")return qb(U,!0,r,i,a,u)}let R=b8D({schemas:e.oneOf});if(R!=null)return bXt({nameOverride:o,generatedName:g,title:O,fernEnum:void 0,enumVarNames:void 0,enumValues:R,_default:e.default,description:m,availability:w,wrapAsNullable:t,groupName:b,context:r,source:a,inline:void 0});let $=p9p({schemas:e.oneOf,context:r});if($!=null&&!r.options.discriminatedUnionV2&&!C)return xWs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:w,wrapAsNullable:t,discriminant:$.discriminant,variants:$.schemas,context:r,groupName:b,encoding:n,source:a,namespace:u});let I=e.oneOf.filter(U=>!Zd(U)&&U.type==="null").length>0;return MSn({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,wrapAsNullable:t||I,context:r,subtypes:e.oneOf.filter(U=>Zd(U)||U.type!=="null"),encoding:n,groupName:b,source:a,namespace:u})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let $=qb(e.anyOf[0],t,r,i,a,u,d);return qSn($,m,b)}if(e.anyOf.length===2){let[$,I]=e.anyOf;if($!=null&&I!=null){if(!Zd($)&&$.type==="null"){let U=qb(I,!0,r,i,a,u);return qSn(U,m,b)}else if(!Zd(I)&&I.type==="null"){let U=qb($,!0,r,i,a,u);return qSn(U,m,b)}}}let C=p9p({schemas:e.anyOf,context:r});if(C!=null&&!r.options.discriminatedUnionV2)return xWs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:w,wrapAsNullable:t,discriminant:C.discriminant,variants:C.schemas,context:r,groupName:b,encoding:n,source:a,namespace:u});let R=e.anyOf.filter($=>!Zd($)&&$.type==="null").length>0;return MSn({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,wrapAsNullable:t||R,context:r,subtypes:e.anyOf.filter($=>Zd($)||$.type!=="null"),encoding:n,groupName:b,source:a,namespace:u})}if(e.allOf!=null||e.properties!=null){let C=[];for(let $ of e.allOf??[])(Zd($)||Object.keys($).length>0)&&C.push($);if((e.properties==null||Nxo(e))&&C.length===1&&C[0]!=null){let $=qb(C[0],t,r,i,a,u,d);return qSn($,m,b)}let R=C.filter($=>{let I=Fxo($);return I||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify($)}`),I});if((e.properties==null||Nxo(e))&&R.length===1&&R[0]!=null){let $=qb(R[0],t,r,i,a,u,d);return qSn($,m,b)}return n9p({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},description:m,required:e.required,wrapAsNullable:t,allOf:R,context:r,propertiesToExclude:l,groupName:b,fullExamples:E,additionalProperties:e.additionalProperties,availability:w,encoding:n,source:a,namespace:u})}if(e.type==="object"&&y8D(e)&&v8D(e)&&Nxo(e))return xxo({nameOverride:o,generatedName:g,title:O,description:m,availability:w,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${g}Key`,title:void 0,description:void 0,availability:void 0,schema:Xd.string({default:ASn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:_Kr({schema:e,logger:r.logger,fallback:s})}),groupName:b},valueSchema:El.unknown({nameOverride:void 0,generatedName:`${g}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:b}),groupName:b,encoding:n,example:e.example});if(e.type==null){let C=e.example??e.default;return El.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:w,groupName:b,example:C})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(i)} value=${JSON.stringify(e)}`)}function h8D(e){if(e!=null){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase();if(t==="true")return!0;if(t==="false")return!1}}}function Wdi(e){if(e.$ref.startsWith(KRi))return e.$ref.replace(KRi,"")}function RWs(e,t,r,i){let n=yf(e,fd.TYPE_NAME),a=D2(t,i),u=e.description,l=Bie(e),d=Wdi(e);if(d==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return gy.reference({generatedName:a,nameOverride:n,title:void 0,schema:d,description:u??void 0,availability:l,groupName:void 0,source:r})}function y8D(e){return e.oneOf==null||e.oneOf.length===0}function v8D(e){return e.allOf==null||e.allOf.length===0}function Nxo(e){return e.properties==null||nY(e.properties)===0}function Lxo(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function qSn(e,t,r){return e.type==="reference"?El.reference({...e,description:t,availability:e.availability,groupName:r}):e.type==="optional"?El.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r,inline:void 0}):e.type==="nullable"?El.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r,inline:void 0}):e}function Fxo(e){return Zd(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>Fxo(t)):e.oneOf!=null?e.oneOf.every(t=>Fxo(t)):e.anyOf!=null?e.anyOf.every(t=>Fxo(t)):!1}function d9p({literal:e,wrapAsNullable:t,groupName:r,description:i,availability:n,nameOverride:a,generatedName:u,title:l}){return t?El.nullable({nameOverride:a,generatedName:u,title:l,value:El.literal({nameOverride:a,generatedName:u,title:l,value:e,description:i,availability:n,groupName:r}),groupName:r,description:i,availability:n,inline:void 0}):El.literal({nameOverride:a,generatedName:u,title:l,value:e,groupName:r,description:i,availability:n})}function w5({primitive:e,wrapAsNullable:t,groupName:r,description:i,availability:n,generatedName:a,nameOverride:u,title:l}){return r=typeof r=="string"?[r]:r,t?El.nullable({nameOverride:u,generatedName:a,title:l,value:El.primitive({nameOverride:u,generatedName:a,title:l,schema:e,description:i,availability:n,groupName:r}),groupName:r,description:i,availability:n,inline:void 0}):El.primitive({nameOverride:u,generatedName:a,title:l,schema:e,description:i,availability:n,groupName:r})}function b8D({schemas:e}){let t=new Set;for(let r of e){if(Zd(r))return;if(r.enum!=null&&Lxo(r.enum))r.enum.forEach(i=>t.add(i));else return}return Array.from(t)}function p9p({schemas:e,context:t}){let r={};for(let i of e){let n=_9p({schema:i,context:t});for(let[a,u]of Object.entries(n)){let l=r[a];l!=null?l[u]=i:r[a]={[u]:i}}}for(let[i,n]of Object.entries(r))if(Object.keys(n).length===e.length)return{discriminant:i,schemas:n}}function _9p({schema:e,context:t}){let r=Zd(e)?t.resolveSchemaReference(e):e;return g8D({schema:r,context:t})}function g8D({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let i of e.anyOf){let n=_9p({schema:i,context:t});for(let[a,u]of Object.entries(n??{}))r[a]=u}return r}for(let[i,n]of Object.entries(e.properties??{})){let a=Zd(n)?t.resolveSchemaReference(n):n;a.type==="string"&&a.enum!=null&&Lxo(a.enum)&&O8D(a.enum).length===1&&a.enum[0]!=null&&(r[i]=a.enum[0]);let u=h9p(a,"const");a.type==="string"&&u!=null&&(r[i]=u),i==="type"&&a.example!=null&&(r[i]=a.example)}return r}function O8D(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 h9p(e,t){let r=e[t];if(r!=null)return r}function m8D({schema:e,logger:t}){let r=$5p({schema:e,logger:t});if(r!=null)return k5p(r)}var TSn=class{document;taskContext;logger;DUMMY;options;namespace;static MESSAGE_REFERENCE_PREFIX="#/components/messages/";constructor({document:t,taskContext:r,options:i,namespace:n}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=i,this.namespace=n}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 i=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};i.push(n)}return i.concat(t??[])}resolveSchemaReference(t){if(!t.$ref.startsWith(KRi))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let i=t.$ref.substring(KRi.length).split("/"),n=this.document.components;if(n==null||n.schemas==null)throw new Error("Document does not have components.schemas.");let[a,u,l]=i;if(a==null||a==="")throw new Error(`${t.$ref} cannot be resolved. No schema key provided.`);let d=n.schemas[a];if(d==null)throw new Error(`Schema "${a}" is undefined in document.components.schemas.`);if(Zd(d)&&(d=this.resolveSchemaReference(d)),u==="properties"&&l!=null){let s=d.properties?.[l];if(s==null)throw new Error(`Property "${l}" not found on "${a}". Full ref: ${t.$ref}`);Zd(s)?d=this.resolveSchemaReference(s):d=s}return d}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,i){}markSchemaWithDiscriminantValue(t,r,i){}};var Uxo=class extends TSn{getExampleMessageReference(t){return`#/components/messages/${t.messageId}`}resolveMessageReference(t){let r="#/components/messages/",i=this.document.components;if(i==null||i.messages==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve message reference: ${t.$ref} in v2 components`);let n=t.$ref.substring(r.length),a=i.messages[n];if(a==null)throw new Error(`${t.$ref} is undefined`);return a}};function CSn(e,t){let r={},i={};return e==null?r=t:i={[e]:t},{rootSchemas:r,namespacedSchemas:i}}function Hdi(e){if(typeof e=="string")return rg.primitive(u_.string(e));if(typeof e=="number")return Number.isInteger(e)?rg.primitive(u_.int(e)):rg.primitive(u_.double(e));if(typeof e=="boolean")return rg.primitive(u_.boolean(e));if(Array.isArray(e)){let t=e.map(r=>Hdi(r));return t.length===0?void 0:rg.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,i]of Object.entries(e)){let n=Hdi(i);n!=null&&t.push({key:u_.string(r),value:n})}return rg.map(t)}}function uha(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function y9p(e){if(e!=null&&Array.isArray(e))return e}var $di=class{schemas;nonRequestReferencedSchemas;context;constructor(t,r,i){this.schemas=t,this.nonRequestReferencedSchemas=r,this.context=i}buildExample({schema:t,exampleId:r,example:i,options:n,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:i,options:{...n,maxCheckerDepth:n.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:i,depth:n,visitedSchemaIds:a,options:u,skipReadonly:l}){switch(i.type){case"enum":return typeof r=="string"&&v9p({schema:i,value:r})?rg.enum(r):i.values[0]!=null?rg.enum(i.values[0]?.value):void 0;case"literal":return rg.literal(i.value);case"nullable":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u)))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:l});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(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u))||Object.is(r,null))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:l});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:i.schema,example:r,options:u});return rg.primitive(d)}case"reference":{let d=this.schemas[i.schema];if(d!=null&&!a.has(i.schema)){a.add(i.schema);let s=d?.type==="object"&&!this.nonRequestReferencedSchemas.has(i.schema),o=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:n,options:u,skipReadonly:s||this.context.options.respectReadonlySchemas?l:!1});return a.delete(i.schema),o}return}case"oneOf":switch(i.value.type){case"discriminated":{let d={},s={},o={},c=uha(r),b=c?.[i.value.discriminantProperty],g=i.value.schemas[b],O=[],m=this.getDiscriminatedUnionVariantSchema(i.value,c);m!=null&&O.push(m),O.push(...Object.entries(i.value.schemas));for(let w of O)if(b!=null&&g!=null&&g.type==="object"){s=this.getAllProperties(g),o=this.getAllRequiredProperties(g),d[i.value.discriminantProperty]=rg.primitive(u_.string(b));break}else{let E=this.buildExampleHelper({exampleId:t,schema:w[1],example:void 0,visitedSchemaIds:a,depth:n,options:u,skipReadonly:l});if(E!=null){this.mergeExampleWith(E,d),d[i.value.discriminantProperty]=rg.primitive(u_.string(w[0]));break}}for(let w of i.value.commonProperties){s[w.key]={schema:w.schema,readonly:!1};let E=this.getResolvedSchema(w.schema);E.type!=="optional"&&E.type!=="nullable"&&(o[w.key]=w.schema)}for(let[w,E]of Object.entries(s)){let A=w in o;if(A&&c?.[w]!=null){let q=this.buildExampleHelper({schema:E.schema,exampleId:t,example:c[w],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});if(q!=null)d[w]=q;else return}else{let q=this.buildExampleHelper({exampleId:t,schema:E.schema,example:c?.[w],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});if(q!=null)d[w]=q;else if(A)return}}return rg.oneOf(odi.discriminated(d))}case"undiscriminated":{let d=this.getUnDiscriminatedUnionVariantSchema(i.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:n,options:u,skipReadonly:l});break}}return;case"unknown":if(r!=null){let d=Hdi(r);if(d!=null)return rg.unknown(d)}return u.ignoreOptionals||this.exceedsMaxDepth(n,u)?void 0:u.isParameter?rg.primitive(u_.string(u.name??"string")):rg.map([{key:u_.string("key"),value:rg.primitive(u_.string("value"))}]);case"array":{let d=y9p(r),s=[];if(d!=null&&d.length>0)for(let o of d){let c=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});c!=null&&s.push(c)}else if(i.example!=null&&i.example.length>0)for(let o of i.example){let c=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});c!=null&&s.push(c)}else{let o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});o!=null&&s.push(o)}return rg.array(s)}case"map":{let d=uha(r??i.example);if(d!=null&&Object.entries(d).length>0){let c=[];for(let[b,g]of Object.entries(d)){let O=this.buildExampleFromPrimitive({schema:i.key.schema,example:b,options:u}),m=this.buildExampleHelper({exampleId:t,example:g,schema:i.value,visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});m!=null&&c.push({key:O,value:m})}return rg.map(c)}if(i.key.schema.type==="string"&&i.value.type==="unknown")return rg.map([{key:u_.string("key"),value:rg.unknown(rg.primitive(u_.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:i.key.schema,example:void 0,options:{...u,name:"key"}}),o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,visitedSchemaIds:a,depth:n+1,options:{...u,name:"value"},skipReadonly:l});return o!=null?rg.map([{key:s,value:o}]):rg.map([])}case"object":{let d={},s=i.fullExamples?.find(g=>g.name===t)??i.fullExamples?.find(g=>g.name==null)??i.fullExamples?.[0],o=uha(r)??(s!=null?uha(s.value):{})??{},c=this.getAllProperties(i),b=this.getAllRequiredProperties(i);for(let[g,O]of Object.entries(c)){if(l&&O.readonly)continue;let m=g in b,w=Object.keys(o).includes(g),E=this.buildExampleHelper({schema:O.schema,exampleId:t,example:o[g],visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:l});if(m&&E!=null)d[g]=E;else{if(m)return;(w&&E!=null||!u.ignoreOptionals&&E!=null)&&(d[g]=E)}}if(i.additionalProperties){for(let[g,O]of Object.entries(o))if(!(g in d)){let m=this.buildExampleHelper({schema:El.unknown({example:O,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,groupName:void 0}),exampleId:t,example:O,visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:l});m!=null&&(d[g]=m)}}return rg.object({properties:d})}default:Fo(i)}}mergeExampleWith(t,r){t._visit({array:Jo,enum:Jo,literal:Jo,map:i=>{for(let n of i){let a=n.key;a.type==="string"&&(r[a.value]=n.value)}},object:i=>{for(let[n,a]of Object.entries(i.properties))r[n]=a},oneOf:i=>{if(i.type==="discriminated")for(let[n,a]of Object.entries(i.value))r[n]=a;else this.mergeExampleWith(i.value,r)},primitive:Jo,unknown:Jo,_other:Jo})}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 i=r?.[t.discriminantProperty];if(i==null||typeof i!="string")return Object.entries(t.schemas)[0];let n=t.schemas[i];return n==null?Object.entries(t.schemas)[0]:[i,n]}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 v9p({schema:t,value:r})?5:0;case"object":{if(!kj(r))return 0;let i=this.getAllProperties(t),n=0;for(let[a,u]of Object.entries(i))r[a]!=null?(n++,n+=this.calcExampleHeuristic(u.schema,r[a])):n--;return n}case"array":{if(!Array.isArray(r))return 0;let i=0;for(let n of r)i+=this.calcExampleHeuristic(t.value,n);return i}case"map":{if(!kj(r))return 0;let i=0;for(let[,n]of Object.entries(r))i+=this.calcExampleHeuristic(t.value,n);return i}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let i=this.getResolvedSchema(t);return i==null?0:this.calcExampleHeuristic(i,r)}case"oneOf":return Object.values(t.value.schemas).map(n=>this.calcExampleHeuristic(n,r)).sort((n,a)=>a-n)[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,i=new Set,n){if(this.exceedsMaxCheckerDepth(r,n))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,i,n);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,i,n);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,i,n))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!i.has(t.schema)){i.add(t.schema);let u=this.hasExample(a,r,i,n);return i.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,i,n));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 i of t.properties)r[i.key]={schema:i.schema,readonly:i.readonly??!1};for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let i of t.properties){let n=this.getResolvedSchema(i.schema);n.type!=="optional"&&n.type!=="nullable"&&(r[i.key]=i.schema)}for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);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:i}){switch(r.type){case"string":return t!=null&&typeof t=="string"?u_.string(t):r.example!=null?u_.string(r.example):u_.string(i.name??Sg.STRING);case"base64":return t!=null&&typeof t=="string"?u_.base64(t):r.example!=null?u_.base64(r.example):u_.base64(Sg.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?u_.boolean(t):r.example!=null?u_.boolean(r.example):u_.boolean(Sg.BOOLEAN);case"date":return t!=null&&typeof t=="string"?u_.date(t):r.example!=null?u_.date(r.example):u_.date(Sg.DATE);case"datetime":return t!=null&&typeof t=="string"?u_.datetime(t):r.example!=null?u_.datetime(r.example):u_.datetime(Sg.DATE_TIME);case"double":return t!=null&&typeof t=="number"?u_.double(t):r.example!=null?u_.double(r.example):u_.double(Sg.DOUBLE);case"float":return t!=null&&typeof t=="number"?u_.float(t):r.example!=null?u_.float(r.example):u_.float(Sg.FLOAT);case"int":return t!=null&&typeof t=="number"?u_.int(t):r.example!=null?u_.int(r.example):u_.int(Sg.INT);case"int64":return t!=null&&typeof t=="number"?u_.int64(t):r.example!=null?u_.int64(r.example):u_.int64(Sg.INT64);case"uint":return t!=null&&typeof t=="number"?u_.uint(t):r.example!=null?u_.uint(r.example):u_.uint(Sg.UINT);case"uint64":return t!=null&&typeof t=="number"?u_.uint64(t):r.example!=null?u_.uint64(r.example):u_.uint64(Sg.UINT64);default:Fo(r)}}};function v9p({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function gXt(e){switch(e.type){case"object":return El.object({allOf:e.allOf,properties:e.properties.map(t=>j8D(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,inline:void 0});case"array":return El.array({description:e.description,availability:e.availability,value:gXt(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0});case"enum":return El.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,inline:void 0});case"literal":return El.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 El.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:gXt(e.value),groupName:e.groupName,inline:void 0});case"optional":return El.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:gXt(e.value),groupName:e.groupName,inline:void 0});case"primitive":return El.primitive({description:e.description,availability:e.availability,schema:b9p(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return El.map({description:e.description,availability:e.availability,key:El.primitive({description:e.key.description,availability:e.key.availability,schema:b9p(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,groupName:e.groupName}),value:gXt(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,encoding:e.encoding,example:void 0,inline:void 0});case"reference":return El.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 El.oneOf(P8D(e.value));case"unknown":return El.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,groupName:void 0,description:void 0,availability:void 0});default:Fo(e)}}function P8D(e){switch(e.type){case"discriminated":return QY.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:gXt(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,gXt(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return QY.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>gXt(t)),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:Fo(e)}}function b9p(e){switch(e.type){case"string":return Xd.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return Xd.base64({example:void 0});case"boolean":return Xd.boolean({default:e.default,example:void 0});case"date":return Xd.date({example:void 0});case"datetime":return Xd.datetime({example:void 0});case"double":return Xd.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 Xd.float({example:void 0});case"int":return Xd.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 Xd.int64({default:e.default,example:void 0});case"uint":return Xd.uint({default:void 0,example:void 0});case"uint64":return Xd.uint64({default:void 0,example:void 0});default:Fo(e)}}function j8D(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:gXt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function Vxo(e){return e.type!=="optional"&&e.type!=="nullable"}function FWs(e){return e==="POST"||e==="PUT"||e==="PATCH"}function sha(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 Wxo=class{schemas;context;exampleTypeFactory;logger;constructor(t,r){this.schemas=t,this.context=r,this.schemas=t,this.exampleTypeFactory=new $di(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=S8D(t.request),i=D8D(t.response);if(r?.type==="unsupported"||i?.type==="unsupported")return[];let n=[];if(r!=null&&r.type==="present"){let c=this.isSchemaRequired(r.schema);if(r.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:FWs(t.method),schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});b!=null&&n.push([void 0,b])}else for(let{name:b,value:g}of r.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:FWs(t.method),schema:r.schema,exampleId:b,example:g,options:{isParameter:!1,ignoreOptionals:!0}});O!=null&&n.push([b,O])}if(c&&n.length===0)return this.logger.trace(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(i!=null&&i.type==="present"){let c=this.isSchemaRequired(i.schema);if(t.response?.type==="json"&&t.response.statusCode===204)a.push([void 0,yze.withoutStreaming(rg.object({properties:{}}))]);else if(i.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:void 0,example:void 0,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});b!=null&&(t.response?.type==="json"?a.push([void 0,yze.withoutStreaming(b)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,yze.withStreaming({sse:t.response?.type==="streamingSse",events:[b]})]))}else for(let{name:b,value:g}of i.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:b,example:g,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});O!=null&&(t.response?.type==="json"?a.push([b,yze.withoutStreaming(O)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,yze.withStreaming({sse:t.response?.type==="streamingSse",events:[O]})]))}if(c&&a.length===0)return this.logger.trace(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let c of t.pathParameters){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!OXt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for path parameter ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&u.push({name:c.name,parameterNameOverride:c.parameterNameOverride,value:g})}let l=[];for(let c of t.queryParameters){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!OXt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for query parameter ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&l.push({name:c.name,value:g})}let d=[];for(let c of t.headers){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!OXt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for header ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&d.push({name:c.name,value:g})}let s=[];t.request!=null&&t.response!=null?s=w8D(n,a):t.request!=null?s=n.map(([c,b])=>({id:c,request:b,response:void 0})):t.response!=null&&(s=a.map(([c,b])=>({id:c,request:void 0,response:b})));let o=t.examples.filter(c=>sha(c)).flatMap(c=>{if(c.type==="unknown"){if(c.value!=null){let b=c.value["code-samples"];if(b!=null)return this.convertCodeSamples(b)}return}else return c.codeSamples}).filter(c=>Qb(c));return s.length===0?[E5t.full({name:void 0,description:void 0,pathParameters:u,queryParameters:l,headers:d,request:void 0,response:void 0,codeSamples:o})]:s.map(({id:c,request:b,response:g})=>E5t.full({name:c,description:void 0,pathParameters:u,queryParameters:l,headers:d,request:b,response:g,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?kJr.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):kJr.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?_V.Csharp:r.sdk,code:r.code})).filter(Qb)}isSchemaRequired(t){return Vxo(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function w8D(e,t){let r=[];if(e.length<=1){let[n,a]=e[0]??[];if(t.length===0)return r.push({id:n,request:a,response:void 0}),r;for(let[u,l]of t)r.push({id:u??n,request:a,response:l});return r}if(t.length<=1){let[n,a]=t[0]??[];if(t.length===0)return r.push({id:n,request:void 0,response:a}),r;for(let[u,l]of e)r.push({id:u??n,request:l,response:a});return r}let i=new Set;for(let[n,a]of e){let u=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(n==null){if(u==null)continue;r.push({id:void 0,request:a,response:u});continue}let l=!1;for(let d=0;d<t.length;d++){let[s,o]=t[d];s==null||i.has(d)||n===s&&(r.push({id:n,request:a,response:o}),s!=null&&i.add(d),l=!0)}!l&&u!=null&&r.push({id:n,request:a,response:u})}for(let n=0;n<t.length;n++){if(i.has(n))continue;let[a,u]=t[n],l=e.find(([d])=>d==null)?.[1]??e[0]?.[1];l!=null&&r.push({id:a,request:l,response:u})}return r}function S8D(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:E8D(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function D8D(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"&&e.type!=="streamingSse"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function OXt(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return OXt(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undiscriminated":return OXt(e.value.value);default:return!1}default:Fo(e)}}function E8D(e){return El.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:gXt(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0,writeonly:void 0,inline:void 0}).filter(Qb),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,inline:void 0})}var BSn=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new $di(t,new Set,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,publish:i,subscribe:n,handshake:a,source:u,namespace:l}){let d=[];for(let s of r){let o=[];for(let g of a.queryParameters){let O=this.isSchemaRequired(g.schema),m=this.exampleTypeFactory.buildExample({schema:g.schema,exampleId:void 0,example:s.queryParameters?.[g.name],options:{name:g.name,isParameter:!0,ignoreOptionals:!0}});m!=null&&!OXt(m)&&(m=void 0),!(O&&m==null)&&m!=null&&o.push({name:g.name,value:m})}let c=[];for(let g of a.headers){let O=this.isSchemaRequired(g.schema),m=this.exampleTypeFactory.buildExample({schema:g.schema,exampleId:void 0,example:s.headers?.[g.name],options:{name:g.name,isParameter:!0,ignoreOptionals:!0}});m!=null&&!OXt(m)&&(m=void 0),!(O&&m==null)&&m!=null&&c.push({name:g.name,value:m})}let b=[];for(let g of s.messages){let O=t.getExampleMessageReference(g),m=t.resolveMessageReference({$ref:O}),w=Zd(m.payload)?t.resolveSchemaReference(m.payload):m.payload,E=this.exampleTypeFactory.buildExample({schema:qb(w,!1,t,[g.messageId],u,l),exampleId:void 0,example:g.value,options:{isParameter:!1,ignoreOptionals:!0}});E!=null&&b.push({messageType:g.type,payload:E,description:void 0})}d.push({name:s.summary,queryParameters:o,headers:c,description:s.description,messages:b})}return d}buildWebsocketSessionExample({publish:t,subscribe:r,handshake:i}){let n={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},a=[];for(let l of i.queryParameters){let d=this.isSchemaRequired(l.schema),s=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(s!=null&&!OXt(s)&&(s=void 0),d&&s==null)return;s!=null&&a.push({name:l.name,value:s})}let u=[];for(let l of i.headers){let d=this.isSchemaRequired(l.schema),s=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(s!=null&&!OXt(s)&&(s=void 0),d&&s==null)return;s!=null&&u.push({name:l.name,value:s})}if(t!=null){let l=this.exampleTypeFactory.buildExample({schema:t,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});l!=null&&n.messages.push({messageType:"publish",payload:l,description:void 0})}if(r!=null){let l=this.exampleTypeFactory.buildExample({schema:r,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});l!=null&&n.messages.push({messageType:"subscribe",payload:l,description:void 0})}return n}isSchemaRequired(t){return Vxo(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 mG={FERN_PARAMETER_OPTIONAL:"x-fern-optional",FERN_CHANNEL_ADDRESS:"x-fern-address",FERN_DISPLAY_NAME:"x-fern-display-name",FERN_SDK_GROUP_NAME:"x-fern-sdk-group-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path",FERN_ENUM:"x-fern-enum",IGNORE:"x-fern-ignore"};function Hxo(e){return yf(e,mG.FERN_EXAMPLES)??[]}function $xo(e,t){return t.includes("://")?t:`${e}://${t}`}function Gxo(e){return e.startsWith("/")?e:"/"+e}function m9p({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},u={};for(let[s,o]of Object.entries(n.components?.schemas??{})){let c=qb(o,!1,e,[s],r,e.namespace);a[s]=c}let l=new BSn(a,e),d={};for(let[s,o]of Object.entries(n.servers??{}))d[s]={name:s,url:$xo(o.protocol,o.url)};for(let[s,o]of Object.entries(n.channels??{})){let c=yf(o,mG.IGNORE);if(c!=null&&c){e.logger.debug(`Channel ${s} is marked with x-fern-ignore. Skipping.`);continue}let b=[];if(o.parameters!=null)for(let[E,A]of Object.entries(o.parameters??{}))b.push({name:E,description:A.description,parameterNameOverride:void 0,schema:A.schema!=null?qb(A.schema,!1,e,t,r,e.namespace):El.primitive({schema:Xd.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:Bie(A),source:r});let g=[],O=[];if(o.bindings?.ws!=null){if(o.bindings.ws.headers!=null){let E=o.bindings.ws.headers.required??[];for(let[A,q]of Object.entries(o.bindings.ws.headers.properties??{})){let D=Zd(q)?e.resolveSchemaReference(q):q;g.push({name:A,schema:qb(D,!E.includes(A),e,[...t,A],r,e.namespace),description:D.description,parameterNameOverride:void 0,env:void 0,availability:Bie(D),source:r})}}if(o.bindings.ws.query!=null){let E=o.bindings.ws.query.required??[];for(let[A,q]of Object.entries(o.bindings.ws.query.properties??{})){let D=Zd(q)?e.resolveSchemaReference(q):q;O.push({name:A,schema:qb(D,!E.includes(A),e,[...t,A],r,e.namespace),description:D.description,parameterNameOverride:void 0,availability:Bie(D),source:r})}}}let m;o.publish!=null&&("oneOf"in o.publish.message?m=g9p({generatedName:o.publish.operationId??"PublishEvent",event:o.publish,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):m=O9p({action:"Publish",channelPath:s,message:o.publish.message,context:e,source:r}));let w;if(o.subscribe!=null&&("oneOf"in o.subscribe.message?w=g9p({generatedName:o.subscribe.operationId??"SubscribeEvent",event:o.subscribe,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):w=O9p({action:"Subscribe",channelPath:s,message:o.subscribe.message,context:e,source:r})),g.length>0||O.length>0||m!=null||w!=null){let E=Hxo(o),A=[];if(E.length>0)A=l.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:E,handshake:{headers:g,queryParameters:O},publish:m,subscribe:w,source:r,namespace:e.namespace});else{let C=l.buildWebsocketSessionExample({handshake:{headers:g,queryParameters:O},publish:m,subscribe:w});C!=null&&A.push(C)}let q=yf(o,mG.FERN_CHANNEL_ADDRESS),D=q??Gxo(s);u[s]={audiences:yf(o,fd.AUDIENCES)??[],handshake:{headers:g.map(C=>({...C,schema:cE(C.schema),env:C.env})),queryParameters:O.map(C=>({...C,schema:cE(C.schema)})),pathParameters:b.map(C=>({...C,parameterNameOverride:void 0,schema:cE(C.schema)}))},groupName:[yf(o,mG.FERN_SDK_GROUP_NAME)??s],publish:m!=null?cE(m):m,subscribe:w!=null?cE(w):w,servers:(o.servers?.map(C=>d[C])??Object.values(d)).filter(C=>C!=null),summary:yf(o,mG.FERN_DISPLAY_NAME),path:D,description:o.description,examples:A,source:r}}}return{groupedSchemas:CSn(e.namespace,a),channels:u??void 0,servers:Object.values(d),basePath:yf(n,mG.BASE_PATH)}}function g9p({generatedName:e,event:t,context:r,breadcrumbs:i,source:n,options:a,asyncApiOptions:u}){if("oneOf"in t.message&&t.message.oneOf!=null){let l=[],d=[];for(let s of t.message.oneOf){let o,c={type:"notFound"};if(Zd(s)){let b=r.resolveMessageReference(s);!Zd(b.payload)&&u.naming==="v2"?(c=b.name?{type:"name",name:b.name}:c,o={...b.payload,title:b.name??b.payload.title,description:b.name??b.payload.description}):o=b.payload}else o=s;d.push(c),l.push(o)}return MSn({description:t.description??t.message.description,availability:Bie(t.message),subtypes:l,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:i,context:r,encoding:void 0,source:n,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?d:[]})}}function O9p({action:e,channelPath:t,message:r,context:i,source:n}){if(r.payload!=null){let a=r.payload;return Zd(r.payload)&&(a=i.resolveSchemaReference(r.payload)),Zd(a)?qb(a,!1,i,[t,e],n,i.namespace):qb(a,!1,i,[t,e],n,i.namespace)}}var Qxo=class extends TSn{getExampleMessageReference(t){return`#/channels/${t.channelId}/messages/${t.messageId}`}resolveMessageReference(t){let r="#/channels/",i="#/components/messages/";if(t.$ref.startsWith(r)){let l=t.$ref.split("/"),d=l[2],s=l[4];if(d==null||s==null||!this.document.channels?.[d])throw new Error(`Failed to resolve message reference ${t.$ref} in channel ${d}`);let c=this.document.channels[d].messages?.[s];if(c==null)throw new Error(`${t.$ref} is undefined`);return{name:s,...c}}let n=this.document.components;if(!t.$ref.startsWith(i)||!n?.messages)throw new Error(`Failed to resolve message reference: ${t.$ref} in v3 components`);let a=t.$ref.substring(i.length),u=n.messages[a];if(u==null)throw new Error(`${t.$ref} is undefined`);return{name:a,...u}}};var P9p="#/channels/",j9p="#/servers/",LWs="$message.";function S9p({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},u={},l={},d=[],s={};for(let[m,w]of Object.entries(n.components?.schemas??{}))a[m]=qb(w,!1,e,[m],r,e.namespace);for(let[m,w]of Object.entries(n.channels??{}))if(u[m]||(u[m]={}),w.messages)for(let[E,A]of Object.entries(w.messages))A&&A.payload!=null&&(l[E]||(l[E]=[]),l[E].push({channelId:m,payload:A.payload}));for(let[m,w]of Object.entries(l))if(w.length===1){let E=w[0],A=E.channelId;u[A]=u[A]||{},u[A][m]=qb(E.payload,!1,e,[m],r,e.namespace)}else{d.push(m);for(let{channelId:E,payload:A}of w){let q=`${E}_${m}`;u[E]||(u[E]={}),u[E][q]=qb(A,!1,e,[q],r,e.namespace)}}let o=Object.values(u).reduce((m,w)=>({...m,...w}),{}),c=new BSn(o,e),b={};for(let[m,w]of Object.entries(n.servers??{}))b[m]={name:m,url:$xo(w.protocol,w.host)};let g={};for(let[m,w]of Object.entries(n.operations??{})){if(yf(w,mG.IGNORE))continue;let E=M8D(w);if(g[E]||(g[E]={subscribe:[],publish:[]}),w.action==="receive")g[E].subscribe.push(...w.messages);else if(w.action==="send")g[E].publish.push(...w.messages);else throw new Error(`Operation ${m} has an invalid action: ${w.action}`)}let O={};for(let[m,w]of Object.entries(g)){O[m]={subscribe:void 0,publish:void 0};let E=m.split("/").pop()??m,A=E.charAt(0).toUpperCase()+E.slice(1);w.subscribe.length>0&&u[m]!=null&&(O[m].subscribe=w9p({generatedName:A+"SubscribeEvent",channelPath:m,messages:w.subscribe,breadcrumbs:t,context:e,source:r,messageSchemas:u[m],duplicatedMessageIds:d})),w.publish.length>0&&u[m]!=null&&(O[m].publish=w9p({generatedName:A+"PublishEvent",channelPath:m,messages:w.publish,breadcrumbs:t,context:e,source:r,messageSchemas:u[m],duplicatedMessageIds:d}))}for(let[m,w]of Object.entries(n.channels??{})){if(yf(w,mG.IGNORE))continue;let E=[],A=[],q=[];if(w.parameters!=null)for(let[D,C]of Object.entries(w.parameters)){let{type:R,parameterKey:$}=A8D(C.location),I=yf(C,mG.FERN_PARAMETER_OPTIONAL),U=G3(Dg(m))+G3(Dg(D)),H=yf(C,mG.FERN_ENUM),k=C.enum!=null&&Array.isArray(C.enum)?T8D({parameterName:U,fernEnum:H,parameterDescription:C.description,enumValues:C.enum,defaultValue:C.default,context:e,source:r}):El.primitive({schema:Xd.string({default:C.default,pattern:void 0,format:void 0,maxLength:void 0,minLength:void 0,example:C.examples?.[0]}),description:void 0,availability:void 0,generatedName:"",title:U,groupName:void 0,nameOverride:void 0});I&&(k=El.optional({value:k,description:void 0,availability:void 0,generatedName:"",title:U,groupName:void 0,nameOverride:void 0,inline:void 0}));let K={name:$,description:C.description,parameterNameOverride:void 0,schema:k,variableReference:void 0,availability:Bie(C),source:r};R==="header"?E.push({...K,env:void 0}):R==="path"?A.push(K):R==="payload"&&q.push(K)}if(E.length>0||q.length>0||O[m]!=null&&(O[m].publish!=null||O[m].subscribe!=null)){let D=Hxo(w),C=[];if(D.length>0)C=c.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:D,handshake:{headers:E,queryParameters:q},publish:O[m]?.publish,subscribe:O[m]?.subscribe,source:r,namespace:e.namespace});else{let R=c.buildWebsocketSessionExample({handshake:{headers:E,queryParameters:q},publish:O[m]?.publish,subscribe:O[m]?.subscribe});R!=null&&C.push(R)}s[m]={audiences:yf(w,fd.AUDIENCES)??[],handshake:{headers:E.map(R=>({...R,schema:cE(R.schema),env:R.env})),queryParameters:q.map(R=>({...R,schema:cE(R.schema)})),pathParameters:A.map(R=>({...R,parameterNameOverride:void 0,schema:cE(R.schema)}))},groupName:[yf(w,mG.FERN_SDK_GROUP_NAME)??m],publish:O[m]?.publish!=null?cE(O[m].publish):void 0,subscribe:O[m]?.subscribe!=null?cE(O[m].subscribe):void 0,summary:yf(w,mG.FERN_DISPLAY_NAME),servers:w.servers?.map(R=>q8D(b,R))??Object.values(b),path:w.address??Gxo(m),description:w.description,examples:C,source:r}}}return{groupedSchemas:CSn(e.namespace,a),channels:s,servers:Object.values(b),basePath:yf(n,mG.BASE_PATH)}}function M8D(e){if(!e.channel.$ref.startsWith(P9p))throw new Error(`Failed to resolve channel path from operation ${e.channel.$ref}`);return e.channel.$ref.substring(P9p.length)}function A8D(e){try{let[t,r]=e.split("#/");if(t==null||r==null)throw new Error(`Invalid location format: ${e}; unable to parse message type and parameter key`);if(!t.startsWith(LWs))throw new Error(`Invalid location format: ${e}; expected ${LWs} prefix`);let i=t.substring(LWs.length);if(i!=="header"&&i!=="path"&&i!=="payload")throw new Error(`Invalid message type: ${i}. Must be one of: header, path, payload`);return{type:i,parameterKey:r}}catch{throw new Error(`Invalid location format: ${e}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`)}}function q8D(e,t){if(!t.$ref.startsWith(j9p))throw new Error(`Failed to resolve server name from server ref ${t.$ref}`);let r=t.$ref.substring(j9p.length),i=e[r];if(i==null)throw new Error(`Failed to find server with name ${r}`);return i}function T8D({parameterName:e,fernEnum:t,parameterDescription:r,enumValues:i,defaultValue:n,context:a,source:u}){return bXt({nameOverride:void 0,generatedName:e,title:void 0,wrapAsNullable:!1,description:r??void 0,availability:void 0,fernEnum:t??{},enumVarNames:void 0,enumValues:i,_default:n,groupName:void 0,context:a,source:u,inline:void 0})}function w9p({generatedName:e,channelPath:t,messages:r,context:i,breadcrumbs:n,source:a,messageSchemas:u,duplicatedMessageIds:l}){if(r.length>0){let d=[];for(let s of r){let o=i.resolveMessageReference(s),c;l.some(g=>g===o.name)?c=`${t}_${o.name}`:c=o.name;let b=u[c];b!=null&&d.push(b)}return o9p({description:void 0,availability:void 0,subtypes:d,nameOverride:void 0,generatedName:e,title:void 0,groupName:void 0,wrapAsNullable:!1,breadcrumbs:n,context:i,encoding:void 0,source:a,namespace:i.namespace,subtypePrefixOverrides:[]})}}function D9p({document:e,taskContext:t,options:r,source:i,asyncApiOptions:n,namespace:a}){let u=[];if(a!=null&&u.push(a),parseFloat(e.asyncapi)<3){let l=e;l.tags?.[0]!=null?u.push(l.tags[0].name):n.naming!=="v2"&&u.push("websocket");let d=new Uxo({document:l,taskContext:t,options:r,namespace:a});return m9p({context:d,breadcrumbs:u,source:i,asyncApiOptions:n,document:l})}else{let l=e,d=new Qxo({document:l,taskContext:t,options:r,namespace:a});return S9p({context:d,breadcrumbs:u,source:i,asyncApiOptions:n,document:l})}}function E9p(e){let t=C8D(e),r={};return UWs({obj:t,occurrences:r,breadcrumbs:[]}),r}function UWs({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let i of e)UWs({obj:i,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let i=e.$ref;t[i]==null?t[i]=1:t[i]+=1;return}for(let i in e)UWs({obj:e[i],occurrences:t,breadcrumbs:[...r,i]})}}}function C8D(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?cha(r.get):void 0,put:r?.put!=null?cha(r.put):void 0,post:r?.post!=null?cha(r.post):void 0,patch:r?.patch!=null?cha(r.patch):void 0,delete:r?.delete!=null?cha(r.delete):void 0}]))}}function cha(e){return{...e,requestBody:e.requestBody!=null?Zd(e.requestBody)?e.requestBody:B8D(e.requestBody):void 0}}function B8D(e){let t,r;for(let i in e.content){let n=JB.parse(i);n!=null&&(n.isJSON()?t=e.content[i]:n.isMultipart()&&(r=e.content[i]))}return r!=null&&t!=null?{...e,content:{[JB.MULTIPART_FORM_DATA]:r}}:e}var Jxo=class{endpoints;parser=new MBi;constructor({context:t,options:r}){this.endpoints=r.filter?.endpoints?new Set(this.validateAndFilterEndpoints({context:t,endpoints:r.filter.endpoints})):void 0}skipEndpoint({method:t,path:r}){return this.endpoints!=null&&!this.endpoints.has(`${t} ${r}`)}hasEndpoints(){return this.endpoints!=null}validateAndFilterEndpoints({context:t,endpoints:r}){let i=[];for(let n of r){let a=this.parser.tryParse(n);if(a==null){t.logger.debug(`Ignoring configured filter endpoint "${n}"; expected format "POST /users/get"`);continue}i.push(`${a.method} ${a.path}`)}return i}};var M9p="#/components/parameters/",A9p="#/components/responses/",q9p="#/components/examples/",T9p="#/components/requestBodies/",xSn=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;filter;namespace;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=i,this.refOccurrences=E9p(t),this.options=n,this.source=a,this.filter=new Jxo({context:r,options:n}),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 i={type:"namespace",name:this.namespace};r.push(i)}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(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return{"x-fern-type":"unknown"};i=i[n]}return i==null?(this.logger.warn(`Encountered undefined reference: ${t.$ref}`),{"x-fern-type":"unknown"}):(Zd(i)&&(i=this.resolveSchemaReference(i)),i)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(M9p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(M9p.length),i=this.document.components.parameters[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return Zd(i)?this.resolveParameterReference(i):i}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(T9p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(T9p.length),i=this.document.components.requestBodies[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return Zd(i)?this.resolveRequestBodyReference(i):i}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(A9p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(A9p.length),i=this.document.components.responses[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return Zd(i)?this.resolveResponseReference(i):i}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(q9p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(q9p.length),i=this.document.components.examples[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return Zd(i)?this.resolveExampleReference(i):i}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}};var ISn=class extends xSn{constructor({document:t,taskContext:r,options:i,source:n,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:i,source:n,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,i){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,i){}getDiscriminatedUnionMetadata(t){}};var Kxo=class extends xSn{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discriminatedUnionReferences={};discriminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u})}getDummy(){return new ISn({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,i){let n=this.discriminatedUnionReferences[t.$ref];n!=null?(n.discriminants.add(r),n.numReferences+=i):this.discriminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:i}}getReferencesFromDiscriminatedUnion(t){return this.discriminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,i){let n=this.discriminatedUnionMetadata[t.$ref];n!=null?n.discriminants.set(r,i):this.discriminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,i]])}}getDiscriminatedUnionMetadata(t){return this.discriminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function C9p(e){return yf(e,fd.ASYNC_CONFIG)}var B9p="$request.";function x9p(e){let t=yf(e,fd.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:x8D(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function x8D(e){return e.startsWith(B9p)?e.slice(B9p.length):e}function I9p(e){let t=e;if(t.cursor!=null)return hze.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});if("offset"in e){let r=e;return hze.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}if("type"in e&&e.type==="custom"){let r=e;return hze.custom({results:r.results})}throw new Error("Invalid pagination extension")}function z9p(e,t){let r=yf(t,fd.PAGINATION);if(r!=null){if(typeof r=="boolean"){let i=yf(e,fd.PAGINATION);if(typeof i=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return i==null?void 0:I9p(i)}return I9p(r)}}var I8D=Yu.object({lang:Yu.string(),label:Yu.optional(Yu.string()),source:Yu.string()}),VWs=Yu.array(I8D);var R9p={README_EXT:"x-readme"};function z8D(e){if(!Array.isArray(e))return!1;for(let t of e)if(!kj(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function N9p(e){let t=yf(e,R9p.README_EXT);if(!kj(t))return[];let r=t["code-samples"];if(!z8D(r))return[];let i=[];for(let n of r)i.push({name:n.name,language:n.language,code:n.code,install:n.install,docs:void 0});return i}function F9p(e,t,r){let n=(yf(t,fd.EXAMPLES)??[]).filter(s=>{let o=l2.serialization.ExampleEndpointCallSchema.parse(s);return o.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),o.ok}),a=aha(t,mV.REDOCLY_CODE_SAMPLES_KEBAB,VWs,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],l=[...aha(t,mV.REDOCLY_CODE_SAMPLES_CAMEL,VWs,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...a];l.length>0&&n.push({"code-samples":l.map(s=>({name:s.label??s.lang,language:s.lang,code:s.source,install:void 0,docs:void 0}))});let d=N9p(t);return d.length>0&&n.push({"code-samples":d}),n.map(E5t.unknown)}function L9p(e){let t=yf(e,fd.AVAILABILITY);if(t==="ga"||t==="generally-available")return pV.GenerallyAvailable;if(t==="beta"||t==="pre-release")return pV.Beta;if(t==="deprecated")return pV.Deprecated;if(e.deprecated)return pV.Deprecated}function Yxo(e){return{url:R8D({url:e.url,variables:e.variables??{}}),description:e.description,name:N8D(e),audiences:yf(e,fd.AUDIENCES)}}function R8D({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([i,n])=>[i,n.default]));for(let[i,n]of Object.entries(r))e=e.replace(`{${i}}`,n);return e}function N8D(e){let t=yf(e,[fd.SERVER_NAME_V1,fd.SERVER_NAME_V2]);if(t!=null)return t;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox"}function U9p(e){return yf(e,fd.PARAMETER_NAME)}function V9p(e){return yf(e,fd.SDK_VARIABLE)}function Xxo({path:e,httpMethod:t,parameters:r,context:i,requestBreadcrumbs:n,source:a}){let u={pathParameters:[],queryParameters:[],headers:[]};for(let l of r){let d=yf(l,fd.IGNORE);if(d!=null&&d){i.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let s=Zd(l)?i.resolveParameterReference(l):l,o=s.required??!1,c=Bie(s),b=[...n,s.name],g=D2(b,i.options.preserveSchemaIds),O=s.schema!=null?qb(s.schema,!o,i,b,a,i.namespace,!1,new Set,_Kr({schema:s,logger:i.logger})):o?El.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:_Kr({schema:s,logger:i.logger})}),description:void 0,availability:c,groupName:void 0}):El.optional({nameOverride:void 0,generatedName:g,title:void 0,value:El.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:_Kr({schema:s,logger:i.logger})}),description:void 0,availability:void 0,groupName:void 0}),description:void 0,availability:c,groupName:void 0,inline:void 0});if(s.in==="header"&&s.schema!=null&&!Zd(s.schema)&&s.schema.default!=null){let w=s.schema.default;typeof w=="string"&&w.length>0&&(O=El.literal({nameOverride:void 0,generatedName:g,title:void 0,value:cx.string(w),description:void 0,availability:c,groupName:void 0}))}let m={name:s.name,schema:O,description:s.description,parameterNameOverride:U9p(s),availability:c,source:a};s.in==="query"?u.queryParameters.push(m):s.in==="path"?u.pathParameters.push({...m,variableReference:V9p(s)}):s.in==="header"?!F8D.has(s.name.toLowerCase())&&!i.authHeaders.has(s.name)?u.headers.push({...m,env:void 0}):i.logger.debug(`Ignoring ${s.name} header, in ${t.toUpperCase()} ${e}`):i.logger.warn(`Skipping ${s.in} parameter, ${s.name}, in ${t.toUpperCase()} ${e}`)}return u}var F8D=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function W9p(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r,schema:n??{},examples:lha(i,t)}}}function zSn(e,t){for(let r of Object.keys(e))if(r.includes("json")||r==="*/*"){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r.includes("*")?void 0:r,schema:n??{},examples:lha(i,t)}}}function H9p(e,t){for(let r of Object.keys(e)){let i=e[r];if(i==null)continue;return{schema:i.schema??{},examples:lha(i,t)}}}function lha(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let i=yf(e,mV.EXAMPLES);return i!=null&&Object.keys(i).length>0&&r.push(...Object.entries(i).map(([n,a])=>({name:a.summary??n,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([n,a])=>{let u=Zd(a)?t.resolveExampleReference(a):a;return{name:u.summary??n,value:u.value,description:u.description}})),r}function L8D(e,t){for(let[r,i]of Object.entries(e.content))if(JB.parse(r)?.isURLEncoded())return{schema:i.schema,contentType:r,examples:lha(i,t)}}function U8D(e){for(let[t,r]of Object.entries(e.content))if(JB.parse(t)?.isMultipart())return{schema:r.schema,encoding:r.encoding}}function V8D(e){for(let t in e.content)if(JB.parse(t)?.isOctetStream())return!0;return!1}function W8D(e,t){let r=Zd(e)?WWs(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([i,n])=>!Zd(n)&&n.type==="string"&&n.format==="binary")!=null}function RSn({requestBody:e,document:t,context:r,requestBreadcrumbs:i,source:n,namespace:a}){let u=Zd(e)?r.resolveRequestBodyReference(e):e,l=U8D(u),d=l?.schema,s=l?.encoding,o=L8D(u,r),c=zSn(u.content,r);if(V8D(u))return VSe.octetStream({description:u.description,source:n});if(d!=null&&c==null||d!=null&&W8D(d,t)){let b=Zd(d)?WWs(d,t):{id:void 0,schema:d},g=qb(b.schema,!1,r,i,n,a),O=[];if(g.type==="object")for(let m of g.properties){if(m.schema.type==="primitive"&&m.schema.schema.type==="string"&&m.schema.schema.format==="binary"){O.push({key:m.key,schema:vze.file({isOptional:!1,isArray:!1,description:void 0}),description:m.schema.description,contentType:s?.[m.key]?.contentType,exploded:!1,encoding:void 0});continue}if(m.schema.type==="optional"&&m.schema.value.type==="primitive"&&m.schema.value.schema.type==="string"&&m.schema.value.schema.format==="binary"){O.push({key:m.key,schema:vze.file({isOptional:!0,isArray:!1,description:m.schema.value.description}),description:m.schema.value.description,contentType:s?.[m.key]?.contentType,exploded:!1,encoding:void 0});continue}if(m.schema.type==="array"&&m.schema.value.type==="primitive"&&m.schema.value.schema.type==="string"&&m.schema.value.schema.format==="binary"){O.push({key:m.key,schema:vze.file({isOptional:!1,isArray:!0,description:m.schema.value.description}),description:m.schema.description,contentType:s?.[m.key]?.contentType,exploded:!1,encoding:void 0});continue}if(m.schema.type==="optional"&&m.schema.value.type==="array"&&m.schema.value.value.type==="primitive"&&m.schema.value.value.schema.type==="string"&&m.schema.value.value.schema.format==="binary"){O.push({key:m.key,schema:vze.file({isOptional:!0,isArray:!0,description:m.schema.value.value.description}),description:m.schema.value.description,contentType:s?.[m.key]?.contentType,exploded:!1,encoding:void 0});continue}let w=s?.[m.key]?.contentType;O.push({key:m.key,schema:vze.json(m.schema),description:void 0,contentType:s?.[m.key]?.contentType,exploded:s?.[m.key]?.explode,encoding:w==null?r.options.defaultFormParameterEncoding:void 0})}return VSe.multipart({name:Zd(d)&&r.getNumberOfOccurrencesForRef(d)===1?b.id:void 0,description:b.schema.description,properties:O,source:n})}if(c!=null){let b=qb(c.schema,!1,r,i,n,a,!0);return VSe.json({description:void 0,schema:b,contentType:c.contentType,fullExamples:c.examples,additionalProperties:!Zd(c.schema)&&SSn(c.schema.additionalProperties),source:n})}if(o!=null&&o.schema!=null){let b=qb(o.schema,!1,r,i,n,a);return VSe.json({schema:b,description:u.description,contentType:o.contentType,source:n,fullExamples:o.examples,additionalProperties:!1})}}function WWs(e,t){if(!e.$ref.startsWith(KRi))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=Wdi(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let i=t.components?.schemas?.[r];if(i==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return Zd(i)?WWs(i,t):{id:r,schema:i}}var HWs={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",498:"InvalidTokenError",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"},$9p=new Set(Object.values(HWs));var H8D=["200","201","202","204"];function Q9p({operationContext:e,responses:t,context:r,responseBreadcrumbs:i,responseStatusCode:n,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let l=$8D({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,s;for(let o of n!=null?[n]:H8D){let c=t[o];c!=null&&(d=!0,s==null&&(s=G9p({operationContext:e,response:c,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace,statusCode:typeof o=="string"?parseInt(o):o})))}if(s==null&&!d&&t.default!=null&&(s=G9p({operationContext:e,response:t.default,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace})),s!=null)switch(s.type){case"json":return{value:s,errors:l};case"streamingJson":case"streamingSse":return{value:s,errors:l};case"file":case"text":case"streamingText":return{value:s,errors:l};default:Fo(s)}return{value:void 0,errors:l}}function G9p({operationContext:e,streamFormat:t,response:r,context:i,responseBreadcrumbs:n,source:a,namespace:u,statusCode:l}){let d=Zd(r)?i.resolveResponseReference(r):r;if(d.content!=null&&Object.entries(d.content).find(([b,g])=>{if(g.schema==null)return!1;let O=Zd(g.schema)?i.resolveSchemaReference(g.schema):g.schema;return O.type==="string"&&O.format==="binary"}))return lx.file({description:d.description,source:a,statusCode:l});let s=W9p(d.content??{},i);if(s!=null&&t!=null)switch(t){case"json":return lx.streamingJson({statusCode:l,description:d.description,responseProperty:yf(e.operation,fd.RESPONSE_PROPERTY),fullExamples:s.examples,schema:qb(s.schema,!1,i,n,a,u),source:a});case"sse":return lx.streamingSse({description:d.description,responseProperty:void 0,fullExamples:s.examples,schema:qb(s.schema,!1,i,n,a,u),source:a,statusCode:l})}let o=zSn(d.content??{},i);if(o!=null){if(t!=null)switch(t){case"json":return lx.streamingJson({description:d.description,responseProperty:void 0,fullExamples:o.examples,schema:qb(o.schema,!1,i,n,a,u),source:a,statusCode:l});case"sse":return lx.streamingSse({description:d.description,responseProperty:void 0,fullExamples:o.examples,schema:qb(o.schema,!1,i,n,a,u),source:a,statusCode:l})}return lx.json({description:d.description,schema:qb(o.schema,!1,i,n,a,u),responseProperty:yf(e.operation,fd.RESPONSE_PROPERTY),fullExamples:o.examples,source:a,statusCode:l})}for(let[c,b]of Object.entries(d.content??{})){let g=JB.parse(c);if(g!=null){if(g.isOctetStream()||g.isPDF()||g.isAudio()||g.isImage()||g.isVideo())return lx.file({description:d.description,source:a,statusCode:l});if(g.isPlainText()){let O=b.schema;if(O==null)return lx.text({description:d.description,source:a,statusCode:l});let m=Zd(O)?i.resolveSchemaReference(O):O;return m.type==="string"&&m.format==="byte"?lx.file({description:d.description,source:a,statusCode:l}):lx.text({description:d.description,source:a,statusCode:l})}}}}function $8D({responses:e,context:t,source:r,namespace:i}){let n={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let l=parseInt(a);if(l<400||l>600)continue;let d=Zd(u)?t.resolveResponseReference(u):u,s=H9p(d.content??{},t),o=HWs[l];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}n[l]={statusCode:l,nameOverride:void 0,generatedName:o,description:d.description,schema:qb(s?.schema??{},!1,t,[o,"Body"],r,i),fullExamples:s?.examples,source:r}}return n}function hKr({operationContext:e,context:t,responseStatusCode:r,suffix:i,streamFormat:n,source:a}){let{document:u,operation:l,path:d,method:s,baseBreadcrumbs:o,sdkMethodName:c}=e,b=yf(l,fd.IDEMPOTENT),g=yf(l,[fd.REQUEST_NAME_V1,fd.REQUEST_NAME_V2]),O=[...o,"Request"],m=Xxo({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:O,path:d,httpMethod:s,source:a}),w=/{([^}]+)}/g,A=[...d.matchAll(w)].map(U=>U[1]).filter(U=>!m.pathParameters.some(H=>H.name===U));if(A.length>0)for(let U of A)m.pathParameters.push({name:U??"",variableReference:void 0,parameterNameOverride:void 0,availability:void 0,source:a,schema:El.primitive({schema:Xd.string({default:void 0,example:void 0,format:void 0,maxLength:void 0,minLength:void 0,pattern:void 0}),description:void 0,generatedName:"",nameOverride:void 0,groupName:void 0,availability:void 0,title:void 0}),description:void 0});let q=l.requestBody!=null?RSn({requestBody:l.requestBody,document:u,context:new ISn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:O,source:a,namespace:t.namespace}):void 0;Q8D({context:t,convertedParameters:m})&&q!=null&&q.type==="json"&&q.schema.type!=="object"&&l.requestBody!=null?q=RSn({requestBody:l.requestBody,document:u,context:t,requestBreadcrumbs:[...O,"Body"],source:a,namespace:t.namespace}):l.requestBody!=null&&(q=RSn({requestBody:l.requestBody,document:u,context:t,requestBreadcrumbs:[...O],source:a,namespace:t.namespace}));let D=[...o,"Response"],C=Q9p({operationContext:e,streamFormat:n,responses:l.responses,context:t,responseBreadcrumbs:D,responseStatusCode:r,source:a});e.method==="GET"&&(q=void 0);let R=L9p(l),$=F9p(e,l,t),I=yf(l,fd.SERVER_NAME_V2);return{summary:l.summary,internal:yf(l,mV.INTERNAL),idempotent:b,audiences:yf(l,fd.AUDIENCES)??[],operationId:l.operationId!=null&&i!=null?l.operationId+"_"+i:l.operationId,tags:t.resolveTagsToTagIds(l.tags),namespace:t.namespace,sdkName:c,pathParameters:m.pathParameters,queryParameters:m.queryParameters,headers:m.headers,requestNameOverride:g??void 0,generatedRequestName:D2(O,t.options.preserveSchemaIds),request:q,response:C.value,errors:C.errors,servers:I!=null?[{name:I,url:void 0,audiences:void 0}]:(l.servers??[]).map(U=>Yxo(U)),description:l.description,authed:G8D(l,u),availability:R,method:s,path:d,examples:$,pagination:e.pagination,source:a}}function G8D(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function Q8D({context:e,convertedParameters:t}){return e.options.inlinePathParameters&&t.pathParameters.length>0||t.queryParameters.length>0||t.headers.length>0}function K9p({operationContext:e,context:t,asyncExtension:r,source:i}){let{operation:n,pathItemParameters:a,operationParameters:u}=e,l=r.discriminant.name,d=r.discriminant.value,s=r["response-status-code"],o=J9p({context:t,headerToIgnore:l,parameters:a}),c=J9p({context:t,headerToIgnore:l,parameters:u}),b=hKr({operationContext:{...e,pathItemParameters:o,operationParameters:c,operation:{...n,responses:Object.fromEntries(Object.entries(n.responses).filter(([O])=>parseInt(O)!==s))}},context:t,streamFormat:void 0,source:i}),g=hKr({operationContext:{...e,pathItemParameters:o,operationParameters:c,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:s,streamFormat:void 0,source:i});return g.headers.push({name:l,schema:El.literal({nameOverride:void 0,generatedName:D2([l],t.options.preserveSchemaIds),title:void 0,description:void 0,availability:void 0,value:cx.string(d),groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:i}),{sync:b,async:g}}function J9p({context:e,headerToIgnore:t,parameters:r}){return r.filter(i=>{let n=Zd(i)?e.resolveParameterReference(i):i;return!(n.in==="header"&&n.name===t)})}var $Ws="stream";function k9p({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:hKr({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let i=Y9p({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(i?.schemaReference!=null){let s=Wdi(i.schemaReference);s!=null&&t.excludeSchema(s)}let n=X9p({operation:e.operation,response:r.responseStream}),a=hKr({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+$Ws}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:i?.requestBody,responses:n},baseBreadcrumbs:[...e.baseBreadcrumbs,$Ws]},context:t,streamFormat:r.format,suffix:$Ws,source:t.source});a.examples=a.examples.filter(s=>Z9p(s,t)!==!1);let u=Y9p({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),l=X9p({operation:e.operation,response:r.response}),d=hKr({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u?.requestBody,responses:l}},context:t,source:t.source});return d.examples=d.examples.filter(s=>Z9p(s,t)!==!0),{streaming:a,nonStreaming:d}}default:Fo(r)}}function Y9p({context:e,operation:t,streamingExtension:r,isStreaming:i}){if(t.requestBody==null)return;let n=Zd(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=zSn(n.content,e);if(a==null)return;let u=Zd(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let l=u.properties?.[r.streamConditionProperty];l!=null&&Zd(l)&&(l=void 0);let d={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":i,...l??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[JB.APPLICATION_JSON]:{schema:d}}},schemaReference:Zd(a.schema)?a.schema:void 0}}function X9p({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[JB.APPLICATION_JSON]:{schema:t}}}}}function Z9p(e,t){return e._visit({unknown:r=>{let i=l2.serialization.ExampleEndpointCallSchema.parse(r);if(i.ok&&i.value.response!=null)return i.value.response.stream!=null},full:()=>{},_other:()=>{}})}function eLp({context:e,operationContext:t,source:r}){let{document:i,operation:n,path:a,method:u,baseBreadcrumbs:l,sdkMethodName:d}=t,s=[...l,"Payload"],o=Xxo({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:s,path:a,httpMethod:u,source:r});if(n.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 c=RSn({requestBody:n.requestBody,document:i,context:e,requestBreadcrumbs:[...l,"Payload"],source:r,namespace:e.namespace});if(c==null||c.type!=="json"){e.logger.error(`Skipping webhook ${a} because non-json request body`);return}if(n.operationId==null){e.logger.error(`Skipping webhook ${a} because no operation id present`);return}return{summary:n.summary,sdkName:d,namespace:e.namespace,method:u,operationId:n.operationId,tags:e.resolveTagsToTagIds(n.tags),headers:o.headers,generatedPayloadName:D2(s,e.options.preserveSchemaIds),payload:c.schema,description:n.description,examples:J8D(c.fullExamples),source:r}}function J8D(e){if(e==null)return[];let t=[];for(let r of e){let i=Hdi(r.value);i!=null&&t.push({description:r.description,name:r.name,payload:i})}return t}function GWs({context:e,pathItemContext:t,operation:r,convertToWebhook:i}){let n=yf(r,fd.IGNORE);if(n!=null&&n){e.logger.debug(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=K8D(r,e),u=z9p(e.document,r),l={...t,sdkMethodName:a,baseBreadcrumbs:Y8D({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path,shouldUseIdiomaticRequestNames:e.options.shouldUseIdiomaticRequestNames}),operation:r,operationParameters:r.parameters??[],pagination:u};if(i){let c=eLp({context:e,operationContext:l,source:e.source});return c!=null?{type:"webhook",value:c}:void 0}let d=x9p(r);if(d!=null){let c=k9p({context:e,operationContext:l,streamingExtension:d});return c!=null?{type:"streaming",streaming:c.streaming,nonStreaming:c.nonStreaming}:void 0}let s=C9p(r);if(s!=null){let c=K9p({context:e,operationContext:l,asyncExtension:s,source:e.source});return{type:"async",async:c.async,sync:c.sync}}return{type:"http",value:hKr({context:e,operationContext:l,streamFormat:void 0,source:e.source})}}function K8D(e,t){let r=yf(e,fd.SDK_METHOD_NAME),i=yf(e,fd.SDK_GROUP_NAME)??[];if(r!=null){let n=typeof i=="string"?[i]:i;return n=t.resolveGroupName(n),{groupName:n,methodName:r}}}function Y8D({sdkMethodName:e,operation:t,httpMethod:r,path:i,shouldUseIdiomaticRequestNames:n}){let a=[];if(e!=null){if(n&&a.push(e.methodName),e.groupName.length>0){let u=e.groupName[e.groupName.length-1];u!=null&&a.push(typeof u=="string"?u:u.name)}n||a.push(e.methodName)}else t.operationId!=null?a.push(t.operationId):a.push(Dg(`${r}_${i.split("/").join("_")}`));return a}function tLp(e,t,r,i){let n=[],a=iLp(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let l of a){if(i.filter.skipEndpoint({method:l.method,path:e})){i.logger.debug(`Skipping endpoint "${l.method} ${e}"`);continue}let d=X8D({operation:l.operation}),s=GWs({context:i,pathItemContext:{...u,method:l.method},operation:l.operation,convertToWebhook:d});s!=null&&n.push(s)}return n}function rLp(e,t,r,i){let n=[],a=iLp(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let l of a){if(i.filter.skipEndpoint({method:l.method,path:e})){i.logger.debug(`Skipping endpoint "${l.method} ${e}"`);continue}let d=GWs({context:i,pathItemContext:{...u,method:l.method},operation:l.operation,convertToWebhook:!0});d!=null&&n.push(d)}return n}function iLp(e){let t=[];return e.get!=null&&t.push({method:pG.Get,operation:e.get}),e.post!=null&&t.push({method:pG.Post,operation:e.post}),e.put!=null&&t.push({method:pG.Put,operation:e.put}),e.delete!=null&&t.push({method:pG.Delete,operation:e.delete}),e.patch!=null&&t.push({method:pG.Patch,operation:e.patch}),t}function X8D({operation:e}){return yf(e,[fd.WEBHOOK])??!1}function nLp(e){let t=yf(e,fd.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=yf(e,fd.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function aLp(e){return yf(e,fd.FERN_BASIC_AUTH)}function QWs(e,t){if(Zd(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return Z8D(e,t)}function Z8D(e,t){if(e.type==="apiKey"&&e.in==="header"){let r=yf(e,mV.BEARER_FORMAT),i=yf(e,fd.FERN_HEADER_AUTH);return g5.header({headerName:e.name,prefix:r!=null?"Bearer":i?.prefix,headerVariableName:i?.name??yf(e,fd.HEADER_VARIABLE_NAME),headerEnvVar:i?.env})}else if(e.type==="http"&&e.scheme==="bearer"){let r=yf(e,fd.FERN_BEARER_TOKEN);return g5.bearer({tokenVariableName:r?.name??yf(e,fd.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:r?.env})}else if(e.type==="http"&&e.scheme==="basic"){let r=aLp(e),i=nLp(e);return g5.basic({usernameVariableName:r?.username?.name??i.usernameVariable,usernameEnvVar:r?.username?.env,passwordVariableName:r?.password?.name??i.passwordVariable,passwordEnvVar:r?.password?.env})}else{if(e.type==="openIdConnect")return g5.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return g5.oauth({scopesEnum:k8D(e,t)})}}function k8D(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let i=bXt({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,inline:void 0}),n=cE(i);if(n.type==="enum")return n}}function oLp(e){return yf(e,fd.BASE_PATH)}var e5D=Yu.record(Yu.string(),Yu.object({summary:Yu.string().optional(),description:Yu.string().optional()}));function uLp({document:e,context:t}){return aha(e,fd.GROUPS,e5D,t.logger)}function sLp({context:e,document:t}){return yf(t,fd.FERN_VERSION)??void 0}function cLp(e){let t=yf(e,fd.FERN_GLOBAL_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?oha({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function lLp(e){let t=yf(e,fd.FERN_IDEMPOTENCY_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?oha({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function fLp(e,t){let r=yf(e,fd.SDK_VARIABLES);return r==null?{}:Object.fromEntries(Object.entries(r).map(([i,n])=>{if(n.type==="string")return[i,{nameOverride:void 0,generatedName:D2([i],t),title:n.title,schema:vj.string({default:ASn(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 ${i} has unsupported schema ${JSON.stringify(n)}`)}))}var t5D="webhooks";function dLp(e){return yf(e,t5D)??{}}function pLp(e){return yf(e,fd.RESOLUTIONS)}function _Lp({openapi:e}){let t=pLp(e);if(t==null)return e;let r={};for(let i of t){let n=`#/components/schemas/${i.name}`;for(let a of i.resolutions)e=r5D({openapi:e,schemaReference:a,schemaName:i.name}),e=hLp({openapi:e,replaceReference:a,schemaReference:n,replacedReferences:r}),r={...r,...Object.fromEntries(i.resolutions.map(u=>[n,u]))}}return e}function r5D({openapi:e,schemaReference:t,schemaName:r}){let i=t.replace("#/","").split("/").map(a=>a.replaceAll("~1","/")),n=e;for(let a of i){let u=n[a];if(u==null)return e;n=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=n,e}function hLp({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:i}){let n=Object.keys(i).filter(d=>t.startsWith(d)).sort((d,s)=>s.length-d.length)[0];if(n!=null){let d=i[n];if(d!=null){let s=r.replace(n,d);return hLp({openapi:e,replaceReference:t,schemaReference:s,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replaceAll("~1","/")),u=e;for(let d of a.slice(0,-1)){let s=u[d];if(s==null)return e;u=s}let l=a[a.length-1];return l==null||(u[l]={$ref:r}),e}function vLp({openApi:e,taskContext:t,options:r,source:i,namespace:n}){e=_Lp({openapi:e});let a=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([I,U])=>QWs(U,i)==null?[]:[I,QWs(U,i)])),u=new Set(...Object.entries(a).map(([I,U])=>U.type==="basic"||U.type==="bearer"?"Authorization":U.type==="header"?U.headerName:null)),l=fLp(e,r.preserveSchemaIds),d=cLp(e),s=lLp(e),o=r.audiences??[],c=[],b=[],g=new Kxo({document:e,taskContext:t,authHeaders:u,options:r,source:i,namespace:n});g.filter.hasEndpoints()&&t.logger.debug("Endpoint filter applied..."),Object.entries(e.paths??{}).forEach(([I,U])=>{if(U==null)return;t.logger.debug(`Converting path ${I}`);let H=tLp(I,U,e,g);for(let k of H){let K=yLp({operation:k});if(!(o.length>0&&!o.some(ee=>K.includes(ee))))switch(k.type){case"async":c.push(k.sync),c.push(k.async);break;case"http":c.push(k.value);break;case"streaming":c.push(k.streaming),k.nonStreaming&&c.push(k.nonStreaming);break;case"webhook":b.push(k.value);break;default:Fo(k)}}}),Object.entries(dLp(e)).forEach(([I,U])=>{if(U==null)return;t.logger.debug(`Converting path ${I}`);let H=rLp(I,U,e,g);for(let k of H){let K=yLp({operation:k});o.length>0&&!o.some(ee=>K.includes(ee))||b.push(k.value)}});let O=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([I,U])=>{if(!Zd(U)){let H=yf(U,fd.IGNORE);if(H!=null&&H)return[];if($9p.has(I))return[I,qb({...U,"x-fern-type-name":`${I}Body`},!1,g,[I],i,n)]}return[I,qb(U,!1,g,[I],i,n)]}).filter(I=>I.length>0)),m=i5D(O,g,i),w=n5D(m,g),E={};for(let[I,U]of Object.entries(w)){let H=cE(U);g.isSchemaExcluded(I)||(E[I]=H,t.logger.debug(`Converted schema ${I}`))}let A=new $di(w,g.nonRequestReferencedSchemas,g),q=b.map(I=>{let H=I.examples;if(!r.disableExamples&&H.length===0){let k=A.buildExample({schema:I.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});k!=null&&(H=[{name:void 0,description:void 0,payload:k}])}return{...I,payload:cE(I.payload),examples:H}}),D=new Wxo(w,g),C=c.map(I=>{let U=I.examples,H=U;if(!r.disableExamples&&(U.length===0||U.every(sha))){let ee=D.buildEndpointExample(I);ee.length>0&&(H=[...ee,...U.filter(fe=>!sha(fe))])}let k=I.request,K=I.response;return{...I,request:k?.type==="json"?{...k,schema:cE(k.schema)}:k,response:K?.type==="json"?{...K,schema:cE(K.schema)}:K,queryParameters:I.queryParameters.map(ee=>({description:ee.description,name:ee.name,schema:cE(ee.schema),parameterNameOverride:ee.parameterNameOverride,availability:ee.availability,source:ee.source})),pathParameters:I.pathParameters.map(ee=>({description:ee.description,name:ee.name,schema:cE(ee.schema),parameterNameOverride:ee.parameterNameOverride,variableReference:ee.variableReference,availability:ee.availability,source:ee.source})),headers:I.headers.map(ee=>({description:ee.description,name:ee.name,schema:cE(ee.schema),parameterNameOverride:ee.parameterNameOverride,env:ee.env,availability:ee.availability,source:ee.source})),examples:H,errors:rd(I.errors,ee=>{let fe=ee.fullExamples?.map(me=>{let ge=Hdi(me.value);if(ge!=null)return{name:me.name,description:me.description,example:ge}}).filter(Qb);if(fe?.length===0){let me=A.buildExample({schema:ee.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});me!=null&&fe.push({name:void 0,description:void 0,example:me})}return{generatedName:ee.generatedName,nameOverride:ee.nameOverride,schema:cE(ee.schema),description:ee.description,source:ee.source,examples:fe}})}}),R=uLp({document:e,context:g});return{apiVersion:sLp({context:g,document:e}),basePath:oLp(e),title:e.info.title,description:e.info.description,groups:Object.fromEntries(Object.entries(R??{}).map(([I,U])=>[I,{summary:U.summary??void 0,description:U.description??void 0}])),servers:(e.servers??[]).map(I=>Yxo(I)),websocketServers:[],tags:{tagsById:Object.fromEntries((e.tags??[]).map(I=>[I.name,{id:I.name,description:I.description}])),orderedTagIds:e.tags?.map(I=>I.name)},endpoints:C,webhooks:q,channels:{},groupedSchemas:CSn(n,E),securitySchemes:a,hasEndpointsMarkedInternal:C.some(I=>I.internal),nonRequestReferencedSchemas:g.getReferencedSchemas(),variables:l,globalHeaders:d,idempotencyHeaders:s}}function i5D(e,t,r){let i={};for(let[n,a]of Object.entries(e)){if(a.type!=="object"){i[n]=a;continue}let u={$ref:`#/components/schemas/${n}`},l=t.getReferencesFromDiscriminatedUnion(u);if(l==null){i[n]=a;continue}let d={...a,type:"object",properties:a.properties.filter(o=>!l.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!l.discriminants.has(o.propertyKey)),source:r};i[n]=d;let s=bLp({schema:a,schemas:e});for(let o of[...new Set(s)]){let c=i[o]??e[o];c==null||c.type!=="object"||(i[o]={...c,type:"object",properties:c.properties.filter(b=>!l.discriminants.has(b.key)),allOfPropertyConflicts:c.allOfPropertyConflicts.filter(b=>!l.discriminants.has(b.propertyKey))})}}return i}function n5D(e,t){let r={};for(let[i,n]of Object.entries(e)){if(n.type!=="object"){r[i]=n;continue}let a={$ref:`#/components/schemas/${i}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[i]=n;continue}let l=[];for(let s of n.properties)if(u.discriminants.has(s.key)){let o=u.discriminants.get(s.key);o!=null&&l.push({...s,schema:El.literal({nameOverride:void 0,generatedName:D2([n.generatedName,o],t.options.preserveSchemaIds),title:void 0,value:cx.string(o),groupName:void 0,description:void 0,availability:n.availability})})}else l.push(s);let d={...n,type:"object",properties:l};r[i]=d}return r}function bLp({schema:e,schemas:t}){let r=[];for(let i of e.allOf){r.push(i.schema);let n=t[i.schema];n!=null&&n.type==="object"&&r.push(...bLp({schema:n,schemas:t}))}return r}function yLp({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:Fo(e)}return t}function YRi({context:e,documents:t,options:r}){let i={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],websocketServers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channels:{},groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}};for(let n of t){let a=n.source!=null?n.source:wie.openapi({file:"<memory>"});switch(n.type){case"openapi":{let u=vLp({taskContext:e,openApi:n.value,options:CWs({options:n.settings,overrides:r}),source:a,namespace:n.namespace});i=o5D(i,u);break}case"asyncapi":{let u=D9p({document:n.value,taskContext:e,options:CWs({options:n.settings,overrides:r}),source:a,asyncApiOptions:a5D({options:n.settings}),namespace:n.namespace});u.servers!=null&&(i.websocketServers=[...i.websocketServers,...u.servers.map(l=>({...l,audiences:void 0,description:void 0}))]),u.channels!=null&&(i.channels={...i.channels,...u.channels}),u.groupedSchemas!=null&&(i.groupedSchemas=gLp(i.groupedSchemas,u.groupedSchemas)),u.basePath!=null&&(i.basePath=u.basePath);break}default:Fo(n)}}return i}function a5D({options:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??H5p.naming}}function o5D(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],websocketServers:[...e.websocketServers,...t.websocketServers],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],channels:{...e.channels,...t.channels},groupedSchemas:gLp(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 gLp(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,i]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...i}:e.namespacedSchemas[r]=i;return e}var Zxo={config:new OLp.Config({apis:{},styleguide:{plugins:[TWs],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0};function fha(e){return e.swagger!=null}function JWs(e){return e.openapi!=null}function Gdi(e,t={}){return{...Object.fromEntries(CN(e.namedDefinitionFiles).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...CN(e.importedDefinitions).reduce((r,[i,n])=>({...r,...$ra(Gdi(n.definition,{defaultURL:n.url}),(a,u)=>PR(i,sy.of(u)))}),{})}}function dha(e,t={}){return{...Object.fromEntries(CN(e.packageMarkers).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...CN(e.importedDefinitions).reduce((r,[i,n])=>({...r,...$ra(dha(n.definition,{defaultURL:n.url}),(a,u)=>PR(i,sy.of(u)))}),{})}}function yKr(e){return{...dha(e),...Gdi(e)}}function xie(e,t){return yKr(e.definition)[t]?.contents}function dF(e,t){for(let[r,i]of CN(yKr(e.definition)))t(r,i.contents,{isPackageMarker:_Ci(r)===X1,defaultUrl:i.defaultUrl})}function XRi(e,t){for(let[r,i]of CN(dha(e.definition)))t(r,i.contents)}var AHp=yi(MHp(),1);async function nya(e){return(await(0,AHp.convertObj)(e,{})).openapi}var THp=require("fs/promises");var qHp=require("fs/promises");async function ozo({absoluteFilePathToOverrides:e,data:t,context:r,allowNullKeys:i}){let n=null;try{let a=(await(0,qHp.readFile)(e,"utf8")).toString();try{n=JSON.parse(a)}catch{n=Kd.load(a,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return yds({data:t,overrides:n,allowNullKeys:i})}async function CHp({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,THp.readFile)(t)).toString(),n=await Kd.load(i);return r!=null?await ozo({absoluteFilePathToOverrides:r,context:e,data:n}):n}var oya=yi(Bxo(),1);var BHp=yi(Bxo(),1),X$s=yi(require("path"),1);var aya=class extends BHp.BaseResolver{absolutePathToOpenAPIOverrides;constructor(t){super(),this.absolutePathToOpenAPIOverrides=t}resolveExternalRef(t,r){let i=super.resolveExternalRef(t,r);return TGr(Wl.of(i))?i:this.absolutePathToOpenAPIOverrides!=null?X$s.default.resolve(X$s.default.dirname(this.absolutePathToOpenAPIOverrides),r):i}};async function Z$s({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,parsed:r}){return(r!=null?await(0,oya.bundle)({...Zxo,doc:{source:new oya.Source(e,"<openapi>"),parsed:r},externalRefResolver:new aya(t)}):await(0,oya.bundle)({...Zxo,ref:e,externalRefResolver:new aya(t)})).bundle.parsed}var bHD=["examples","example",fd.EXAMPLES,mV.REDOCLY_CODE_SAMPLES_CAMEL,mV.REDOCLY_CODE_SAMPLES_KEBAB];async function uya({context:e,absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r}){let i=await Z$s({absolutePathToOpenAPI:t}),n;if(r!=null?n=r:typeof i=="object"&&i[fd.OPENAPI_OVERIDES_FILEPATH]!=null&&(n=Xu(_p(t),Xa.of(i[fd.OPENAPI_OVERIDES_FILEPATH]))),n!=null){let a=await ozo({absoluteFilePathToOverrides:n,context:e,data:i,allowNullKeys:bHD});return await Z$s({absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r,parsed:a})}return i}var U5t=class{absoluteFilePath;constructor(t){this.absoluteFilePath=t}async loadDocuments({context:t,specs:r}){let i=[];for(let n of r){let a=(await(0,xHp.readFile)(n.absoluteFilepath)).toString(),u=aT(this.absoluteFilePath,n.source.file);n.source.relativePathToDependency!=null&&(u=Xu(n.source.relativePathToDependency,u));let l=n.source.type==="protobuf"?wie.protobuf({file:u}):wie.openapi({file:u});if(a.includes("openapi")||a.includes("swagger")){let d=await uya({absolutePathToOpenAPI:n.absoluteFilepath,context:t,absolutePathToOpenAPIOverrides:n.absoluteFilepathToOverrides});if(JWs(d))i.push({type:"openapi",value:d,source:l,namespace:n.namespace,settings:n.settings});else if(fha(d)){let s=await nya(d);i.push({type:"openapi",value:s,source:l,namespace:n.namespace,settings:n.settings})}}else if(a.includes("asyncapi")){let d=await CHp({context:t,absoluteFilePath:n.absoluteFilepath,absoluteFilePathToOverrides:n.absoluteFilepathToOverrides});i.push({type:"asyncapi",value:d,source:l,namespace:n.namespace,settings:n.settings})}else t.failAndThrow(`${n.absoluteFilepath} is not a valid OpenAPI or AsyncAPI file`)}return i}};var yzo=require("fs/promises"),cGp=yi(Lte(),1);var sGp=yi(uGp(),1);async function SG(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...u}={}){let l=n.reduce((o,c)=>({...o,[c]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[o,c]of Object.entries(l))d=d.replaceAll(o,c);e?.debug(`+ ${d}`);let s=(0,sGp.default)(t,r,u);return i||(s.stdout?.pipe(process.stdout),s.stderr?.pipe(process.stderr)),s.then(o=>(o.stdout==null&&(o.stdout=""),o.stderr==null&&(o.stderr=""),o))}function _zo(e,{logger:t,...r}={}){return(i,n)=>SG(t,e,i,{...r,...n})}var fGD="buf.gen.yaml",lGp="output",dGD=`${lGp}/openapi.yaml`,hzo=class{context;constructor({context:t}){this.context=t}async generate({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,relativeFilepathToProtobufRoot:i,local:n}){return n?this.generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,relativeFilepathToProtobufRoot:i}):this.generateRemote()}async generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,relativeFilepathToProtobufRoot:i}){let n=await this.setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t,relativeFilepathToProtobufRoot:i}),a=aT(t,r);return this.doGenerateLocal({cwd:n,target:a})}async setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t,relativeFilepathToProtobufRoot:r}){let i=Wl.of((await cGp.default.dir()).path);return await(0,yzo.cp)(t,i,{recursive:!0}),await(0,yzo.writeFile)(Xu(i,Xa.of(fGD)),pGD({relativeFilepathToProtobufRoot:r})),i}async doGenerateLocal({cwd:t,target:r}){let i=_zo("which",{cwd:t,logger:this.context.logger});try{await i(["buf"])}catch{this.context.failAndThrow("Missing required dependency; please install 'buf' to continue (e.g. 'brew install buf').")}try{await i(["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/fern-api/protoc-gen-openapi/cmd/protoc-gen-openapi@latest').")}let n=_zo("buf",{cwd:t,logger:this.context.logger});return await n(["config","init"]),await n(["generate",r]),Xu(t,Xa.of(dGD))}async generateRemote(){this.context.failAndThrow("Remote Protobuf generation is unimplemented.")}};function pGD({relativeFilepathToProtobufRoot:e}){return`
1937
+ `)),{ok:!0,value:t}):i}}function wAo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var i1n=class e extends Error{errors;constructor(t){super(t.map(wAo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var n1n=class e extends Error{errors;constructor(t){super(t.map(wAo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function VA(e){return{optional:()=>h5s(e),transform:t=>y5s(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new n1n(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new i1n(i.errors)}}}function h5s(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>JP.OPTIONAL};return{...t,...VA(t)}}function y5s(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...VA(r)}}function aRp(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:DM(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:DM(t,"bigint")}]},getType:()=>JP.BIGINT};return{...O5(e),...VA(e)}}var GPD=/^([+-]?\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 oRp(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:DM(t,"string")}]}:GPD.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:DM(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:DM(t,"Date object")}]},getType:()=>JP.DATE};return{...O5(e),...VA(e)}}function _G(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...O5(r),...VA(r)}}}function SAo(e){let t=new Set(e);return _G(JP.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:DM(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:DM(i,"enum")}]}:{ok:!0,value:i})()}function uRp(e){let t=v5s(e);return{...t,...VA(t)}}function v5s(e){return{parse:(t,r)=>a1n(e).parse(t,r),json:(t,r)=>a1n(e).json(t,r),getType:()=>a1n(e).getType()}}function a1n(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function Kpa(e){return Object.entries(e)}function Ypa(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function sdi(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 Xpa(e){return Object.keys(e)}function sRp(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function M5t(e){return{withParsedProperties:t=>b5s(e,t)}}function b5s(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((l,[d,s])=>({...l,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!sdi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:DM(i,"object")}]};let a=new Set(Object.keys(t)),u=Ypa(i,Object.keys(i).filter(l=>!a.has(l)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...VA(r),...M5t(r)}}function cRp(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function cdi(e){return e.isProperty}function DAo(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>cdi(i)?i.rawKey:r),_getParsedProperties:()=>Xpa(e),parse:(r,i)=>{let n={},a=[];for(let[u,l]of Kpa(e)){let d=cdi(l)?l.rawKey:u,s=cdi(l)?l.valueSchema:l,o={rawKey:d,parsedKey:u,valueSchema:s};n[d]=o,dRp(s)&&a.push(d)}return lRp({value:r,requiredKeys:a,getProperty:u=>{let l=n[u];if(l!=null)return{transformedKey:l.parsedKey,transform:d=>l.valueSchema.parse(d,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of Kpa(e)){let l=cdi(u)?u.valueSchema:u;dRp(l)&&n.push(a)}return lRp({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return cdi(u)?{transformedKey:u.rawKey,transform:l=>u.valueSchema.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:l=>u.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>JP.OBJECT};return{...O5(t),...VA(t),...M5t(t),...yRi(t)}}function lRp({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!sdi(e))return{ok:!1,errors:[{path:a,message:DM(e,"object")}]};let u=new Set(t),l=[],d={};for(let[s,o]of Object.entries(e)){let c=r(s);if(c!=null){u.delete(s);let b=c.transform(o);b.ok?d[c.transformedKey]=b.value:(d[s]=o,l.push(...b.errors))}else switch(i){case"fail":l.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=o;break}}return l.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),l.length===0||n?{ok:!0,value:d}:{ok:!1,errors:l}}function yRi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>fRp({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>fRp({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>JP.OBJECT};return{...r,...VA(r),...M5t(r),...yRi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>JP.OBJECT};return{...t,...VA(t),...M5t(t),...yRi(t)}}}}function fRp({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=sRp(Xpa(t),s=>n.has(s)),l=r(Ypa(t,u)),d=i(Ypa(t,a));return l.ok&&d.ok?{ok:!0,value:{...l.value,...d.value}}:{ok:!1,errors:[...l.ok?[]:l.errors,...d.ok?[]:d.errors]}}function dRp(e){return!QPD(e)}function QPD(e){switch(e.getType()){case JP.ANY:case JP.UNKNOWN:case JP.OPTIONAL:return!0;default:return!1}}function pRp(e){return DAo(e)}function _Rp(e){let t={...v5s(e),_getRawProperties:()=>a1n(e)._getRawProperties(),_getParsedProperties:()=>a1n(e)._getParsedProperties()};return{...t,...VA(t),...M5t(t),...yRi(t)}}function EAo(e){let t={parse:(r,i)=>hRp(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>hRp(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>JP.LIST};return{...O5(t),...VA(t)}}function hRp(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:DM(e,"list"),path:[]}]}}function yRp(e){return _G(JP.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:DM(r,`"${e}"`)}]})()}function vRp(e){return _G(JP.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:DM(r,`${e.toString()}`)}]})()}var bRp=_G(JP.ANY,e=>({ok:!0,value:e}));var gRp=_G(JP.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DM(e,"boolean")}]});var ORp=_G(JP.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DM(e,"number")}]});var mRp=_G(JP.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DM(e,"string")}]});var PRp=_G(JP.UNKNOWN,e=>({ok:!0,value:e}));function wRp(e,t){let r={parse:(i,n)=>jRp({value:i,isKeyNumeric:e.getType()===JP.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>jRp({value:i,isKeyNumeric:e.getType()===JP.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>JP.RECORD};return{...O5(r),...VA(r)}}function jRp({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return sdi(e)?Kpa(e).reduce((a,[u,l])=>{if(l==null)return a;let d=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),c=i(l,s);if(d.ok&&o.ok&&c.ok)return{ok:!0,value:{...d.value,[o.value]:c.value}};let b=[];return d.ok||b.push(...d.errors),o.ok||b.push(...o.errors),c.ok||b.push(...c.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:DM(e,"object")}]}}function SRp(e){let t=EAo(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:DM(i,"Set")}]},getType:()=>JP.SET};return{...O5(r),...VA(r)}}function ERp(e){let t={parse:(r,i)=>DRp((n,a)=>n.parse(r,a),e,i),json:(r,i)=>DRp((n,a)=>n.json(r,a),e,i),getType:()=>JP.UNDISCRIMINATED_UNION};return{...O5(t),...VA(t)}}function DRp(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let l of u.errors)i.push({path:l.path,message:`[Variant ${n}] ${l.message}`})}return{ok:!1,errors:i}}function MRp(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function qRp(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=SAo(Xpa(t)),a={parse:(u,l)=>ARp({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:d=>n.parse(d,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),json:(u,l)=>ARp({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:d=>n.json(d,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),getType:()=>JP.UNION};return{...O5(a),...VA(a),...M5t(a)}}function ARp({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:l=[]}){if(!sdi(e))return{ok:!1,errors:[{path:l,message:DM(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:l,message:`Missing discriminant ("${t}")`}]};let o=i(d);if(!o.ok)return{ok:!1,errors:o.errors};let c=n(o.value);if(c==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...l,t],message:"Unexpected discriminant value"}]};let b=u(s,c);return b.ok?{ok:!0,value:{[r]:d,...b.value}}:b}var BO=At.objectWithoutOptionalProperties({title:At.string().optional()});var MAo=At.objectWithoutOptionalProperties({file:At.string()});var AAo=At.objectWithoutOptionalProperties({file:At.string()});var qAo=At.union("type",{openapi:MAo,protobuf:AAo}).transform({transform:e=>{switch(e.type){case"openapi":return wie.openapi(e);case"protobuf":return wie.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var ly=At.objectWithoutOptionalProperties({source:qAo.optional()});var TAo=At.objectWithoutOptionalProperties({typeName:At.string()});var CAo=At.union("type",{protobuf:TAo}).transform({transform:e=>{switch(e.type){case"protobuf":return t1n.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Die=At.objectWithoutOptionalProperties({encoding:CAo.optional()});var _f=At.objectWithoutOptionalProperties({description:At.string().optional()});var BAo=At.enum_(["GenerallyAvailable","Beta","Deprecated"]);var dh=At.objectWithoutOptionalProperties({availability:BAo.optional()});var tXt=At.number();var rXt=At.objectWithoutOptionalProperties({statusCode:tXt.optional()});var s0=At.objectWithoutOptionalProperties({nameOverride:At.string().optional(),generatedName:At.string()});var uE=At.objectWithoutOptionalProperties({inline:At.boolean().optional()});var JY=At.string();var KY=At.string();var xAo=At.objectWithoutOptionalProperties({id:KY}).extend(_f);var IAo=At.string();var zAo=At.objectWithoutOptionalProperties({usernameVariableName:At.string().optional(),usernameEnvVar:At.string().optional(),passwordVariableName:At.string().optional(),passwordEnvVar:At.string().optional()});var RAo=At.objectWithoutOptionalProperties({tokenVariableName:At.string().optional(),tokenEnvVar:At.string().optional()});var NAo=At.objectWithoutOptionalProperties({headerName:At.string(),prefix:At.string().optional(),headerVariableName:At.string().optional(),headerEnvVar:At.string().optional()});var FAo=At.objectWithoutOptionalProperties({queryParameterName:At.string()});var LAo=At.objectWithoutOptionalProperties({snake:At.string().optional(),camel:At.string().optional(),screamingSnake:At.string().optional(),pascal:At.string().optional()});var ldi=At.objectWithoutOptionalProperties({nameOverride:At.string().optional(),generatedName:At.string(),value:At.string(),casing:LAo.optional()}).extend(_f).extend(dh);var UAo=At.objectWithoutOptionalProperties({type:At.stringLiteral("namespace"),name:At.string()});var VAo=At.undiscriminatedUnion([At.string(),UAo]);var fdi=At.list(VAo);var xO=At.objectWithoutOptionalProperties({groupName:fdi.optional()});var o1n=At.objectWithoutOptionalProperties({default:ldi.optional(),values:At.list(ldi)}).extend(_f).extend(s0).extend(xO).extend(dh).extend(ly).extend(BO).extend(uE);var WAo=At.objectWithoutOptionalProperties({scopesEnum:o1n.optional()});var HAo=At.union("type",{basic:zAo,bearer:RAo,header:NAo,query:FAo,oauth:WAo}).transform({transform:e=>{switch(e.type){case"basic":return g5.basic(e);case"bearer":return g5.bearer(e);case"header":return g5.header(e);case"query":return g5.query(e);case"oauth":return g5.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var Zpa=At.objectWithoutOptionalProperties({name:At.string().optional(),url:At.string(),audiences:At.list(At.string()).optional()}).extend(_f);var $Ao=At.string();var iXt=At.objectWithoutOptionalProperties({namespace:At.string().optional()});var O5s={};Co(O5s,{FullExample:()=>WA,FullObjectExample:()=>QAo,FullOneOfExample:()=>KAo,KeyValuePair:()=>JAo,LiteralExample:()=>GAo,PrimitiveExample:()=>s1n,PropertyKey:()=>u1n});var u1n=At.string();var s1n=At.union("type",{int:At.object({value:At.number()}),int64:At.object({value:At.number()}),uint:At.object({value:At.number()}),uint64:At.object({value:At.number()}),float:At.object({value:At.number()}),double:At.object({value:At.number()}),string:At.object({value:At.string()}),datetime:At.object({value:At.string()}),date:At.object({value:At.string()}),base64:At.object({value:At.string()}),boolean:At.object({value:At.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return u_.int(e.value);case"int64":return u_.int64(e.value);case"uint":return u_.uint(e.value);case"uint64":return u_.uint64(e.value);case"float":return u_.float(e.value);case"double":return u_.double(e.value);case"string":return u_.string(e.value);case"datetime":return u_.datetime(e.value);case"date":return u_.date(e.value);case"base64":return u_.base64(e.value);case"boolean":return u_.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var GAo=At.union("type",{boolean:At.object({value:At.boolean()}),string:At.object({value:At.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return r1n.boolean(e.value);case"string":return r1n.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var WA=At.union("type",{primitive:At.object({value:s1n}),object:At.lazyObject(()=>QAo),array:At.object({value:At.list(At.lazy(()=>WA))}),map:At.object({value:At.list(At.lazyObject(()=>JAo))}),enum:At.object({value:At.string()}),literal:At.object({value:GAo}),oneOf:At.object({value:At.lazy(()=>KAo)}),unknown:At.object({value:At.lazy(()=>WA)})}).transform({transform:e=>{switch(e.type){case"primitive":return rg.primitive(e.value);case"object":return rg.object(e);case"array":return rg.array(e.value);case"map":return rg.map(e.value);case"enum":return rg.enum(e.value);case"literal":return rg.literal(e.value);case"oneOf":return rg.oneOf(e.value);case"unknown":return rg.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var QAo=At.objectWithoutOptionalProperties({properties:At.record(u1n,At.lazy(()=>WA))});var JAo=At.objectWithoutOptionalProperties({key:s1n,value:At.lazy(()=>WA)});var KAo=At.union("type",{discriminated:At.object({value:At.record(u1n,At.lazy(()=>WA))}),undiscriminated:At.object({value:At.lazy(()=>WA)})}).transform({transform:e=>{switch(e.type){case"discriminated":return odi.discriminated(e.value);case"undiscriminated":return odi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var m5s={};Co(m5s,{AllOfPropertyConflict:()=>w1n,ArraySchema:()=>Rqo,Availability:()=>BAo,BooleanSchema:()=>Tqo,CasingOverrides:()=>LAo,CommonProperty:()=>$qo,CursorPagination:()=>yqo,CustomCodeSample:()=>_qo,CustomCodeSampleLanguage:()=>fqo,CustomCodeSampleSdk:()=>pqo,CustomPagination:()=>bqo,DiscriminatedOneOfSchema:()=>Wqo,DoubleSchema:()=>Aqo,Endpoint:()=>gqo,EndpointExample:()=>g1n,EndpointResponseExample:()=>lqo,EndpointSdkName:()=>nXt,EnumSchema:()=>o1n,EnumValue:()=>ldi,ErrorExample:()=>aqo,FernExample:()=>uqo,FileResponse:()=>_1n,FileSchema:()=>ZAo,FullEndpointExample:()=>hqo,GlobalHeader:()=>Bqo,Header:()=>ddi,HeaderExample:()=>b1n,HttpEndpointServer:()=>y1n,HttpError:()=>oqo,HttpMethod:()=>c1n,IdempotencyHeader:()=>xqo,IntSchema:()=>Eqo,JsonRequest:()=>rqo,JsonResponse:()=>h1n,LiteralSchema:()=>j1n,LiteralSchemaValue:()=>Iqo,LongSchema:()=>Mqo,MapSchema:()=>Nqo,MultipartRequest:()=>p1n,MultipartRequestProperty:()=>tqo,MultipartRequestPropertyEncoding:()=>eqo,MultipartSchema:()=>kAo,NullableSchema:()=>Lqo,ObjectProperty:()=>Vqo,ObjectPropertyConflictInfo:()=>S1n,ObjectSchema:()=>zqo,OctetStreamRequest:()=>d1n,OffsetPagination:()=>vqo,OneOfSchema:()=>Uqo,OpenApiIntermediateRepresentation:()=>TRp,OptionalSchema:()=>Fqo,Pagination:()=>O1n,PathParameter:()=>l1n,PathParameterExample:()=>sqo,PrimitiveSchema:()=>_di,PrimitiveSchemaValue:()=>Cqo,QueryParameter:()=>f1n,QueryParameterExample:()=>v1n,ReferencedSchema:()=>aXt,Request:()=>iqo,Response:()=>nqo,Schema:()=>IO,Schemas:()=>Dqo,SdkGroupInfo:()=>YAo,StreamingResponseExample:()=>cqo,StringSchema:()=>qqo,SupportedSdkLanguage:()=>dqo,Tags:()=>XAo,TextResponse:()=>pdi,UnDiscriminatedOneOfSchema:()=>Hqo,Webhook:()=>Oqo,WebhookExampleCall:()=>P1n,WebhookHttpMethod:()=>m1n,WebsocketChannel:()=>Sqo,WebsocketHandshake:()=>mqo,WebsocketMessageExample:()=>jqo,WebsocketServer:()=>Pqo,WebsocketSessionExample:()=>wqo});var YAo=At.objectWithoutOptionalProperties({summary:At.string().optional(),description:At.string().optional()});var XAo=At.objectWithoutOptionalProperties({tagsById:At.record(KY,xAo),orderedTagIds:At.list(KY).optional()});var c1n=At.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var l1n=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>IO),variableReference:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(_f).extend(dh).extend(ly);var f1n=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>IO),parameterNameOverride:At.string().optional()}).extend(_f).extend(dh).extend(ly);var ddi=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>IO),env:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(_f).extend(dh).extend(ly);var nXt=At.objectWithoutOptionalProperties({groupName:fdi,methodName:At.string()});var d1n=At.objectWithoutOptionalProperties({}).extend(_f).extend(ly);var ZAo=At.objectWithoutOptionalProperties({isOptional:At.boolean(),isArray:At.boolean()}).extend(_f);var kAo=At.union("type",{file:ZAo,json:At.object({value:At.lazy(()=>IO)})}).transform({transform:e=>{switch(e.type){case"file":return vze.file(e);case"json":return vze.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var eqo=At.enum_(["json","form"]);var tqo=At.objectWithoutOptionalProperties({key:At.string(),schema:kAo,contentType:At.string().optional(),exploded:At.boolean().optional(),encoding:eqo.optional()}).extend(_f);var p1n=At.objectWithoutOptionalProperties({name:At.string().optional(),properties:At.list(tqo)}).extend(_f).extend(ly);var rqo=At.objectWithoutOptionalProperties({schema:At.lazy(()=>IO),contentType:At.string().optional(),additionalProperties:At.boolean()}).extend(_f).extend(ly);var iqo=At.union("type",{octetStream:d1n,multipart:p1n,json:rqo}).transform({transform:e=>{switch(e.type){case"octetStream":return udi.octetStream(e);case"multipart":return udi.multipart(e);case"json":return udi.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var _1n=At.objectWithoutOptionalProperties({}).extend(_f).extend(ly).extend(rXt);var h1n=At.objectWithoutOptionalProperties({schema:At.lazy(()=>IO),responseProperty:At.string().optional()}).extend(_f).extend(ly).extend(rXt);var pdi=At.objectWithoutOptionalProperties({}).extend(_f).extend(ly).extend(rXt);var nqo=At.union("type",{file:_1n,json:h1n,text:pdi,streamingSse:h1n,streamingText:pdi,streamingJson:h1n}).transform({transform:e=>{switch(e.type){case"file":return Sie.file(e);case"json":return Sie.json(e);case"text":return Sie.text(e);case"streamingSse":return Sie.streamingSse(e);case"streamingText":return Sie.streamingText(e);case"streamingJson":return Sie.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var aqo=At.objectWithoutOptionalProperties({name:At.string().optional(),description:At.string().optional(),example:At.lazy(()=>WA)});var oqo=At.objectWithoutOptionalProperties({schema:At.lazy(()=>IO).optional(),examples:At.list(aqo).optional()}).extend(_f).extend(s0).extend(ly);var y1n=At.objectWithoutOptionalProperties({name:At.string().optional(),url:At.string().optional(),audiences:At.list(At.string()).optional()});var uqo=At.unknown();var sqo=At.objectWithoutOptionalProperties({name:At.string(),parameterNameOverride:At.string().optional(),value:At.lazy(()=>WA)});var v1n=At.objectWithoutOptionalProperties({name:At.string(),value:At.lazy(()=>WA)});var b1n=At.objectWithoutOptionalProperties({name:At.string(),value:At.lazy(()=>WA)});var cqo=At.objectWithoutOptionalProperties({sse:At.boolean(),events:At.list(At.lazy(()=>WA))});var lqo=At.union("type",{withStreaming:cqo,withoutStreaming:At.object({value:At.lazy(()=>WA)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return yze.withStreaming(e);case"withoutStreaming":return yze.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var fqo=At.objectWithoutOptionalProperties({name:At.string().optional(),language:At.string(),code:At.string(),install:At.string().optional()}).extend(_f);var dqo=At.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var pqo=At.objectWithoutOptionalProperties({name:At.string().optional(),sdk:dqo,code:At.string()}).extend(_f);var _qo=At.union("type",{language:fqo,sdk:pqo}).transform({transform:e=>{switch(e.type){case"language":return kJr.language(e);case"sdk":return kJr.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var hqo=At.objectWithoutOptionalProperties({name:At.string().optional(),pathParameters:At.list(sqo).optional(),queryParameters:At.list(v1n).optional(),headers:At.list(b1n).optional(),request:At.lazy(()=>WA).optional(),response:lqo.optional(),codeSamples:At.list(_qo)}).extend(_f);var g1n=At.union("type",{unknown:At.object({value:uqo}),full:hqo}).transform({transform:e=>{switch(e.type){case"unknown":return E5t.unknown(e.value);case"full":return E5t.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var yqo=At.objectWithoutOptionalProperties({cursor:At.string(),nextCursor:At.property("next_cursor",At.string()),results:At.string()});var vqo=At.objectWithoutOptionalProperties({offset:At.string(),results:At.string(),step:At.string().optional(),hasNextPage:At.string().optional()});var bqo=At.objectWithoutOptionalProperties({results:At.string()});var O1n=At.union("type",{cursor:yqo,offset:vqo,custom:bqo}).transform({transform:e=>{switch(e.type){case"cursor":return hze.cursor(e);case"offset":return hze.offset(e);case"custom":return hze.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var gqo=At.objectWithoutOptionalProperties({authed:At.boolean(),internal:At.boolean().optional(),idempotent:At.boolean().optional(),method:c1n,audiences:At.list(At.string()),path:At.string(),summary:At.string().optional(),operationId:At.string().optional(),tags:At.list(KY),pathParameters:At.list(l1n),queryParameters:At.list(f1n),headers:At.list(ddi),sdkName:nXt.optional(),generatedRequestName:At.string(),requestNameOverride:At.string().optional(),request:iqo.optional(),response:nqo.optional(),errors:At.record(tXt,oqo),servers:At.list(y1n),examples:At.list(g1n),pagination:O1n.optional()}).extend(_f).extend(dh).extend(ly).extend(iXt);var m1n=At.enum_(["GET","POST"]);var P1n=At.objectWithoutOptionalProperties({name:At.string().optional(),payload:At.lazy(()=>WA)}).extend(_f);var Oqo=At.objectWithoutOptionalProperties({sdkName:nXt.optional(),method:m1n,summary:At.string().optional(),operationId:At.string(),tags:At.list(KY),headers:At.list(ddi),generatedPayloadName:At.string(),payload:At.lazy(()=>IO),examples:At.list(P1n)}).extend(_f).extend(ly).extend(iXt);var mqo=At.objectWithoutOptionalProperties({queryParameters:At.list(f1n),headers:At.list(ddi),pathParameters:At.list(l1n)});var Pqo=At.objectWithoutOptionalProperties({name:At.string(),url:At.string()});var jqo=At.objectWithoutOptionalProperties({messageType:At.string(),payload:At.lazy(()=>WA)}).extend(_f);var wqo=At.objectWithoutOptionalProperties({name:At.string().optional(),queryParameters:At.list(v1n).optional(),headers:At.list(b1n).optional(),messages:At.list(jqo)}).extend(_f);var Sqo=At.objectWithoutOptionalProperties({audiences:At.list(At.string()),path:At.string(),groupName:fdi,summary:At.string().optional(),handshake:mqo,publish:At.lazy(()=>IO).optional(),subscribe:At.lazy(()=>IO).optional(),servers:At.list(Pqo),examples:At.list(wqo)}).extend(_f).extend(ly);var Dqo=At.objectWithoutOptionalProperties({rootSchemas:At.record(JY,At.lazy(()=>IO)),namespacedSchemas:At.record($Ao,At.record(JY,At.lazy(()=>IO)))});var Eqo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional()});var Mqo=At.objectWithoutOptionalProperties({default:At.number().optional()});var Aqo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional()});var qqo=At.objectWithoutOptionalProperties({default:At.string().optional(),pattern:At.string().optional(),format:At.string().optional(),minLength:At.number().optional(),maxLength:At.number().optional()});var Tqo=At.objectWithoutOptionalProperties({default:At.boolean().optional()});var Cqo=At.union("type",{int:Eqo,int64:Mqo,uint:At.object({}),uint64:At.object({}),float:At.object({}),double:Aqo,string:qqo,datetime:At.object({}),date:At.object({}),base64:At.object({}),boolean:Tqo}).transform({transform:e=>{switch(e.type){case"int":return vj.int(e);case"int64":return vj.int64(e);case"uint":return vj.uint();case"uint64":return vj.uint64();case"float":return vj.float();case"double":return vj.double(e);case"string":return vj.string(e);case"datetime":return vj.datetime();case"date":return vj.date();case"base64":return vj.base64();case"boolean":return vj.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var _di=At.objectWithoutOptionalProperties({schema:Cqo}).extend(_f).extend(s0).extend(xO).extend(dh).extend(BO);var Bqo=At.objectWithoutOptionalProperties({header:At.string(),name:At.string().optional(),optional:At.boolean().optional(),env:At.string().optional(),schema:At.lazy(()=>IO).optional()});var xqo=At.objectWithoutOptionalProperties({header:At.string(),name:At.string().optional(),env:At.string().optional(),schema:At.lazy(()=>IO).optional()});var TRp=At.objectWithoutOptionalProperties({apiVersion:At.unknown().optional(),title:At.string().optional(),description:At.string().optional(),basePath:At.string().optional(),servers:At.list(Zpa),websocketServers:At.list(Zpa),groups:At.record(At.string(),YAo),tags:XAo,hasEndpointsMarkedInternal:At.boolean(),endpoints:At.list(gqo),webhooks:At.list(Oqo),channels:At.record(At.string(),Sqo),groupedSchemas:Dqo,variables:At.record(At.string(),_di),nonRequestReferencedSchemas:At.set(JY),securitySchemes:At.record(IAo,HAo),globalHeaders:At.list(Bqo).optional(),idempotencyHeaders:At.list(xqo).optional()});var aXt=At.objectWithoutOptionalProperties({schema:JY}).extend(_f).extend(s0).extend(xO).extend(dh).extend(ly).extend(BO);var Iqo=At.union("type",{boolean:At.object({value:At.boolean()}),string:At.object({value:At.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return cx.boolean(e.value);case"string":return cx.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var j1n=At.objectWithoutOptionalProperties({value:Iqo}).extend(_f).extend(s0).extend(xO).extend(dh).extend(BO);var IO=At.union("type",{primitive:_di,object:At.lazyObject(()=>zqo),array:At.lazyObject(()=>Rqo),map:At.lazyObject(()=>Nqo),optional:At.lazyObject(()=>Fqo),enum:o1n,reference:aXt,literal:j1n,oneOf:At.object({value:At.lazy(()=>Uqo)}),nullable:At.lazyObject(()=>Lqo),unknown:s0}).transform({transform:e=>{switch(e.type){case"primitive":return gy.primitive(e);case"object":return gy.object(e);case"array":return gy.array(e);case"map":return gy.map(e);case"optional":return gy.optional(e);case"enum":return gy.enum(e);case"reference":return gy.reference(e);case"literal":return gy.literal(e);case"oneOf":return gy.oneOf(e.value);case"nullable":return gy.nullable(e);case"unknown":return gy.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var w1n=At.objectWithoutOptionalProperties({propertyKey:At.string(),allOfSchemaIds:At.list(JY),conflictingTypeSignatures:At.boolean()});var zqo=At.objectWithoutOptionalProperties({allOf:At.list(aXt),properties:At.list(At.lazyObject(()=>Vqo)),allOfPropertyConflicts:At.list(w1n),additionalProperties:At.boolean()}).extend(_f).extend(s0).extend(xO).extend(dh).extend(ly).extend(BO).extend(uE);var S1n=At.objectWithoutOptionalProperties({differentSchema:At.boolean()});var Vqo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>IO),readonly:At.boolean().optional(),writeonly:At.boolean().optional(),conflict:At.record(JY,S1n),generatedName:At.string(),nameOverride:At.string().optional(),audiences:At.list(At.string())}).extend(dh);var Rqo=At.objectWithoutOptionalProperties({value:At.lazy(()=>IO)}).extend(_f).extend(s0).extend(xO).extend(dh).extend(BO).extend(uE);var Nqo=At.objectWithoutOptionalProperties({key:_di,value:At.lazy(()=>IO)}).extend(_f).extend(s0).extend(xO).extend(dh).extend(Die).extend(BO).extend(uE);var Fqo=At.objectWithoutOptionalProperties({value:At.lazy(()=>IO)}).extend(_f).extend(s0).extend(xO).extend(dh).extend(BO).extend(uE);var Lqo=At.objectWithoutOptionalProperties({value:At.lazy(()=>IO)}).extend(_f).extend(s0).extend(xO).extend(dh).extend(BO).extend(uE);var Uqo=At.union("type",{discriminated:At.lazyObject(()=>Wqo),undiscriminated:At.lazyObject(()=>Hqo)}).transform({transform:e=>{switch(e.type){case"discriminated":return eKr.discriminated(e);case"undiscriminated":return eKr.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Wqo=At.objectWithoutOptionalProperties({discriminantProperty:At.string(),commonProperties:At.list(At.lazyObject(()=>$qo)),schemas:At.record(At.string(),At.lazy(()=>IO))}).extend(_f).extend(s0).extend(xO).extend(dh).extend(Die).extend(ly).extend(BO).extend(uE);var $qo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>IO)});var Hqo=At.objectWithoutOptionalProperties({schemas:At.list(At.lazy(()=>IO))}).extend(_f).extend(s0).extend(xO).extend(dh).extend(Die).extend(ly).extend(BO).extend(uE);var P5s={};Co(P5s,{ArraySchemaWithExample:()=>fTo,Base64WithExample:()=>oTo,BooleanWithExample:()=>uTo,CommonPropertyWithExample:()=>OTo,DateWithExample:()=>aTo,DatetimeWithExample:()=>nTo,DiscriminatedOneOfSchemaWithExample:()=>bTo,DoubleWithExample:()=>rTo,EndpointWithExample:()=>BRp,EnumSchemaWithExample:()=>cTo,FloatWithExample:()=>tTo,HeaderWithExample:()=>hdi,HttpErrorWithExample:()=>Yqo,Int64WithExample:()=>Zqo,IntWithExample:()=>Xqo,JsonRequestWithExample:()=>Qqo,JsonResponseWithExample:()=>E1n,MapSchemaWithExample:()=>dTo,NamedFullExample:()=>oXt,NullableSchemaWithExample:()=>_To,ObjectPropertyWithExample:()=>vTo,ObjectSchemaWithExample:()=>hTo,OneOfSchemaWithExample:()=>yTo,OptionalSchemaWithExample:()=>pTo,PathParameterWithExample:()=>Gqo,PrimitiveSchemaValueWithExample:()=>sTo,PrimitiveSchemaWithExample:()=>M1n,QueryParameterWithExample:()=>D1n,RequestWithExample:()=>Jqo,ResponseWithExample:()=>Kqo,SchemaWithExample:()=>EM,StringSchemaWithExample:()=>iTo,Uint64WithExample:()=>eTo,UintWithExample:()=>kqo,UnDiscriminatedOneOfSchemaWithExample:()=>gTo,UnknownSchemaWithExample:()=>lTo,WebhookWithExample:()=>xRp,WebsocketHandshakeWithExample:()=>CRp});var oXt=At.objectWithoutOptionalProperties({name:At.string().optional(),value:At.unknown()}).extend(_f);var D1n=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>EM),parameterNameOverride:At.string().optional()}).extend(_f).extend(dh).extend(ly);var hdi=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>EM),env:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(_f).extend(dh).extend(ly);var CRp=At.objectWithoutOptionalProperties({queryParameters:At.list(D1n),headers:At.list(hdi)});var Gqo=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>EM),variableReference:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(_f).extend(dh).extend(ly);var Qqo=At.objectWithoutOptionalProperties({schema:At.lazy(()=>EM),contentType:At.string().optional(),fullExamples:At.list(oXt).optional(),additionalProperties:At.boolean()}).extend(_f).extend(ly);var Jqo=At.union("type",{octetStream:d1n,multipart:p1n,json:Qqo}).transform({transform:e=>{switch(e.type){case"octetStream":return VSe.octetStream(e);case"multipart":return VSe.multipart(e);case"json":return VSe.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var E1n=At.objectWithoutOptionalProperties({schema:At.lazy(()=>EM),responseProperty:At.string().optional(),fullExamples:At.list(oXt).optional()}).extend(_f).extend(ly).extend(rXt);var Kqo=At.union("type",{file:_1n,json:E1n,text:pdi,streamingSse:E1n,streamingText:pdi,streamingJson:E1n}).transform({transform:e=>{switch(e.type){case"file":return lx.file(e);case"json":return lx.json(e);case"text":return lx.text(e);case"streamingSse":return lx.streamingSse(e);case"streamingText":return lx.streamingText(e);case"streamingJson":return lx.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Yqo=At.objectWithoutOptionalProperties({statusCode:tXt,schema:At.lazy(()=>EM),fullExamples:At.list(oXt).optional()}).extend(_f).extend(s0).extend(ly);var BRp=At.objectWithoutOptionalProperties({authed:At.boolean(),internal:At.boolean().optional(),idempotent:At.boolean().optional(),method:c1n,audiences:At.list(At.string()),path:At.string(),summary:At.string().optional(),operationId:At.string().optional(),tags:At.list(KY),pathParameters:At.list(Gqo),queryParameters:At.list(D1n),headers:At.list(hdi),sdkName:nXt.optional(),generatedRequestName:At.string(),requestNameOverride:At.string().optional(),request:Jqo.optional(),response:Kqo.optional(),errors:At.record(tXt,Yqo),servers:At.list(y1n),examples:At.list(g1n),pagination:O1n.optional()}).extend(_f).extend(dh).extend(ly).extend(iXt);var xRp=At.objectWithoutOptionalProperties({sdkName:nXt.optional(),method:m1n,summary:At.string().optional(),operationId:At.string(),tags:At.list(KY),headers:At.list(hdi),generatedPayloadName:At.string(),payload:At.lazy(()=>EM),examples:At.list(P1n)}).extend(_f).extend(ly).extend(iXt);var Xqo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional(),example:At.number().optional()});var Zqo=At.objectWithoutOptionalProperties({default:At.number().optional(),example:At.number().optional()});var kqo=At.objectWithoutOptionalProperties({default:At.number().optional(),example:At.number().optional()});var eTo=At.objectWithoutOptionalProperties({default:At.number().optional(),example:At.number().optional()});var tTo=At.objectWithoutOptionalProperties({example:At.number().optional()});var rTo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional(),example:At.number().optional()});var iTo=At.objectWithoutOptionalProperties({default:At.string().optional(),pattern:At.string().optional(),format:At.string().optional(),minLength:At.number().optional(),maxLength:At.number().optional(),example:At.string().optional()});var nTo=At.objectWithoutOptionalProperties({example:At.string().optional()});var aTo=At.objectWithoutOptionalProperties({example:At.string().optional()});var oTo=At.objectWithoutOptionalProperties({example:At.string().optional()});var uTo=At.objectWithoutOptionalProperties({default:At.boolean().optional(),example:At.boolean().optional()});var sTo=At.union("type",{int:Xqo,int64:Zqo,uint:kqo,uint64:eTo,float:tTo,double:rTo,string:iTo,datetime:nTo,date:aTo,base64:oTo,boolean:uTo}).transform({transform:e=>{switch(e.type){case"int":return Xd.int(e);case"int64":return Xd.int64(e);case"uint":return Xd.uint(e);case"uint64":return Xd.uint64(e);case"float":return Xd.float(e);case"double":return Xd.double(e);case"string":return Xd.string(e);case"datetime":return Xd.datetime(e);case"date":return Xd.date(e);case"base64":return Xd.base64(e);case"boolean":return Xd.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var M1n=At.objectWithoutOptionalProperties({schema:sTo}).extend(_f).extend(s0).extend(xO).extend(dh).extend(BO);var cTo=At.objectWithoutOptionalProperties({default:ldi.optional(),values:At.list(ldi),example:At.string().optional()}).extend(_f).extend(s0).extend(xO).extend(dh).extend(ly).extend(BO).extend(uE);var lTo=At.objectWithoutOptionalProperties({example:At.unknown()}).extend(xO).extend(s0).extend(_f).extend(dh).extend(BO);var EM=At.union("type",{primitive:M1n,object:At.lazyObject(()=>hTo),array:At.lazyObject(()=>fTo),map:At.lazyObject(()=>dTo),optional:At.lazyObject(()=>pTo),enum:cTo,reference:aXt,literal:j1n,oneOf:At.object({value:At.lazy(()=>yTo)}),nullable:At.lazyObject(()=>_To),unknown:lTo}).transform({transform:e=>{switch(e.type){case"primitive":return El.primitive(e);case"object":return El.object(e);case"array":return El.array(e);case"map":return El.map(e);case"optional":return El.optional(e);case"enum":return El.enum(e);case"reference":return El.reference(e);case"literal":return El.literal(e);case"oneOf":return El.oneOf(e.value);case"nullable":return El.nullable(e);case"unknown":return El.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var fTo=At.objectWithoutOptionalProperties({value:At.lazy(()=>EM),example:At.list(At.unknown()).optional()}).extend(xO).extend(s0).extend(_f).extend(dh).extend(BO).extend(uE);var dTo=At.objectWithoutOptionalProperties({key:M1n,value:At.lazy(()=>EM),example:At.unknown().optional()}).extend(xO).extend(s0).extend(_f).extend(dh).extend(Die).extend(BO).extend(uE);var pTo=At.objectWithoutOptionalProperties({value:At.lazy(()=>EM)}).extend(xO).extend(s0).extend(_f).extend(dh).extend(BO).extend(uE);var _To=At.objectWithoutOptionalProperties({value:At.lazy(()=>EM)}).extend(xO).extend(s0).extend(_f).extend(dh).extend(BO).extend(uE);var hTo=At.objectWithoutOptionalProperties({allOf:At.list(aXt),properties:At.list(At.lazyObject(()=>vTo)),allOfPropertyConflicts:At.list(w1n),fullExamples:At.list(oXt).optional(),additionalProperties:At.boolean()}).extend(_f).extend(s0).extend(xO).extend(dh).extend(ly).extend(BO).extend(uE);var vTo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>EM),readonly:At.boolean().optional(),writeonly:At.boolean().optional(),audiences:At.list(At.string()),conflict:At.record(JY,S1n),nameOverride:At.string().optional(),generatedName:At.string()}).extend(dh);var yTo=At.union("type",{discriminated:At.lazyObject(()=>bTo),undiscriminated:At.lazyObject(()=>gTo)}).transform({transform:e=>{switch(e.type){case"discriminated":return QY.discriminated(e);case"undiscriminated":return QY.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var bTo=At.objectWithoutOptionalProperties({discriminantProperty:At.string(),commonProperties:At.list(At.lazyObject(()=>OTo)),schemas:At.record(At.string(),At.lazy(()=>EM))}).extend(_f).extend(s0).extend(xO).extend(dh).extend(Die).extend(ly).extend(BO).extend(uE);var OTo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>EM)});var gTo=At.objectWithoutOptionalProperties({schemas:At.list(At.lazy(()=>EM))}).extend(_f).extend(s0).extend(xO).extend(dh).extend(Die).extend(ly).extend(BO).extend(uE);var IRp=/^(\d+)/,A1n=/^[a-zA-Z][a-zA-Z0-9_]*$/,zRp={"<":"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 ydi(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","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),l=e%10;return l===0?i[u]:`${i[u]}_${t[l]}`}if(e<1e3){let u=Math.floor(e/100),l=e%100;return l===0?`${t[u]}_hundred`:`${t[u]}_hundred_${ydi(l)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${ydi(a)}`}function kpa(e){let t=e.match(IRp);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=ydi(n);return i.length>0?`${a}_${i}`:a}}}function q1n(e){let t=kpa(e),r=zRp[e];return t!=null?G3(Dg(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":G3(Dg(e)))}function Eie(e,t){return e.type==="primitive"&&t.type==="primitive"?RRp(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?JPD(e.values,t.values):e.type==="array"&&t.type==="array"?Eie(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"?Eie(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?KPD(e.value,t.value):e.type==="object"&&t.type==="object"?YPD(e,t):e.type==="map"&&t.type==="map"?RRp(e.key.schema,t.key.schema)&&Eie(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function RRp(e,t){return e.type===t.type}function JPD(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return F1e(r,i)}function KPD(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,i])=>{let n=t.schemas[r];return n==null?!1:Eie(i,n)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,i)=>{let n=t.schemas[i];return n==null?!1:Eie(r,n)}):!1}function YPD(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(i=>[i.key,i.schema]));return Object.entries(t.properties).every(([i,n])=>{let a=r[i];return a==null?!1:Eie(a,n.schema)})}var j2;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(j2||(j2={}));var mTo=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;respectNullableSchemas;onlyIncludeReferencedSchemas;inlinePathParameters;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:u}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=u,this.globalHeaderOverrides=a,this.detectGlobalHeaders=i?.detectGlobalHeaders??!0,this.objectQueryParameters=i?.objectQueryParameters??!1,this.respectReadonlySchemas=i?.respectReadonlySchemas??!1,this.respectNullableSchemas=i?.respectNullableSchemas??!1,this.onlyIncludeReferencedSchemas=i?.onlyIncludeReferencedSchemas??!1,this.inlinePathParameters=i?.inlinePathParameters??!1,this.referencedSchemaIds=i?.onlyIncludeReferencedSchemas?new Set:void 0,this.enableUniqueErrorsPerEndpoint=i?.enableUniqueErrorsPerEndpoint??!1,this.builder=new hRi(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let l={};if(!this.enableUniqueErrorsPerEndpoint)for(let d of r.endpoints)for(let[s,o]of Object.entries(d.errors)){let c=parseInt(s),b=l[c];b==null&&o.schema!=null?l[c]=o.schema:b!=null&&o.schema!=null&&Eie(b,o.schema)||this.unknownSchema.add(c)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}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}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.onlyIncludeReferencedSchemas&&this.isInAnyState(j2.Channel,j2.Endpoint,j2.Webhook)}markSchemaAsReferenced(t,r){switch(t.type){case"primitive":return;case"object":this.markObjectSchemaAsReferenced(t,r);return;case"array":this.markSchemaAsReferenced(t.value,r);return;case"map":this.markSchemaAsReferenced(t.value,r);return;case"optional":this.markSchemaAsReferenced(t.value,r);return;case"reference":this.markSchemaIdAsReferenced(t.schema,r);return;case"oneOf":this.markOneofSchemaAsReferenced(t.value,r);return;case"nullable":this.markSchemaAsReferenced(t.value,r);return;case"enum":return;case"literal":return;case"unknown":return;default:Fo(t)}}markObjectSchemaAsReferenced(t,r){for(let i of t.allOf)this.markSchemaIdAsReferenced(i.schema,r);for(let i of t.properties)this.markSchemaAsReferenced(i.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let i of Object.values(t.schemas))this.markSchemaAsReferenced(i,r);return;case"undiscriminated":for(let i of t.schemas)this.markSchemaAsReferenced(i,r);return;default:Fo(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let i=this.getSchema(t,r);i!=null&&this.markSchemaAsReferenced(i,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function fI(e){switch(e){case pV.Deprecated:return"deprecated";case pV.Beta:return"pre-release";case pV.GenerallyAvailable:return"generally-available";default:return}}function XPD(e){let t=e.find(i=>typeof i=="object"&&i.type==="namespace"),r=e.filter(i=>typeof i=="string"||i.type!=="namespace");return t?[t,...r]:r}function NRp(e){let t=e?XPD(e):void 0;if(t==null||t.length===0)return JTi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(Dg(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(Dg(n.name)):r.push(n.name,JTi);break}default:Fo(n.type)}else Fo(n);return r.join("/")}function T1n(e){return sy.of(`${NRp(e)}.yml`)}function j5s({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?JTi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,NRp(r))}function FRp({sdkName:e,namespaceOverride:t}){return sy.of(`${j5s({sdkName:e,namespaceOverride:t})}.yml`)}function LRp({location:e,namespaceOverride:t}){return t!=null?PR(sy.of(t),e):e}function PTo(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:Fo(e.type)}}function C1n(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:Fo(e)}}function MM(e){return typeof e=="string"?e:e.type}function B1n(e){if(typeof e!="string")return e.docs}function e_a(e){if(typeof e!="string")return e.default}function w5s(e){if(typeof e!="string")return e.validation}var ZPD=-2147483648,kPD=2147483647,ejD=-17976931348623157e292,tjD=17976931348623157e292;function H0({schema:e,fileContainingReference:t,declarationFile:r=t,context:i,namespace:n,declarationDepth:a}){switch(i.shouldMarkSchemaAsReferenced()&&i.markSchemaAsReferenced(e,n),e.type){case"primitive":return jTo(e);case"array":return E5s({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return M5s({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return D5s({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return q5s();case"optional":return wTo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return A5s({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return ljD({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,T5s(e);case"object":return fjD({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return djD({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:Fo(e)}}function jTo(e){switch(e.schema.type){case"string":return njD({description:e.description,schema:e.schema});case"int":return ajD({description:e.description,schema:e.schema});case"float":return ojD({description:e.description,schema:e.schema});case"double":return ujD({description:e.description,schema:e.schema});case"boolean":return rjD({description:e.description,schema:e.schema});case"int64":return ijD({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:fI(e.availability)}:{}}}function rjD({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function ijD({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function njD({description:e,schema:t}){let r="string",i=sjD(t);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function ajD({description:e,schema:t}){let r="integer",i=VRp(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function ojD({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function ujD({description:e,schema:t}){let r="double",i=VRp(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function sjD(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=cjD(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function cjD(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 VRp(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=S5s(r,t),i=S5s(i,t),n=S5s(n,t),!(r==null&&i==null&&a==null&&u==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:u,multipleOf:n}}function S5s(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[ZPD,kPD]:[ejD,tjD];return e<r||e>i?void 0:e}function D5s({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=pjD(n)??e.schema,u=C1n(n),l=_jD(n),d=STo({context:r,fileContainingReference:t,declarationFile:T1n(u),type:a}),s=n.type==="nullable"?`optional<${d}>`:d;return e.description==null&&l==null?s:{type:n.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:fI(e.availability)}:{}}}function E5s({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=H0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=`list<${MM(u)}>`;return e.description==null&&e.title==null?l:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:fI(e.availability)}:{},type:l}}function M5s({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=jTo(e.key),l=H0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),d=e.encoding!=null?PTo(e.encoding):void 0,s=`map<${MM(u)}, ${MM(l)}>`;if(e.description==null&&d==null&&e.title==null)return s;let o={type:s};return e.description!=null&&(o.docs=e.description),e.encoding!=null&&(o.encoding=d),e.availability!=null&&(o.availability=fI(e.availability)),o}function A5s({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.respectNullableSchemas)return wTo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let u=H0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=MM(u),d=B1n(u),s=e_a(u),o=w5s(u),c=l.startsWith("nullable<")?l:`nullable<${l}>`;if(e.availability==null&&e.description==null&&d==null&&s==null&&o==null&&e.title==null)return URp({typeReference:c,itemType:l});let b={type:c};return(e.description!=null||d!=null)&&(b.docs=e.description??d),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=fI(e.availability)),URp({typeReference:b,itemType:l})}function wTo({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=H0({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=MM(u),d=B1n(u),s=e_a(u),o=w5s(u),c=l.startsWith("optional<")?l:`optional<${l}>`;if(e.availability==null&&e.description==null&&d==null&&s==null&&o==null&&e.title==null)return c;let b={type:c};return(e.description!=null||d!=null)&&(b.docs=e.description??d),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=fI(e.availability)),b}function q5s(){return"unknown"}function T5s(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:Fo(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:fI(e.availability)}:{}}}function ljD({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=t_a(e,n),u=e.nameOverride??e.generatedName;i.builder.addType(r,{name:u,schema:a.schema});let l=STo({type:u,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return l;let d={type:l};return e.description!=null&&(d.docs=e.description),e.default!=null&&(d.default=e.default.value),e.availability!=null&&(d.availability=fI(e.availability)),d}function fjD({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=C5s({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=e.nameOverride??e.generatedName;i.builder.addType(r,{name:l,schema:u.schema});let d=STo({type:l,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:fI(e.availability)}:{}}}function djD({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=B5s({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=e.nameOverride??e.generatedName;i.builder.addType(r,{name:l,schema:u.schema});let d=STo({type:l,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{...e.title!=null?{"display-name":e.title}:{},type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:fI(e.availability)}:{}}}function STo({type:e,fileContainingReference:t,declarationFile:r,context:i}){if(r===t)return e;let n=i.builder.addImport({file:t,fileToImport:r});return n!=null?`${n}.${e}`:e}function pjD(e){return gy._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 _jD(e){return gy._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 URp({typeReference:e,itemType:t}){return t.startsWith("optional<")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}function tKr(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Fo(e)}}function HRp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=vjD(e);break;case"array":a=hjD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=yjD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=bjD({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=OjD(e.nameOverride,e.generatedName);break;case"optional":a=$Rp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=gjD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=t_a(e,n);break;case"literal":a=mjD(e,e.nameOverride,e.generatedName);break;case"object":a=C5s({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=B5s({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:Fo(e)}return a}function C5s({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(j2.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),u=!1,l={},d=new Set;for(let g of e.properties){if(g.readonly&&(u=!0),a&&g.readonly)continue;if(Object.keys(g.conflict).length>0){if(Object.entries(g.conflict).every(([D,C])=>!C.differentSchema))continue;Object.entries(g.conflict).forEach(([D])=>{x5s({property:g.key,schemaId:D,context:t,namespace:i}).forEach(R=>{d.add(R)})})}let O=H0({schema:g.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),m=g.audiences,w=g.nameOverride,E=fI(g.availability),A=SjD(g);l[g.key]=wjD({typeReference:O,audiences:m,name:w,availability:E,propertyAccess:A})}let s=new Set;for(let g of e.allOfPropertyConflicts)g.allOfSchemaIds.forEach(O=>d.add(O)),g.conflictingTypeSignatures&&s.add(g.propertyKey);let o=[];for(let g of e.allOf){let O=GRp({schema:g.schema,context:t,namespace:i});if(O==null||d.has(g.schema)||d.has(O))continue;let m=H0({schema:gy.reference(g),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(MM(m))}for(let g of d){let O=I5s(t,g,i);for(let m of O.properties)l[m.key]==null&&(s.has(m.key)&&(l[m.key]="unknown"),l[m.key]=H0({schema:m.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let m of O.allOf){if(d.has(m.schema))continue;let w=H0({schema:gy.reference(m),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(MM(w))}}let c={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(l).map(([g,O])=>jjD(g)?[g,typeof O=="string"?{type:O,name:`_${g}`}:{...O,name:`_${g}`}]:[g,O]))};o.length>0&&(c.extends=o),e.additionalProperties&&(c["extra-properties"]=!0),e.availability!=null&&(c.availability=fI(e.availability)),e.source!=null&&(c.source=tKr(e.source)),c.inline=z5s(e,n);let b=e.nameOverride??e.generatedName;return{name:u&&t.respectReadonlySchemas&&!a?`${b}Read`:b,schema:c}}function x5s({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return x5s({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:u}=I5s(r,t,i),l=a.some(s=>s.key===e),d=[...u.flatMap(s=>x5s({property:e,context:r,schemaId:s.schema,namespace:i}))];if(l||d.length>0)return[t,...d]}return[]}function I5s(e,t,r){let i=e.getSchema(t,r);if(i==null)return{properties:[],allOf:[]};if(i.type==="object")return{properties:i.properties,allOf:i.allOf};if(i.type==="reference")return I5s(e,i.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${i.type}`)}function hjD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:E5s({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function yjD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:M5s({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function vjD(e){let t=jTo(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...i}=t;return{name:e.nameOverride??e.generatedName,schema:{...i}}}function WRp(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function t_a(e,t){let r={enum:e.values.map(a=>{let u=a.nameOverride??a.generatedName,l=a.value;if(u===l&&a.description==null&&(a.casing==null||WRp(a.casing)))return u;let d={value:a.value};if(u!==l&&(d.name=u),a.description!=null&&(d.docs=a.description),a.casing!=null&&!WRp(a.casing)){let s={},o=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,o=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,o=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,o=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,o=!0),o&&(d.casing=s)}return d})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=z5s(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?tKr(e.source):void 0};for(let a of r.enum){let u=typeof a=="string"?a:a.name??a.value;i.has(u.toLowerCase())||(n.enum.push(a),i.add(u.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function bjD({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:D5s({schema:e,context:t,fileContainingReference:r,namespace:i})}}function gjD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:A5s({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:$Rp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function $Rp({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:wTo({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function OjD(e,t){return{name:e??t,schema:q5s()}}function mjD(e,t,r){return{name:t??r,schema:T5s(e)}}function B5s({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?PTo(e.encoding):void 0;if(e.type==="discriminated"){let l={};for(let s of e.commonProperties)l[s.key]=H0({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let d={};for(let[s,o]of Object.entries(e.schemas))d[s]=H0({schema:o,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":l,docs:e.description??void 0,availability:e.availability!=null?fI(e.availability):void 0,union:d,encoding:a,source:e.source!=null?tKr(e.source):void 0}}}let u=[];for(let l of e.schemas)u.push(H0({schema:l,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:u,encoding:a,source:e.source!=null?tKr(e.source):void 0,inline:z5s(e,n)}}}var PjD=/^[0-9]/;function jjD(e){return PjD.test(e)}function GRp({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?GRp({context:t,schema:i.schema,namespace:r}):e}function wjD({typeReference:e,audiences:t,name:r,availability:i,propertyAccess:n}){return t.length===0&&r==null&&i==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{},...n!=null?{access:n}:{}}}function z5s(e,t){return e.inline===!0||t>0?!0:void 0}function SjD(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return l2.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return l2.ObjectPropertyAccess.WriteOnly}}function QRp(e){let t=e.replace(/^x-|^X-/,"");return Dg(t)}var JRp="BasicAuthScheme",DTo="BearerAuthScheme";function KRp(e){if(e.authOverrides!=null){for(let[r,i]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:i});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,i]of Object.entries(e.ir.securitySchemes))if(i.type==="basic"){let n={scheme:"basic"};i.usernameVariableName!=null&&(n.username===void 0?n.username={name:i.usernameVariableName}:n.username.name=i.usernameVariableName),i.usernameEnvVar!=null&&(n.username===void 0?n.username={env:i.usernameEnvVar}:n.username.env=i.usernameEnvVar),i.passwordVariableName!=null&&(n.password===void 0?n.password={name:i.passwordVariableName}:n.password.name=i.passwordVariableName),i.passwordEnvVar!=null&&(n.password===void 0?n.password={env:i.passwordEnvVar}:n.password.env=i.passwordEnvVar),e.builder.addAuthScheme({name:JRp,schema:n}),t||(e.builder.setAuth(JRp),t=!0)}else if(i.type==="bearer"){let n={scheme:"bearer"};i.tokenVariableName!=null&&(n.token===void 0?n.token={name:i.tokenVariableName}:n.token.name=i.tokenVariableName),i.tokenEnvVar!=null&&(n.token===void 0?n.token={env:i.tokenEnvVar}:n.token.env=i.tokenEnvVar),e.builder.addAuthScheme({name:DTo,schema:n}),t||(e.builder.setAuth(DTo),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??QRp(i.headerName),env:i.headerEnvVar}});else{let n={header:i.headerName,name:i.headerVariableName??"apiKey",type:"string"};i.headerEnvVar!=null&&(n.env=i.headerEnvVar),i.prefix!=null&&(n.prefix=i.prefix),e.builder.addAuthScheme({name:r,schema:n}),e.builder.setAuth(r),t=!0}else if(i.type==="oauth"){let n={scheme:"bearer"};e.builder.addAuthScheme({name:DTo,schema:n}),t||(e.builder.setAuth(DTo),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(sy.of("__package__.yml"),{name:"OauthScope",schema:t_a(i.scopesEnum,0).schema})}}function uXt({header:e,context:t,fileContainingReference:r,namespace:i}){let n=H0({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=MM(n),u=e.name.replace(/^x-|^X-/,""),l=e.parameterNameOverride!=null?e.parameterNameOverride:Dg(u);if(e.description==null&&e.name===l&&e.env==null&&e.availability==null)return a;let d={type:a};return l!==e.name&&(d.name=l),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=fI(e.availability)),d}function ETo({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=H0({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return MM(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:MM(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=fI(e.availability)),a}function ATo({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=R5s({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=MM(n.value),u=e_a(n.value);if(a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>"),e.description==null&&!n.allowMultiple&&u==null&&e.parameterNameOverride==null&&e.availability==null)return a;let l={type:a};return u!=null&&(l.default=u),n.allowMultiple&&(l["allow-multiple"]=!0),e.description!=null&&(l.docs=e.description),e.parameterNameOverride!=null&&(l.name=e.parameterNameOverride),e.availability!=null&&(l.availability=fI(e.availability)),DjD(n.value)&&n.value.validation!==void 0&&(l.validation=n.value.validation),l}function R5s({schema:e,context:t,fileContainingReference:r,namespace:i}){if(e.type==="reference"){let n=t.getSchema(e.schema,i);if(n==null)return;if(n.type==="array")return{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,groupName:void 0,inline:void 0}),context:t,declarationFile:sy.of(X1),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[];for(let[u,l]of Object.entries(n.value.schemas))l.type==="literal"&&l.value.type==="string"&&(A1n.test(l.value.value)?a.push(l.value.value):a.push({value:l.value.value,name:q1n(l.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[u,l]=n.value.schemas;if(u!=null&&l!=null&&MTo({array:u,primitive:l}))return{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:l,description:e.description,availability:e.availability,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(u!=null&&l!=null&&MTo({array:u,primitive:l}))return{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[u,l]of Object.entries(n.value.schemas))return R5s({schema:l,context:t,fileContainingReference:r,namespace:i})}else if(t.objectQueryParameters)return{value:H0({schema:e,context:t,fileContainingReference:r,declarationFile:sy.of(X1),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let n=t.getSchema(e.value.schema,i);if(n==null)return;if(n.type==="array")return{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:sy.of(X1),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.objectQueryParameters)return{value:H0({schema:e,context:t,fileContainingReference:r,declarationFile:sy.of(X1),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let n=[];for(let[a,u]of Object.entries(e.value.value.schemas))u.type==="literal"&&u.value.type==="string"&&(A1n.test(u.value.value)?n.push(u.value.value):n.push({value:u.value.value,name:q1n(u.value.value)}));if(n.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:n}}),{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&&MTo({array:a,primitive:u}))return{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(a!=null&&u!=null&&MTo({array:u,primitive:a}))return{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[a,u]of Object.entries(e.value.value.schemas))return R5s({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:void 0,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.objectQueryParameters?{value:H0({schema:e,context:t,fileContainingReference:r,declarationFile:sy.of(X1),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:H0({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:H0({schema:gy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:H0({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function MTo({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function DjD(e){return e.type!=null}function YRp({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"]=EjD(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=MjD({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=vdi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function EjD(e){let t={};return e.forEach(r=>{let i=vdi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function MjD({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=vdi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function vdi(e){switch(e.type){case"primitive":return XRp(e.value);case"object":return ZRp(e.properties);case"array":return AjD(e.value);case"map":return qjD(e.value);case"oneOf":return TjD(e.value);case"enum":return e.value;case"literal":return CjD(e.value);case"unknown":return vdi(e.value);default:Fo(e)}}function XRp(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:Fo(e)}}function ZRp(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,vdi(r)]))}function AjD(e){return e.map(t=>vdi(t))}function qjD(e){return Object.fromEntries(e.map(t=>[XRp(t.key),vdi(t.value)]))}function TjD(e){return e.type==="discriminated"?ZRp(e.value):vdi(e.value)}function CjD(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Fo(e)}}function rKr(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function qTo(e,t){return t??(e?.groupName!=null?rKr(e.groupName):void 0)}function kRp({channel:e,context:t,declarationFile:r}){let i={path:e.path,url:e.servers[0]?.name,auth:!1};e.audiences!=null&&e.audiences.length>0&&(i.audiences=e.audiences),e.summary!=null&&(i["display-name"]=e.summary),e.description!=null&&(i.docs=e.description);let n=rKr(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=ETo({pathParameter:d,context:t,fileContainingReference:r,namespace:n});Object.keys(a).length>0&&(i["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let s=ATo({queryParameter:d,context:t,fileContainingReference:r,namespace:n});s!=null&&(u[d.name]=s)}Object.keys(u).length>0&&(i["query-parameters"]=u);let l={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let s=uXt({header:d,context:t,fileContainingReference:r,namespace:n});l[d.name]=s}Object.keys(l).length>0&&(i.headers=l),t.builder.addChannel(r,{channel:i}),e.subscribe!=null&&t.builder.addChannelMessage(r,{messageId:"subscribe",message:{origin:"server",body:H0({schema:e.subscribe,context:t,fileContainingReference:r,namespace:n,declarationDepth:0})}}),e.publish!=null&&t.builder.addChannelMessage(r,{messageId:"publish",message:{origin:"client",body:H0({schema:e.publish,context:t,fileContainingReference:r,namespace:n,declarationDepth:0})}});for(let d of e.examples){let s=YRp({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:s})}}var iKr="Base",BjD="Default";function bdi(e){return Object.entries(e).reduce((t,[r,i])=>(Dbn(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function eNp(e){if(e.environmentOverrides!=null){for(let[g,O]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:g,schema:O});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 g of e.ir.servers){let O=g.audiences?{url:g.url,audiences:g.audiences}:g.url;if(g.name==null){r.push(O);continue}t[g.name]=O}let i={},n=[];for(let g of e.ir.endpoints)for(let O of g.servers){if(O.url==null)continue;let m=O.audiences?{url:O.url,audiences:O.audiences}:O.url;if(O.name==null){n.push(m);continue}i[O.name]=m}let a={},u=[];for(let g of e.ir.websocketServers){let O=g.audiences?{url:g.url,audiences:g.audiences}:g.url;if(g.name==null){u.push(O);continue}a[g.name]=O}let l=Object.keys(t).length,d=l>0,s=Object.keys(i).length>0,o=Object.keys(a).length>0;if(!d&&!s&&o&&e.ir.servers.length===0){for(let[g,O]of Object.entries(a))e.builder.addEnvironment({name:g,schema:O});e.builder.setDefaultEnvironment(Object.keys(a)[0]),e.builder.setDefaultUrl(iKr);return}if(n.length>0&&e.logger.error(`Skipping endpoint level servers ${n.map(g=>typeof g=="string"?g:g.url).join(", ")} because x-fern-server-name was not provided.`),!d){let g=e.ir.servers[0]?.url,O=e.ir.servers[0]?.audiences;if(g!=null){let m=O?{url:g,audiences:O}:g;t[BjD]=m}}let c=Object.values(t).map(g=>typeof g=="string"?g:g.url),b=r.filter(g=>{let O=typeof g=="string"?g:g.url;return!c.includes(O)});if(b.length>0&&e.logger.error(`Skipping top level servers ${b.map(g=>typeof g=="string"?g:g.url).join(", ")} because x-fern-server-name was not provided.`),s)if(l===1){let g=Object.keys(t)[0],O=Object.values(t)[0],m=typeof O=="string"?O:O.url;e.builder.addEnvironment({name:g,schema:{urls:{[iKr]:m,...bdi(i),...bdi(a)}}}),e.builder.setDefaultEnvironment(g),e.builder.setDefaultUrl(iKr)}else{let g=!0;for(let[O,m]of Object.entries(t))g?(e.builder.addEnvironment({name:O,schema:{urls:{[iKr]:typeof m=="string"?m:m.url,...bdi(i),...bdi(a)}}}),e.builder.setDefaultEnvironment(O),g=!1):e.builder.addEnvironment({name:O,schema:{urls:{[iKr]:typeof m=="string"?m:m.url,...bdi(i),...bdi(a)}}});e.builder.setDefaultUrl(iKr)}else{let g=!0;for(let[O,m]of Object.entries(t))g?(o?e.builder.addEnvironment({name:O,schema:{urls:{[iKr]:typeof m=="string"?m:m.url,...bdi(a)}}}):e.builder.addEnvironment({name:O,schema:m}),e.builder.setDefaultEnvironment(O),g=!1):o?e.builder.addEnvironment({name:O,schema:{urls:{[iKr]:typeof m=="string"?m:m.url,...bdi(a)}}}):e.builder.addEnvironment({name:O,schema:m});o&&e.builder.setDefaultUrl(iKr)}}function TTo(e){return MM(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var N5s=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},xjD=.75,IjD=new Set("authorization");function tNp(e){if(e.globalHeaderOverrides!=null){for(let[r,i]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:i});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,i]of Object.entries(t)){let n="optional<string>";if(i.name==null&&i.env==null&&typeof i.schema=="string")n=i.schema;else if(i!=null){let a=i.schema?C1n(i.schema):void 0,u=a!=null?rKr(a):void 0,l=sy.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?MM(H0({schema:i.schema,context:e,fileContainingReference:u?PR(sy.of(Dg(u)),l):l,namespace:u,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(IjD.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let l=t[a.name],d=uXt({header:{...a,schema:l?.schema??a.schema,name:l?.name??a.name},fileContainingReference:sy.of(Q3),context:e,namespace:void 0});u=new N5s(d),r[a.name]=u}u.increment()}let i=e.ir.endpoints.length*xjD;for(let[n,a]of Object.entries(r)){let u=t[n],l=a.count===e.ir.endpoints.length,d=a.count>=i;u==null&&(l?e.builder.addGlobalHeader({name:n,schema:a.schema}):d&&e.builder.addGlobalHeader({name:n,schema:TTo(a.schema)}))}}}function rNp(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?C1n(t.schema):void 0,i=r!=null?rKr(r):void 0,n=uXt({header:{...t,schema:t.schema??gy.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0,schema:vj.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:sy.of(Q3),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:TTo(n)})}}function hG(e){switch(e.type){case"primitive":return nNp(e.value);case"object":return aNp(e.properties);case"array":return oNp(e.value);case"map":return RjD(e.value);case"oneOf":return NjD(e.value);case"enum":return e.value;case"literal":return FjD(e.value);case"unknown":return hG(e.value);default:Fo(e)}}function iNp(e){switch(e.type){case"withStreaming":return e.sse?{stream:zjD(e.events)}:{stream:oNp(e.events)};case"withoutStreaming":return{body:hG(e.value)};default:Fo(e)}}function nNp(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:Fo(e)}}function aNp(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,hG(r)]))}function zjD(e){return e.map(t=>({event:"",data:hG(t)}))}function oNp(e){return e.map(t=>hG(t))}function RjD(e){return Object.fromEntries(e.map(t=>[nNp(t.key),hG(t.value)]))}function NjD(e){return e.type==="discriminated"?aNp(e.value):hG(e.value)}function FjD(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Fo(e)}}function uNp({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"]=LjD(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=UjD(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=VjD({context:t,namedFullExamples:e.headers})),e.request!=null&&(r.request=hG(e.request)),e.response!=null&&(r.response=iNp(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(i=>i.type==="language"?{name:i.name??void 0,docs:i.description??void 0,language:i.language,code:i.code,install:i.install??void 0}:{name:i.name??void 0,docs:i.description??void 0,sdk:i.sdk,code:i.code}).filter(Qb)),r)}function LjD(e){let t={};return e.forEach(r=>{let i=hG(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function UjD(e){let t={};return e.forEach(r=>{let i=hG(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function VjD({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=hG(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function sNp(e){return pG._visit(e,{get:()=>l2.HttpMethodSchema.Get,post:()=>l2.HttpMethodSchema.Post,put:()=>l2.HttpMethodSchema.Put,patch:()=>l2.HttpMethodSchema.Patch,delete:()=>l2.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("Unknown http method is unsupported")}})}function cNp(e){return e==="POST"||e==="PUT"||e==="PATCH"}function lNp({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,u=e.path,l=qTo(e.sdkName,e.namespace),d={};for(let m of e.pathParameters)m.parameterNameOverride&&(u=u.replace(m.name,m.parameterNameOverride)),d[m.parameterNameOverride??m.name]=ETo({pathParameter:m,context:r,fileContainingReference:t,namespace:l}),a.add(m.name);let s={};for(let m of e.queryParameters){let w=ATo({queryParameter:m,context:r,fileContainingReference:t,namespace:l});w!=null&&(s[m.name]=w,a.add(m.name))}let o;if(e.pagination!=null)switch(e.pagination.type){case"cursor":o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":o={type:"custom",results:e.pagination.results};break;default:Fo(e.pagination)}let c={path:u,method:sNp(e.method),auth:e.authed,docs:e.description??void 0,pagination:o,source:e.source!=null?tKr(e.source):void 0};!$jD({context:r,request:e.request})&&Object.keys(d).length>0&&(c["path-parameters"]=d),e.summary!=null&&(c["display-name"]=e.summary);let b={},g=r.builder.getGlobalHeaderNames(),O=e.headers.filter(m=>!g.has(m.name));for(let m of O){let w=uXt({header:m,context:r,fileContainingReference:t,namespace:l});b[m.name]=w,a.add(typeof w=="string"?m.name:w.name??m.name)}if(e.request!=null){r.setInState(j2.Request);let m=HjD({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.inlinePathParameters&&Object.keys(d).length>0?d:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(i),headers:Object.keys(b).length>0?b:void 0,usedNames:a,namespace:l});c.request=m.value,n=[...n,...m.schemaIdsToExclude??[]],r.unsetInState(j2.Request)}else{let m=r.inlinePathParameters&&Object.keys(d).length>0,w=Object.keys(s).length>0,E=Object.keys(b).length>0,A={};(m||w||E)&&(A.name=e.requestNameOverride??e.generatedRequestName),m&&(A["path-parameters"]=d),w&&(A["query-parameters"]=s),E&&(A.headers=b),Object.keys(A).length>0&&(c.request=A)}if(e.response!=null&&e.response._visit({json:m=>{let w=H0({schema:m.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c.response={docs:m.description??void 0,type:MM(w)},m.statusCode!=null&&(c.response["status-code"]=m.statusCode),m.responseProperty!=null&&(c.response.property=m.responseProperty)},streamingJson:m=>{let w=H0({schema:m.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c["response-stream"]={docs:m.description??void 0,type:MM(w),format:"json"}},streamingSse:m=>{let w=H0({schema:m.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c["response-stream"]={docs:m.description??void 0,type:MM(w),format:"sse"}},file:m=>{c.response={docs:m.description??void 0,type:"file","status-code":m.statusCode}},streamingText:m=>{c["response-stream"]={docs:m.description??void 0,type:"text"}},text:m=>{c.response={docs:m.description??void 0,type:"text","status-code":m.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let m=r.getDefaultServerName(),w=e.servers[0];w==null?m!=null&&(c.url=m):c.url=w.name??void 0}return e.idempotent&&(c.idempotent=!0),e.availability!=null&&(c.availability=fI(e.availability)),Object.entries(e.errors).forEach(([m,w])=>{let E=w.generatedName,A=sy.of(X1);r.builder.enableUniqueErrorsPerEndpoint&&(E=`${e.generatedRequestName}${w.generatedName}`,w.schema!=null&&(w.schema.type!=="reference"&&w.schema.type!=="oneOf"?w.schema.generatedName=`${e.generatedRequestName}${w.schema.generatedName}`:w.schema.type==="oneOf"&&(w.schema.value.generatedName=`${e.generatedRequestName}${w.schema.value.generatedName}`)));let q={"status-code":parseInt(m)},D=LRp({location:fNp,namespaceOverride:l});if(w.schema!=null){let $=H0({schema:w.schema,context:r,fileContainingReference:D,declarationFile:D,namespace:l,declarationDepth:0});q.type=MM($),q.docs=w.description}r.builder.addError(D,{name:E,schema:r.isErrorUnknownSchema(parseInt(m))?{...q,type:"unknown"}:q}),c.errors==null&&(c.errors=[]);let C=r.builder.addImport({file:t,fileToImport:D});c.errors.push(C!=null?`${C}.${E}`:E),q.type!=null&&w.examples?.forEach($=>{let I={value:hG($.example),name:$.name,docs:$.description};r.builder.addErrorExample(D,{name:E,example:I})})}),e.examples.length>0&&(c.examples=WjD({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?c.audiences=[F5s,...e.audiences]:e.audiences.length>0&&(c.audiences=e.audiences),{value:c,schemaIdsToExclude:n}}function WjD({endpointExamples:e,context:t}){return e.map(r=>{try{return uNp({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function HjD({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:u,queryParameters:l,nonRequestReferencedSchemas:d,headers:s,usedNames:o,namespace:c}){if(i.type==="json"){let b=i.schema.type==="reference"?i.schema.schema:void 0,g=i.schema.type==="reference"?r.getSchema(i.schema.schema,c):i.schema;if(g?.type!=="object"||b!=null&&d.includes(b)){let A=H0({schema:i.schema,fileContainingReference:t,context:r,namespace:c,declarationDepth:0}),q={schemaIdsToExclude:[],value:{body:A}},D=Object.keys(u??{}).length>0,C=Object.keys(l??{}).length>0,R=Object.keys(s??{}).length>0;return D&&(q.value["path-parameters"]=u),C&&(q.value["query-parameters"]=l),R&&(q.value.headers=s),(D||C||R)&&(q.value.name=n??a),i.contentType!=null&&(q.value["content-type"]=i.contentType),i.description!=null&&(q.value.docs=i.description),q}let O=Object.fromEntries(g.properties.filter(A=>A.readonly==null?!0:!(cNp(e.method)&&A.readonly)).map(A=>{let q=H0({schema:A.schema,fileContainingReference:t,context:r,namespace:c,declarationDepth:1}),D=A.nameOverride??A.key,C=fI(A.availability);if(!o.has(D)&&A.audiences.length<=0)return o.add(D),A.nameOverride!=null?[A.key,{type:MM(q),docs:B1n(q),name:A.nameOverride,availability:C}]:[A.key,C?{...typeof q=="string"?{type:q}:q,availability:C}:q];let R={type:MM(q),docs:B1n(q)};return o.has(D)&&(R.name=A.generatedName),A.audiences.length>0&&(R.audiences=A.audiences),C!=null&&(R.availability=C),o.add(D),[A.key,R]})),m=g.allOf.map(A=>{let q=H0({schema:gy.reference(A),fileContainingReference:t,context:r,namespace:c,declarationDepth:0});return MM(q)}),w={properties:O};m.length>0&&(w.extends=m),i.additionalProperties&&(w["extra-properties"]=!0);let E={name:n??g.nameOverride??g.generatedName,"path-parameters":u,"query-parameters":l,headers:s,body:w};return i.contentType!=null&&(E["content-type"]=i.contentType),i.description!=null&&(E.docs=i.description),{schemaIdsToExclude:b!=null?[b]:[],value:E}}else{if(i.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":JB.APPLICATION_OCTET_STREAM,...i.description?{docs:i.description}:{}}};if(i.type==="multipart"){let b=Object.fromEntries(i.properties.map(g=>{if(g.schema.type==="file"){let O=g.schema.isArray?"list<file>":"file";if(O=g.schema.isOptional?`optional<${O}>`:O,g.description!=null||g.contentType!=null){let m={type:O};if(g.description!=null&&(m.docs=g.description),g.contentType!=null){let w=g.contentType.split(",")[0];m["content-type"]=w}return[g.key,m]}return[g.key,O]}else{let O=H0({schema:g.schema.value,fileContainingReference:t,context:r,namespace:c,declarationDepth:1});if(g.contentType!=null||g.exploded||g.encoding==="form"){let m=typeof O=="string"?{type:O}:O;g.contentType!=null&&(m["content-type"]=g.contentType),g.encoding==="form"?m.style="form":g.exploded&&(m.style="exploded"),O=m}return[g.key,O]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":u,"query-parameters":l,headers:s,body:{properties:b},"content-type":JB.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else Fo(i)}}function $jD({context:e,request:t}){if(!e.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;default:Fo(t)}}function GjD({location:e,namespaceOverride:t}){return t!=null?{...e,file:PR(sy.of(t),e.file)}:e}function QjD(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:sy.of(`${Dg(r)}.yml`),endpointId:e.summary!=null?Dg(e.summary):Dg(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:sy.of(X1),endpointId:Dg(e.summary)}:{file:sy.of(X1),endpointId:Dg(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:sy.of(X1),endpointId:i};let n=r_a(r),a=r_a(i);if(F1e(n,a))return{file:sy.of("__package__.yml"),endpointId:r};let u=YjD({operationId:i,tag:r,path:e.path,method:e.method});if(u!=null)return u;let l=[];for(let d=0;d<n.length;++d){let s=n[d];if(s!=null&&s===a[d])l.push(s);else{let o=Dg(r);return{file:sy.of(`${o}.yml`),endpointId:i,tag:r}}}if(l.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:sy.of(Dg(l.join("_"))+".yml"),endpointId:Dg(a.slice(l.length).join("_")),tag:r}}function i_a(e){let t=e.tags[0];if(e.sdkName!=null){let r=j5s({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:sy.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return GjD({namespaceOverride:e.namespace,location:QjD(e)})}function r_a(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=vBe(t),t}var JjD=new RegExp("[^a-zA-Z0-9{}]+"),KjD=new RegExp("[{}]","g");function YjD({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(JjD).join("_").replaceAll(KjD,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:sy.of(Dg(t)+".yml"),endpointId:Dg(e.slice(0,-1*a.length)),tag:t}}function dNp(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:u,file:l,tag:d}=i_a(a),s=l.split(".")[0];s!=null&&t.add(s);let o;if(a.sdkName!=null){let g=e.ir.groups;for(let O of a.sdkName.groupName){let m=typeof O=="string"?O:O.name,w=g[m];if(w==null)break;if(w.summary!=null||w.description!=null){o=g[m];break}}}let c=d==null?void 0:i.tagsById[d];e.setInState(j2.Endpoint),e.setEndpointMethod(a.method);let b=lNp({context:e,endpoint:a,declarationFile:l});e.unsetEndpointMethod(),e.unsetInState(j2.Endpoint),n=[...n,...b.schemaIdsToExclude],e.builder.addEndpoint(l,{name:u,schema:b.value,source:a.source!=null?tKr(a.source):void 0}),(c?.id!=null||c?.description!=null)&&e.builder.setServiceInfo(l,{"display-name":o?.summary??c?.id,docs:o?.description??c?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function pNp(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?rKr(r.groupName):void 0,n=H0({schema:gy.primitive(r),context:e,fileContainingReference:sy.of(X1),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:MM(n),docs:r.description??void 0}})}}function _Np(e){for(let t of e.ir.webhooks){let r=kjD({webhook:t,context:e});if(r==null)continue;let i=qTo(t.sdkName,t.namespace),n={};for(let u of t.headers)n[u.name]=uXt({header:u,context:e,fileContainingReference:r.file,namespace:i});let a={method:t.method,"display-name":t.summary??void 0,headers:n,payload:H0({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:hG(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function XjD({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:PR(sy.of(t),e.file)}:e}function ZjD({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:sy.of(X1),endpointId:i};let n=r_a(r),a=r_a(i);if(F1e(n,a))return{file:sy.of("__package__.yml"),endpointId:r};let u=[];for(let l=0;l<n.length;++l){let d=n[l];if(d!=null&&d===a[l])u.push(d);else{let s=Dg(r);return{file:sy.of(`${s}.yml`),endpointId:i,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:sy.of(Dg(u.join("_"))+".yml"),endpointId:Dg(a.slice(u.length).join("_")),tag:r}}function kjD({webhook:e,context:t}){return e.sdkName!=null?{file:FRp({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:XjD({namespaceOverride:e.namespace,location:ZjD({webhook:e,context:t})})}var ewD=sy.of(X1);function hNp(e){switch(e.type){case"object":return sXt(e.groupName);case"enum":return sXt(e.groupName);case"oneOf":return sXt(e.value.groupName);case"array":return sXt(e.groupName);case"map":return sXt(e.groupName);case"reference":return sXt(e.groupName);case"literal":return sXt(e.groupName);case"optional":return sXt(e.groupName);case"nullable":return sXt(e.groupName);case"primitive":return sXt(e.groupName);case"unknown":return ewD;default:Fo(e)}}function sXt(e){return T1n(e)}var F5s="external",fNp=sy.of(X1);function yNp({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let u=hNp(a),l=HRp({schema:a,context:i,declarationFile:u,namespace:r,declarationDepth:0});if(Jsi(l.schema)){let d=MM(l.schema);if(d===(l.name??n)||d===`optional<${l.name??n}>`)continue}i.builder.addType(u,{name:l.name??n,schema:l.schema})}}function vNp(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),eNp(e),tNp(e),rNp(e),KRp(e),pNp(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(F5s);let t=dNp(e),r=t.sdkGroups;e.setInState(j2.Webhook),_Np(e),e.unsetInState(j2.Webhook),e.setInState(j2.Channel);for(let n of Object.values(e.ir.channels)){let a=T1n(n.groupName);kRp({channel:n,context:e,declarationFile:a})}e.unsetInState(j2.Channel);let i=twD({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});yNp({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))yNp({schemas:a,schemaIdsToExclude:i,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}function twD({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}function L5s(e){let t=new mTo(e);return vNp(t)}var vRi={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!1,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1};function U5s({options:e,overrides:t}){return{enableUniqueErrorsPerEndpoint:t?.enableUniqueErrorsPerEndpoint??e?.enableUniqueErrorsPerEndpoint??vRi.enableUniqueErrorsPerEndpoint,detectGlobalHeaders:t?.detectGlobalHeaders??e?.detectGlobalHeaders??vRi.detectGlobalHeaders,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??vRi.objectQueryParameters,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??vRi.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??vRi.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??vRi.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??vRi.inlinePathParameters}}var CTo=class{args;constructor(t){this.args=t}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=L5s({taskContext:t,ir:r,options:U5s({overrides:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.args.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.args.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.args.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.args.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.args.objectQueryParameters}}),authOverrides:this.args.generatorsConfiguration?.api?.auth!=null?{...this.args.generatorsConfiguration?.api}:void 0,environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:n??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:Kd.dump(a.rootApiFile)},namedDefinitionFiles:{...rd(a.definitionFiles,u=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Kd.dump(u),contents:u})),[sy.of(X1)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Kd.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var n_a=class extends D5t{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;exampleGeneration;converter;constructor(t){super(t),this.inlinePathParameters=t.inlinePathParameters,this.objectQueryParameters=t.objectQueryParameters,this.onlyIncludeReferencedSchemas=t.onlyIncludeReferencedSchemas,this.respectReadonlySchemas=t.respectReadonlySchemas,this.respectNullableSchemas=t.respectNullableSchemas,this.exampleGeneration=t.exampleGeneration,this.converter=new CTo(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:i},n){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:i},n);return this.converter.convert({context:t,ir:a,settings:n,absoluteFilePath:r})}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new USe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion})}};function x1n(e){if(e.settings==null)return;let t={detectGlobalHeaders:!0};return e.settings.unions==="v1"&&(t.discriminatedUnionV2=!0),t}var OLp=yi(Bxo(),1);var mV={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"};var nha={of(e){return e}};var W5p={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},TWs={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:W5p,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},fd={SOURCE:nha.of("source"),SDK_METHOD_NAME:nha.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:nha.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:nha.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"};var OG={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!0,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,preserveSchemaIds:!1,objectQueryParameters:!1,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!1,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json"};function CWs({options:e,overrides:t}){return{disableExamples:t?.disableExamples??OG.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.discriminatedUnionV2??OG.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.useTitlesAsName??OG.useTitlesAsName,audiences:t?.audiences??e?.audiences??OG.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??OG.optionalAdditionalProperties,coerceEnumsToLiterals:t?.coerceEnumsToLiterals??e?.coerceEnumsToLiterals??OG.coerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??OG.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??OG.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??OG.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??OG.inlinePathParameters,preserveSchemaIds:t?.preserveSchemaIds??OG.preserveSchemaIds,shouldUseUndiscriminatedUnionsWithLiterals:t?.shouldUseUndiscriminatedUnionsWithLiterals??e?.shouldUseUndiscriminatedUnionsWithLiterals??OG.shouldUseUndiscriminatedUnionsWithLiterals,shouldUseIdiomaticRequestNames:t?.shouldUseIdiomaticRequestNames??e?.shouldUseIdiomaticRequestNames??OG.shouldUseIdiomaticRequestNames,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??OG.objectQueryParameters,filter:t?.filter??e?.filter??OG.filter,asyncApiNaming:t?.asyncApiNaming??e?.asyncApiNaming??OG.asyncApiNaming,exampleGeneration:t?.exampleGeneration??e?.exampleGeneration??void 0,defaultFormParameterEncoding:t?.defaultFormParameterEncoding??e?.defaultFormParameterEncoding??void 0}}var H5p={naming:"v1"};function yf(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function aha(e,t,r,i,n=[]){try{let a=yf(e,t);if(a!=null)return r.parse(a)}catch{let u=vBe(n).join(" -> ");i.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}function QRi(e){let t=yf(e,"examples");return t!=null&&Array.isArray(t)?t:[]}function $5p({schema:e,logger:t}){return yf(e,fd.ENCODING)??void 0}function G5p(e){return yf(e,fd.FERN_ENUM)}function Q5p({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let u=yf(i,fd.SDK_GROUP_NAME),l=yf(i,fd.TYPE_DEFINITION);if(l!=null)return oha({fernType:l,nameOverride:e,generatedName:t,title:r,description:n,availability:a,groupName:typeof u=="string"?[u]:u})}function oha({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u}){return NU({type:e,_default:void 0,validation:void 0,visitor:{primitive:l=>{switch(l.v1){case"BASE_64":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.base64({example:void 0})});case"BOOLEAN":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.boolean({default:void 0,example:void 0})});case"DATE":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.date({example:void 0})});case"DATE_TIME":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.datetime({example:void 0})});case"FLOAT":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.float({example:void 0})});case"DOUBLE":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.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 El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.uint({default:void 0,example:void 0})});case"INTEGER":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.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 El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.uint64({default:void 0,example:void 0})});case"LONG":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return El.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,groupName:u,schema:Xd.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:Fo(l.v1)}},unknown:()=>El.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,groupName:u}),map:({keyType:l,valueType:d})=>l?.type==="primitive"&&d!=null?El.map({nameOverride:t,generatedName:r,title:i,key:l,value:d,description:n,availability:a,groupName:u,encoding:void 0,example:void 0,inline:void 0}):void 0,list:l=>l!=null?El.array({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,example:void 0,inline:void 0}):void 0,optional:l=>l!=null?El.optional({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,inline:void 0}):void 0,nullable:l=>l!=null?El.nullable({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,inline:void 0}):void 0,set:l=>l!=null?El.array({nameOverride:t,generatedName:r,title:i,value:l,description:n,availability:a,groupName:u,example:void 0,inline:void 0}):void 0,literal:l=>El.literal({nameOverride:t,generatedName:r,title:i,value:l._visit({string:d=>cx.string(d),boolean:d=>cx.boolean(d),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,groupName:u}),named:()=>{}}})}function J5p(e){let t=yf(e,fd.SOURCE);if(t!=null)return t.endsWith(".proto")?wie.protobuf({file:t}):wie.openapi({file:t})}function JRi(e){if(e!=null&&typeof e=="boolean")return e}function Zd(e){return e.$ref!=null}function K5p({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:u,wrapAsNullable:l,context:d,groupName:s,example:o,encoding:c,source:b,namespace:g}){return typeof n=="boolean"||SSn(n)?xxo({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:El.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:void 0}),groupName:s,example:o,encoding:c}):xxo({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:Y5p(qb(n,d.options.optionalAdditionalProperties?l:!1,d,[...i,"Value"],b,g,void 0,void 0,void 0)),groupName:s,example:o,encoding:c})}function Y5p(e){switch(e.type){case"array":case"enum":case"map":case"object":e.inline=!0;break;case"literal":case"primitive":case"reference":case"unknown":break;case"nullable":case"optional":e.inline=!0,e.value=Y5p(e.value);break;case"oneOf":e.value.inline=!0;break;default:Fo(e)}return e}function xxo({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsNullable:a,description:u,availability:l,groupName:d,example:s,encoding:o}){return a?El.nullable({nameOverride:e,generatedName:t,title:r,value:El.map({nameOverride:e,generatedName:t,title:r,description:u,availability:i.availability,key:i,value:n,groupName:d,encoding:o,example:s,inline:void 0}),description:u,availability:l,groupName:d,inline:void 0}):El.map({nameOverride:e,generatedName:t,title:r,description:u,availability:l,key:i,value:n,groupName:d,encoding:o,example:s,inline:void 0})}function SSn(e){return e==null?!1:typeof e=="boolean"?e:!Zd(e)&&Object.keys(e).length===0}function X5p({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:u,wrapAsNullable:l,context:d,groupName:s,example:o,source:c,namespace:b}){let g=n==null?El.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,groupName:s}):qb(n,!1,d,[...i,"Item"],c,b);return k4D({nameOverride:e,generatedName:t,title:r,groupName:s,itemSchema:g,wrapAsNullable:l,description:a,availability:u,example:o})}function k4D({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsNullable:n,description:a,availability:u,groupName:l,example:d}){return n?El.nullable({nameOverride:e,generatedName:t,title:r,value:El.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,groupName:l,example:d,inline:void 0}),description:a,availability:u,groupName:l,inline:void 0}):El.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,groupName:l,example:d,inline:void 0})}function Bie(e){switch(yf(e,fd.AVAILABILITY)){case"deprecated":return pV.Deprecated;case"beta":return pV.Beta;case"generally-available":return pV.GenerallyAvailable;default:break}if(!Zd(e)&&e.deprecated)return pV.Deprecated}function BWs({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:l,wrapAsNullable:d,discriminator:s,context:o,groupName:c,encoding:b,source:g,namespace:O}){let m=s.propertyName,w=Object.fromEntries(Object.entries(s.mapping??{}).map(([A,q])=>{let D=DSn({$ref:q},!1,o,[q],b,g,O);return o.markReferencedByDiscriminatedUnion({$ref:q},m,1),[A,D]})),E=Object.entries(n).filter(([A])=>A!==m).map(([A,q])=>{let D=l!=null&&l.includes(A),C=qb(q,!D,o,[...i,A],g,O);return{key:A,schema:C}});return Z5p({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:E,description:a,availability:u,discriminant:m,subtypes:w,groupName:c,source:g})}function xWs({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:l,wrapAsNullable:d,discriminant:s,variants:o,context:c,groupName:b,encoding:g,source:O,namespace:m}){let w=Object.fromEntries(Object.entries(o).map(([A,q])=>{if(Zd(q)){let D=DSn(q,!1,c,[q.$ref],g,O,m);return c.markReferencedByDiscriminatedUnion(q,s,1),[A,D]}else{let D=ESn(q,!1,c,[...i,A],g,O,m,new Set([s]));return[A,D]}})),E=Object.entries(n).filter(([A])=>A!==s).map(([A,q])=>{let D=l!=null&&l.includes(A),C=qb(q,!D,c,[...i,A],O,m);return{key:A,schema:C}});return Z5p({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:E,description:a,availability:u,discriminant:s,subtypes:w,groupName:b,source:O})}function Z5p({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,availability:u,discriminant:l,subtypes:d,groupName:s,source:o}){return i?El.nullable({nameOverride:e,generatedName:t,title:r,value:El.oneOf(QY.discriminated({description:a,availability:u,discriminantProperty:l,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:n,groupName:s,encoding:void 0,source:o,inline:void 0})),groupName:s,description:a,availability:u,inline:void 0}):El.oneOf(QY.discriminated({description:a,availability:u,discriminantProperty:l,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:n,groupName:s,encoding:void 0,source:o,inline:void 0}))}function k5p(e){if(e.proto!=null)return t1n.protobuf({typeName:e.proto.type})}function bXt({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:u,description:l,availability:d,wrapAsNullable:s,groupName:o,context:c,source:b,inline:g}){let O=t8D(n??[]),m=new Set(a),w=Array.from(m).map((A,q)=>{let D=i?.[A],C=O[q],R=A1n.test(A),$=D?.name??C,I=R?A:q1n(A);return $!=null&&!A1n.test($)&&(c?.logger.warn(`Enum name override ${$} is not a valid name. Falling back on ${I}.`),$=void 0),{nameOverride:$,generatedName:I,value:A,description:D?.description,availability:d,casing:{snake:D?.casing?.snake??void 0,pascal:D?.casing?.pascal??void 0,screamingSnake:D?.casing?.screamingSnake??void 0,camel:D?.casing?.camel??void 0}}}),E=u!=null?w.find(A=>A.value===u):void 0;return e8D({wrapAsNullable:s,nameOverride:e,generatedName:t,title:r,values:w,_default:E,description:l,availability:d,groupName:o,source:b,inline:g})}function e8D({wrapAsNullable:e,nameOverride:t,generatedName:r,title:i,values:n,_default:a,description:u,availability:l,groupName:d,source:s,inline:o}){return e?El.nullable({nameOverride:t,generatedName:r,title:i,value:El.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,default:a,availability:l,example:void 0,groupName:d,source:s,inline:o}),description:u,availability:l,groupName:d,inline:o}):El.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,availability:l,default:a,example:void 0,groupName:d,source:s,inline:o})}function t8D(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(i=>i[r]===t[r]);)r++;return e.map(i=>i.substring(r))}function e9p({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,description:o,availability:c,wrapAsNullable:b,example:g,groupName:O}){return i==="int64"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint32"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint64"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.int({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O})}function t9p(e){return typeof e=="string"?cx.string(e):typeof e=="boolean"?cx.boolean(e):cx.string(`${e}`)}function r9p({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,value:n,description:a,availability:u,groupName:l}){return i?El.nullable({nameOverride:e,generatedName:t,title:r,value:El.literal({nameOverride:e,generatedName:t,title:r,value:t9p(n),description:a,availability:u,groupName:l}),description:a,availability:u,groupName:l,inline:void 0}):El.literal({nameOverride:e,generatedName:t,title:r,value:t9p(n),description:a,availability:u,groupName:l})}function IWs({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,description:o,availability:c,wrapAsNullable:b,example:g,groupName:O}){return i==null||i==="double"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.double({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="float"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.float({example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="int32"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.int({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="int64"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint32"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="uint64"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):i==="time-delta"?w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.float({example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O}):w5({nameOverride:e,generatedName:t,title:r,primitive:Xd.float({example:g}),wrapAsNullable:b,description:o,availability:c,groupName:O})}var r8D={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},i8D={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}}},n8D={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}}},a8D={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},o8D={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},u8D={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},s8D={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},c8D={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function Ixo(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[r8D,i8D,n8D,a8D,o8D,u8D,s8D,c8D],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:l}=a.applyStrategy(t);t=u,r=[...r,...l]}}while(t.join("")!==n.join(""));return r}function D2(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:G3(Dg(n))).join("");return/^\d/.test(i)?kpa(i)??i:i}function zWs(e){let t=e.join("_");return Dg(t)}function cE(e){switch(e.type){case"object":return gy.object({allOf:e.allOf,properties:e.properties.map(t=>f8D(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,inline:e.inline});case"array":return gy.array({description:e.description,availability:e.availability,value:cE(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,inline:e.inline});case"enum":return gy.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,inline:e.inline});case"literal":return gy.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 gy.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:cE(e.value),groupName:e.groupName,inline:e.inline});case"optional":return gy.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:cE(e.value),groupName:e.groupName,inline:e.inline});case"primitive":return gy.primitive({description:e.description,availability:e.availability,schema:i9p(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return gy.map({description:e.description,availability:e.availability,key:gy.primitive({description:e.key.description,availability:e.key.availability,schema:i9p(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,groupName:e.groupName}),value:cE(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return gy.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 gy.oneOf(l8D(e.value));case"unknown":return gy.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:Fo(e)}}function l8D(e){switch(e.type){case"discriminated":return eKr.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:cE(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,cE(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return eKr.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>cE(t)),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:Fo(e)}}function i9p(e){switch(e.type){case"string":return vj.string(e);case"base64":return vj.base64();case"boolean":return vj.boolean(e);case"date":return vj.date();case"datetime":return vj.datetime();case"double":return vj.double(e);case"float":return vj.float();case"int":return vj.int(e);case"int64":return vj.int64(e);case"uint":return vj.uint();case"uint64":return vj.uint64();default:Fo(e)}}function f8D(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:cE(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function zxo(e,t){return Eie(cE(e),cE(t))}function n9p({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:u,wrapAsNullable:l,allOf:d,context:s,propertiesToExclude:o,groupName:c,fullExamples:b,additionalProperties:g,availability:O,encoding:m,source:w,namespace:E}){let A=[...u??[]],q={...n},D=[],C=[];for(let U of d)if(Zd(U)){let H=s.resolveSchemaReference(U);if(H.discriminator!=null&&H.discriminator.mapping!=null)continue;if(H.oneOf!=null){for(let K of H.oneOf){let ee=Zd(K)?s.resolveSchemaReference(K):K,fe=qb(ee,!1,s.DUMMY,i,w,E);fe.type==="object"&&D.push(...fe.properties.map(me=>me.schema.type!=="optional"&&me.schema.type!=="nullable"?{...me,schema:El.optional({nameOverride:void 0,generatedName:"",title:void 0,value:me.schema,description:void 0,availability:me.availability,groupName:void 0,inline:void 0})}:me))}continue}let k=Wdi(U);if(k==null)continue;C.push({schemaId:k,convertedSchema:RWs(U,[k],w,s.options.preserveSchemaIds),properties:a9p({schema:U,context:s,breadcrumbs:i,source:w,namespace:E})}),s.markSchemaAsReferencedByNonRequest(k)}else{let H=qb(U,!1,s,i,w,E);H.type==="object"&&D.push(...H.properties)}let R={};for(let U of C)for(let[H,k]of Object.entries(U.properties)){let K=R[H];K!=null?(K.schemaIds.push(U.schemaId),K.schemas.some(fe=>zxo(fe,k))||K.schemas.push(k)):R[H]={schemaIds:[U.schemaId],schemas:[k]}}let $=[];for(let[U,H]of Object.entries(R))H.schemaIds.length>1&&$.push({propertyKey:U,allOfSchemaIds:H.schemaIds,conflictingTypeSignatures:H.schemas.length>1});let I=Object.entries(q).map(([U,H])=>{let k=A.includes(U),K=yf(H,fd.AUDIENCES)??[],ee=Bie(H),fe=Zd(H)?!1:H.readOnly,me=Zd(H)?!1:H.writeOnly,ge=yf(H,fd.FERN_PROPERTY_NAME),we=[...i,U],Ze=zWs(we),Mt=k?qb(H,!1,s,we,w,E):El.optional({nameOverride:e,generatedName:Ze,title:r,description:void 0,availability:ee,value:qb(H,!1,s,we,w,E),groupName:c,inline:void 0}),De={};for(let Te of C){let xt=Te.properties[U];xt!=null&&!zxo(Mt,xt)?De[Te.schemaId]={differentSchema:!0}:xt!=null&&(De[Te.schemaId]={differentSchema:!1})}return{key:U,schema:Mt,nameOverride:ge,audiences:K,conflict:De,generatedName:zWs([...i,U]),availability:ee,readonly:fe,writeonly:me}});return I.push(...D.map(U=>{let H=U.conflict;for(let k of C){let K=k.properties[U.key];K!=null&&!zxo(U.schema,K)?H[k.schemaId]={differentSchema:!0}:K!=null&&(H[k.schemaId]={differentSchema:!1})}return{...U,conflict:H}})),d8D({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,properties:I.filter(U=>!o.has(U.key)),description:a,allOf:C.map(U=>U.convertedSchema),allOfPropertyConflicts:$,groupName:c,fullExamples:b,additionalProperties:g,availability:O,source:w})}function d8D({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,allOf:u,allOfPropertyConflicts:l,groupName:d,fullExamples:s,additionalProperties:o,availability:c,source:b}){return i?El.nullable({nameOverride:e,generatedName:t,title:r,value:El.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:l,groupName:d,fullExamples:s,additionalProperties:SSn(o),availability:void 0,source:b,inline:void 0}),description:a,availability:c,groupName:d,inline:void 0}):El.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:l,groupName:d,fullExamples:s,additionalProperties:SSn(o),availability:c,source:b,inline:void 0})}function a9p({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[u,l]=Zd(e)?[t.resolveSchemaReference(e),Ixo(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...a9p({schema:d,context:t,breadcrumbs:l,source:i,namespace:n})};for(let[d,s]of Object.entries(u.properties??{})){let o=qb(s,!1,t,[...l,d],i,n);a[d]=o}return a}function o9p({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsNullable:u,context:l,subtypes:d,groupName:s,encoding:o,source:c,subtypePrefixOverrides:b,namespace:g}){let O=u9p(d);return s9p({uniqueSubtypes:O,nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:n,availability:a,groupName:s,context:l,encoding:o,source:c})}function MSn({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsNullable:u,context:l,subtypes:d,groupName:s,encoding:o,source:c,subtypePrefixOverrides:b,namespace:g}){let O=p8D({schemas:d}),m=d.flatMap((E,A)=>{if(!Zd(E)&&E.enum!=null&&l.options.coerceEnumsToLiterals&&E.type==="string")return E.enum.map(D=>El.literal({nameOverride:void 0,generatedName:D2([t,D],l.options.preserveSchemaIds),title:void 0,value:cx.string(String(D)),groupName:void 0,description:void 0,availability:D.availability}));let q=O[A];if(b!=null){let D=b[A];D!=null&&"name"in D&&(q=D.name)}return[qb(E,!1,l,[...i,q??`${A}`],c,g)]}),w=u9p(m);return s9p({uniqueSubtypes:w,nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:n,availability:a,groupName:s,context:l,encoding:o,source:c})}function u9p(e){let t=[];for(let r=0;r<e.length;++r){let i=e[r],n=!1;for(let a=r+1;a<e.length;++a){let u=e[a];if(i!=null&&u!=null&&Eie(i,u)){n=!0;break}}i!=null&&!n&&t.push(i)}return t}function s9p({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,groupName:l,context:d,encoding:s,source:o}){if(Object.entries(e).every(([b,g])=>g.type==="literal")){let b={},g=[];return Object.entries(e).forEach(([O,m])=>{m.type==="literal"&&m.value.type==="string"&&(g.push(m.value.value),m.description!=null&&(b[m.value.value]={description:m.description}))}),bXt({nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,fernEnum:b,enumVarNames:void 0,enumValues:g,_default:void 0,groupName:l,context:d,source:o,inline:void 0})}return e.length===1&&e[0]!=null?e[0]:c9p({nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,subtypes:e,groupName:l,encoding:s,source:o})}function NWs({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsNullable:a,context:u,groupName:l,discriminator:d,encoding:s,source:o,namespace:c}){let b=Object.entries(d.mapping??{}).map(([m,w],E)=>{let A={$ref:w},q=DSn(A,!1,u,[w],s,o,c);return u.markSchemaWithDiscriminantValue(A,d.propertyName,m),q.type==="object"&&(q.properties={[d.propertyName]:El.literal({nameOverride:void 0,generatedName:D2([t,m],u.options.preserveSchemaIds),title:void 0,value:cx.string(m),groupName:void 0,description:void 0,availability:void 0}),...q.properties.filter(D=>D.key!==d.propertyName)}),q}),g=[];for(let m=0;m<b.length;++m){let w=b[m],E=!1;for(let A=m+1;A<b.length;++A){let q=b[A];if(w!=null&&q!=null&&Eie(w,q)){E=!0;break}}w!=null&&!E&&g.push(w)}if(Object.entries(g).every(([m,w])=>w.type==="literal")){let m={},w=[];return Object.entries(g).forEach(([E,A])=>{A.type==="literal"&&A.value.type==="string"&&(w.push(A.value.value),A.description!=null&&(m[A.value.value]={description:A.description}))}),bXt({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,fernEnum:m,enumVarNames:void 0,enumValues:w,_default:void 0,groupName:l,context:u,source:o,inline:void 0})}return g.length===1&&g[0]!=null?g[0]:c9p({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,subtypes:g,groupName:l,encoding:s,source:o})}function p8D({schemas:e}){let t={},r=0;for(let a of e){if(!Zd(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),l={},d=u;for(let[s,o]of Object.entries(t)){let c=nYa(o,u);d=nYa(d,o),l[s]=c}l[r]=d,t=l}}r++}let i=[],n=0;for(let a of e){let u=t[n];if(u!=null&&u.length>0){let l=u.sort();if(l[0]!=null){i.push(l[0]),++n;continue}}Zd(a)?i.push(ydi(n)??`${n}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?i.push(""):i.push(ydi(n)??`${n}`),++n}return i}function c9p({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,description:n,availability:a,subtypes:u,groupName:l,encoding:d,source:s}){return i?El.nullable({nameOverride:e,generatedName:t,title:r,value:El.oneOf(QY.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:l,encoding:d,source:s,inline:void 0})),description:n,availability:a,groupName:l,inline:void 0}):El.oneOf(QY.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:l,encoding:d,source:s,inline:void 0}))}function ASn(e){if(e.default!=null&&typeof e.default=="string")return e.default}function Rxo({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=QRi(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function l9p({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=QRi(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function _Kr({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=QRi(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function f9p({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=QRi(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var KRi="#/components/schemas/";function qb(e,t,r,i,n,a,u=!1,l=new Set,d){let s=J5p(e)??n,o=m8D({schema:e,logger:r.logger});if(Zd(e)){let c=Wdi(e);return c!=null?(u?r.markSchemaAsReferencedByRequest(c):r.markSchemaAsReferencedByNonRequest(c),DSn(e,t,r,i,o,s,a)):ESn(r.resolveSchemaReference(e),t,r,Ixo(e.$ref),o,s,a,l,u,d)}return ESn(e,t,r,i,o,s,a,l,u,d)}function DSn(e,t,r,i,n,a,u){let l=e.$ref.includes("properties")?ESn(r.resolveSchemaReference(e),t,r,i,n,a,u,new Set):El.reference(RWs(e,i,a,r.options.preserveSchemaIds));return t?El.nullable({title:void 0,nameOverride:void 0,generatedName:D2(i,r.options.preserveSchemaIds),value:l,description:void 0,availability:void 0,groupName:void 0,inline:void 0}):l}function _8D(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function ESn(e,t,r,i,n,a,u,l=new Set,d=!1,s){typeof e=="string"&&(e={type:e});let o=yf(e,fd.TYPE_NAME)??(r.options.useTitlesAsName?_8D(e.title):void 0),c=yf(e,fd.SDK_GROUP_NAME)??yf(e,mV.TAGS)?.[0],b=(typeof c=="string"?[c]:c)??[];b=r.resolveGroupName(b);let g=D2(i,r.options.preserveSchemaIds),O=e.title,m=e.description,w=Bie(e),E=[];e.example!=null&&E.push({name:void 0,value:e.example,description:void 0});let A=yf(e,mV.EXAMPLES);A!=null&&Object.keys(A).length>0&&E.push(...Object.entries(A).map(([C,R])=>({name:R?.summary??C,value:R.value,description:R.description})));let q=QRi(e);q!=null&&Object.keys(q).length>0&&E.push(...q.map(C=>({name:void 0,value:C,description:void 0})));let D=Q5p({schema:e,description:m,title:O,nameOverride:o,generatedName:g,availability:w});if(D!=null)return D;if(Array.isArray(e.type)){let C=e.type.indexOf("null"),R=C!==-1;e.type.length===1?e.type=e.type[0]:e.type.length===2&&R?(e.type.splice(C,1),e.type=e.type[0],e.nullable=!0):(R&&(e.type.splice(C,1),e.nullable=!0),e.oneOf==null?e.oneOf=e.type:e.oneOf.push(...e.type))}if(!t&&e.nullable===!0)return ESn(e,!0,r,i,n,a,u,l,d,s);if(e.enum!=null&&(e.type==="string"||e.type==null)){if(!Lxo(e.enum))return w5({nameOverride:o,generatedName:g,title:O,primitive:Xd.string({default:ASn(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:_Kr({schema:e,logger:r.logger,fallback:s})}),groupName:b,wrapAsNullable:t,description:m,availability:w});let C=G5p(e);return e.enum.length===1&&e.enum[0]!=null&&C==null?r9p({nameOverride:o,generatedName:g,title:O,wrapAsNullable:t,value:e.enum[0],description:m,availability:w,groupName:b}):bXt({nameOverride:o,generatedName:g,title:O,fernEnum:C,enumVarNames:yf(e,[mV.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:m,availability:w,wrapAsNullable:t,groupName:b,context:r,source:a,inline:void 0})}if(Lxo(e.type)&&e.type.length>1){let C=e.type.includes("null"),R=e.type.filter($=>$!=="null").map($=>({type:$,nullable:C}));return MSn({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,wrapAsNullable:t,context:r,subtypes:R,groupName:b,encoding:n,source:a,namespace:u})}if(e.type==="boolean"){let C=yf(e,fd.BOOLEAN_LITERAL);return C!=null?d9p({nameOverride:o,generatedName:g,title:O,literal:cx.boolean(C),wrapAsNullable:t,description:m,availability:w,groupName:b}):w5({nameOverride:o,generatedName:g,title:O,primitive:Xd.boolean({default:h8D(e.default),example:l9p({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:w,groupName:b})}if(e.type==="number")return IWs({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:JRi(e.exclusiveMinimum),exclusiveMaximum:JRi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:w,wrapAsNullable:t,example:Rxo({schema:e,logger:r.logger,fallback:s}),groupName:b});if(e.type==="integer")return e9p({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:JRi(e.exclusiveMinimum),exclusiveMaximum:JRi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:w,wrapAsNullable:t,example:Rxo({schema:e,logger:r.logger,fallback:s}),groupName:b});if(e.type==="float")return IWs({nameOverride:o,generatedName:g,title:O,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:JRi(e.exclusiveMinimum),exclusiveMaximum:JRi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:w,wrapAsNullable:t,example:Rxo({schema:e,logger:r.logger,fallback:s}),groupName:b});if(e.type==="string"){if(e.format==="date-time")return w5({nameOverride:o,generatedName:g,title:O,primitive:Xd.datetime({example:_Kr({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:w,groupName:b});if(e.format==="json-string")return El.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:w,groupName:b,example:void 0});let C=h9p(e,"const");return C!=null?d9p({nameOverride:o,generatedName:g,title:O,literal:cx.string(C),wrapAsNullable:t,description:m,availability:w,groupName:b}):w5({nameOverride:o,generatedName:g,title:O,primitive:Xd.string({default:ASn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:_Kr({schema:e,logger:r.logger,fallback:s})}),groupName:b,wrapAsNullable:t,description:m,availability:w})}if(e.type==="array")return X5p({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,item:e.items,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,example:f9p({schema:e,logger:r.logger,fallback:s}),source:a,namespace:u});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&Nxo(e))return K5p({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,additionalProperties:e.additionalProperties,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,encoding:n,example:e.example,source:a,namespace:u});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?NWs({nameOverride:o,generatedName:g,title:O,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,discriminator:e.discriminator,encoding:n,source:a,namespace:u}):BWs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:b,encoding:n,source:a,namespace:u});if(e.oneOf!=null&&e.oneOf.length>0){let C=yf(e,fd.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||C?NWs({nameOverride:o,generatedName:g,title:O,description:m,availability:w,wrapAsNullable:t,context:r,groupName:b,discriminator:e.discriminator,encoding:n,source:a,namespace:u}):BWs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:b,encoding:n,source:a,namespace:u});if(e.oneOf.length===1&&e.oneOf[0]!=null){let R=qb(e.oneOf[0],t,r,i,a,u,d);return qSn(R,m,b)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let U=e.oneOf[0],H=e.oneOf[1];if(!Zd(U)&&U.type==="null")return qb(H,!0,r,i,a,u);if(!Zd(H)&&H.type==="null")return qb(U,!0,r,i,a,u)}let R=b8D({schemas:e.oneOf});if(R!=null)return bXt({nameOverride:o,generatedName:g,title:O,fernEnum:void 0,enumVarNames:void 0,enumValues:R,_default:e.default,description:m,availability:w,wrapAsNullable:t,groupName:b,context:r,source:a,inline:void 0});let $=p9p({schemas:e.oneOf,context:r});if($!=null&&!r.options.discriminatedUnionV2&&!C)return xWs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:w,wrapAsNullable:t,discriminant:$.discriminant,variants:$.schemas,context:r,groupName:b,encoding:n,source:a,namespace:u});let I=e.oneOf.filter(U=>!Zd(U)&&U.type==="null").length>0;return MSn({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,wrapAsNullable:t||I,context:r,subtypes:e.oneOf.filter(U=>Zd(U)||U.type!=="null"),encoding:n,groupName:b,source:a,namespace:u})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let $=qb(e.anyOf[0],t,r,i,a,u,d);return qSn($,m,b)}if(e.anyOf.length===2){let[$,I]=e.anyOf;if($!=null&&I!=null){if(!Zd($)&&$.type==="null"){let U=qb(I,!0,r,i,a,u);return qSn(U,m,b)}else if(!Zd(I)&&I.type==="null"){let U=qb($,!0,r,i,a,u);return qSn(U,m,b)}}}let C=p9p({schemas:e.anyOf,context:r});if(C!=null&&!r.options.discriminatedUnionV2)return xWs({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:w,wrapAsNullable:t,discriminant:C.discriminant,variants:C.schemas,context:r,groupName:b,encoding:n,source:a,namespace:u});let R=e.anyOf.filter($=>!Zd($)&&$.type==="null").length>0;return MSn({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:w,wrapAsNullable:t||R,context:r,subtypes:e.anyOf.filter($=>Zd($)||$.type!=="null"),encoding:n,groupName:b,source:a,namespace:u})}if(e.allOf!=null||e.properties!=null){let C=[];for(let $ of e.allOf??[])(Zd($)||Object.keys($).length>0)&&C.push($);if((e.properties==null||Nxo(e))&&C.length===1&&C[0]!=null){let $=qb(C[0],t,r,i,a,u,d);return qSn($,m,b)}let R=C.filter($=>{let I=Fxo($);return I||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify($)}`),I});if((e.properties==null||Nxo(e))&&R.length===1&&R[0]!=null){let $=qb(R[0],t,r,i,a,u,d);return qSn($,m,b)}return n9p({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},description:m,required:e.required,wrapAsNullable:t,allOf:R,context:r,propertiesToExclude:l,groupName:b,fullExamples:E,additionalProperties:e.additionalProperties,availability:w,encoding:n,source:a,namespace:u})}if(e.type==="object"&&y8D(e)&&v8D(e)&&Nxo(e))return xxo({nameOverride:o,generatedName:g,title:O,description:m,availability:w,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${g}Key`,title:void 0,description:void 0,availability:void 0,schema:Xd.string({default:ASn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:_Kr({schema:e,logger:r.logger,fallback:s})}),groupName:b},valueSchema:El.unknown({nameOverride:void 0,generatedName:`${g}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:b}),groupName:b,encoding:n,example:e.example});if(e.type==null){let C=e.example??e.default;return El.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:w,groupName:b,example:C})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(i)} value=${JSON.stringify(e)}`)}function h8D(e){if(e!=null){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase();if(t==="true")return!0;if(t==="false")return!1}}}function Wdi(e){if(e.$ref.startsWith(KRi))return e.$ref.replace(KRi,"")}function RWs(e,t,r,i){let n=yf(e,fd.TYPE_NAME),a=D2(t,i),u=e.description,l=Bie(e),d=Wdi(e);if(d==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return gy.reference({generatedName:a,nameOverride:n,title:void 0,schema:d,description:u??void 0,availability:l,groupName:void 0,source:r})}function y8D(e){return e.oneOf==null||e.oneOf.length===0}function v8D(e){return e.allOf==null||e.allOf.length===0}function Nxo(e){return e.properties==null||nY(e.properties)===0}function Lxo(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function qSn(e,t,r){return e.type==="reference"?El.reference({...e,description:t,availability:e.availability,groupName:r}):e.type==="optional"?El.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r,inline:void 0}):e.type==="nullable"?El.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r,inline:void 0}):e}function Fxo(e){return Zd(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>Fxo(t)):e.oneOf!=null?e.oneOf.every(t=>Fxo(t)):e.anyOf!=null?e.anyOf.every(t=>Fxo(t)):!1}function d9p({literal:e,wrapAsNullable:t,groupName:r,description:i,availability:n,nameOverride:a,generatedName:u,title:l}){return t?El.nullable({nameOverride:a,generatedName:u,title:l,value:El.literal({nameOverride:a,generatedName:u,title:l,value:e,description:i,availability:n,groupName:r}),groupName:r,description:i,availability:n,inline:void 0}):El.literal({nameOverride:a,generatedName:u,title:l,value:e,groupName:r,description:i,availability:n})}function w5({primitive:e,wrapAsNullable:t,groupName:r,description:i,availability:n,generatedName:a,nameOverride:u,title:l}){return r=typeof r=="string"?[r]:r,t?El.nullable({nameOverride:u,generatedName:a,title:l,value:El.primitive({nameOverride:u,generatedName:a,title:l,schema:e,description:i,availability:n,groupName:r}),groupName:r,description:i,availability:n,inline:void 0}):El.primitive({nameOverride:u,generatedName:a,title:l,schema:e,description:i,availability:n,groupName:r})}function b8D({schemas:e}){let t=new Set;for(let r of e){if(Zd(r))return;if(r.enum!=null&&Lxo(r.enum))r.enum.forEach(i=>t.add(i));else return}return Array.from(t)}function p9p({schemas:e,context:t}){let r={};for(let i of e){let n=_9p({schema:i,context:t});for(let[a,u]of Object.entries(n)){let l=r[a];l!=null?l[u]=i:r[a]={[u]:i}}}for(let[i,n]of Object.entries(r))if(Object.keys(n).length===e.length)return{discriminant:i,schemas:n}}function _9p({schema:e,context:t}){let r=Zd(e)?t.resolveSchemaReference(e):e;return g8D({schema:r,context:t})}function g8D({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let i of e.anyOf){let n=_9p({schema:i,context:t});for(let[a,u]of Object.entries(n??{}))r[a]=u}return r}for(let[i,n]of Object.entries(e.properties??{})){let a=Zd(n)?t.resolveSchemaReference(n):n;a.type==="string"&&a.enum!=null&&Lxo(a.enum)&&O8D(a.enum).length===1&&a.enum[0]!=null&&(r[i]=a.enum[0]);let u=h9p(a,"const");a.type==="string"&&u!=null&&(r[i]=u),i==="type"&&a.example!=null&&(r[i]=a.example)}return r}function O8D(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 h9p(e,t){let r=e[t];if(r!=null)return r}function m8D({schema:e,logger:t}){let r=$5p({schema:e,logger:t});if(r!=null)return k5p(r)}var TSn=class{document;taskContext;logger;DUMMY;options;namespace;static MESSAGE_REFERENCE_PREFIX="#/components/messages/";constructor({document:t,taskContext:r,options:i,namespace:n}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=i,this.namespace=n}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 i=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};i.push(n)}return i.concat(t??[])}resolveSchemaReference(t){if(!t.$ref.startsWith(KRi))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let i=t.$ref.substring(KRi.length).split("/"),n=this.document.components;if(n==null||n.schemas==null)throw new Error("Document does not have components.schemas.");let[a,u,l]=i;if(a==null||a==="")throw new Error(`${t.$ref} cannot be resolved. No schema key provided.`);let d=n.schemas[a];if(d==null)throw new Error(`Schema "${a}" is undefined in document.components.schemas.`);if(Zd(d)&&(d=this.resolveSchemaReference(d)),u==="properties"&&l!=null){let s=d.properties?.[l];if(s==null)throw new Error(`Property "${l}" not found on "${a}". Full ref: ${t.$ref}`);Zd(s)?d=this.resolveSchemaReference(s):d=s}return d}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,i){}markSchemaWithDiscriminantValue(t,r,i){}};var Uxo=class extends TSn{getExampleMessageReference(t){return`#/components/messages/${t.messageId}`}resolveMessageReference(t){let r="#/components/messages/",i=this.document.components;if(i==null||i.messages==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve message reference: ${t.$ref} in v2 components`);let n=t.$ref.substring(r.length),a=i.messages[n];if(a==null)throw new Error(`${t.$ref} is undefined`);return a}};function CSn(e,t){let r={},i={};return e==null?r=t:i={[e]:t},{rootSchemas:r,namespacedSchemas:i}}function Hdi(e){if(typeof e=="string")return rg.primitive(u_.string(e));if(typeof e=="number")return Number.isInteger(e)?rg.primitive(u_.int(e)):rg.primitive(u_.double(e));if(typeof e=="boolean")return rg.primitive(u_.boolean(e));if(Array.isArray(e)){let t=e.map(r=>Hdi(r));return t.length===0?void 0:rg.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,i]of Object.entries(e)){let n=Hdi(i);n!=null&&t.push({key:u_.string(r),value:n})}return rg.map(t)}}function uha(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function y9p(e){if(e!=null&&Array.isArray(e))return e}var $di=class{schemas;nonRequestReferencedSchemas;context;constructor(t,r,i){this.schemas=t,this.nonRequestReferencedSchemas=r,this.context=i}buildExample({schema:t,exampleId:r,example:i,options:n,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:i,options:{...n,maxCheckerDepth:n.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:i,depth:n,visitedSchemaIds:a,options:u,skipReadonly:l}){switch(i.type){case"enum":return typeof r=="string"&&v9p({schema:i,value:r})?rg.enum(r):i.values[0]!=null?rg.enum(i.values[0]?.value):void 0;case"literal":return rg.literal(i.value);case"nullable":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u)))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:l});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(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u))||Object.is(r,null))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:l});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:i.schema,example:r,options:u});return rg.primitive(d)}case"reference":{let d=this.schemas[i.schema];if(d!=null&&!a.has(i.schema)){a.add(i.schema);let s=d?.type==="object"&&!this.nonRequestReferencedSchemas.has(i.schema),o=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:n,options:u,skipReadonly:s||this.context.options.respectReadonlySchemas?l:!1});return a.delete(i.schema),o}return}case"oneOf":switch(i.value.type){case"discriminated":{let d={},s={},o={},c=uha(r),b=c?.[i.value.discriminantProperty],g=i.value.schemas[b],O=[],m=this.getDiscriminatedUnionVariantSchema(i.value,c);m!=null&&O.push(m),O.push(...Object.entries(i.value.schemas));for(let w of O)if(b!=null&&g!=null&&g.type==="object"){s=this.getAllProperties(g),o=this.getAllRequiredProperties(g),d[i.value.discriminantProperty]=rg.primitive(u_.string(b));break}else{let E=this.buildExampleHelper({exampleId:t,schema:w[1],example:void 0,visitedSchemaIds:a,depth:n,options:u,skipReadonly:l});if(E!=null){this.mergeExampleWith(E,d),d[i.value.discriminantProperty]=rg.primitive(u_.string(w[0]));break}}for(let w of i.value.commonProperties){s[w.key]={schema:w.schema,readonly:!1};let E=this.getResolvedSchema(w.schema);E.type!=="optional"&&E.type!=="nullable"&&(o[w.key]=w.schema)}for(let[w,E]of Object.entries(s)){let A=w in o;if(A&&c?.[w]!=null){let q=this.buildExampleHelper({schema:E.schema,exampleId:t,example:c[w],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});if(q!=null)d[w]=q;else return}else{let q=this.buildExampleHelper({exampleId:t,schema:E.schema,example:c?.[w],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});if(q!=null)d[w]=q;else if(A)return}}return rg.oneOf(odi.discriminated(d))}case"undiscriminated":{let d=this.getUnDiscriminatedUnionVariantSchema(i.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:n,options:u,skipReadonly:l});break}}return;case"unknown":if(r!=null){let d=Hdi(r);if(d!=null)return rg.unknown(d)}return u.ignoreOptionals||this.exceedsMaxDepth(n,u)?void 0:u.isParameter?rg.primitive(u_.string(u.name??"string")):rg.map([{key:u_.string("key"),value:rg.primitive(u_.string("value"))}]);case"array":{let d=y9p(r),s=[];if(d!=null&&d.length>0)for(let o of d){let c=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});c!=null&&s.push(c)}else if(i.example!=null&&i.example.length>0)for(let o of i.example){let c=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});c!=null&&s.push(c)}else{let o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});o!=null&&s.push(o)}return rg.array(s)}case"map":{let d=uha(r??i.example);if(d!=null&&Object.entries(d).length>0){let c=[];for(let[b,g]of Object.entries(d)){let O=this.buildExampleFromPrimitive({schema:i.key.schema,example:b,options:u}),m=this.buildExampleHelper({exampleId:t,example:g,schema:i.value,visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});m!=null&&c.push({key:O,value:m})}return rg.map(c)}if(i.key.schema.type==="string"&&i.value.type==="unknown")return rg.map([{key:u_.string("key"),value:rg.unknown(rg.primitive(u_.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:i.key.schema,example:void 0,options:{...u,name:"key"}}),o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,visitedSchemaIds:a,depth:n+1,options:{...u,name:"value"},skipReadonly:l});return o!=null?rg.map([{key:s,value:o}]):rg.map([])}case"object":{let d={},s=i.fullExamples?.find(g=>g.name===t)??i.fullExamples?.find(g=>g.name==null)??i.fullExamples?.[0],o=uha(r)??(s!=null?uha(s.value):{})??{},c=this.getAllProperties(i),b=this.getAllRequiredProperties(i);for(let[g,O]of Object.entries(c)){if(l&&O.readonly)continue;let m=g in b,w=Object.keys(o).includes(g),E=this.buildExampleHelper({schema:O.schema,exampleId:t,example:o[g],visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:l});if(m&&E!=null)d[g]=E;else{if(m)return;(w&&E!=null||!u.ignoreOptionals&&E!=null)&&(d[g]=E)}}if(i.additionalProperties){for(let[g,O]of Object.entries(o))if(!(g in d)){let m=this.buildExampleHelper({schema:El.unknown({example:O,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,groupName:void 0}),exampleId:t,example:O,visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:l});m!=null&&(d[g]=m)}}return rg.object({properties:d})}default:Fo(i)}}mergeExampleWith(t,r){t._visit({array:Jo,enum:Jo,literal:Jo,map:i=>{for(let n of i){let a=n.key;a.type==="string"&&(r[a.value]=n.value)}},object:i=>{for(let[n,a]of Object.entries(i.properties))r[n]=a},oneOf:i=>{if(i.type==="discriminated")for(let[n,a]of Object.entries(i.value))r[n]=a;else this.mergeExampleWith(i.value,r)},primitive:Jo,unknown:Jo,_other:Jo})}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 i=r?.[t.discriminantProperty];if(i==null||typeof i!="string")return Object.entries(t.schemas)[0];let n=t.schemas[i];return n==null?Object.entries(t.schemas)[0]:[i,n]}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 v9p({schema:t,value:r})?5:0;case"object":{if(!kj(r))return 0;let i=this.getAllProperties(t),n=0;for(let[a,u]of Object.entries(i))r[a]!=null?(n++,n+=this.calcExampleHeuristic(u.schema,r[a])):n--;return n}case"array":{if(!Array.isArray(r))return 0;let i=0;for(let n of r)i+=this.calcExampleHeuristic(t.value,n);return i}case"map":{if(!kj(r))return 0;let i=0;for(let[,n]of Object.entries(r))i+=this.calcExampleHeuristic(t.value,n);return i}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let i=this.getResolvedSchema(t);return i==null?0:this.calcExampleHeuristic(i,r)}case"oneOf":return Object.values(t.value.schemas).map(n=>this.calcExampleHeuristic(n,r)).sort((n,a)=>a-n)[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,i=new Set,n){if(this.exceedsMaxCheckerDepth(r,n))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,i,n);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,i,n);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,i,n))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!i.has(t.schema)){i.add(t.schema);let u=this.hasExample(a,r,i,n);return i.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,i,n));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 i of t.properties)r[i.key]={schema:i.schema,readonly:i.readonly??!1};for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let i of t.properties){let n=this.getResolvedSchema(i.schema);n.type!=="optional"&&n.type!=="nullable"&&(r[i.key]=i.schema)}for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);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:i}){switch(r.type){case"string":return t!=null&&typeof t=="string"?u_.string(t):r.example!=null?u_.string(r.example):u_.string(i.name??Sg.STRING);case"base64":return t!=null&&typeof t=="string"?u_.base64(t):r.example!=null?u_.base64(r.example):u_.base64(Sg.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?u_.boolean(t):r.example!=null?u_.boolean(r.example):u_.boolean(Sg.BOOLEAN);case"date":return t!=null&&typeof t=="string"?u_.date(t):r.example!=null?u_.date(r.example):u_.date(Sg.DATE);case"datetime":return t!=null&&typeof t=="string"?u_.datetime(t):r.example!=null?u_.datetime(r.example):u_.datetime(Sg.DATE_TIME);case"double":return t!=null&&typeof t=="number"?u_.double(t):r.example!=null?u_.double(r.example):u_.double(Sg.DOUBLE);case"float":return t!=null&&typeof t=="number"?u_.float(t):r.example!=null?u_.float(r.example):u_.float(Sg.FLOAT);case"int":return t!=null&&typeof t=="number"?u_.int(t):r.example!=null?u_.int(r.example):u_.int(Sg.INT);case"int64":return t!=null&&typeof t=="number"?u_.int64(t):r.example!=null?u_.int64(r.example):u_.int64(Sg.INT64);case"uint":return t!=null&&typeof t=="number"?u_.uint(t):r.example!=null?u_.uint(r.example):u_.uint(Sg.UINT);case"uint64":return t!=null&&typeof t=="number"?u_.uint64(t):r.example!=null?u_.uint64(r.example):u_.uint64(Sg.UINT64);default:Fo(r)}}};function v9p({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function gXt(e){switch(e.type){case"object":return El.object({allOf:e.allOf,properties:e.properties.map(t=>j8D(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,inline:void 0});case"array":return El.array({description:e.description,availability:e.availability,value:gXt(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0});case"enum":return El.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,inline:void 0});case"literal":return El.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 El.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:gXt(e.value),groupName:e.groupName,inline:void 0});case"optional":return El.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:gXt(e.value),groupName:e.groupName,inline:void 0});case"primitive":return El.primitive({description:e.description,availability:e.availability,schema:b9p(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return El.map({description:e.description,availability:e.availability,key:El.primitive({description:e.key.description,availability:e.key.availability,schema:b9p(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,groupName:e.groupName}),value:gXt(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,encoding:e.encoding,example:void 0,inline:void 0});case"reference":return El.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 El.oneOf(P8D(e.value));case"unknown":return El.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,groupName:void 0,description:void 0,availability:void 0});default:Fo(e)}}function P8D(e){switch(e.type){case"discriminated":return QY.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:gXt(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,gXt(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return QY.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>gXt(t)),groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:Fo(e)}}function b9p(e){switch(e.type){case"string":return Xd.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return Xd.base64({example:void 0});case"boolean":return Xd.boolean({default:e.default,example:void 0});case"date":return Xd.date({example:void 0});case"datetime":return Xd.datetime({example:void 0});case"double":return Xd.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 Xd.float({example:void 0});case"int":return Xd.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 Xd.int64({default:e.default,example:void 0});case"uint":return Xd.uint({default:void 0,example:void 0});case"uint64":return Xd.uint64({default:void 0,example:void 0});default:Fo(e)}}function j8D(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:gXt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function Vxo(e){return e.type!=="optional"&&e.type!=="nullable"}function FWs(e){return e==="POST"||e==="PUT"||e==="PATCH"}function sha(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 Wxo=class{schemas;context;exampleTypeFactory;logger;constructor(t,r){this.schemas=t,this.context=r,this.schemas=t,this.exampleTypeFactory=new $di(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=S8D(t.request),i=D8D(t.response);if(r?.type==="unsupported"||i?.type==="unsupported")return[];let n=[];if(r!=null&&r.type==="present"){let c=this.isSchemaRequired(r.schema);if(r.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:FWs(t.method),schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});b!=null&&n.push([void 0,b])}else for(let{name:b,value:g}of r.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:FWs(t.method),schema:r.schema,exampleId:b,example:g,options:{isParameter:!1,ignoreOptionals:!0}});O!=null&&n.push([b,O])}if(c&&n.length===0)return this.logger.trace(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(i!=null&&i.type==="present"){let c=this.isSchemaRequired(i.schema);if(t.response?.type==="json"&&t.response.statusCode===204)a.push([void 0,yze.withoutStreaming(rg.object({properties:{}}))]);else if(i.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:void 0,example:void 0,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});b!=null&&(t.response?.type==="json"?a.push([void 0,yze.withoutStreaming(b)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,yze.withStreaming({sse:t.response?.type==="streamingSse",events:[b]})]))}else for(let{name:b,value:g}of i.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:b,example:g,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});O!=null&&(t.response?.type==="json"?a.push([b,yze.withoutStreaming(O)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,yze.withStreaming({sse:t.response?.type==="streamingSse",events:[O]})]))}if(c&&a.length===0)return this.logger.trace(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let c of t.pathParameters){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!OXt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for path parameter ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&u.push({name:c.name,parameterNameOverride:c.parameterNameOverride,value:g})}let l=[];for(let c of t.queryParameters){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!OXt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for query parameter ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&l.push({name:c.name,value:g})}let d=[];for(let c of t.headers){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!OXt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for header ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&d.push({name:c.name,value:g})}let s=[];t.request!=null&&t.response!=null?s=w8D(n,a):t.request!=null?s=n.map(([c,b])=>({id:c,request:b,response:void 0})):t.response!=null&&(s=a.map(([c,b])=>({id:c,request:void 0,response:b})));let o=t.examples.filter(c=>sha(c)).flatMap(c=>{if(c.type==="unknown"){if(c.value!=null){let b=c.value["code-samples"];if(b!=null)return this.convertCodeSamples(b)}return}else return c.codeSamples}).filter(c=>Qb(c));return s.length===0?[E5t.full({name:void 0,description:void 0,pathParameters:u,queryParameters:l,headers:d,request:void 0,response:void 0,codeSamples:o})]:s.map(({id:c,request:b,response:g})=>E5t.full({name:c,description:void 0,pathParameters:u,queryParameters:l,headers:d,request:b,response:g,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?kJr.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):kJr.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?_V.Csharp:r.sdk,code:r.code})).filter(Qb)}isSchemaRequired(t){return Vxo(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function w8D(e,t){let r=[];if(e.length<=1){let[n,a]=e[0]??[];if(t.length===0)return r.push({id:n,request:a,response:void 0}),r;for(let[u,l]of t)r.push({id:u??n,request:a,response:l});return r}if(t.length<=1){let[n,a]=t[0]??[];if(t.length===0)return r.push({id:n,request:void 0,response:a}),r;for(let[u,l]of e)r.push({id:u??n,request:l,response:a});return r}let i=new Set;for(let[n,a]of e){let u=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(n==null){if(u==null)continue;r.push({id:void 0,request:a,response:u});continue}let l=!1;for(let d=0;d<t.length;d++){let[s,o]=t[d];s==null||i.has(d)||n===s&&(r.push({id:n,request:a,response:o}),s!=null&&i.add(d),l=!0)}!l&&u!=null&&r.push({id:n,request:a,response:u})}for(let n=0;n<t.length;n++){if(i.has(n))continue;let[a,u]=t[n],l=e.find(([d])=>d==null)?.[1]??e[0]?.[1];l!=null&&r.push({id:a,request:l,response:u})}return r}function S8D(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:E8D(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function D8D(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"&&e.type!=="streamingSse"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function OXt(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return OXt(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undiscriminated":return OXt(e.value.value);default:return!1}default:Fo(e)}}function E8D(e){return El.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:gXt(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0,writeonly:void 0,inline:void 0}).filter(Qb),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,inline:void 0})}var BSn=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new $di(t,new Set,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,publish:i,subscribe:n,handshake:a,source:u,namespace:l}){let d=[];for(let s of r){let o=[];for(let g of a.queryParameters){let O=this.isSchemaRequired(g.schema),m=this.exampleTypeFactory.buildExample({schema:g.schema,exampleId:void 0,example:s.queryParameters?.[g.name],options:{name:g.name,isParameter:!0,ignoreOptionals:!0}});m!=null&&!OXt(m)&&(m=void 0),!(O&&m==null)&&m!=null&&o.push({name:g.name,value:m})}let c=[];for(let g of a.headers){let O=this.isSchemaRequired(g.schema),m=this.exampleTypeFactory.buildExample({schema:g.schema,exampleId:void 0,example:s.headers?.[g.name],options:{name:g.name,isParameter:!0,ignoreOptionals:!0}});m!=null&&!OXt(m)&&(m=void 0),!(O&&m==null)&&m!=null&&c.push({name:g.name,value:m})}let b=[];for(let g of s.messages){let O=t.getExampleMessageReference(g),m=t.resolveMessageReference({$ref:O}),w=Zd(m.payload)?t.resolveSchemaReference(m.payload):m.payload,E=this.exampleTypeFactory.buildExample({schema:qb(w,!1,t,[g.messageId],u,l),exampleId:void 0,example:g.value,options:{isParameter:!1,ignoreOptionals:!0}});E!=null&&b.push({messageType:g.type,payload:E,description:void 0})}d.push({name:s.summary,queryParameters:o,headers:c,description:s.description,messages:b})}return d}buildWebsocketSessionExample({publish:t,subscribe:r,handshake:i}){let n={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},a=[];for(let l of i.queryParameters){let d=this.isSchemaRequired(l.schema),s=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(s!=null&&!OXt(s)&&(s=void 0),d&&s==null)return;s!=null&&a.push({name:l.name,value:s})}let u=[];for(let l of i.headers){let d=this.isSchemaRequired(l.schema),s=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(s!=null&&!OXt(s)&&(s=void 0),d&&s==null)return;s!=null&&u.push({name:l.name,value:s})}if(t!=null){let l=this.exampleTypeFactory.buildExample({schema:t,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});l!=null&&n.messages.push({messageType:"publish",payload:l,description:void 0})}if(r!=null){let l=this.exampleTypeFactory.buildExample({schema:r,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});l!=null&&n.messages.push({messageType:"subscribe",payload:l,description:void 0})}return n}isSchemaRequired(t){return Vxo(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 mG={FERN_PARAMETER_OPTIONAL:"x-fern-optional",FERN_CHANNEL_ADDRESS:"x-fern-address",FERN_DISPLAY_NAME:"x-fern-display-name",FERN_SDK_GROUP_NAME:"x-fern-sdk-group-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path",FERN_ENUM:"x-fern-enum",IGNORE:"x-fern-ignore"};function Hxo(e){return yf(e,mG.FERN_EXAMPLES)??[]}function $xo(e,t){return t.includes("://")?t:`${e}://${t}`}function Gxo(e){return e.startsWith("/")?e:"/"+e}function m9p({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},u={};for(let[s,o]of Object.entries(n.components?.schemas??{})){let c=qb(o,!1,e,[s],r,e.namespace);a[s]=c}let l=new BSn(a,e),d={};for(let[s,o]of Object.entries(n.servers??{}))d[s]={name:s,url:$xo(o.protocol,o.url)};for(let[s,o]of Object.entries(n.channels??{})){let c=yf(o,mG.IGNORE);if(c!=null&&c){e.logger.debug(`Channel ${s} is marked with x-fern-ignore. Skipping.`);continue}let b=[];if(o.parameters!=null)for(let[E,A]of Object.entries(o.parameters??{}))b.push({name:E,description:A.description,parameterNameOverride:void 0,schema:A.schema!=null?qb(A.schema,!1,e,t,r,e.namespace):El.primitive({schema:Xd.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:Bie(A),source:r});let g=[],O=[];if(o.bindings?.ws!=null){if(o.bindings.ws.headers!=null){let E=o.bindings.ws.headers.required??[];for(let[A,q]of Object.entries(o.bindings.ws.headers.properties??{})){let D=Zd(q)?e.resolveSchemaReference(q):q;g.push({name:A,schema:qb(D,!E.includes(A),e,[...t,A],r,e.namespace),description:D.description,parameterNameOverride:void 0,env:void 0,availability:Bie(D),source:r})}}if(o.bindings.ws.query!=null){let E=o.bindings.ws.query.required??[];for(let[A,q]of Object.entries(o.bindings.ws.query.properties??{})){let D=Zd(q)?e.resolveSchemaReference(q):q;O.push({name:A,schema:qb(D,!E.includes(A),e,[...t,A],r,e.namespace),description:D.description,parameterNameOverride:void 0,availability:Bie(D),source:r})}}}let m;o.publish!=null&&("oneOf"in o.publish.message?m=g9p({generatedName:o.publish.operationId??"PublishEvent",event:o.publish,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):m=O9p({action:"Publish",channelPath:s,message:o.publish.message,context:e,source:r}));let w;if(o.subscribe!=null&&("oneOf"in o.subscribe.message?w=g9p({generatedName:o.subscribe.operationId??"SubscribeEvent",event:o.subscribe,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):w=O9p({action:"Subscribe",channelPath:s,message:o.subscribe.message,context:e,source:r})),g.length>0||O.length>0||m!=null||w!=null){let E=Hxo(o),A=[];if(E.length>0)A=l.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:E,handshake:{headers:g,queryParameters:O},publish:m,subscribe:w,source:r,namespace:e.namespace});else{let C=l.buildWebsocketSessionExample({handshake:{headers:g,queryParameters:O},publish:m,subscribe:w});C!=null&&A.push(C)}let q=yf(o,mG.FERN_CHANNEL_ADDRESS),D=q??Gxo(s);u[s]={audiences:yf(o,fd.AUDIENCES)??[],handshake:{headers:g.map(C=>({...C,schema:cE(C.schema),env:C.env})),queryParameters:O.map(C=>({...C,schema:cE(C.schema)})),pathParameters:b.map(C=>({...C,parameterNameOverride:void 0,schema:cE(C.schema)}))},groupName:[yf(o,mG.FERN_SDK_GROUP_NAME)??s],publish:m!=null?cE(m):m,subscribe:w!=null?cE(w):w,servers:(o.servers?.map(C=>d[C])??Object.values(d)).filter(C=>C!=null),summary:yf(o,mG.FERN_DISPLAY_NAME),path:D,description:o.description,examples:A,source:r}}}return{groupedSchemas:CSn(e.namespace,a),channels:u??void 0,servers:Object.values(d),basePath:yf(n,mG.BASE_PATH)}}function g9p({generatedName:e,event:t,context:r,breadcrumbs:i,source:n,options:a,asyncApiOptions:u}){if("oneOf"in t.message&&t.message.oneOf!=null){let l=[],d=[];for(let s of t.message.oneOf){let o,c={type:"notFound"};if(Zd(s)){let b=r.resolveMessageReference(s);!Zd(b.payload)&&u.naming==="v2"?(c=b.name?{type:"name",name:b.name}:c,o={...b.payload,title:b.name??b.payload.title,description:b.name??b.payload.description}):o=b.payload}else o=s;d.push(c),l.push(o)}return MSn({description:t.description??t.message.description,availability:Bie(t.message),subtypes:l,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:i,context:r,encoding:void 0,source:n,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?d:[]})}}function O9p({action:e,channelPath:t,message:r,context:i,source:n}){if(r.payload!=null){let a=r.payload;return Zd(r.payload)&&(a=i.resolveSchemaReference(r.payload)),Zd(a)?qb(a,!1,i,[t,e],n,i.namespace):qb(a,!1,i,[t,e],n,i.namespace)}}var Qxo=class extends TSn{getExampleMessageReference(t){return`#/channels/${t.channelId}/messages/${t.messageId}`}resolveMessageReference(t){let r="#/channels/",i="#/components/messages/";if(t.$ref.startsWith(r)){let l=t.$ref.split("/"),d=l[2],s=l[4];if(d==null||s==null||!this.document.channels?.[d])throw new Error(`Failed to resolve message reference ${t.$ref} in channel ${d}`);let c=this.document.channels[d].messages?.[s];if(c==null)throw new Error(`${t.$ref} is undefined`);return{name:s,...c}}let n=this.document.components;if(!t.$ref.startsWith(i)||!n?.messages)throw new Error(`Failed to resolve message reference: ${t.$ref} in v3 components`);let a=t.$ref.substring(i.length),u=n.messages[a];if(u==null)throw new Error(`${t.$ref} is undefined`);return{name:a,...u}}};var P9p="#/channels/",j9p="#/servers/",LWs="$message.";function S9p({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},u={},l={},d=[],s={};for(let[m,w]of Object.entries(n.components?.schemas??{}))a[m]=qb(w,!1,e,[m],r,e.namespace);for(let[m,w]of Object.entries(n.channels??{}))if(u[m]||(u[m]={}),w.messages)for(let[E,A]of Object.entries(w.messages))A&&A.payload!=null&&(l[E]||(l[E]=[]),l[E].push({channelId:m,payload:A.payload}));for(let[m,w]of Object.entries(l))if(w.length===1){let E=w[0],A=E.channelId;u[A]=u[A]||{},u[A][m]=qb(E.payload,!1,e,[m],r,e.namespace)}else{d.push(m);for(let{channelId:E,payload:A}of w){let q=`${E}_${m}`;u[E]||(u[E]={}),u[E][q]=qb(A,!1,e,[q],r,e.namespace)}}let o=Object.values(u).reduce((m,w)=>({...m,...w}),{}),c=new BSn(o,e),b={};for(let[m,w]of Object.entries(n.servers??{}))b[m]={name:m,url:$xo(w.protocol,w.host)};let g={};for(let[m,w]of Object.entries(n.operations??{})){if(yf(w,mG.IGNORE))continue;let E=M8D(w);if(g[E]||(g[E]={subscribe:[],publish:[]}),w.action==="receive")g[E].subscribe.push(...w.messages);else if(w.action==="send")g[E].publish.push(...w.messages);else throw new Error(`Operation ${m} has an invalid action: ${w.action}`)}let O={};for(let[m,w]of Object.entries(g)){O[m]={subscribe:void 0,publish:void 0};let E=m.split("/").pop()??m,A=E.charAt(0).toUpperCase()+E.slice(1);w.subscribe.length>0&&u[m]!=null&&(O[m].subscribe=w9p({generatedName:A+"SubscribeEvent",channelPath:m,messages:w.subscribe,breadcrumbs:t,context:e,source:r,messageSchemas:u[m],duplicatedMessageIds:d})),w.publish.length>0&&u[m]!=null&&(O[m].publish=w9p({generatedName:A+"PublishEvent",channelPath:m,messages:w.publish,breadcrumbs:t,context:e,source:r,messageSchemas:u[m],duplicatedMessageIds:d}))}for(let[m,w]of Object.entries(n.channels??{})){if(yf(w,mG.IGNORE))continue;let E=[],A=[],q=[];if(w.parameters!=null)for(let[D,C]of Object.entries(w.parameters)){let{type:R,parameterKey:$}=A8D(C.location),I=yf(C,mG.FERN_PARAMETER_OPTIONAL),U=G3(Dg(m))+G3(Dg(D)),H=yf(C,mG.FERN_ENUM),k=C.enum!=null&&Array.isArray(C.enum)?T8D({parameterName:U,fernEnum:H,parameterDescription:C.description,enumValues:C.enum,defaultValue:C.default,context:e,source:r}):El.primitive({schema:Xd.string({default:C.default,pattern:void 0,format:void 0,maxLength:void 0,minLength:void 0,example:C.examples?.[0]}),description:void 0,availability:void 0,generatedName:"",title:U,groupName:void 0,nameOverride:void 0});I&&(k=El.optional({value:k,description:void 0,availability:void 0,generatedName:"",title:U,groupName:void 0,nameOverride:void 0,inline:void 0}));let K={name:$,description:C.description,parameterNameOverride:void 0,schema:k,variableReference:void 0,availability:Bie(C),source:r};R==="header"?E.push({...K,env:void 0}):R==="path"?A.push(K):R==="payload"&&q.push(K)}if(E.length>0||q.length>0||O[m]!=null&&(O[m].publish!=null||O[m].subscribe!=null)){let D=Hxo(w),C=[];if(D.length>0)C=c.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:D,handshake:{headers:E,queryParameters:q},publish:O[m]?.publish,subscribe:O[m]?.subscribe,source:r,namespace:e.namespace});else{let R=c.buildWebsocketSessionExample({handshake:{headers:E,queryParameters:q},publish:O[m]?.publish,subscribe:O[m]?.subscribe});R!=null&&C.push(R)}s[m]={audiences:yf(w,fd.AUDIENCES)??[],handshake:{headers:E.map(R=>({...R,schema:cE(R.schema),env:R.env})),queryParameters:q.map(R=>({...R,schema:cE(R.schema)})),pathParameters:A.map(R=>({...R,parameterNameOverride:void 0,schema:cE(R.schema)}))},groupName:[yf(w,mG.FERN_SDK_GROUP_NAME)??m],publish:O[m]?.publish!=null?cE(O[m].publish):void 0,subscribe:O[m]?.subscribe!=null?cE(O[m].subscribe):void 0,summary:yf(w,mG.FERN_DISPLAY_NAME),servers:w.servers?.map(R=>q8D(b,R))??Object.values(b),path:w.address??Gxo(m),description:w.description,examples:C,source:r}}}return{groupedSchemas:CSn(e.namespace,a),channels:s,servers:Object.values(b),basePath:yf(n,mG.BASE_PATH)}}function M8D(e){if(!e.channel.$ref.startsWith(P9p))throw new Error(`Failed to resolve channel path from operation ${e.channel.$ref}`);return e.channel.$ref.substring(P9p.length)}function A8D(e){try{let[t,r]=e.split("#/");if(t==null||r==null)throw new Error(`Invalid location format: ${e}; unable to parse message type and parameter key`);if(!t.startsWith(LWs))throw new Error(`Invalid location format: ${e}; expected ${LWs} prefix`);let i=t.substring(LWs.length);if(i!=="header"&&i!=="path"&&i!=="payload")throw new Error(`Invalid message type: ${i}. Must be one of: header, path, payload`);return{type:i,parameterKey:r}}catch{throw new Error(`Invalid location format: ${e}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`)}}function q8D(e,t){if(!t.$ref.startsWith(j9p))throw new Error(`Failed to resolve server name from server ref ${t.$ref}`);let r=t.$ref.substring(j9p.length),i=e[r];if(i==null)throw new Error(`Failed to find server with name ${r}`);return i}function T8D({parameterName:e,fernEnum:t,parameterDescription:r,enumValues:i,defaultValue:n,context:a,source:u}){return bXt({nameOverride:void 0,generatedName:e,title:void 0,wrapAsNullable:!1,description:r??void 0,availability:void 0,fernEnum:t??{},enumVarNames:void 0,enumValues:i,_default:n,groupName:void 0,context:a,source:u,inline:void 0})}function w9p({generatedName:e,channelPath:t,messages:r,context:i,breadcrumbs:n,source:a,messageSchemas:u,duplicatedMessageIds:l}){if(r.length>0){let d=[];for(let s of r){let o=i.resolveMessageReference(s),c;l.some(g=>g===o.name)?c=`${t}_${o.name}`:c=o.name;let b=u[c];b!=null&&d.push(b)}return o9p({description:void 0,availability:void 0,subtypes:d,nameOverride:void 0,generatedName:e,title:void 0,groupName:void 0,wrapAsNullable:!1,breadcrumbs:n,context:i,encoding:void 0,source:a,namespace:i.namespace,subtypePrefixOverrides:[]})}}function D9p({document:e,taskContext:t,options:r,source:i,asyncApiOptions:n,namespace:a}){let u=[];if(a!=null&&u.push(a),parseFloat(e.asyncapi)<3){let l=e;l.tags?.[0]!=null?u.push(l.tags[0].name):n.naming!=="v2"&&u.push("websocket");let d=new Uxo({document:l,taskContext:t,options:r,namespace:a});return m9p({context:d,breadcrumbs:u,source:i,asyncApiOptions:n,document:l})}else{let l=e,d=new Qxo({document:l,taskContext:t,options:r,namespace:a});return S9p({context:d,breadcrumbs:u,source:i,asyncApiOptions:n,document:l})}}function E9p(e){let t=C8D(e),r={};return UWs({obj:t,occurrences:r,breadcrumbs:[]}),r}function UWs({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let i of e)UWs({obj:i,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let i=e.$ref;t[i]==null?t[i]=1:t[i]+=1;return}for(let i in e)UWs({obj:e[i],occurrences:t,breadcrumbs:[...r,i]})}}}function C8D(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?cha(r.get):void 0,put:r?.put!=null?cha(r.put):void 0,post:r?.post!=null?cha(r.post):void 0,patch:r?.patch!=null?cha(r.patch):void 0,delete:r?.delete!=null?cha(r.delete):void 0}]))}}function cha(e){return{...e,requestBody:e.requestBody!=null?Zd(e.requestBody)?e.requestBody:B8D(e.requestBody):void 0}}function B8D(e){let t,r;for(let i in e.content){let n=JB.parse(i);n!=null&&(n.isJSON()?t=e.content[i]:n.isMultipart()&&(r=e.content[i]))}return r!=null&&t!=null?{...e,content:{[JB.MULTIPART_FORM_DATA]:r}}:e}var Jxo=class{endpoints;parser=new MBi;constructor({context:t,options:r}){this.endpoints=r.filter?.endpoints?new Set(this.validateAndFilterEndpoints({context:t,endpoints:r.filter.endpoints})):void 0}skipEndpoint({method:t,path:r}){return this.endpoints!=null&&!this.endpoints.has(`${t} ${r}`)}hasEndpoints(){return this.endpoints!=null}validateAndFilterEndpoints({context:t,endpoints:r}){let i=[];for(let n of r){let a=this.parser.tryParse(n);if(a==null){t.logger.debug(`Ignoring configured filter endpoint "${n}"; expected format "POST /users/get"`);continue}i.push(`${a.method} ${a.path}`)}return i}};var M9p="#/components/parameters/",A9p="#/components/responses/",q9p="#/components/examples/",T9p="#/components/requestBodies/",xSn=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;filter;namespace;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=i,this.refOccurrences=E9p(t),this.options=n,this.source=a,this.filter=new Jxo({context:r,options:n}),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 i={type:"namespace",name:this.namespace};r.push(i)}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(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return{"x-fern-type":"unknown"};i=i[n]}return i==null?(this.logger.warn(`Encountered undefined reference: ${t.$ref}`),{"x-fern-type":"unknown"}):(Zd(i)&&(i=this.resolveSchemaReference(i)),i)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(M9p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(M9p.length),i=this.document.components.parameters[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return Zd(i)?this.resolveParameterReference(i):i}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(T9p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(T9p.length),i=this.document.components.requestBodies[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return Zd(i)?this.resolveRequestBodyReference(i):i}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(A9p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(A9p.length),i=this.document.components.responses[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return Zd(i)?this.resolveResponseReference(i):i}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(q9p))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(q9p.length),i=this.document.components.examples[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return Zd(i)?this.resolveExampleReference(i):i}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}};var ISn=class extends xSn{constructor({document:t,taskContext:r,options:i,source:n,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:i,source:n,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,i){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,i){}getDiscriminatedUnionMetadata(t){}};var Kxo=class extends xSn{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discriminatedUnionReferences={};discriminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u})}getDummy(){return new ISn({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,i){let n=this.discriminatedUnionReferences[t.$ref];n!=null?(n.discriminants.add(r),n.numReferences+=i):this.discriminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:i}}getReferencesFromDiscriminatedUnion(t){return this.discriminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,i){let n=this.discriminatedUnionMetadata[t.$ref];n!=null?n.discriminants.set(r,i):this.discriminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,i]])}}getDiscriminatedUnionMetadata(t){return this.discriminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function C9p(e){return yf(e,fd.ASYNC_CONFIG)}var B9p="$request.";function x9p(e){let t=yf(e,fd.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:x8D(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function x8D(e){return e.startsWith(B9p)?e.slice(B9p.length):e}function I9p(e){let t=e;if(t.cursor!=null)return hze.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});if("offset"in e){let r=e;return hze.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}if("type"in e&&e.type==="custom"){let r=e;return hze.custom({results:r.results})}throw new Error("Invalid pagination extension")}function z9p(e,t){let r=yf(t,fd.PAGINATION);if(r!=null){if(typeof r=="boolean"){let i=yf(e,fd.PAGINATION);if(typeof i=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return i==null?void 0:I9p(i)}return I9p(r)}}var I8D=Yu.object({lang:Yu.string(),label:Yu.optional(Yu.string()),source:Yu.string()}),VWs=Yu.array(I8D);var R9p={README_EXT:"x-readme"};function z8D(e){if(!Array.isArray(e))return!1;for(let t of e)if(!kj(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function N9p(e){let t=yf(e,R9p.README_EXT);if(!kj(t))return[];let r=t["code-samples"];if(!z8D(r))return[];let i=[];for(let n of r)i.push({name:n.name,language:n.language,code:n.code,install:n.install,docs:void 0});return i}function F9p(e,t,r){let n=(yf(t,fd.EXAMPLES)??[]).filter(s=>{let o=l2.serialization.ExampleEndpointCallSchema.parse(s);return o.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),o.ok}),a=aha(t,mV.REDOCLY_CODE_SAMPLES_KEBAB,VWs,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],l=[...aha(t,mV.REDOCLY_CODE_SAMPLES_CAMEL,VWs,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...a];l.length>0&&n.push({"code-samples":l.map(s=>({name:s.label??s.lang,language:s.lang,code:s.source,install:void 0,docs:void 0}))});let d=N9p(t);return d.length>0&&n.push({"code-samples":d}),n.map(E5t.unknown)}function L9p(e){let t=yf(e,fd.AVAILABILITY);if(t==="ga"||t==="generally-available")return pV.GenerallyAvailable;if(t==="beta"||t==="pre-release")return pV.Beta;if(t==="deprecated")return pV.Deprecated;if(e.deprecated)return pV.Deprecated}function Yxo(e){return{url:R8D({url:e.url,variables:e.variables??{}}),description:e.description,name:N8D(e),audiences:yf(e,fd.AUDIENCES)}}function R8D({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([i,n])=>[i,n.default]));for(let[i,n]of Object.entries(r))e=e.replace(`{${i}}`,n);return e}function N8D(e){let t=yf(e,[fd.SERVER_NAME_V1,fd.SERVER_NAME_V2]);if(t!=null)return t;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox"}function U9p(e){return yf(e,fd.PARAMETER_NAME)}function V9p(e){return yf(e,fd.SDK_VARIABLE)}function Xxo({path:e,httpMethod:t,parameters:r,context:i,requestBreadcrumbs:n,source:a}){let u={pathParameters:[],queryParameters:[],headers:[]};for(let l of r){let d=yf(l,fd.IGNORE);if(d!=null&&d){i.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let s=Zd(l)?i.resolveParameterReference(l):l,o=s.required??!1,c=Bie(s),b=[...n,s.name],g=D2(b,i.options.preserveSchemaIds),O=s.schema!=null?qb(s.schema,!o,i,b,a,i.namespace,!1,new Set,_Kr({schema:s,logger:i.logger})):o?El.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:_Kr({schema:s,logger:i.logger})}),description:void 0,availability:c,groupName:void 0}):El.optional({nameOverride:void 0,generatedName:g,title:void 0,value:El.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:Xd.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:_Kr({schema:s,logger:i.logger})}),description:void 0,availability:void 0,groupName:void 0}),description:void 0,availability:c,groupName:void 0,inline:void 0});if(s.in==="header"&&s.schema!=null&&!Zd(s.schema)&&s.schema.default!=null){let w=s.schema.default;typeof w=="string"&&w.length>0&&(O=El.literal({nameOverride:void 0,generatedName:g,title:void 0,value:cx.string(w),description:void 0,availability:c,groupName:void 0}))}let m={name:s.name,schema:O,description:s.description,parameterNameOverride:U9p(s),availability:c,source:a};s.in==="query"?u.queryParameters.push(m):s.in==="path"?u.pathParameters.push({...m,variableReference:V9p(s)}):s.in==="header"?!F8D.has(s.name.toLowerCase())&&!i.authHeaders.has(s.name)?u.headers.push({...m,env:void 0}):i.logger.debug(`Ignoring ${s.name} header, in ${t.toUpperCase()} ${e}`):i.logger.warn(`Skipping ${s.in} parameter, ${s.name}, in ${t.toUpperCase()} ${e}`)}return u}var F8D=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function W9p(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r,schema:n??{},examples:lha(i,t)}}}function zSn(e,t){for(let r of Object.keys(e))if(r.includes("json")||r==="*/*"){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r.includes("*")?void 0:r,schema:n??{},examples:lha(i,t)}}}function H9p(e,t){for(let r of Object.keys(e)){let i=e[r];if(i==null)continue;return{schema:i.schema??{},examples:lha(i,t)}}}function lha(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let i=yf(e,mV.EXAMPLES);return i!=null&&Object.keys(i).length>0&&r.push(...Object.entries(i).map(([n,a])=>({name:a.summary??n,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([n,a])=>{let u=Zd(a)?t.resolveExampleReference(a):a;return{name:u.summary??n,value:u.value,description:u.description}})),r}function L8D(e,t){for(let[r,i]of Object.entries(e.content))if(JB.parse(r)?.isURLEncoded())return{schema:i.schema,contentType:r,examples:lha(i,t)}}function U8D(e){for(let[t,r]of Object.entries(e.content))if(JB.parse(t)?.isMultipart())return{schema:r.schema,encoding:r.encoding}}function V8D(e){for(let t in e.content)if(JB.parse(t)?.isOctetStream())return!0;return!1}function W8D(e,t){let r=Zd(e)?WWs(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([i,n])=>!Zd(n)&&n.type==="string"&&n.format==="binary")!=null}function RSn({requestBody:e,document:t,context:r,requestBreadcrumbs:i,source:n,namespace:a}){let u=Zd(e)?r.resolveRequestBodyReference(e):e,l=U8D(u),d=l?.schema,s=l?.encoding,o=L8D(u,r),c=zSn(u.content,r);if(V8D(u))return VSe.octetStream({description:u.description,source:n});if(d!=null&&c==null||d!=null&&W8D(d,t)){let b=Zd(d)?WWs(d,t):{id:void 0,schema:d},g=qb(b.schema,!1,r,i,n,a),O=[];if(g.type==="object")for(let m of g.properties){if(m.schema.type==="primitive"&&m.schema.schema.type==="string"&&m.schema.schema.format==="binary"){O.push({key:m.key,schema:vze.file({isOptional:!1,isArray:!1,description:void 0}),description:m.schema.description,contentType:s?.[m.key]?.contentType,exploded:!1,encoding:void 0});continue}if(m.schema.type==="optional"&&m.schema.value.type==="primitive"&&m.schema.value.schema.type==="string"&&m.schema.value.schema.format==="binary"){O.push({key:m.key,schema:vze.file({isOptional:!0,isArray:!1,description:m.schema.value.description}),description:m.schema.value.description,contentType:s?.[m.key]?.contentType,exploded:!1,encoding:void 0});continue}if(m.schema.type==="array"&&m.schema.value.type==="primitive"&&m.schema.value.schema.type==="string"&&m.schema.value.schema.format==="binary"){O.push({key:m.key,schema:vze.file({isOptional:!1,isArray:!0,description:m.schema.value.description}),description:m.schema.description,contentType:s?.[m.key]?.contentType,exploded:!1,encoding:void 0});continue}if(m.schema.type==="optional"&&m.schema.value.type==="array"&&m.schema.value.value.type==="primitive"&&m.schema.value.value.schema.type==="string"&&m.schema.value.value.schema.format==="binary"){O.push({key:m.key,schema:vze.file({isOptional:!0,isArray:!0,description:m.schema.value.value.description}),description:m.schema.value.description,contentType:s?.[m.key]?.contentType,exploded:!1,encoding:void 0});continue}let w=s?.[m.key]?.contentType;O.push({key:m.key,schema:vze.json(m.schema),description:void 0,contentType:s?.[m.key]?.contentType,exploded:s?.[m.key]?.explode,encoding:w==null?r.options.defaultFormParameterEncoding:void 0})}return VSe.multipart({name:Zd(d)&&r.getNumberOfOccurrencesForRef(d)===1?b.id:void 0,description:b.schema.description,properties:O,source:n})}if(c!=null){let b=qb(c.schema,!1,r,i,n,a,!0);return VSe.json({description:void 0,schema:b,contentType:c.contentType,fullExamples:c.examples,additionalProperties:!Zd(c.schema)&&SSn(c.schema.additionalProperties),source:n})}if(o!=null&&o.schema!=null){let b=qb(o.schema,!1,r,i,n,a);return VSe.json({schema:b,description:u.description,contentType:o.contentType,source:n,fullExamples:o.examples,additionalProperties:!1})}}function WWs(e,t){if(!e.$ref.startsWith(KRi))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=Wdi(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let i=t.components?.schemas?.[r];if(i==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return Zd(i)?WWs(i,t):{id:r,schema:i}}var HWs={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",498:"InvalidTokenError",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"},$9p=new Set(Object.values(HWs));var H8D=["200","201","202","204"];function Q9p({operationContext:e,responses:t,context:r,responseBreadcrumbs:i,responseStatusCode:n,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let l=$8D({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,s;for(let o of n!=null?[n]:H8D){let c=t[o];c!=null&&(d=!0,s==null&&(s=G9p({operationContext:e,response:c,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace,statusCode:typeof o=="string"?parseInt(o):o})))}if(s==null&&!d&&t.default!=null&&(s=G9p({operationContext:e,response:t.default,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace})),s!=null)switch(s.type){case"json":return{value:s,errors:l};case"streamingJson":case"streamingSse":return{value:s,errors:l};case"file":case"text":case"streamingText":return{value:s,errors:l};default:Fo(s)}return{value:void 0,errors:l}}function G9p({operationContext:e,streamFormat:t,response:r,context:i,responseBreadcrumbs:n,source:a,namespace:u,statusCode:l}){let d=Zd(r)?i.resolveResponseReference(r):r;if(d.content!=null&&Object.entries(d.content).find(([b,g])=>{if(g.schema==null)return!1;let O=Zd(g.schema)?i.resolveSchemaReference(g.schema):g.schema;return O.type==="string"&&O.format==="binary"}))return lx.file({description:d.description,source:a,statusCode:l});let s=W9p(d.content??{},i);if(s!=null&&t!=null)switch(t){case"json":return lx.streamingJson({statusCode:l,description:d.description,responseProperty:yf(e.operation,fd.RESPONSE_PROPERTY),fullExamples:s.examples,schema:qb(s.schema,!1,i,n,a,u),source:a});case"sse":return lx.streamingSse({description:d.description,responseProperty:void 0,fullExamples:s.examples,schema:qb(s.schema,!1,i,n,a,u),source:a,statusCode:l})}let o=zSn(d.content??{},i);if(o!=null){if(t!=null)switch(t){case"json":return lx.streamingJson({description:d.description,responseProperty:void 0,fullExamples:o.examples,schema:qb(o.schema,!1,i,n,a,u),source:a,statusCode:l});case"sse":return lx.streamingSse({description:d.description,responseProperty:void 0,fullExamples:o.examples,schema:qb(o.schema,!1,i,n,a,u),source:a,statusCode:l})}return lx.json({description:d.description,schema:qb(o.schema,!1,i,n,a,u),responseProperty:yf(e.operation,fd.RESPONSE_PROPERTY),fullExamples:o.examples,source:a,statusCode:l})}for(let[c,b]of Object.entries(d.content??{})){let g=JB.parse(c);if(g!=null){if(g.isOctetStream()||g.isPDF()||g.isAudio()||g.isImage()||g.isVideo())return lx.file({description:d.description,source:a,statusCode:l});if(g.isPlainText()){let O=b.schema;if(O==null)return lx.text({description:d.description,source:a,statusCode:l});let m=Zd(O)?i.resolveSchemaReference(O):O;return m.type==="string"&&m.format==="byte"?lx.file({description:d.description,source:a,statusCode:l}):lx.text({description:d.description,source:a,statusCode:l})}}}}function $8D({responses:e,context:t,source:r,namespace:i}){let n={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let l=parseInt(a);if(l<400||l>600)continue;let d=Zd(u)?t.resolveResponseReference(u):u,s=H9p(d.content??{},t),o=HWs[l];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}n[l]={statusCode:l,nameOverride:void 0,generatedName:o,description:d.description,schema:qb(s?.schema??{},!1,t,[o,"Body"],r,i),fullExamples:s?.examples,source:r}}return n}function hKr({operationContext:e,context:t,responseStatusCode:r,suffix:i,streamFormat:n,source:a}){let{document:u,operation:l,path:d,method:s,baseBreadcrumbs:o,sdkMethodName:c}=e,b=yf(l,fd.IDEMPOTENT),g=yf(l,[fd.REQUEST_NAME_V1,fd.REQUEST_NAME_V2]),O=[...o,"Request"],m=Xxo({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:O,path:d,httpMethod:s,source:a}),w=/{([^}]+)}/g,A=[...d.matchAll(w)].map(U=>U[1]).filter(U=>!m.pathParameters.some(H=>H.name===U));if(A.length>0)for(let U of A)m.pathParameters.push({name:U??"",variableReference:void 0,parameterNameOverride:void 0,availability:void 0,source:a,schema:El.primitive({schema:Xd.string({default:void 0,example:void 0,format:void 0,maxLength:void 0,minLength:void 0,pattern:void 0}),description:void 0,generatedName:"",nameOverride:void 0,groupName:void 0,availability:void 0,title:void 0}),description:void 0});let q=l.requestBody!=null?RSn({requestBody:l.requestBody,document:u,context:new ISn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:O,source:a,namespace:t.namespace}):void 0;Q8D({context:t,convertedParameters:m})&&q!=null&&q.type==="json"&&q.schema.type!=="object"&&l.requestBody!=null?q=RSn({requestBody:l.requestBody,document:u,context:t,requestBreadcrumbs:[...O,"Body"],source:a,namespace:t.namespace}):l.requestBody!=null&&(q=RSn({requestBody:l.requestBody,document:u,context:t,requestBreadcrumbs:[...O],source:a,namespace:t.namespace}));let D=[...o,"Response"],C=Q9p({operationContext:e,streamFormat:n,responses:l.responses,context:t,responseBreadcrumbs:D,responseStatusCode:r,source:a});e.method==="GET"&&(q=void 0);let R=L9p(l),$=F9p(e,l,t),I=yf(l,fd.SERVER_NAME_V2);return{summary:l.summary,internal:yf(l,mV.INTERNAL),idempotent:b,audiences:yf(l,fd.AUDIENCES)??[],operationId:l.operationId!=null&&i!=null?l.operationId+"_"+i:l.operationId,tags:t.resolveTagsToTagIds(l.tags),namespace:t.namespace,sdkName:c,pathParameters:m.pathParameters,queryParameters:m.queryParameters,headers:m.headers,requestNameOverride:g??void 0,generatedRequestName:D2(O,t.options.preserveSchemaIds),request:q,response:C.value,errors:C.errors,servers:I!=null?[{name:I,url:void 0,audiences:void 0}]:(l.servers??[]).map(U=>Yxo(U)),description:l.description,authed:G8D(l,u),availability:R,method:s,path:d,examples:$,pagination:e.pagination,source:a}}function G8D(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function Q8D({context:e,convertedParameters:t}){return e.options.inlinePathParameters&&t.pathParameters.length>0||t.queryParameters.length>0||t.headers.length>0}function K9p({operationContext:e,context:t,asyncExtension:r,source:i}){let{operation:n,pathItemParameters:a,operationParameters:u}=e,l=r.discriminant.name,d=r.discriminant.value,s=r["response-status-code"],o=J9p({context:t,headerToIgnore:l,parameters:a}),c=J9p({context:t,headerToIgnore:l,parameters:u}),b=hKr({operationContext:{...e,pathItemParameters:o,operationParameters:c,operation:{...n,responses:Object.fromEntries(Object.entries(n.responses).filter(([O])=>parseInt(O)!==s))}},context:t,streamFormat:void 0,source:i}),g=hKr({operationContext:{...e,pathItemParameters:o,operationParameters:c,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:s,streamFormat:void 0,source:i});return g.headers.push({name:l,schema:El.literal({nameOverride:void 0,generatedName:D2([l],t.options.preserveSchemaIds),title:void 0,description:void 0,availability:void 0,value:cx.string(d),groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:i}),{sync:b,async:g}}function J9p({context:e,headerToIgnore:t,parameters:r}){return r.filter(i=>{let n=Zd(i)?e.resolveParameterReference(i):i;return!(n.in==="header"&&n.name===t)})}var $Ws="stream";function k9p({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:hKr({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let i=Y9p({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(i?.schemaReference!=null){let s=Wdi(i.schemaReference);s!=null&&t.excludeSchema(s)}let n=X9p({operation:e.operation,response:r.responseStream}),a=hKr({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+$Ws}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:i?.requestBody,responses:n},baseBreadcrumbs:[...e.baseBreadcrumbs,$Ws]},context:t,streamFormat:r.format,suffix:$Ws,source:t.source});a.examples=a.examples.filter(s=>Z9p(s,t)!==!1);let u=Y9p({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),l=X9p({operation:e.operation,response:r.response}),d=hKr({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u?.requestBody,responses:l}},context:t,source:t.source});return d.examples=d.examples.filter(s=>Z9p(s,t)!==!0),{streaming:a,nonStreaming:d}}default:Fo(r)}}function Y9p({context:e,operation:t,streamingExtension:r,isStreaming:i}){if(t.requestBody==null)return;let n=Zd(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=zSn(n.content,e);if(a==null)return;let u=Zd(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let l=u.properties?.[r.streamConditionProperty];l!=null&&Zd(l)&&(l=void 0);let d={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":i,...l??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[JB.APPLICATION_JSON]:{schema:d}}},schemaReference:Zd(a.schema)?a.schema:void 0}}function X9p({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[JB.APPLICATION_JSON]:{schema:t}}}}}function Z9p(e,t){return e._visit({unknown:r=>{let i=l2.serialization.ExampleEndpointCallSchema.parse(r);if(i.ok&&i.value.response!=null)return i.value.response.stream!=null},full:()=>{},_other:()=>{}})}function eLp({context:e,operationContext:t,source:r}){let{document:i,operation:n,path:a,method:u,baseBreadcrumbs:l,sdkMethodName:d}=t,s=[...l,"Payload"],o=Xxo({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:s,path:a,httpMethod:u,source:r});if(n.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 c=RSn({requestBody:n.requestBody,document:i,context:e,requestBreadcrumbs:[...l,"Payload"],source:r,namespace:e.namespace});if(c==null||c.type!=="json"){e.logger.error(`Skipping webhook ${a} because non-json request body`);return}if(n.operationId==null){e.logger.error(`Skipping webhook ${a} because no operation id present`);return}return{summary:n.summary,sdkName:d,namespace:e.namespace,method:u,operationId:n.operationId,tags:e.resolveTagsToTagIds(n.tags),headers:o.headers,generatedPayloadName:D2(s,e.options.preserveSchemaIds),payload:c.schema,description:n.description,examples:J8D(c.fullExamples),source:r}}function J8D(e){if(e==null)return[];let t=[];for(let r of e){let i=Hdi(r.value);i!=null&&t.push({description:r.description,name:r.name,payload:i})}return t}function GWs({context:e,pathItemContext:t,operation:r,convertToWebhook:i}){let n=yf(r,fd.IGNORE);if(n!=null&&n){e.logger.debug(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=K8D(r,e),u=z9p(e.document,r),l={...t,sdkMethodName:a,baseBreadcrumbs:Y8D({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path,shouldUseIdiomaticRequestNames:e.options.shouldUseIdiomaticRequestNames}),operation:r,operationParameters:r.parameters??[],pagination:u};if(i){let c=eLp({context:e,operationContext:l,source:e.source});return c!=null?{type:"webhook",value:c}:void 0}let d=x9p(r);if(d!=null){let c=k9p({context:e,operationContext:l,streamingExtension:d});return c!=null?{type:"streaming",streaming:c.streaming,nonStreaming:c.nonStreaming}:void 0}let s=C9p(r);if(s!=null){let c=K9p({context:e,operationContext:l,asyncExtension:s,source:e.source});return{type:"async",async:c.async,sync:c.sync}}return{type:"http",value:hKr({context:e,operationContext:l,streamFormat:void 0,source:e.source})}}function K8D(e,t){let r=yf(e,fd.SDK_METHOD_NAME),i=yf(e,fd.SDK_GROUP_NAME)??[];if(r!=null){let n=typeof i=="string"?[i]:i;return n=t.resolveGroupName(n),{groupName:n,methodName:r}}}function Y8D({sdkMethodName:e,operation:t,httpMethod:r,path:i,shouldUseIdiomaticRequestNames:n}){let a=[];if(e!=null){if(n&&a.push(e.methodName),e.groupName.length>0){let u=e.groupName[e.groupName.length-1];u!=null&&a.push(typeof u=="string"?u:u.name)}n||a.push(e.methodName)}else t.operationId!=null?a.push(t.operationId):a.push(Dg(`${r}_${i.split("/").join("_")}`));return a}function tLp(e,t,r,i){let n=[],a=iLp(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let l of a){if(i.filter.skipEndpoint({method:l.method,path:e})){i.logger.debug(`Skipping endpoint "${l.method} ${e}"`);continue}let d=X8D({operation:l.operation}),s=GWs({context:i,pathItemContext:{...u,method:l.method},operation:l.operation,convertToWebhook:d});s!=null&&n.push(s)}return n}function rLp(e,t,r,i){let n=[],a=iLp(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let l of a){if(i.filter.skipEndpoint({method:l.method,path:e})){i.logger.debug(`Skipping endpoint "${l.method} ${e}"`);continue}let d=GWs({context:i,pathItemContext:{...u,method:l.method},operation:l.operation,convertToWebhook:!0});d!=null&&n.push(d)}return n}function iLp(e){let t=[];return e.get!=null&&t.push({method:pG.Get,operation:e.get}),e.post!=null&&t.push({method:pG.Post,operation:e.post}),e.put!=null&&t.push({method:pG.Put,operation:e.put}),e.delete!=null&&t.push({method:pG.Delete,operation:e.delete}),e.patch!=null&&t.push({method:pG.Patch,operation:e.patch}),t}function X8D({operation:e}){return yf(e,[fd.WEBHOOK])??!1}function nLp(e){let t=yf(e,fd.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=yf(e,fd.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function aLp(e){return yf(e,fd.FERN_BASIC_AUTH)}function QWs(e,t){if(Zd(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return Z8D(e,t)}function Z8D(e,t){if(e.type==="apiKey"&&e.in==="header"){let r=yf(e,mV.BEARER_FORMAT),i=yf(e,fd.FERN_HEADER_AUTH);return g5.header({headerName:e.name,prefix:r!=null?"Bearer":i?.prefix,headerVariableName:i?.name??yf(e,fd.HEADER_VARIABLE_NAME),headerEnvVar:i?.env})}else if(e.type==="http"&&e.scheme==="bearer"){let r=yf(e,fd.FERN_BEARER_TOKEN);return g5.bearer({tokenVariableName:r?.name??yf(e,fd.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:r?.env})}else if(e.type==="http"&&e.scheme==="basic"){let r=aLp(e),i=nLp(e);return g5.basic({usernameVariableName:r?.username?.name??i.usernameVariable,usernameEnvVar:r?.username?.env,passwordVariableName:r?.password?.name??i.passwordVariable,passwordEnvVar:r?.password?.env})}else{if(e.type==="openIdConnect")return g5.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return g5.oauth({scopesEnum:k8D(e,t)})}}function k8D(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let i=bXt({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,inline:void 0}),n=cE(i);if(n.type==="enum")return n}}function oLp(e){return yf(e,fd.BASE_PATH)}var e5D=Yu.record(Yu.string(),Yu.object({summary:Yu.string().optional(),description:Yu.string().optional()}));function uLp({document:e,context:t}){return aha(e,fd.GROUPS,e5D,t.logger)}function sLp({context:e,document:t}){return yf(t,fd.FERN_VERSION)??void 0}function cLp(e){let t=yf(e,fd.FERN_GLOBAL_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?oha({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function lLp(e){let t=yf(e,fd.FERN_IDEMPOTENCY_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?oha({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function fLp(e,t){let r=yf(e,fd.SDK_VARIABLES);return r==null?{}:Object.fromEntries(Object.entries(r).map(([i,n])=>{if(n.type==="string")return[i,{nameOverride:void 0,generatedName:D2([i],t),title:n.title,schema:vj.string({default:ASn(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 ${i} has unsupported schema ${JSON.stringify(n)}`)}))}var t5D="webhooks";function dLp(e){return yf(e,t5D)??{}}function pLp(e){return yf(e,fd.RESOLUTIONS)}function _Lp({openapi:e}){let t=pLp(e);if(t==null)return e;let r={};for(let i of t){let n=`#/components/schemas/${i.name}`;for(let a of i.resolutions)e=r5D({openapi:e,schemaReference:a,schemaName:i.name}),e=hLp({openapi:e,replaceReference:a,schemaReference:n,replacedReferences:r}),r={...r,...Object.fromEntries(i.resolutions.map(u=>[n,u]))}}return e}function r5D({openapi:e,schemaReference:t,schemaName:r}){let i=t.replace("#/","").split("/").map(a=>a.replaceAll("~1","/")),n=e;for(let a of i){let u=n[a];if(u==null)return e;n=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=n,e}function hLp({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:i}){let n=Object.keys(i).filter(d=>t.startsWith(d)).sort((d,s)=>s.length-d.length)[0];if(n!=null){let d=i[n];if(d!=null){let s=r.replace(n,d);return hLp({openapi:e,replaceReference:t,schemaReference:s,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replaceAll("~1","/")),u=e;for(let d of a.slice(0,-1)){let s=u[d];if(s==null)return e;u=s}let l=a[a.length-1];return l==null||(u[l]={$ref:r}),e}function vLp({openApi:e,taskContext:t,options:r,source:i,namespace:n}){e=_Lp({openapi:e});let a=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([I,U])=>QWs(U,i)==null?[]:[I,QWs(U,i)])),u=new Set(...Object.entries(a).map(([I,U])=>U.type==="basic"||U.type==="bearer"?"Authorization":U.type==="header"?U.headerName:null)),l=fLp(e,r.preserveSchemaIds),d=cLp(e),s=lLp(e),o=r.audiences??[],c=[],b=[],g=new Kxo({document:e,taskContext:t,authHeaders:u,options:r,source:i,namespace:n});g.filter.hasEndpoints()&&t.logger.debug("Endpoint filter applied..."),Object.entries(e.paths??{}).forEach(([I,U])=>{if(U==null)return;t.logger.debug(`Converting path ${I}`);let H=tLp(I,U,e,g);for(let k of H){let K=yLp({operation:k});if(!(o.length>0&&!o.some(ee=>K.includes(ee))))switch(k.type){case"async":c.push(k.sync),c.push(k.async);break;case"http":c.push(k.value);break;case"streaming":c.push(k.streaming),k.nonStreaming&&c.push(k.nonStreaming);break;case"webhook":b.push(k.value);break;default:Fo(k)}}}),Object.entries(dLp(e)).forEach(([I,U])=>{if(U==null)return;t.logger.debug(`Converting path ${I}`);let H=rLp(I,U,e,g);for(let k of H){let K=yLp({operation:k});o.length>0&&!o.some(ee=>K.includes(ee))||b.push(k.value)}});let O=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([I,U])=>{if(!Zd(U)){let H=yf(U,fd.IGNORE);if(H!=null&&H)return[];if($9p.has(I))return[I,qb({...U,"x-fern-type-name":`${I}Body`},!1,g,[I],i,n)]}return[I,qb(U,!1,g,[I],i,n)]}).filter(I=>I.length>0)),m=i5D(O,g,i),w=n5D(m,g),E={};for(let[I,U]of Object.entries(w)){let H=cE(U);g.isSchemaExcluded(I)||(E[I]=H,t.logger.debug(`Converted schema ${I}`))}let A=new $di(w,g.nonRequestReferencedSchemas,g),q=b.map(I=>{let H=I.examples;if(!r.disableExamples&&H.length===0){let k=A.buildExample({schema:I.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});k!=null&&(H=[{name:void 0,description:void 0,payload:k}])}return{...I,payload:cE(I.payload),examples:H}}),D=new Wxo(w,g),C=c.map(I=>{let U=I.examples,H=U;if(!r.disableExamples&&(U.length===0||U.every(sha))){let ee=D.buildEndpointExample(I);ee.length>0&&(H=[...ee,...U.filter(fe=>!sha(fe))])}let k=I.request,K=I.response;return{...I,request:k?.type==="json"?{...k,schema:cE(k.schema)}:k,response:K?.type==="json"?{...K,schema:cE(K.schema)}:K,queryParameters:I.queryParameters.map(ee=>({description:ee.description,name:ee.name,schema:cE(ee.schema),parameterNameOverride:ee.parameterNameOverride,availability:ee.availability,source:ee.source})),pathParameters:I.pathParameters.map(ee=>({description:ee.description,name:ee.name,schema:cE(ee.schema),parameterNameOverride:ee.parameterNameOverride,variableReference:ee.variableReference,availability:ee.availability,source:ee.source})),headers:I.headers.map(ee=>({description:ee.description,name:ee.name,schema:cE(ee.schema),parameterNameOverride:ee.parameterNameOverride,env:ee.env,availability:ee.availability,source:ee.source})),examples:H,errors:rd(I.errors,ee=>{let fe=ee.fullExamples?.map(me=>{let ge=Hdi(me.value);if(ge!=null)return{name:me.name,description:me.description,example:ge}}).filter(Qb);if(fe?.length===0){let me=A.buildExample({schema:ee.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});me!=null&&fe.push({name:void 0,description:void 0,example:me})}return{generatedName:ee.generatedName,nameOverride:ee.nameOverride,schema:cE(ee.schema),description:ee.description,source:ee.source,examples:fe}})}}),R=uLp({document:e,context:g});return{apiVersion:sLp({context:g,document:e}),basePath:oLp(e),title:e.info.title,description:e.info.description,groups:Object.fromEntries(Object.entries(R??{}).map(([I,U])=>[I,{summary:U.summary??void 0,description:U.description??void 0}])),servers:(e.servers??[]).map(I=>Yxo(I)),websocketServers:[],tags:{tagsById:Object.fromEntries((e.tags??[]).map(I=>[I.name,{id:I.name,description:I.description}])),orderedTagIds:e.tags?.map(I=>I.name)},endpoints:C,webhooks:q,channels:{},groupedSchemas:CSn(n,E),securitySchemes:a,hasEndpointsMarkedInternal:C.some(I=>I.internal),nonRequestReferencedSchemas:g.getReferencedSchemas(),variables:l,globalHeaders:d,idempotencyHeaders:s}}function i5D(e,t,r){let i={};for(let[n,a]of Object.entries(e)){if(a.type!=="object"){i[n]=a;continue}let u={$ref:`#/components/schemas/${n}`},l=t.getReferencesFromDiscriminatedUnion(u);if(l==null){i[n]=a;continue}let d={...a,type:"object",properties:a.properties.filter(o=>!l.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!l.discriminants.has(o.propertyKey)),source:r};i[n]=d;let s=bLp({schema:a,schemas:e});for(let o of[...new Set(s)]){let c=i[o]??e[o];c==null||c.type!=="object"||(i[o]={...c,type:"object",properties:c.properties.filter(b=>!l.discriminants.has(b.key)),allOfPropertyConflicts:c.allOfPropertyConflicts.filter(b=>!l.discriminants.has(b.propertyKey))})}}return i}function n5D(e,t){let r={};for(let[i,n]of Object.entries(e)){if(n.type!=="object"){r[i]=n;continue}let a={$ref:`#/components/schemas/${i}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[i]=n;continue}let l=[];for(let s of n.properties)if(u.discriminants.has(s.key)){let o=u.discriminants.get(s.key);o!=null&&l.push({...s,schema:El.literal({nameOverride:void 0,generatedName:D2([n.generatedName,o],t.options.preserveSchemaIds),title:void 0,value:cx.string(o),groupName:void 0,description:void 0,availability:n.availability})})}else l.push(s);let d={...n,type:"object",properties:l};r[i]=d}return r}function bLp({schema:e,schemas:t}){let r=[];for(let i of e.allOf){r.push(i.schema);let n=t[i.schema];n!=null&&n.type==="object"&&r.push(...bLp({schema:n,schemas:t}))}return r}function yLp({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:Fo(e)}return t}function YRi({context:e,documents:t,options:r}){let i={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],websocketServers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channels:{},groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}};for(let n of t){let a=n.source!=null?n.source:wie.openapi({file:"<memory>"});switch(n.type){case"openapi":{let u=vLp({taskContext:e,openApi:n.value,options:CWs({options:n.settings,overrides:r}),source:a,namespace:n.namespace});i=o5D(i,u);break}case"asyncapi":{let u=D9p({document:n.value,taskContext:e,options:CWs({options:n.settings,overrides:r}),source:a,asyncApiOptions:a5D({options:n.settings}),namespace:n.namespace});u.servers!=null&&(i.websocketServers=[...i.websocketServers,...u.servers.map(l=>({...l,audiences:void 0,description:void 0}))]),u.channels!=null&&(i.channels={...i.channels,...u.channels}),u.groupedSchemas!=null&&(i.groupedSchemas=gLp(i.groupedSchemas,u.groupedSchemas)),u.basePath!=null&&(i.basePath=u.basePath);break}default:Fo(n)}}return i}function a5D({options:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??H5p.naming}}function o5D(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],websocketServers:[...e.websocketServers,...t.websocketServers],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],channels:{...e.channels,...t.channels},groupedSchemas:gLp(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 gLp(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,i]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...i}:e.namespacedSchemas[r]=i;return e}var Zxo={config:new OLp.Config({apis:{},styleguide:{plugins:[TWs],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0};function fha(e){return e.swagger!=null}function JWs(e){return e.openapi!=null}function Gdi(e,t={}){return{...Object.fromEntries(CN(e.namedDefinitionFiles).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...CN(e.importedDefinitions).reduce((r,[i,n])=>({...r,...$ra(Gdi(n.definition,{defaultURL:n.url}),(a,u)=>PR(i,sy.of(u)))}),{})}}function dha(e,t={}){return{...Object.fromEntries(CN(e.packageMarkers).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...CN(e.importedDefinitions).reduce((r,[i,n])=>({...r,...$ra(dha(n.definition,{defaultURL:n.url}),(a,u)=>PR(i,sy.of(u)))}),{})}}function yKr(e){return{...dha(e),...Gdi(e)}}function xie(e,t){return yKr(e.definition)[t]?.contents}function dF(e,t){for(let[r,i]of CN(yKr(e.definition)))t(r,i.contents,{isPackageMarker:_Ci(r)===X1,defaultUrl:i.defaultUrl})}function XRi(e,t){for(let[r,i]of CN(dha(e.definition)))t(r,i.contents)}var AHp=yi(MHp(),1);async function nya(e){return(await(0,AHp.convertObj)(e,{})).openapi}var THp=require("fs/promises");var qHp=require("fs/promises");async function ozo({absoluteFilePathToOverrides:e,data:t,context:r,allowNullKeys:i}){let n=null;try{let a=(await(0,qHp.readFile)(e,"utf8")).toString();try{n=JSON.parse(a)}catch{n=Kd.load(a,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return yds({data:t,overrides:n,allowNullKeys:i})}async function CHp({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,THp.readFile)(t)).toString(),n=await Kd.load(i);return r!=null?await ozo({absoluteFilePathToOverrides:r,context:e,data:n}):n}var oya=yi(Bxo(),1);var BHp=yi(Bxo(),1),X$s=yi(require("path"),1);var aya=class extends BHp.BaseResolver{absolutePathToOpenAPIOverrides;constructor(t){super(),this.absolutePathToOpenAPIOverrides=t}resolveExternalRef(t,r){let i=super.resolveExternalRef(t,r);return TGr(Wl.of(i))?i:this.absolutePathToOpenAPIOverrides!=null?X$s.default.resolve(X$s.default.dirname(this.absolutePathToOpenAPIOverrides),r):i}};async function Z$s({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,parsed:r}){return(r!=null?await(0,oya.bundle)({...Zxo,doc:{source:new oya.Source(e,"<openapi>"),parsed:r},externalRefResolver:new aya(t)}):await(0,oya.bundle)({...Zxo,ref:e,externalRefResolver:new aya(t)})).bundle.parsed}var bHD=["examples","example",fd.EXAMPLES,mV.REDOCLY_CODE_SAMPLES_CAMEL,mV.REDOCLY_CODE_SAMPLES_KEBAB];async function uya({context:e,absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r}){let i=await Z$s({absolutePathToOpenAPI:t}),n;if(r!=null?n=r:typeof i=="object"&&i[fd.OPENAPI_OVERIDES_FILEPATH]!=null&&(n=Xu(_p(t),Xa.of(i[fd.OPENAPI_OVERIDES_FILEPATH]))),n!=null){let a=await ozo({absoluteFilePathToOverrides:n,context:e,data:i,allowNullKeys:bHD});return await Z$s({absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r,parsed:a})}return i}var U5t=class{absoluteFilePath;constructor(t){this.absoluteFilePath=t}async loadDocuments({context:t,specs:r}){let i=[];for(let n of r){let a=(await(0,xHp.readFile)(n.absoluteFilepath)).toString(),u=aT(this.absoluteFilePath,n.source.file);n.source.relativePathToDependency!=null&&(u=Xu(n.source.relativePathToDependency,u));let l=n.source.type==="protobuf"?wie.protobuf({file:u}):wie.openapi({file:u});if(a.includes("openapi")||a.includes("swagger")){let d=await uya({absolutePathToOpenAPI:n.absoluteFilepath,context:t,absolutePathToOpenAPIOverrides:n.absoluteFilepathToOverrides});if(JWs(d)){i.push({type:"openapi",value:d,source:l,namespace:n.namespace,settings:n.settings});continue}else if(fha(d)){let s=await nya(d);i.push({type:"openapi",value:s,source:l,namespace:n.namespace,settings:n.settings});continue}}if(a.includes("asyncapi")){let d=await CHp({context:t,absoluteFilePath:n.absoluteFilepath,absoluteFilePathToOverrides:n.absoluteFilepathToOverrides});i.push({type:"asyncapi",value:d,source:l,namespace:n.namespace,settings:n.settings});continue}t.failAndThrow(`${n.absoluteFilepath} is not a valid OpenAPI or AsyncAPI file`)}return i}};var yzo=require("fs/promises"),cGp=yi(Lte(),1);var sGp=yi(uGp(),1);async function SG(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...u}={}){let l=n.reduce((o,c)=>({...o,[c]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[o,c]of Object.entries(l))d=d.replaceAll(o,c);e?.debug(`+ ${d}`);let s=(0,sGp.default)(t,r,u);return i||(s.stdout?.pipe(process.stdout),s.stderr?.pipe(process.stderr)),s.then(o=>(o.stdout==null&&(o.stdout=""),o.stderr==null&&(o.stderr=""),o))}function _zo(e,{logger:t,...r}={}){return(i,n)=>SG(t,e,i,{...r,...n})}var fGD="buf.gen.yaml",lGp="output",dGD=`${lGp}/openapi.yaml`,hzo=class{context;constructor({context:t}){this.context=t}async generate({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,relativeFilepathToProtobufRoot:i,local:n}){return n?this.generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,relativeFilepathToProtobufRoot:i}):this.generateRemote()}async generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,relativeFilepathToProtobufRoot:i}){let n=await this.setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t,relativeFilepathToProtobufRoot:i}),a=aT(t,r);return this.doGenerateLocal({cwd:n,target:a})}async setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t,relativeFilepathToProtobufRoot:r}){let i=Wl.of((await cGp.default.dir()).path);return await(0,yzo.cp)(t,i,{recursive:!0}),await(0,yzo.writeFile)(Xu(i,Xa.of(fGD)),pGD({relativeFilepathToProtobufRoot:r})),i}async doGenerateLocal({cwd:t,target:r}){let i=_zo("which",{cwd:t,logger:this.context.logger});try{await i(["buf"])}catch{this.context.failAndThrow("Missing required dependency; please install 'buf' to continue (e.g. 'brew install buf').")}try{await i(["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/fern-api/protoc-gen-openapi/cmd/protoc-gen-openapi@latest').")}let n=_zo("buf",{cwd:t,logger:this.context.logger});return await n(["config","init"]),await n(["generate",r]),Xu(t,Xa.of(dGD))}async generateRemote(){this.context.failAndThrow("Remote Protobuf generation is unimplemented.")}};function pGD({relativeFilepathToProtobufRoot:e}){return`
1938
1938
  version: v1
1939
1939
  plugins:
1940
1940
  - plugin: openapi
@@ -1944,7 +1944,7 @@ plugins:
1944
1944
  - enum_type=string
1945
1945
  - default_response=false
1946
1946
  - source_root=${e}
1947
- `}async function qze({context:e,specs:t,relativePathToDependency:r}){let i=new hzo({context:e}),n=t.filter(l=>l.type==="openapi").map(l=>({...l,relativePathToDependency:r})),a=t.filter(l=>l.type==="protobuf"),u=await Promise.all(a.map(async l=>_GD({generator:i,protobufSpec:l,relativePathToDependency:r})));return[...n,...u]}async function _GD({generator:e,protobufSpec:t,relativePathToDependency:r}){return{type:"openapi",absoluteFilepath:await e.generate({absoluteFilepathToProtobufRoot:t.absoluteFilepathToProtobufRoot,absoluteFilepathToProtobufTarget:t.absoluteFilepathToProtobufTarget,relativeFilepathToProtobufRoot:t.relativeFilepathToProtobufRoot,local:t.generateLocally}),absoluteFilepathToOverrides:t.absoluteFilepathToOverrides,settings:t.settings,source:{type:"protobuf",relativePathToDependency:r,root:t.absoluteFilepathToProtobufRoot,file:t.absoluteFilepathToProtobufTarget}}}var sKp=require("fs"),qDn=require("fs/promises");var cKp=require("os"),lKp=yi(require("path"),1),fKp=require("stream/promises"),dKp=yi(jRo(),1),pKp=yi(Lte(),1);var rJs=yi(JBi(),1);var aP;(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"})(aP||(aP={}));var HJD=BQr();async function _Kp({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:i,cliVersion:n,settings:a,loadAPIWorkspace:u}){let l,d={type:aP.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},s=t.dependencies[e];return s==null?d={type:aP.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${XJD(s)}`},async o=>{switch(s.type){case"version":l=await KJD({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;case"local":l=await JJD({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;default:Fo(s)}}),l!=null?{didSucceed:!0,definition:l}:{didSucceed:!1,failure:d}}var hKp="dependencies";var $JD="metadata.json",GJD=".fern";function QJD(e){return Xu(Wl.of((0,cKp.homedir)()),Xa.of(GJD),Xa.of(hKp),Xa.of(e.organization),Xa.of(e.apiName),Xa.of(e.version))}async function JJD({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){if(n==null){t.failWithoutThrowing("Failed to load api definition");return}t.logger.info("Parsing...");let a=await n({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:Xa.of(e.path)},i);return t.logger.info("Loaded..."),u}async function KJD({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){let a=QJD(e),u=Xu(a,Xa.of(hKp)),l=Xu(a,Xa.of($JD)),d;if(!await Cf(u)||!await Cf(l)){t.logger.info("Downloading manifest...");let c=await HJD.definitionRegistry.get(rJs.FernFiddle.OrganizationId(e.organization),rJs.FernFiddle.ApiId(e.apiName),e.version);if(!c.ok){c.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:m=>{t.failWithoutThrowing("Failed to download API manifest",m)}});return}let b=c.body.yamlSchemaVersion!=null?parseInt(c.body.yamlSchemaVersion):void 0,g=oRi(r),O=oRi(c.body.cliVersion);if(b!=null){if(b>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${c.body.cliVersion}`);return}else if(b<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(g.major!==O.major||g.minor!==O.minor){t.failWithoutThrowing(`CLI version is ${c.body.cliVersion}. Expected ${g.major}.${g.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+c.body.definitionS3DownloadUrl),await(0,qDn.mkdir)(u,{recursive:!0});try{await YJD({s3PreSignedReadUrl:c.body.definitionS3DownloadUrl,absolutePathToLocalOutput:u})}catch(m){t.failWithoutThrowing("Failed to download API",m);return}d=c.body,await(0,qDn.writeFile)(l,JSON.stringify(d))}else d=JSON.parse((await(0,qDn.readFile)(l)).toString());if(t.logger.info("Parsing..."),n==null){t.failWithoutThrowing("Failed to load API");return}let s=await n({absolutePathToWorkspace:u,context:t,cliVersion:d.cliVersion,workspaceName:void 0});if(!s.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",s.failures);return}if(s.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await s.workspace.getDefinition({context:t},i)}async function YJD({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await xR.get(e,{responseType:"stream"}),i=await pKp.default.dir(),n=lKp.default.join(i.path,"api.tgz");await(0,fKp.pipeline)(r.data,(0,sKp.createWriteStream)(n)),await(0,dKp.extract)({file:n,cwd:t})}function XJD(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:Fo(e)}}var MKp=yi(mKp(),1);function wRo(e,t){for(let[r,i]of CN(e))kJD({relativeFilepath:r,failure:i,logger:t})}function kJD({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case aP.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 aP.FILE_READ:r.error("Failed to open file: "+e);break;case aP.FILE_MISSING:r.error("Missing file: "+e);break;case aP.FILE_PARSE:t.error instanceof gna?r.error(jie({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case aP.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of eKD(i))r.error(jie({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case aP.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case aP.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${GYa}: `+t.dependencyName);break;case aP.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case aP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case aP.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(jie({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(i=>i!=="")]}));for(let i of t.error.allErrors)i!==t.error.error&&r.debug(jie({title:i.message??"Unknown error",breadcrumbs:[e,...i.instancePath.split("/").filter(n=>n!=="")]}));break;default:Fo(t)}}function eKD(e){switch(e.code){case Hl.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${Js.underline(e.expected)} but received ${Js.underline(e.received)}`}];case Hl.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${Js.underline(t)}`}));case Hl.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>Js.underline(t)).join(", ")}`}];case Hl.invalid_union:case Hl.invalid_arguments:case Hl.invalid_return_type:case Hl.invalid_date:case Hl.invalid_string:case Hl.too_small:case Hl.too_big:case Hl.invalid_intersection_types:case Hl.not_multiple_of:case Hl.custom:default:return[{title:e.message}]}}var PKp=require("fs/promises");async function jKp(e,t){let r=[];for(let i of await qBe(e,t))r.push(await tKD({relativeFilepath:aT(e,i),absoluteFilepath:i}));return r}async function tKD({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,PKp.readFile)(t)).toString()}}async function wKp(e){let t={},r={};function i(n){try{t[n.relativeFilepath]={defaultUrl:void 0,contents:Kd.load(n.fileContents,{schema:Kd.CORE_SCHEMA}),rawContents:n.fileContents}}catch(a){r[n.relativeFilepath]={type:aP.FILE_PARSE,error:a}}}return await Promise.all(e.map(i)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}async function SKp({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:i,settings:n,loadAPIWorkspace:a}){let u={},l={},d={};return await Promise.all(CN(t.packageMarkers).map(async([s,o])=>{if(o.contents.export==null)u[s]=o;else{let{export:c,...b}=o.contents;if(nY(b)>0)d[s]={type:aP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:s};else{let g=_p(s);if(D4t(t.namedDefinitionFiles).some(m=>m!==s&&m.startsWith(g)))d[s]={type:aP.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:g};else{let m=await _Kp({dependencyName:typeof o.contents.export=="string"?o.contents.export:o.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:i,settings:n,loadAPIWorkspace:a});m.didSucceed?l[_p(s)]={definition:m.definition,url:typeof o.contents.export=="object"?o.contents.export.url:void 0}:d[s]=m.failure}}}})),nY(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:u,importedDefinitions:l}}var DKp=yi(require("path"),1);var aJs={};Co(aJs,{additionalProperties:()=>aKD,default:()=>uKD,definitions:()=>oKD,properties:()=>iKD,required:()=>nKD,type:()=>rKD});var rKD="object",iKD={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"}]}},nKD=["name"],aKD=!1,oKD={"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"}]},"token-header":{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.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"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}},uKD={type:rKD,properties:iKD,required:nKD,additionalProperties:aKD,definitions:oKD};var oJs={};Co(oJs,{additionalProperties:()=>lKD,default:()=>dKD,definitions:()=>fKD,properties:()=>cKD,type:()=>sKD});var sKD="object",cKD={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"}]}},lKD=!1,fKD={"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.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{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"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{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"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"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"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{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:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},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.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"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"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{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:{$ref:"#/definitions/types.TypeReferenceSchema"}},{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"},url:{oneOf:[{type:"string"},{type:"null"}]},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}},dKD={type:sKD,properties:cKD,additionalProperties:lKD,definitions:fKD};var uJs={};Co(uJs,{additionalProperties:()=>hKD,default:()=>vKD,definitions:()=>yKD,properties:()=>_KD,type:()=>pKD});var pKD="object",_KD={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"}]}},hKD=!1,yKD={"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.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{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"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{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"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"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"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{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:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},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.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"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"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{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:{$ref:"#/definitions/types.TypeReferenceSchema"}},{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"},url:{oneOf:[{type:"string"},{type:"null"}]},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"}]}},vKD={type:pKD,properties:_KD,additionalProperties:hKD,definitions:yKD};function EKp({files:e,absolutePathToDefinition:t}){let r,i={},n={},a={};for(let[u,l]of CN(e)){let d=l.contents,s=o=>{a[u]={type:aP.JSONSCHEMA_VALIDATION,error:o}};if(u===Q3){let o=DGr(d,aJs);if(o.success){let c=l2.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:c["default-url"],contents:c,rawContents:l.rawContents}}else s(o)}else if(DKp.default.basename(u)===X1){let o=DGr(d,uJs);if(o.success){let c=l2.serialization.PackageMarkerFileSchema.parseOrThrow(d);n[u]={defaultUrl:typeof c.export=="object"?c.export.url:void 0,contents:c,rawContents:l.rawContents}}else s(o)}else{let o=DGr(d,oJs);if(o.success){let c=l2.serialization.DefinitionFileSchema.parseOrThrow(d);i[u]={defaultUrl:void 0,contents:c,rawContents:l.rawContents,absoluteFilePath:Xu(t,u)}}else s(o)}}return r==null?{didSucceed:!1,failures:{[Xa.of(Q3)]:{type:aP.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:i,rootApiFile:r,packageMarkers:n}}var wpi=class extends D5t{context;fernWorkspaces={};loadAPIWorkspace;constructor({context:t,loadAPIWorkspace:r,...i}){super(i),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 i=(0,MKp.default)(r??{}),n=this.fernWorkspaces[i];if(n==null){let a=t||this.context,u=Xu(this.absoluteFilePath,Xa.of(R8)),l=await Dys({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await jKp(u,"{yml,yaml}"),s=await wKp(d);if(!s.didSucceed)return wRo(s.failures,a.logger),a.failAndThrow();let o=EKp({files:s.files,absolutePathToDefinition:u});if(!o.didSucceed)return wRo(o.failures,a.logger),a.failAndThrow();let c=await SKp({dependenciesConfiguration:l,structuralValidationResult:o,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!c.didSucceed)return wRo(c.failures,a.logger),a.failAndThrow();n=new USe({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:l,workspaceName:this.workspaceName,definition:{absoluteFilePath:u,rootApiFile:o.rootApiFile,namedDefinitionFiles:o.namedDefinitionFiles,packageMarkers:c.packageMarkers,importedDefinitions:c.importedDefinitions},cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[i]=n}return n}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};function SV(e){let t=gKD(e),{value:r,done:i}=sJs(t,"{");return i?{head:r,parts:[]}:{head:r,parts:[...bKD(t)]}}function*bKD(e){let t;do{let{value:r}=sJs(e,"}"),i=sJs(e,"{");t=i.done,yield{pathParameter:r,tail:i.value}}while(!t)}function*gKD(e){for(let t of e)yield t}function sJs(e,t){let r="",i=e.next();for(;i.done!==!0&&i.value!==t;)r+=i.value,i=e.next();return{value:r,done:i.done??!1}}function Iya(e){let t=2166136261;function r(n,a){if(typeof n=="object"&&n!=null){if(a>64){i("[MaxDepthExceeded]");return}if(Array.isArray(n)){i("[");for(let u=0;u<n.length;u++)u>0&&i(","),r(n[u],a+1);i("]")}else i("{"),Object.keys(n).sort().forEach((l,d)=>{d>0&&i(","),i(l),i(":"),r(n[l],a+1)}),i("}")}else i(String(n))}function i(n){for(let a=0;a<n.length;a++){let u=n.charCodeAt(a);t^=u,t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24),t>>>=0}}return r(e,0),t.toString(16)}function AKp({fieldName:e,containerType:t,maxDepth:r,currentDepth:i,typeDeclarations:n,skipOptionalProperties:a}){if(i>=r)return IXt({containerType:t});switch(t.type){case"list":{let u=ZT({fieldName:e,typeReference:t.list,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?IXt({containerType:t}):{type:"success",example:GO.list({list:[u.example,u.example],itemType:t.list}),jsonExample:[u.jsonExample,u.jsonExample]}}case"literal":return{type:"success",example:GO.literal({literal:t.literal._visit({boolean:u=>n_.boolean(u),string:u=>n_.string({original:u}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:t.literal._visit({boolean:u=>u,string:u=>u,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":{if(a)return IXt({containerType:t});let u=ZT({fieldName:e,typeReference:t.optional,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?IXt({containerType:t}):{type:"success",example:GO.optional({optional:u.example,valueType:t.optional}),jsonExample:u.jsonExample}}case"nullable":{if(a)return IXt({containerType:t});let u=ZT({fieldName:e,typeReference:t.nullable,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?IXt({containerType:t}):{type:"success",example:GO.nullable({nullable:u.example,valueType:t.nullable}),jsonExample:u.jsonExample}}case"set":{let u=ZT({fieldName:e,typeReference:t.set,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?IXt({containerType:t}):{type:"success",example:GO.set({set:[u.example],itemType:t.set}),jsonExample:[u.jsonExample]}}case"map":{let u=ZT({fieldName:e,typeReference:t.keyType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a}),l=ZT({fieldName:e,typeReference:t.valueType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"||l.type==="failure"?IXt({containerType:t}):{type:"success",example:GO.map({map:[{key:u.example,value:l.example}],keyType:t.keyType,valueType:t.valueType}),jsonExample:{[u.jsonExample]:l.jsonExample}}}default:Fo(t)}}function IXt({containerType:e}){switch(e.type){case"list":return{type:"success",example:GO.list({list:[],itemType:e.list}),jsonExample:[]};case"literal":return{type:"success",example:GO.literal({literal:e.literal._visit({boolean:t=>n_.boolean(t),string:t=>n_.string({original:t}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:e.literal._visit({boolean:t=>t,string:t=>t,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":return{type:"success",example:GO.optional({optional:void 0,valueType:e.optional}),jsonExample:void 0};case"nullable":return{type:"success",example:GO.nullable({nullable:void 0,valueType:e.nullable}),jsonExample:void 0};case"set":return{type:"success",example:GO.set({set:[],itemType:e.set}),jsonExample:[]};case"map":return{type:"success",example:GO.map({map:[],keyType:e.keyType,valueType:e.valueType}),jsonExample:{}};default:Fo(e)}}function TKp({fieldName:e,primitiveType:t}){switch(t.v1){case"STRING":return jKD({fieldName:e,validation:OKD(t.v2)});case"BASE_64":return{type:"success",example:n_.base64(Sg.BASE64),jsonExample:Sg.BASE64};case"BOOLEAN":return{type:"success",example:n_.boolean(Sg.BOOLEAN),jsonExample:Sg.BOOLEAN};case"DATE":return{type:"success",example:n_.date(Sg.DATE),jsonExample:Sg.DATE};case"DATE_TIME":return{type:"success",example:n_.datetime({datetime:new Date(Sg.DATE_TIME),raw:Sg.DATE_TIME}),jsonExample:Sg.DATE_TIME};case"DOUBLE":return wKD({fieldName:e,validation:mKD(t.v2)});case"FLOAT":return{type:"success",example:n_.float(Sg.FLOAT),jsonExample:Sg.FLOAT};case"INTEGER":return SKD({fieldName:e,validation:PKD(t.v2)});case"UINT_64":return{type:"success",example:n_.uint64(Sg.INT64),jsonExample:Sg.INT64};case"UINT":return{type:"success",example:n_.uint(Sg.UINT),jsonExample:Sg.UINT};case"BIG_INTEGER":return{type:"success",example:n_.bigInteger(Sg.INT64.toString()),jsonExample:`${Sg.INT64}`};case"LONG":return{type:"success",example:n_.long(Sg.INT64),jsonExample:Sg.INT64};case"UUID":return{type:"success",example:n_.uuid(Sg.UUID),jsonExample:Sg.UUID};default:Fo(t.v1)}}function OKD(e){if(e?.type==="string")return e.validation}function mKD(e){if(e?.type==="double")return e.validation}function PKD(e){if(e?.type==="integer")return e.validation}function qKp(e){if(e<=Sg.SAMPLE_STRINGS.length){let t=Sg.SAMPLE_STRINGS[e-1];if(t)return t;throw new Error(`Unexpected undefined value in SAMPLE_STRINGS at index ${e-1}`)}return Sg.SAMPLE_STRINGS[Sg.SAMPLE_STRINGS.length-1]+".".repeat(e-Sg.SAMPLE_STRINGS.length)}function jKD({fieldName:e,validation:t}){if(t){let i=t.minLength,n=t.maxLength;if(i){let a=qKp(i);return{type:"success",example:n_.string({original:a}),jsonExample:a}}else if(n){let a=qKp(n);return{type:"success",example:n_.string({original:a}),jsonExample:a}}}let r=e??Sg.STRING;return{type:"success",example:n_.string({original:r}),jsonExample:r}}function wKD({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:n_.double(r),jsonExample:r};if(i)return{type:"success",example:n_.double(i),jsonExample:i}}return{type:"success",example:n_.double(Sg.DOUBLE),jsonExample:Sg.DOUBLE}}function SKD({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:n_.integer(r),jsonExample:r};if(i)return{type:"success",example:n_.integer(i),jsonExample:i}}return{type:"success",example:n_.integer(Sg.INT),jsonExample:Sg.INT}}function ZT({fieldName:e,typeReference:t,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){if(n>i)return{type:"failure",message:"Exceeded max depth"};switch(t.type){case"named":{let u=r[t.typeId];if(u==null)return{type:"failure",message:`Failed to find type declaration with id ${t.typeId}`};let l=BDn({fieldName:e,typeDeclaration:u,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(l==null)return{type:"failure",message:"Failed to generate example for type declaration"};if(l.type==="failure")return l;let{example:d,jsonExample:s}=l;return{type:"success",example:{jsonExample:s,shape:Ab.named({shape:d,typeName:u.name})},jsonExample:s}}case"container":{let u=AKp({fieldName:e,containerType:t.container,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(u.type==="failure"){let{example:s,jsonExample:o}=IXt({containerType:t.container});return{type:"success",example:{jsonExample:o,shape:Ab.container(s)},jsonExample:o}}let{example:l,jsonExample:d}=u;return{type:"success",example:{jsonExample:d,shape:Ab.container(l)},jsonExample:d}}case"primitive":{let{jsonExample:u,example:l}=TKp({fieldName:e,primitiveType:t.primitive});return{type:"success",example:{jsonExample:u,shape:Ab.primitive(l)},jsonExample:u}}case"unknown":{let u={key:"value"};return{type:"success",example:{jsonExample:u,shape:Ab.unknown(u)},jsonExample:u}}}}function xDn({typeReference:e,typeDeclarations:t}){if(e.type==="container"&&e.container.type==="optional")return!0;if(e.type==="named"){let r=t[e.typeId];if(r?.shape.type==="alias"&&r?.shape.resolvedType.type==="container"&&r?.shape.resolvedType.container.type==="optional")return!0}return!1}function BDn({fieldName:e,typeDeclarations:t,typeDeclaration:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){switch(r.shape.type){case"alias":{let u=ZT({fieldName:e,typeDeclarations:t,typeReference:r.shape.aliasOf,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(u.type==="failure")return u;let{example:l,jsonExample:d}=u;return{type:"success",example:tw.alias({value:l}),jsonExample:d}}case"enum":{let u=r.shape.values[0];return u==null?{type:"failure",message:"No enum values present"}:{type:"success",example:tw.enum({value:u.name}),jsonExample:u.name.wireValue}}case"object":{let u={},l=[];if(r.shape.extends!=null)for(let c of r.shape.extends){let b=t[c.typeId];if(b==null)continue;let g=BDn({fieldName:e,typeDeclaration:b,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});g!=null&&g.type==="success"&&g.example.type==="object"&&(Object.assign(u,g.jsonExample),l.push(...g.example.properties))}let d=DKD({fieldName:e,typeDeclaration:r,objectTypeDeclaration:r.shape,typeDeclarations:t,currentDepth:n,maxDepth:i,skipOptionalProperties:a});if(d.type==="failure")return d;let{example:s,jsonExample:o}=d;return{type:"success",example:tw.object({...s,properties:[...l,...s.properties]}),jsonExample:Object.assign({},u,o)}}case"undiscriminatedUnion":{let u=0;for(let l of r.shape.members){let d=ZT({fieldName:e,typeReference:l.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(d.type==="failure"){++u;continue}let{example:s,jsonExample:o}=d;return{type:"success",example:tw.undiscriminatedUnion({index:u,singleUnionType:s}),jsonExample:o}}break}case"union":{let u=r.shape.discriminant,l={};if(r.shape.baseProperties!=null)for(let d of r.shape.baseProperties){let s=ZT({fieldName:d.name.wireValue,typeReference:d.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});s.type==="success"&&(l[d.name.wireValue]=s.jsonExample)}for(let d of r.shape.types){let s=d.shape._visit({noProperties:()=>({type:"success",example:tw.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:QN.noProperties()}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,...l}}),samePropertiesAsObject:o=>{let c=t[o.typeId];if(c==null)return{type:"failure",message:`Failed to find type declaration with id ${o.typeId}`};let b=BDn({currentDepth:n,maxDepth:i,fieldName:e,typeDeclaration:c,typeDeclarations:t,skipOptionalProperties:a});if(b==null)return{type:"failure",message:"Failed to generate example for type reference"};if(b.type==="failure")return b;let{example:g,jsonExample:O}=b;return{type:"success",example:tw.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:QN.samePropertiesAsObject({typeId:c.name.typeId,object:g.type==="object"?g:{properties:[]}})}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,...typeof O=="object"?O:{},...l}}},singleProperty:o=>{let c=ZT({currentDepth:n+1,maxDepth:i,fieldName:e,typeReference:o.type,typeDeclarations:t,skipOptionalProperties:a});if(c.type==="failure")return c;let{example:b,jsonExample:g}=c;return{type:"success",example:tw.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:QN.singleProperty(b)}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,[o.name.wireValue]:g,...l}}},_other:()=>{throw new Error("Encountered unknown union type")}});if(s.type!=="failure")return s}}}return{type:"failure",message:"Failed to generate example for type reference"}}function DKD({fieldName:e,typeDeclaration:t,objectTypeDeclaration:r,typeDeclarations:i,maxDepth:n,currentDepth:a,skipOptionalProperties:u}){let l={},d=[];for(let s of[...r.properties??[],...r.extendedProperties??[]]){let o=ZT({fieldName:s.name.wireValue,typeReference:s.valueType,typeDeclarations:i,currentDepth:a+1,maxDepth:n,skipOptionalProperties:u});if(o.type==="failure"&&!xDn({typeDeclarations:i,typeReference:s.valueType}))return{type:"failure",message:`Failed to generate required property ${s.name.wireValue} b/c ${o.message}`};if(o.type==="failure")continue;let{example:c,jsonExample:b}=o;d.push({name:s.name,originalTypeDeclaration:t.name,value:c}),l[s.name.wireValue]=b}return{type:"success",example:tw.object({properties:d}),jsonExample:l}}var cJs=pd.primitive({v1:g0.String,v2:Z_.string({default:void 0,validation:void 0})});function zya({ir:e,endpoint:t,service:r,typeDeclarations:i,skipOptionalRequestProperties:n,generationResponse:a}){let u={name:void 0,endpointHeaders:[],endpointPathParameters:[],queryParameters:[],servicePathParameters:[],serviceHeaders:[],rootPathParameters:[],request:void 0,response:Cq.ok(KT.body(void 0)),docs:void 0},l=[{params:t.pathParameters,add:s=>u.endpointPathParameters.push(s)},{params:r.pathParameters,add:s=>u.servicePathParameters.push(s)},{params:e.pathParameters,add:s=>u.rootPathParameters.push(s)}];for(let s of l)for(let o of s.params){let c=ZT({fieldName:o.name.originalName,currentDepth:0,maxDepth:1,typeDeclarations:i,typeReference:o.valueType,skipOptionalProperties:n});if(c.type==="failure")return c;let{example:b}=c;s.add({name:o.name,value:b})}for(let s of t.queryParameters){if(n&&xDn({typeDeclarations:i,typeReference:s.valueType}))continue;let o=ZT({fieldName:s.name.name.originalName,currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:s.valueType,skipOptionalProperties:n});if(o.type==="failure")return o;let{example:c}=o;u.queryParameters.push({name:s.name,shape:s.allowMultiple?f2.exploded():f2.single(),value:c})}let d=[{params:t.headers,add:s=>u.endpointHeaders.push(s)},{params:r.headers,add:s=>u.serviceHeaders.push(s)}];for(let s of d)for(let o of s.params){if(n&&xDn({typeDeclarations:i,typeReference:o.valueType}))continue;let c=ZT({fieldName:o.name.name.originalName,currentDepth:0,maxDepth:1,typeDeclarations:i,typeReference:o.valueType,skipOptionalProperties:n});if(c.type==="failure")return c;let{example:b}=c;s.add({name:o.name,value:b})}if(t.requestBody!=null)switch(t.requestBody.type){case"bytes":return{type:"failure",message:"Bytes request unsupported"};case"fileUpload":return{type:"failure",message:"File upload unsupported"};case"inlinedRequestBody":{let s={},o=[];if(t.requestBody.extends!=null)for(let c of t.requestBody.extends){let b=i[c.typeId];if(b==null)throw new Error(`Failed to find extended type declaration with id ${c.typeId}`);let g=BDn({typeDeclaration:b,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});g!=null&&g.type==="success"&&Object.assign(s,g.jsonExample)}for(let c of[...t.requestBody.properties??[],...t.requestBody.extendedProperties??[]]){let b=ZT({fieldName:c.name.wireValue,typeReference:c.valueType,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});if(b.type==="failure"&&!xDn({typeDeclarations:i,typeReference:c.valueType}))return{type:"failure",message:`Failed to generate required property ${c.name.wireValue} b/c ${b.message}`};if(b.type==="failure")continue;let{example:g,jsonExample:O}=b;o.push({name:c.name,originalTypeDeclaration:void 0,value:g}),s[c.name.wireValue]=O}u.request=U$.inlinedRequestBody({jsonExample:s,properties:o});break}case"reference":{let s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.requestBody.requestBodyType,skipOptionalProperties:n});if(s.type==="failure")return s;let{example:o}=s;u.request=U$.reference(o);break}default:Fo(t.requestBody)}if(a.type==="success"&&t.response?.body!=null)switch(t.response.body.type){case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":{let s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.responseBodyType,skipOptionalProperties:!1});if(s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Cq.ok(KT.body({...o,jsonExample:c}));break}case"streamParameter":{let s;switch(t.response.body.nonStreamResponse.type){case"bytes":return{type:"failure",message:"Bytes unsupported"};case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.nonStreamResponse.value.responseBodyType,skipOptionalProperties:!1});break;case"text":s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:cJs,skipOptionalProperties:!1});break;default:Fo(t.response.body.nonStreamResponse)}if(s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Cq.ok(KT.body({...o,jsonExample:c}));break}case"streaming":{let s;switch(t.response.body.value.type){case"sse":{if(s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Cq.ok(KT.sse([{data:{...o,jsonExample:c},event:""}]));break}case"json":{if(s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Cq.ok(KT.stream([{...o,jsonExample:c}]));break}case"text":{if(s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:cJs,skipOptionalProperties:!1}),s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Cq.ok(KT.stream([{...o,jsonExample:c}]));break}default:Fo(t.response.body.value)}break}case"text":{let s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:cJs,skipOptionalProperties:!1});if(s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Cq.ok(KT.body({...o,jsonExample:c}));break}case"bytes":return{type:"failure",message:"Bytes unsupported"};default:Fo(t.response.body)}else if(a.type==="error")if(a.declaration.type==null)u.response=Cq.error({body:void 0,error:a.declaration.name});else{let s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:a.declaration.type,skipOptionalProperties:n});if(s.type==="failure")return s;let{example:o}=s;u.response=Cq.error({body:o,error:a.declaration.name})}try{return{type:"success",example:{id:Iya(u),url:EKD(t,u),...u},jsonExample:void 0}}catch(s){return{type:"failure",message:`Parse failure with exceptions ${s}`}}}function EKD(e,t){let r={};[...t.rootPathParameters,...t.servicePathParameters,...t.endpointPathParameters].forEach(n=>{let a=n.value.jsonExample,u=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=u});let i=e.fullPath.head+e.fullPath.parts.map(n=>r[n.pathParameter]+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function mNi({ir:e,exampleGeneration:t}){for(let[r,i]of Object.entries(e.services))for(let n of i.endpoints){if(n.userSpecifiedExamples.length>0&&t?.skipAutogenerationIfManualExamplesExist===!0)continue;let a=zya({ir:e,service:i,endpoint:n,typeDeclarations:e.types,skipOptionalRequestProperties:!t?.includeOptionalRequestPropertyExamples,generationResponse:{type:"success"}});if(a.type==="failure")continue;let{example:u}=a;n.autogeneratedExamples=[{example:u}]}return e}function lJs(e,t){return{apiName:e.apiName,basePath:e.basePath,apiDisplayName:e.apiDisplayName??t.apiDisplayName,apiDocs:e.apiDocs??t.apiDocs,auth:e.auth??t.auth,headers:[...e.headers??[],...t.headers??[]],environments:e.environments??t.environments,types:{...e.types??{},...t.types??{}},constants:{...e.constants??{},...t.constants??{}},errors:{...e.errors??{},...t.errors??{}},services:{...e.services??{},...t.services??{}},webhookGroups:{...e.webhookGroups??{},...t.webhookGroups??{}},subpackages:{...e.subpackages??{},...t.subpackages??{}},websocketChannels:{...e.websocketChannels??{},...t.websocketChannels??{}},rootPackage:{service:e.rootPackage.service??t.rootPackage.service,types:[...e.rootPackage.types??[],...t.rootPackage.types??[]],errors:[...e.rootPackage.errors??[],...t.rootPackage.errors??[]],subpackages:[...e.rootPackage.subpackages??[],...t.rootPackage.subpackages??[]],fernFilepath:e.rootPackage.fernFilepath??t.rootPackage.fernFilepath,webhooks:e.rootPackage.webhooks??t.rootPackage.webhooks,websocket:e.rootPackage.websocket??t.rootPackage.websocket,hasEndpointsInTree:e.rootPackage.hasEndpointsInTree||t.rootPackage.hasEndpointsInTree,navigationConfig:e.rootPackage.navigationConfig??t.rootPackage.navigationConfig,docs:e.rootPackage.docs??t.rootPackage.docs},fdrApiDefinitionId:e.fdrApiDefinitionId??t.fdrApiDefinitionId,apiVersion:e.apiVersion??t.apiVersion,idempotencyHeaders:[...e.idempotencyHeaders??[],...t.idempotencyHeaders??[]],pathParameters:[...e.pathParameters??[],...t.pathParameters??[]],errorDiscriminationStrategy:e.errorDiscriminationStrategy??t.errorDiscriminationStrategy,variables:[...e.variables??[],...t.variables??[]],serviceTypeReferenceInfo:e.serviceTypeReferenceInfo??t.serviceTypeReferenceInfo,readmeConfig:e.readmeConfig??t.readmeConfig,sourceConfig:e.sourceConfig??t.sourceConfig,publishConfig:e.publishConfig??t.publishConfig,dynamic:e.dynamic??t.dynamic,sdkConfig:e.sdkConfig??t.sdkConfig}}var Oy=class{breadcrumbs=[];constructor({breadcrumbs:t=[]}={}){this.breadcrumbs=t}};var CKp={[Jb.GenerationLanguage.PHP]:new Set(["abstract","and","as","break","callable","case","catch","class","clone","const","continue","declare","default","do","echo","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","extends","final","finally","fn","for","foreach","function","global","goto","list","if","implements","include","include_once","instanceof","insteadof","interface","match","namespace","new","or","parent","Parent","print","private","protected","public","readonly","require","require_once","return","static","switch","throw","trait","try","use","var","while","xor","yield"].flatMap(e=>[e,G3(e)])),[Jb.GenerationLanguage.TYPESCRIPT]:new Set(["any","as","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","module","new","null","number","of","package","private","protected","public","require","return","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","var","void","while","with","yield","Date","Error","File","Object","Record"]),[Jb.GenerationLanguage.JAVA]:new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","try","void","volatile","while"]),[Jb.GenerationLanguage.PYTHON]:new Set(["False","None","True","and","as","assert","async","","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","float","int","complex","bool","uuid","list","set","map","long","self","all"]),[Jb.GenerationLanguage.GO]:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[Jb.GenerationLanguage.RUBY]:new Set(["__ENCODING__","__LINE__","__FILE__","alias","and","begin","break","case","class","def","defined","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","Object","JSON","Date","DateTime"]),[Jb.GenerationLanguage.CSHARP]:new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while","add","and","alias","ascending","args","async","","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","managed","nameof","nint","not","notnull","nuint","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value","var","when","where","with","yield"]),[Jb.GenerationLanguage.SWIFT]:new Set([])};var MKD=["go","ruby"];function ZSe({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let u=c=>({unsafeName:c,safeName:AKD({name:c,keywords:qKD({generationLanguage:e,keywords:t})})}),l=Dg(n),d=G3(l),s=aYa(n),o=Lra(l);return r&&(!BKD(o)&&(e==null||MKD.includes(e))&&(l=o.map((c,b)=>{if(b>0){let g=SRo(c);if(g!=null)return g;if(DRo(c))return c.toUpperCase()}return c}).join(""),d=o.map((c,b)=>{let g=SRo(c);return g??(DRo(c)?c.toUpperCase():b===0?G3(c):c)}).join("")),s=n.split(" ").map(c=>c.split(/(\d+)/).map(aYa).join("")).join("_")),{originalName:n,camelCase:u(a?.casingOverrides?.camel??l),snakeCase:u(a?.casingOverrides?.snake??s),screamingSnakeCase:u(a?.casingOverrides?.["screaming-snake"]??s.toUpperCase()),pascalCase:u(a?.casingOverrides?.pascal??d)}},generateNameAndWireValue:({name:n,wireValue:a,opts:u})=>({name:i.generateName(n,u),wireValue:a})};return i}function AKD({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":CKD(e)?"_"+e:e}function qKD({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return CKp[e]}var TKD=/^[0-9]/;function CKD(e){return TKD.test(e)}function BKD(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=SRo(i)!=null||DRo(i),a=SRo(t)!=null||DRo(t);return n&&a})}function SRo(e){return IKD.get(e.toUpperCase())}function DRo(e){return xKD.has(e.toUpperCase())}var xKD=new Set(["ACL","API","ASCII","CPU","CSS","DNS","EOF","GUID","HTML","HTTP","HTTPS","ID","IP","JSON","LHS","QPS","RAM","RHS","RPC","SAML","SCIM","SLA","SMTP","SQL","SSH","SSO","TCP","TLS","TTL","UDP","UI","UID","UUID","URI","URL","UTF8","VM","XML","XMPP","XSRF","XSS"]),IKD=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]);var PNi=class e{args;spec;settings;logger;generationLanguage;smartCasing;casingsGenerator;constructor(t){this.args=t,this.spec=t.spec,this.settings=t.settings,this.logger=t.logger,this.generationLanguage=t.generationLanguage,this.smartCasing=t.smartCasing,this.casingsGenerator=ZSe({generationLanguage:t.generationLanguage,keywords:void 0,smartCasing:t.smartCasing})}static BREADCRUMBS_TO_IGNORE=["properties","allOf","anyOf"];convertBreadcrumbsToName(t){let r=t.filter((n,a)=>!(/^\d+$/.test(n)||e.BREADCRUMBS_TO_IGNORE.includes(n)||a===0&&n==="components"||a===1&&n==="schemas"||t[0]==="paths"&&(a===0||a===1&&["get","post","put","delete","patch"].includes(n)||a===2&&t[1]!=null&&["get","post","put","delete","patch"].includes(t[1])&&n==="parameters"))),i=Dg(r.join("_"));return i.charAt(0).toUpperCase()+i.slice(1)}createPackage(t={}){return{fernFilepath:{allParts:[],packagePath:[],file:t.name!=null?this.casingsGenerator.generateName(t.name):void 0},service:void 0,types:[],errors:[],subpackages:[],docs:void 0,webhooks:void 0,websocket:void 0,hasEndpointsInTree:!1,navigationConfig:void 0}}async resolveReference(t){let r=this.spec,i;if(t.$ref.startsWith("http://")||t.$ref.startsWith("https://")){let a=t.$ref.split("#"),u=a[0];if(i=a[1],!u)return{resolved:!1};let l=await fetch(u);if(!l.ok)return{resolved:!1};try{let d=await l.text();try{r=JSON.parse(d)}catch{r=Kd.load(d)}if(r==null)return{resolved:!1}}catch{return{resolved:!1}}if(!i)return{resolved:!0,value:r}}let n=(i??t.$ref).replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(a=>a.replace(/~1/g,"/"));for(let a of n){if(typeof r!="object"||r==null)return{resolved:!1};r=r[a]}return r==null?{resolved:!1}:{resolved:!0,value:r}}createNamedTypeReference(t){return pd.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(t??"defaultName"),typeId:t,default:void 0,inline:!1})}typeReferenceToDeclaredTypeName(t){if(t.type!=="named")return;let r=t.typeId;return{typeId:r,fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r)}}removeSchemaFromInlinedTypes({id:t,inlinedTypes:r}){return Object.fromEntries(Object.entries(r).filter(([i])=>i!==t))}maybeTrimPrefix(t,r){return t.startsWith(r)?t.slice(r.length):t}isOptional(t){return t.type==="container"&&t.container.type==="optional"}isList(t){return t.type==="container"&&t.container.type==="list"}isFile(t){return t.type==="primitive"&&t.primitive.v2?.type==="string"&&t.primitive.v2.validation?.format==="binary"}getAsString(t){if(typeof t=="string")return t}getAsInteger(t){if(typeof t=="number"&&Number.isInteger(t))return t}getAsNumber(t){if(typeof t=="number")return t}getAsBoolean(t){if(typeof t=="boolean")return t}getAsArray(t){if(Array.isArray(t))return t}getAsObject(t){if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t}};var sz=class extends Oy{getExtensionValue(t){if(!(typeof t!="object"||t==null))return t[this.key]}};var Rya=class{errors=[];logger;constructor({logger:t}){this.logger=t}collect(t){this.errors.push(t)}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}logErrors(){for(let t of this.errors)this.logger.log(V0.Info,jie({title:t.message,breadcrumbs:t.path,subtitle:t.path!=null?k_.dim(t.path.join(" -> ")):void 0}))}};var AG={};Co(AG,{FernAvailabilityExtension:()=>ERo,FernEnumExtension:()=>MRo,FernIgnoreExtension:()=>ARo});var ERo=class extends sz{node;key="x-fern-availability";constructor({breadcrumbs:t,node:r}){super({breadcrumbs:t}),this.node=r}async convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.node);if(i==null||typeof i!="string")return;switch(i.toUpperCase().replace(/[-_\s]/g,"_")){case"IN_DEVELOPMENT":return a7.InDevelopment;case"PRE_RELEASE":return a7.PreRelease;case"GENERAL_AVAILABILITY":return a7.GeneralAvailability;case"DEPRECATED":return a7.Deprecated;default:return}}};var zKD=Yu.object({snake:Yu.string().optional(),camel:Yu.string().optional(),screamingSnake:Yu.string().optional(),pascal:Yu.string().optional()}),RKD=Yu.object({description:Yu.string().optional(),name:Yu.string().optional(),casing:zKD.optional()}),BKp=Yu.record(RKD);var MRo=class extends sz{schema;key="x-fern-enum";constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.schema);if(i==null)return;let n=BKp.safeParse(i);if(!n.success){r.collect({message:`Invalid x-fern-enum extension: ${n.error.message}`,path:this.breadcrumbs});return}return n.data}};var ARo=class extends sz{operation;key="x-fern-ignore";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null){if(typeof i!="boolean"){r.collect({message:"Received unexpected non-boolean value for x-fern-ignore",path:this.breadcrumbs});return}return i}}};function jNi(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","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),l=e%10;return l===0?i[u]:`${i[u]}_${t[l]}`}if(e<1e3){let u=Math.floor(e/100),l=e%100;return l===0?`${t[u]}_hundred`:`${t[u]}_hundred_${jNi(l)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${jNi(a)}`}var pJs=yi(xKp(),1);var IKp=["get","post","put","delete","patch"];var qRo=class extends sz{operation;key="x-fern-idempotent";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null){if(typeof i!="boolean"){r.collect({message:"Received unexpected non-boolean value for x-fern-idempotent",path:this.breadcrumbs});return}return i}}};var LKD=Yu.object({cursor:Yu.string(),next_cursor:Yu.string(),results:Yu.string()}),UKD=Yu.object({offset:Yu.string(),results:Yu.string(),step:Yu.string().optional(),"has-next-page":Yu.string().optional()}),fJs=Yu.union([Yu.boolean(),LKD,UKD]);var dJs="$request.",TRo="$response.",CRo=class extends sz{operation;document;key="x-fern-pagination";constructor({breadcrumbs:t,operation:r,document:i}){super({breadcrumbs:t}),this.operation=r,this.document=i}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i==null)return;let n=fJs.safeParse(i);if(!n.success){r.collect({message:`Invalid x-fern-pagination extension: ${n.error.message}`,path:this.breadcrumbs});return}if(typeof n.data=="boolean"){let a=this.getExtensionValue(this.document);if(a==null)return;if(typeof a=="boolean"){r.collect({message:"Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.",path:this.breadcrumbs});return}let u=fJs.safeParse(a);if(!u.success){r.collect({message:`Invalid x-fern-pagination extension: ${u.error.message}`,path:this.breadcrumbs});return}if(typeof u.data=="boolean"){r.collect({message:"Global pagination extension is a boolean, expected an object.",path:this.breadcrumbs});return}return this.convertPaginationConfig(u.data,t)}if(typeof n.data=="boolean"){r.collect({message:"Pagination extension is a boolean with no global configuration.",path:this.breadcrumbs});return}return this.convertPaginationConfig(n.data,t)}convertPaginationConfig(t,r){let i=t;if("cursor"in i)return{type:"cursor",cursor:r.maybeTrimPrefix(i.cursor,dJs),nextCursor:r.maybeTrimPrefix(i.next_cursor,TRo),results:r.maybeTrimPrefix(i.results,TRo)};let n=t;return{type:"offset",offset:r.maybeTrimPrefix(n.offset,dJs),results:r.maybeTrimPrefix(n.results,TRo),step:n.step!=null?r.maybeTrimPrefix(n.step,dJs):void 0,hasNextPage:n["has-next-page"]!=null?r.maybeTrimPrefix(n["has-next-page"],TRo):void 0}}};var VKD="$request.",WKD=Yu.object({"stream-condition":Yu.string().optional(),format:Yu.enum(["sse","json"]).optional(),"stream-description":Yu.string().optional(),"response-stream":Yu.any(),response:Yu.any()}),HKD=Yu.union([Yu.boolean(),WKD]),BRo=class extends sz{operation;key="x-fern-streaming";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i==null)return;let n=HKD.safeParse(i);if(!n.success){r.collect({message:`Invalid x-fern-streaming extension: ${n.error.message}`,path:this.breadcrumbs});return}if(typeof n.data=="boolean")return n.data?{type:"stream",format:"json"}:void 0;if(n.data["stream-condition"]==null&&n.data.format!=null)return{type:"stream",format:n.data.format};if(n.data["stream-condition"]==null){r.collect({message:"Missing required stream-condition property",path:this.breadcrumbs});return}return{type:"streamCondition",format:n.data.format??"json",streamDescription:n.data["stream-description"],streamConditionProperty:t.maybeTrimPrefix(n.data["stream-condition"],VKD),responseStream:n.data["response-stream"],response:n.data.response}}};var xRo=class extends sz{operation;key="x-fern-webhook";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null){if(typeof i!="boolean"){r.collect({message:"Received unexpected non-boolean value for x-fern-webhook",path:this.breadcrumbs});return}return i}}};var IRo=class extends sz{operation;key="x-fern-sdk-group-name";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i==null)return;let n=Array.isArray(i)?i.filter(a=>typeof a=="string"):typeof i=="string"?[i]:[];if(n.length!==0)return{groups:n}}};var zRo=class extends sz{operation;key="x-fern-sdk-method-name";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null&&typeof i=="string")return{methodName:i}}};var RRo=class e extends Oy{static LIST_UNKNOWN=pd.container(Ev.list(pd.unknown()));schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){if(this.schema.items==null)return{typeReference:e.LIST_UNKNOWN};let n=await new cX({breadcrumbs:[...this.breadcrumbs,"items"],schemaOrReference:this.schema.items}).convert({context:t,errorCollector:r});return n!=null?{typeReference:pd.container(Ev.list(n.type)),inlinedTypes:n.inlinedTypes}:{typeReference:e.LIST_UNKNOWN}}};var NRo=class extends Oy{schema;maybeFernEnum;constructor({breadcrumbs:t,schema:r,maybeFernEnum:i}){super({breadcrumbs:t}),this.schema=r,this.maybeFernEnum=i}convert({context:t,errorCollector:r}){if(!this.schema.enum)return;let n=this.schema.enum.filter(u=>typeof u=="string").map(u=>{let l=this.maybeFernEnum?.[u],d=l?.name??u.toString();return{name:t.casingsGenerator.generateNameAndWireValue({name:d,wireValue:u.toString()}),docs:l?.description,availability:void 0,casing:l?.casing}});if(n.length===0)return;let a=t.getAsString(this.schema.default);return{enum:a0.enum({default:a!=null?n.find(u=>u.name.wireValue===a):void 0,values:n})}}};var FRo=class extends Oy{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){if(!this.schema.properties&&!this.schema.allOf)return{object:a0.object({properties:[],extends:[],extendedProperties:[],extraProperties:this.schema.additionalProperties!=null})};let i=[],n={};for(let[u,l]of Object.entries(this.schema.properties??{})){let d=[...this.breadcrumbs,"properties",u],s="nullable"in l?l.nullable:!1,o=t.convertBreadcrumbsToName(d),b=await new cX({breadcrumbs:d,schemaOrReference:l,schemaIdOverride:o,wrapAsOptional:!this.schema.required?.includes(u),wrapAsNullable:s}).convert({context:t,errorCollector:r});b!=null&&(i.push({name:t.casingsGenerator.generateNameAndWireValue({name:u,wireValue:u}),valueType:b.type,docs:l.description,availability:b.availability,propertyAccess:await t.getPropertyAccess(l)}),n={...n,...b.inlinedTypes})}let a=[];for(let[u,l]of(this.schema.allOf??[]).entries()){let d=[...this.breadcrumbs,"allOf",u.toString()];if(t.isReferenceObject(l)){let s=await t.convertReferenceToTypeReference(l);s.ok&&a.push(s.reference);continue}for(let[s,o]of Object.entries(l.properties??{})){let c=[...d,s],b=t.convertBreadcrumbsToName(c),O=await new cX({breadcrumbs:c,schemaOrReference:o,schemaIdOverride:b,wrapAsOptional:!l.required?.includes(s),wrapAsNullable:"nullable"in o?o.nullable:!1}).convert({context:t,errorCollector:r});O!=null&&(i.push({name:t.casingsGenerator.generateNameAndWireValue({name:s,wireValue:s}),valueType:O.type,docs:o.description,availability:O.availability,propertyAccess:await t.getPropertyAccess(o)}),n={...n,...O.inlinedTypes})}}return{object:a0.object({properties:i,extends:a.map(u=>t.typeReferenceToDeclaredTypeName(u)).filter(Qb),extendedProperties:[],extraProperties:this.schema.additionalProperties!=null}),inlinedTypes:n}}};var LRo=class extends Oy{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){return this.schema.discriminator!=null?await this.convertAsDiscriminatedUnion({context:t,errorCollector:r}):this.convertAsUndiscriminatedUnion({context:t,errorCollector:r})}async convertAsDiscriminatedUnion({context:t,errorCollector:r}){let i=[],n={};if(this.schema.discriminator!=null){for(let[a,u]of Object.entries(this.schema.discriminator.mapping??{})){let l=new cX({schemaOrReference:{$ref:u},breadcrumbs:[...this.breadcrumbs,"discriminator","mapping",a]}),d=t.getTypeIdFromSchemaReference({$ref:u}),s=await l.convert({context:t,errorCollector:r});if(s?.type!=null&&d!=null){let o=t.casingsGenerator.generateNameAndWireValue({name:a,wireValue:a});i.push({docs:void 0,discriminantValue:o,availability:s.availability,displayName:void 0,shape:Z8.samePropertiesAsObject({typeId:d,name:t.casingsGenerator.generateName(d),fernFilepath:{allParts:[],packagePath:[],file:void 0}})}),n={...n,...s.inlinedTypes}}}return{union:a0.union({baseProperties:[],discriminant:t.casingsGenerator.generateNameAndWireValue({name:this.schema.discriminator.propertyName,wireValue:this.schema.discriminator.propertyName}),extends:[],types:i}),inlinedTypes:n}}}async convertAsUndiscriminatedUnion({context:t,errorCollector:r}){if(!this.schema.oneOf||this.schema.oneOf.length===0)return;let i=[],n={};for(let[a,u]of this.schema.oneOf.entries()){let l=[...this.breadcrumbs,"oneOf",jNi(a)??""];if(t.isReferenceObject(u)){let c=await t.convertReferenceToTypeReference(u);c.ok&&i.push({type:c.reference,docs:u.description});continue}let d=t.convertBreadcrumbsToName(l),o=await new Dpi({id:d,breadcrumbs:l,schema:u}).convert({context:t,errorCollector:r});o!=null&&(i.push({type:t.createNamedTypeReference(d),docs:u.description}),n={...n,...o.inlinedTypes,[d]:o.typeDeclaration})}return{union:a0.undiscriminatedUnion({members:i}),inlinedTypes:n}}};var URo=class extends Oy{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}convert({context:t,errorCollector:r}){switch(this.schema.type){case"string":{let i=t.getAsString(this.schema.const);return i!=null?pd.container(Ev.literal(k8.string(i))):pd.primitive({v1:"STRING",v2:Z_.string({default:t.getAsString(this.schema.default),validation:this.getStringValidation(this.schema)})})}case"number":case"integer":switch(this.schema.format){case"double":case void 0:return pd.primitive({v1:"DOUBLE",v2:Z_.double({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return pd.primitive({v1:"FLOAT",v2:Z_.float({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return pd.primitive({v1:"INTEGER",v2:Z_.integer({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return pd.primitive({v1:"LONG",v2:Z_.long({default:t.getAsNumber(this.schema.default)})});case"uint32":return pd.primitive({v1:"UINT",v2:Z_.uint({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return pd.primitive({v1:"UINT_64",v2:Z_.uint64({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return pd.primitive({v1:"INTEGER",v2:Z_.integer({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"boolean":{let i=t.getAsBoolean(this.schema.const);return i!=null?pd.container(Ev.literal(k8.boolean(i))):pd.primitive({v1:"BOOLEAN",v2:Z_.boolean({default:this.schema.default})})}default:return}}getNumberValidation(t){return{max:t.maximum,min:t.minimum,exclusiveMax:typeof t.exclusiveMaximum=="boolean"?t.exclusiveMaximum:void 0,exclusiveMin:typeof t.exclusiveMinimum=="boolean"?t.exclusiveMinimum:void 0,multipleOf:t.multipleOf}}getStringValidation(t){return{minLength:t.minLength,maxLength:t.maxLength,pattern:t.pattern,format:t.format}}};var Dpi=class extends Oy{schema;id;inlined;constructor({breadcrumbs:t,schema:r,id:i,inlined:n=!1}){super({breadcrumbs:t}),this.schema=r,this.id=i,this.inlined=n}async convert({context:t,errorCollector:r}){if(this.schema.enum?.length){let u=new AG.FernEnumExtension({breadcrumbs:this.breadcrumbs,schema:this.schema}).convert({context:t,errorCollector:r}),d=new NRo({breadcrumbs:this.breadcrumbs,schema:this.schema,maybeFernEnum:u}).convert({context:t,errorCollector:r});if(d!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:d.enum,context:t,errorCollector:r}),inlinedTypes:{}}}let n=new URo({schema:this.schema}).convert({context:t,errorCollector:r});if(n!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:a0.alias({aliasOf:n,resolvedType:n}),context:t,errorCollector:r}),inlinedTypes:{}};if(this.schema.type==="array"){let u=await new RRo({breadcrumbs:this.breadcrumbs,schema:this.schema}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:a0.alias({aliasOf:u.typeReference,resolvedType:u.typeReference}),context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}if(this.schema.oneOf!=null){let u=await new LRo({breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:u.union,context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}if(this.schema.type==="object"||this.schema.properties!=null||this.schema.allOf!=null){let u=await new FRo({breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:u.object,context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}}async createTypeDeclaration({shape:t,context:r,errorCollector:i}){return{name:this.convertDeclaredTypeName({context:r}),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:await r.getAvailability({node:this.schema,breadcrumbs:this.breadcrumbs,errorCollector:i}),docs:this.schema.description,referencedTypes:new Set,source:void 0,inline:this.inlined}}convertDeclaredTypeName({context:t}){return{typeId:this.id,fernFilepath:{allParts:[],packagePath:[],file:void 0},name:t.casingsGenerator.generateName(this.id)}}};var cX=class extends Oy{schemaOrReference;schemaIdOverride;wrapAsOptional;wrapAsNullable;constructor({breadcrumbs:t,schemaOrReference:r,schemaIdOverride:i,wrapAsOptional:n=!1,wrapAsNullable:a=!1}){super({breadcrumbs:t}),this.schemaOrReference=r,this.schemaIdOverride=i,this.wrapAsOptional=n,this.wrapAsNullable=a}async convert({context:t,errorCollector:r}){if(t.isReferenceObject(this.schemaOrReference)){let l=await t.convertReferenceToTypeReference(this.schemaOrReference);return l.ok?{type:l.reference,inlinedTypes:{}}:void 0}let i=this.schemaIdOverride??t.convertBreadcrumbsToName(this.breadcrumbs),n=new Dpi({breadcrumbs:this.breadcrumbs,schema:this.schemaOrReference,id:i}),a=await t.getAvailability({node:this.schemaOrReference,breadcrumbs:this.breadcrumbs,errorCollector:r}),u=await n.convert({context:t,errorCollector:r});if(u!=null){if(u.typeDeclaration.shape.type==="alias"){let d=u.typeDeclaration.shape.aliasOf;return{type:this.wrapTypeReference(d),inlinedTypes:u.inlinedTypes,availability:a}}let l=t.createNamedTypeReference(i);return{type:this.wrapTypeReference(l),schema:u.typeDeclaration,inlinedTypes:{...u.inlinedTypes,[i]:u.typeDeclaration},availability:a}}}wrapTypeReference(t){return this.wrapAsOptional&&this.wrapAsNullable?this.wrapInOptional(this.wrapInNullable(t)):this.wrapAsOptional?this.wrapInOptional(t):this.wrapAsNullable?this.wrapInNullable(t):t}wrapInOptional(t){return pd.container(Ev.optional(t))}wrapInNullable(t){return pd.container(Ev.nullable(t))}};var Nya=class e extends Oy{static STRING=pd.primitive({v1:"STRING",v2:Z_.string({default:void 0,validation:void 0})});static OPTIONAL_STRING=pd.container(Ev.optional(e.STRING));parameter;constructor({breadcrumbs:t,parameter:r}){super({breadcrumbs:t}),this.parameter=r}async convert({context:t,errorCollector:r}){let i,n={};if(this.parameter.schema!=null){let l=await new cX({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required}).convert({context:t,errorCollector:r});l!=null&&(i=l.type,n=l.inlinedTypes??{})}let a=await t.getAvailability({node:this.parameter,breadcrumbs:this.breadcrumbs,errorCollector:r});switch(this.parameter.in){case"query":return{type:"query",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??e.OPTIONAL_STRING,allowMultiple:this.parameter.explode??!1,availability:a},inlinedTypes:n};case"header":return{type:"header",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??e.OPTIONAL_STRING,env:void 0,availability:a},inlinedTypes:n};case"path":return{type:"path",parameter:{name:t.casingsGenerator.generateName(this.parameter.name),docs:this.parameter.description,valueType:i??e.STRING,location:"ENDPOINT",variable:void 0},inlinedTypes:n};default:return}}};var VRo=class extends Oy{requestBody;group;method;constructor({breadcrumbs:t,requestBody:r,group:i,method:n}){super({breadcrumbs:t}),this.requestBody=r,this.group=i,this.method=n}async convert({context:t,errorCollector:r}){if(!this.requestBody.content)return;let i=Object.keys(this.requestBody.content).filter(u=>u.includes("json"));for(let u of i){let l=this.handleJsonOrFormContent({contentType:u,context:t,errorCollector:r});if(l!=null)return l}let n=Object.keys(this.requestBody.content).filter(u=>u.includes("multipart"));for(let u of n){let l=[...this.group,this.method,"Request"].join("_"),d=await this.convertRequestSchemaForMediaType({schemaId:l,contentType:u,context:t,errorCollector:r});if(d!=null&&d.schema?.shape.type==="object")return{requestBody:eI.fileUpload({docs:this.requestBody.description,name:t.casingsGenerator.generateName(l),properties:d.schema?.shape.properties.map(o=>this.convertRequestBodyProperty({context:t,property:o,contentType:u}))}),inlinedTypes:t.removeSchemaFromInlinedTypes({id:l,inlinedTypes:d.inlinedTypes}),examples:d.examples}}let a=Object.keys(this.requestBody.content).filter(u=>u.includes("urlencoded"));for(let u of a){let l=this.handleJsonOrFormContent({contentType:u,context:t,errorCollector:r});if(l!=null)return l}}async convertRequestSchemaForMediaType({schemaId:t,contentType:r,context:i,errorCollector:n}){let a=this.requestBody.content[r];if(a==null||a.schema==null)return;let l=await new cX({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:a.schema,schemaIdOverride:t}).convert({context:i,errorCollector:n});if(l==null)return;let d=a.examples!=null?Object.fromEntries(await Promise.all(Object.entries(a.examples).map(async([s,o])=>[s,i.isReferenceObject(o)?await i.resolveReference(o):o]))):void 0;return{...l,examples:d}}async handleJsonOrFormContent({contentType:t,context:r,errorCollector:i}){let n=[...this.group,this.method,"Request"].join("_"),a=await this.convertRequestSchemaForMediaType({schemaId:n,contentType:t,context:r,errorCollector:i});if(a!=null)return a.schema?.shape.type==="object"?{requestBody:eI.inlinedRequestBody({contentType:t,docs:this.requestBody.description,name:r.casingsGenerator.generateName(n),extendedProperties:a.schema?.shape.extendedProperties,extends:a.schema?.shape.extends,properties:a.schema?.shape.properties,extraProperties:a.schema?.shape.extraProperties}),inlinedTypes:r.removeSchemaFromInlinedTypes({id:n,inlinedTypes:a.inlinedTypes})}:{requestBody:eI.reference({contentType:t,docs:this.requestBody.description,requestBodyType:a.type}),inlinedTypes:r.removeSchemaFromInlinedTypes({id:n,inlinedTypes:a.inlinedTypes})}}convertRequestBodyProperty({context:t,property:r,contentType:i}){return t.isFile(r.valueType)?GN.file(xU.file({key:r.name,isOptional:!1,contentType:i,docs:r.docs})):t.isOptional(r.valueType)&&t.isFile(r.valueType.container.optional)?GN.file(xU.file({key:r.name,isOptional:!0,contentType:i,docs:r.docs})):t.isList(r.valueType)&&t.isFile(r.valueType.container.list)?GN.file(xU.fileArray({key:r.name,isOptional:!1,contentType:i,docs:r.docs})):t.isList(r.valueType)&&t.isOptional(r.valueType.container.list)&&t.isFile(r.valueType.container.list.container.optional)?GN.file(xU.fileArray({key:r.name,isOptional:!1,contentType:i,docs:r.docs})):t.isOptional(r.valueType)&&t.isList(r.valueType.container.optional)&&t.isFile(r.valueType.container.optional.container.list)?GN.file(xU.fileArray({key:r.name,isOptional:!0,contentType:i,docs:r.docs})):GN.bodyProperty({...r,contentType:i,style:void 0,name:r.name})}};var WRo=class extends Oy{responseBody;group;method;statusCode;constructor({breadcrumbs:t,responseBody:r,group:i,method:n,statusCode:a}){super({breadcrumbs:t}),this.responseBody=r,this.group=i,this.method=n,this.statusCode=a}async convert({context:t,errorCollector:r}){if(!this.responseBody.content)return;let i=Object.keys(this.responseBody.content).filter(n=>n.includes("json"));for(let n of[...i]){let a=this.responseBody.content[n];if(a==null||a.schema==null)continue;let u=[...this.group,this.method,"Response",this.statusCode].join("_"),d=await new cX({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:a.schema,schemaIdOverride:u}).convert({context:t,errorCollector:r});if(d==null)continue;let s=a.examples!=null?Object.fromEntries(await Promise.all(Object.entries(a.examples).map(async([o,c])=>[o,t.isReferenceObject(c)?await t.resolveReference(c):c]))):void 0;if(n.includes("json"))return{responseBody:cT.json(sSe.response({responseBodyType:d.type,docs:this.responseBody.description})),inlinedTypes:d.inlinedTypes,examples:s}}}};var $KD=/{([^}]+)}/g,IDn=class extends Oy{operation;method;path;inlinedTypes={};constructor({breadcrumbs:t,operation:r,method:i,path:n}){super({breadcrumbs:t}),this.operation=r,this.method=i,this.path=n}convertHttpMethod(){switch(this.method){case"get":return o7.Get;case"post":return o7.Post;case"put":return o7.Put;case"delete":return o7.Delete;case"patch":return o7.Patch;default:return}}async convertParameters({context:t,errorCollector:r,breadcrumbs:i}){let n=[],a=[],u=[];if(!this.operation.parameters)return{pathParameters:n,queryParameters:a,headers:u};for(let s of this.operation.parameters){if(t.isReferenceObject(s)){let b=await t.resolveReference(s);if(b.resolved)s=b.value;else continue}let c=await new Nya({breadcrumbs:i,parameter:s}).convert({context:t,errorCollector:r});if(c!=null)switch(this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes},c.type){case"path":n.push(c.parameter);break;case"query":a.push(c.parameter);break;case"header":u.push(c.parameter);break}}let d=[...this.path.matchAll($KD)].map(s=>s[1]).filter(s=>!n.some(o=>o.name.originalName===s));for(let s of d)s!=null&&n.push({name:t.casingsGenerator.generateName(s),valueType:Nya.STRING,docs:void 0,location:"ENDPOINT",variable:void 0});return{pathParameters:n,queryParameters:a,headers:u}}async convertRequestBody({context:t,errorCollector:r,breadcrumbs:i,group:n,method:a}){if(this.operation.requestBody==null)return;let u;if(t.isReferenceObject(this.operation.requestBody)){let s=await t.resolveReference(this.operation.requestBody);s.resolved&&(u=s.value)}else u=this.operation.requestBody;if(u==null)return null;let d=await new VRo({breadcrumbs:i,requestBody:u,group:n??[],method:a}).convert({context:t,errorCollector:r});if(d!=null)return this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},{value:d.requestBody,examples:d.examples}}async convertResponseBody({context:t,errorCollector:r,breadcrumbs:i,group:n,method:a}){if(this.operation.responses!=null)for(let[u,l]of Object.entries(this.operation.responses)){let d=parseInt(u);if(isNaN(d)||d<200||d>=300)continue;let s;if(t.isReferenceObject(l)){let b=await t.resolveReference(l);b.resolved&&(s=b.value)}else s=l;if(s==null)continue;let c=await new WRo({breadcrumbs:[...i,u],responseBody:s,group:n??[],method:a,statusCode:u}).convert({context:t,errorCollector:r});if(c!=null)return this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes},{value:{statusCode:d,body:c.responseBody},examples:c.examples}}}computeGroupNameAndLocationFromExtensions({context:t,errorCollector:r}){let n=new zRo({breadcrumbs:this.breadcrumbs,operation:this.operation}).convert({context:t,errorCollector:r})?.methodName,u=new IRo({breadcrumbs:this.breadcrumbs,operation:this.operation}).convert({context:t,errorCollector:r})?.groups??[];if(n!=null)return{group:u,method:n}}computeGroupNameFromTagAndOperationId({context:t,errorCollector:r}){let i=this.operation.tags?.[0],n=this.operation.operationId;if(n==null){let l=this.operation.summary!=null?Dg(this.operation.summary):Dg(`${this.method}_${this.path.split("/").join("_")}`);return i!=null?{group:[i],method:l}:{method:l}}if(i==null)return{method:n};let a=zKp(i),u=zKp(n);return F1e(a,u)?{method:i}:this.computeGroupAndMethodFromTokens({tag:i,tagTokens:a,operationId:n,operationIdTokens:u})}computeGroupAndMethodFromTokens({tag:t,tagTokens:r,operationId:i,operationIdTokens:n}){if(r.some((l,d)=>l!==n[d]))return{group:[t],method:i};let u=n.slice(r.length);return{group:[t],method:Dg(u.join("_"))}}};function zKp(e){let t=GKD(e)?QKD(e):JKD(e);return t=t.map(r=>r.toLowerCase()),t=vBe(t),t}function GKD(e){return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)}function QKD(e){return e.split(/(?=[A-Z])/)}function JKD(e){return e.split(/[^a-zA-Z0-9]+/)}var HRo=class extends IDn{idempotent;constructor({breadcrumbs:t,operation:r,method:i,path:n,idempotent:a}){super({breadcrumbs:t,operation:r,method:i,path:n}),this.idempotent=a}async convert({context:t,errorCollector:r}){let i=this.convertHttpMethod();if(i==null)return;let{group:n,method:a}=this.computeGroupNameAndLocationFromExtensions({context:t,errorCollector:r})??this.computeGroupNameFromTagAndOperationId({context:t,errorCollector:r}),{headers:u,pathParameters:l,queryParameters:d}=await this.convertParameters({context:t,errorCollector:r,breadcrumbs:[...this.breadcrumbs,"parameters"]}),s=await this.convertRequestBody({context:t,errorCollector:r,breadcrumbs:[...this.breadcrumbs,"requestBody"],group:n,method:a}),o=s?.value,c=await this.convertResponseBody({context:t,errorCollector:r,breadcrumbs:[...this.breadcrumbs,"responses"],group:n,method:a});return{group:n,endpoint:{id:`${n?.join(".")??""}.${a}`,displayName:this.operation.summary,method:i,name:t.casingsGenerator.generateName(a),baseUrl:void 0,path:SV(this.path),pathParameters:l,queryParameters:d,headers:u,requestBody:o,sdkRequest:void 0,response:c?.value,errors:[],auth:this.operation.security!=null||t.spec.security!=null,availability:await t.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.operation.description,userSpecifiedExamples:[],autogeneratedExamples:[],idempotent:this.idempotent??!1,basePath:void 0,fullPath:SV(this.path),allPathParameters:l,pagination:void 0,transport:void 0},inlinedTypes:this.inlinedTypes}}convertExamples({requestExamples:t,responseExamples:r,context:i}){return[]}};var $Ro=class extends IDn{constructor({breadcrumbs:t,operation:r,method:i,path:n}){super({breadcrumbs:t,operation:r,method:i,path:n})}async convert({context:t,errorCollector:r}){if(this.operation.operationId==null){r.collect({message:"Skipping webhook because no operation id present",path:this.breadcrumbs});return}if(this.operation.requestBody==null){r.collect({message:"Skipping webhook because no request body present",path:this.breadcrumbs});return}let i=this.convertHttpMethod();if(i==null)return;if(i!=="POST"&&i!=="GET"){r.collect({message:"Skipping webhook because non-POST or GET method",path:this.breadcrumbs});return}let{group:n,method:a}=this.computeGroupNameAndLocationFromExtensions({context:t,errorCollector:r})??this.computeGroupNameFromTagAndOperationId({context:t,errorCollector:r}),u=[...this.breadcrumbs,"Payload"],{headers:l,pathParameters:d,queryParameters:s}=await this.convertParameters({context:t,errorCollector:r,breadcrumbs:u}),o=await this.convertRequestBody({context:t,errorCollector:r,breadcrumbs:u,group:n,method:a}),c;if(o?.value.type==="inlinedRequestBody")c=RU.inlinedPayload({name:o.value.name,extends:o.value.extends,properties:o.value.properties});else if(o?.value.type==="reference")c=RU.reference({payloadType:o.value.requestBodyType,docs:o.value.docs});else return;return{group:n,webhook:{id:`${n?.join(".")??""}.${a}`,name:t.casingsGenerator.generateName(a),displayName:this.operation.summary,method:i,headers:l,payload:c,examples:[],availability:await t.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.operation.description},inlinedTypes:this.inlinedTypes}}};var GRo=class extends Oy{pathItem;path;constructor({breadcrumbs:t,pathItem:r,path:i}){super({breadcrumbs:t}),this.pathItem=r,this.path=i}async convert({context:t,errorCollector:r}){let i=[],n=[],a={};for(let u of IKp){let l=this.pathItem[u];if(l==null)continue;let d=[...this.breadcrumbs,u],s=await this.tryParseAsWebhook({operationBreadcrumbs:d,operation:l,method:u,context:t,errorCollector:r});if(s!=null){n.push(s),Object.assign(a,s.inlinedTypes);continue}new BRo({breadcrumbs:d,operation:l}).convert({context:t,errorCollector:r})!=null;let b=await this.tryParseAsHttpEndpoint({operationBreadcrumbs:d,operation:l,method:u,context:t,errorCollector:r});b!=null&&(i.push(b),Object.assign(a,b.inlinedTypes))}return{endpoints:i,webhooks:n,inlinedTypes:a}}async tryParseAsWebhook({operation:t,method:r,operationBreadcrumbs:i,context:n,errorCollector:a}){return new xRo({breadcrumbs:i,operation:t}).convert({context:n,errorCollector:a})?await new $Ro({breadcrumbs:i,operation:t,method:pJs.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path}).convert({context:n,errorCollector:a}):void 0}async tryParseAsHttpEndpoint({operation:t,method:r,operationBreadcrumbs:i,context:n,errorCollector:a}){new CRo({breadcrumbs:i,operation:t,document:n.spec}).convert({context:n,errorCollector:a})!=null;let s=new qRo({breadcrumbs:i,operation:t}).convert({context:n,errorCollector:a});return await new HRo({breadcrumbs:i,operation:t,method:pJs.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path,idempotent:s}).convert({context:n,errorCollector:a})}};var QRo=class extends Oy{securityScheme;constructor({breadcrumbs:t,securityScheme:r}){super({breadcrumbs:t}),this.securityScheme=r}convert({context:t,errorCollector:r}){switch(this.securityScheme.type){case"http":{if(this.securityScheme.scheme==="bearer")return DR.bearer({token:t.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description});if(this.securityScheme.scheme==="basic")return DR.basic({username:t.casingsGenerator.generateName("username"),password:t.casingsGenerator.generateName("password"),usernameEnvVar:void 0,passwordEnvVar:void 0,docs:this.securityScheme.description});break}case"apiKey":{if(this.securityScheme.in==="header")return DR.header({name:{name:t.casingsGenerator.generateName(this.securityScheme.name),wireValue:this.securityScheme.name},valueType:pd.container(Ev.optional(pd.primitive({v1:"STRING",v2:Z_.string({default:void 0,validation:void 0})}))),prefix:void 0,headerEnvVar:void 0,docs:this.securityScheme.description});break}case"oauth2":return DR.bearer({token:t.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description})}}};var Fya=class extends sz{server;key="x-fern-server-name";constructor({breadcrumbs:t,server:r}){super({breadcrumbs:t}),this.server=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.server);if(!(i==null||typeof i!="string"))return i}};var JRo=class extends Oy{servers;constructor({breadcrumbs:t,servers:r}){super({breadcrumbs:t}),this.servers=r}convert({context:t,errorCollector:r}){if(this.servers==null||this.servers.length===0||this.servers[0]==null)return;let i;return this.servers.some(a=>new Fya({breadcrumbs:this.breadcrumbs,server:a}).convert({context:t,errorCollector:r})!=null)?i=this.servers.map(a=>{let l=new Fya({breadcrumbs:this.breadcrumbs,server:a}).convert({context:t,errorCollector:r});if(l!=null)return{id:l,name:t.casingsGenerator.generateName(l),url:this.getServerUrl(a),docs:a.description}}).filter(Qb):i=[{id:"default",name:t.casingsGenerator.generateName("Default"),url:this.getServerUrl(this.servers[0]),docs:this.servers[0].description}],{defaultEnvironment:i[0]?.id,environments:BU.singleBaseUrl({environments:i})}}getServerUrl(t){if(t.variables==null)return t.url;let r=t.url;for(let[i,n]of Object.entries(t.variables))n.default!=null&&(r=r.replace(`{${i}}`,n.default));return r}};var Lya=class extends Oy{ir;constructor({breadcrumbs:t,context:r}){super({breadcrumbs:t}),this.ir={auth:{docs:void 0,requirement:uc.AuthSchemesRequirement.All,schemes:[]},types:{},services:{},errors:{},webhookGroups:{},websocketChannels:void 0,headers:[],idempotencyHeaders:[],apiVersion:void 0,apiDisplayName:void 0,apiDocs:void 0,basePath:void 0,pathParameters:[],errorDiscriminationStrategy:uc.ErrorDiscriminationStrategy.statusCode(),variables:[],serviceTypeReferenceInfo:{sharedTypes:[],typesReferencedOnlyByService:{}},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,environments:void 0,fdrApiDefinitionId:void 0,rootPackage:r.createPackage(),subpackages:{},sdkConfig:{hasFileDownloadEndpoints:!1,hasPaginatedEndpoints:!1,hasStreamingEndpoints:!1,isAuthMandatory:!0,platformHeaders:{language:"",sdkName:"",sdkVersion:"",userAgent:void 0}}}}async convert({context:t,errorCollector:r}){t.spec=this.removeXFernIgnores({document:t.spec,context:t,errorCollector:r}),this.convertServers({context:t,errorCollector:r}),await this.convertSecuritySchemes({context:t,errorCollector:r}),await this.convertSchemas({context:t,errorCollector:r}),await this.convertPaths({context:t,errorCollector:r});let i={...this.ir,apiName:t.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:t.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}};return i={...i,...mNi({ir:i,exampleGeneration:{disabled:!1}})},i}removeXFernIgnores({document:t,context:r,errorCollector:i,breadcrumbs:n=[]}){return Array.isArray(t)?t.filter((a,u)=>!new AG.FernIgnoreExtension({breadcrumbs:[...n,String(u)],operation:a}).convert({context:r,errorCollector:i})).map((a,u)=>this.removeXFernIgnores({document:a,context:r,errorCollector:i,breadcrumbs:[...n,String(u)]})):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([a,u])=>!new AG.FernIgnoreExtension({breadcrumbs:[...n,a],operation:u}).convert({context:r,errorCollector:i})).map(([a,u])=>[a,this.removeXFernIgnores({document:u,context:r,errorCollector:i,breadcrumbs:[...n,a]})])):t}async convertSecuritySchemes({context:t,errorCollector:r}){let i=[];for(let[n,a]of Object.entries(t.spec.components?.securitySchemes??{})){let u;if(t.isReferenceObject(a)){let s=await t.resolveReference(a);if(!s.resolved)continue;u=s.value}else u=a;let d=new QRo({breadcrumbs:["components","securitySchemes",n],securityScheme:u}).convert({context:t,errorCollector:r});d!=null&&i.push(d)}i.length>0&&(this.ir.auth={requirement:"ANY",schemes:i,docs:void 0})}convertServers({context:t,errorCollector:r}){let n=new JRo({breadcrumbs:["servers"],servers:t.spec.servers}).convert({context:t,errorCollector:r});n!=null&&(this.ir.environments=n)}async convertSchemas({context:t,errorCollector:r}){for(let[i,n]of Object.entries(t.spec.components?.schemas??{})){let u=await new Dpi({id:i,breadcrumbs:["components","schemas",i],schema:n}).convert({context:t,errorCollector:r});u!=null&&(this.ir.rootPackage.types.push(i),this.ir.types={...this.ir.types,...u.inlinedTypes,[i]:u.typeDeclaration})}}async convertPaths({context:t,errorCollector:r}){let i={};for(let[n,a]of Object.entries(t.spec.paths??{})){if(a==null)continue;let l=await new GRo({breadcrumbs:["paths",n],pathItem:a,path:n}).convert({context:t,errorCollector:r});if(l!=null){for(let d of l.endpoints){let s=d.group?.join(".")??"";i[s]==null&&(i[s]=[]),i[s].push(d.endpoint)}for(let d of l.webhooks){let s=d.group?.join(".")??"";this.ir.webhookGroups[s]==null&&(this.ir.webhookGroups[s]=[]),this.ir.webhookGroups[s].push(d.webhook)}this.ir.types={...this.ir.types,...l.inlinedTypes}}}this.addServicesToIr({groupToEndpoints:i,context:t}),this.addWebhookGroupsToIr({webhookGroups:this.ir.webhookGroups,context:t})}addServicesToIr({groupToEndpoints:t,context:r}){for(let[i,n]of Object.entries(t)){let a=i.split(".").map(l=>r.casingsGenerator.generateName(l)),u=a[a.length-1]??r.casingsGenerator.generateName("");this.ir.services[i]={name:{fernFilepath:{allParts:a,packagePath:a.slice(0,-1),file:u}},displayName:void 0,basePath:SV(""),headers:[],pathParameters:[],availability:void 0,endpoints:n,transport:void 0,encoding:void 0},i!==""?(this.ir.subpackages[i]==null&&(this.ir.subpackages[i]={name:r.casingsGenerator.generateName(i),...r.createPackage({name:i})}),this.ir.subpackages[i].service=i,this.ir.rootPackage.subpackages.push(i)):this.ir.rootPackage.service=i}}addWebhookGroupsToIr({webhookGroups:t,context:r}){for(let[i,n]of Object.entries(t))this.ir.webhookGroups[i]=n,i!==""?(this.ir.subpackages[i]==null&&(this.ir.subpackages[i]={name:r.casingsGenerator.generateName(i),...r.createPackage({name:i})}),this.ir.subpackages[i].webhooks=i,this.ir.rootPackage.subpackages.push(i)):this.ir.rootPackage.webhooks=i}};var Uya=class extends PNi{isReferenceObject(t){return t!=null&&"$ref"in t}getTypeIdFromSchemaReference(t){let r=t.$ref.match(/\/schemas\/(.+)$/);if(!(!r||!r[1]))return r[1]}async convertReferenceToTypeReference(t){let r=this.getTypeIdFromSchemaReference(t);return r==null?{ok:!1}:(await this.resolveReference(t)).resolved?{ok:!0,reference:pd.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r),typeId:r,default:void 0,inline:!1})}:{ok:!1}}async getPropertyAccess(t){let r=t;for(;this.isReferenceObject(r);){let i=await this.resolveReference(r);if(!i.resolved)return;r=i.value}if(!(r.readOnly&&r.writeOnly)){if(r.readOnly)return lSe.ReadOnly;if(r.writeOnly)return lSe.WriteOnly}}async getAvailability({node:t,breadcrumbs:r,errorCollector:i}){for(;this.isReferenceObject(t);){let u=await this.resolveReference(t);if(!u.resolved)return;t=u.value}let a=await new AG.FernAvailabilityExtension({node:t,breadcrumbs:r}).convert({context:this,errorCollector:i});if(a!=null)return{status:a,message:void 0};if(t.deprecated===!0)return{status:a7.Deprecated,message:void 0}}};var KRo=class e extends Oy{static LIST_UNKNOWN=pd.container(Ev.list(pd.unknown()));schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){if(this.schema.items==null)return{typeReference:e.LIST_UNKNOWN};let n=await new H5t({breadcrumbs:[...this.breadcrumbs,"items"],schemaOrReference:this.schema.items}).convert({context:t,errorCollector:r});return n!=null?{typeReference:pd.container(Ev.list(n.type)),inlinedTypes:n.inlinedTypes}:{typeReference:e.LIST_UNKNOWN}}};var YRo=class extends Oy{schema;maybeFernEnum;constructor({breadcrumbs:t,schema:r,maybeFernEnum:i}){super({breadcrumbs:t}),this.schema=r,this.maybeFernEnum=i}convert({context:t,errorCollector:r}){if(!this.schema.enum)return;let n=this.schema.enum.filter(u=>typeof u=="string").map(u=>{let l=this.maybeFernEnum?.[u],d=l?.name??u.toString();return{name:t.casingsGenerator.generateNameAndWireValue({name:d,wireValue:u.toString()}),docs:l?.description,availability:void 0,casing:l?.casing}});if(n.length===0)return;let a=t.getAsString(this.schema.default);return{enum:a0.enum({default:a!=null?n.find(u=>u.name.wireValue===a):void 0,values:n})}}};var XRo=class extends Oy{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){if(!this.schema.properties&&!this.schema.allOf)return{object:a0.object({properties:[],extends:[],extendedProperties:[],extraProperties:this.schema.additionalProperties!=null})};let i=[],n={};for(let[u,l]of Object.entries(this.schema.properties??{})){let d=[...this.breadcrumbs,"properties",u],s="nullable"in l?l.nullable:!1,o=t.convertBreadcrumbsToName(d),b=await new H5t({breadcrumbs:d,schemaOrReference:l,schemaIdOverride:o,wrapAsOptional:!this.schema.required?.includes(u),wrapAsNullable:s}).convert({context:t,errorCollector:r});b!=null&&(i.push({name:t.casingsGenerator.generateNameAndWireValue({name:u,wireValue:u}),valueType:b.type,docs:l.description,availability:b.availability,propertyAccess:await t.getPropertyAccess(l)}),n={...n,...b.inlinedTypes})}let a=[];for(let[u,l]of(this.schema.allOf??[]).entries()){let d=[...this.breadcrumbs,"allOf",u.toString()];if(t.isReferenceObject(l)){let s=await t.convertReferenceToTypeReference(l);s.ok&&a.push(s.reference);continue}for(let[s,o]of Object.entries(l.properties??{})){let c=[...d,s],b=t.convertBreadcrumbsToName(c),O=await new H5t({breadcrumbs:c,schemaOrReference:o,schemaIdOverride:b,wrapAsOptional:!l.required?.includes(s),wrapAsNullable:"nullable"in o?o.nullable:!1}).convert({context:t,errorCollector:r});O!=null&&(i.push({name:t.casingsGenerator.generateNameAndWireValue({name:s,wireValue:s}),valueType:O.type,docs:o.description,availability:O.availability,propertyAccess:await t.getPropertyAccess(o)}),n={...n,...O.inlinedTypes})}}return{object:a0.object({properties:i,extends:a.map(u=>t.typeReferenceToDeclaredTypeName(u)).filter(Qb),extendedProperties:[],extraProperties:this.schema.additionalProperties!=null}),inlinedTypes:n}}};var ZRo=class extends Oy{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){return this.schema.discriminator!=null?await this.convertAsDiscriminatedUnion({context:t,errorCollector:r}):this.convertAsUndiscriminatedUnion({context:t,errorCollector:r})}async convertAsDiscriminatedUnion({context:t,errorCollector:r}){let i=[],n={};if(this.schema.discriminator!=null){for(let[a,u]of Object.entries(this.schema.discriminator.mapping??{})){let l=new H5t({schemaOrReference:{$ref:u},breadcrumbs:[...this.breadcrumbs,"discriminator","mapping",a]}),d=t.getTypeIdFromSchemaReference({$ref:u}),s=await l.convert({context:t,errorCollector:r});if(s?.type!=null&&d!=null){let o=t.casingsGenerator.generateNameAndWireValue({name:a,wireValue:a});i.push({docs:void 0,discriminantValue:o,availability:s.availability,displayName:void 0,shape:Z8.samePropertiesAsObject({typeId:d,name:t.casingsGenerator.generateName(d),fernFilepath:{allParts:[],packagePath:[],file:void 0}})}),n={...n,...s.inlinedTypes}}}return{union:a0.union({baseProperties:[],discriminant:t.casingsGenerator.generateNameAndWireValue({name:this.schema.discriminator.propertyName,wireValue:this.schema.discriminator.propertyName}),extends:[],types:i}),inlinedTypes:n}}}async convertAsUndiscriminatedUnion({context:t,errorCollector:r}){if(!this.schema.oneOf||this.schema.oneOf.length===0)return;let i=[],n={};for(let[a,u]of this.schema.oneOf.entries()){let l=[...this.breadcrumbs,"oneOf",jNi(a)??""];if(t.isReferenceObject(u)){let c=await t.convertReferenceToTypeReference(u);c.ok&&i.push({type:c.reference,docs:u.description});continue}let d=t.convertBreadcrumbsToName(l),o=await new Rze({id:d,breadcrumbs:l,schema:u}).convert({context:t,errorCollector:r});o!=null&&(i.push({type:t.createNamedTypeReference(d),docs:u.description}),n={...n,...o.inlinedTypes,[d]:o.typeDeclaration})}return{union:a0.undiscriminatedUnion({members:i}),inlinedTypes:n}}};var kRo=class extends Oy{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}convert({context:t,errorCollector:r}){switch(this.schema.type){case"string":{let i=t.getAsString(this.schema.const);return i!=null?pd.container(Ev.literal(k8.string(i))):pd.primitive({v1:"STRING",v2:Z_.string({default:t.getAsString(this.schema.default),validation:this.getStringValidation(this.schema)})})}case"number":case"integer":switch(this.schema.format){case"double":case void 0:return pd.primitive({v1:"DOUBLE",v2:Z_.double({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return pd.primitive({v1:"FLOAT",v2:Z_.float({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return pd.primitive({v1:"INTEGER",v2:Z_.integer({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return pd.primitive({v1:"LONG",v2:Z_.long({default:t.getAsNumber(this.schema.default)})});case"uint32":return pd.primitive({v1:"UINT",v2:Z_.uint({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return pd.primitive({v1:"UINT_64",v2:Z_.uint64({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return pd.primitive({v1:"INTEGER",v2:Z_.integer({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"boolean":{let i=t.getAsBoolean(this.schema.const);return i!=null?pd.container(Ev.literal(k8.boolean(i))):pd.primitive({v1:"BOOLEAN",v2:Z_.boolean({default:this.schema.default})})}default:return}}getNumberValidation(t){return{max:t.maximum,min:t.minimum,exclusiveMax:typeof t.exclusiveMaximum=="boolean"?t.exclusiveMaximum:void 0,exclusiveMin:typeof t.exclusiveMinimum=="boolean"?t.exclusiveMinimum:void 0,multipleOf:t.multipleOf}}getStringValidation(t){return{minLength:t.minLength,maxLength:t.maxLength,pattern:t.pattern,format:t.format}}};var Rze=class extends Oy{schema;id;inlined;constructor({breadcrumbs:t,schema:r,id:i,inlined:n=!1}){super({breadcrumbs:t}),this.schema=r,this.id=i,this.inlined=n}async convert({context:t,errorCollector:r}){if(this.schema.enum?.length){let u=new AG.FernEnumExtension({breadcrumbs:this.breadcrumbs,schema:this.schema}).convert({context:t,errorCollector:r}),d=new YRo({breadcrumbs:this.breadcrumbs,schema:this.schema,maybeFernEnum:u}).convert({context:t,errorCollector:r});if(d!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:d.enum,context:t,errorCollector:r}),inlinedTypes:{}}}let n=new kRo({schema:this.schema}).convert({context:t,errorCollector:r});if(n!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:a0.alias({aliasOf:n,resolvedType:n}),context:t,errorCollector:r}),inlinedTypes:{}};if(this.schema.type==="array"){let u=await new KRo({breadcrumbs:this.breadcrumbs,schema:this.schema}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:a0.alias({aliasOf:u.typeReference,resolvedType:u.typeReference}),context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}if(this.schema.oneOf!=null){let u=await new ZRo({breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:u.union,context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}if(this.schema.type==="object"||this.schema.properties!=null||this.schema.allOf!=null){let u=await new XRo({breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:u.object,context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}}async createTypeDeclaration({shape:t,context:r,errorCollector:i}){return{name:this.convertDeclaredTypeName({context:r}),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:await r.getAvailability({node:this.schema,breadcrumbs:this.breadcrumbs,errorCollector:i}),docs:this.schema.description,referencedTypes:new Set,source:void 0,inline:this.inlined}}convertDeclaredTypeName({context:t}){return{typeId:this.id,fernFilepath:{allParts:[],packagePath:[],file:void 0},name:t.casingsGenerator.generateName(this.id)}}};var H5t=class extends Oy{schemaOrReference;schemaIdOverride;wrapAsOptional;wrapAsNullable;constructor({breadcrumbs:t,schemaOrReference:r,schemaIdOverride:i,wrapAsOptional:n=!1,wrapAsNullable:a=!1}){super({breadcrumbs:t}),this.schemaOrReference=r,this.schemaIdOverride=i,this.wrapAsOptional=n,this.wrapAsNullable=a}async convert({context:t,errorCollector:r}){if(t.isReferenceObject(this.schemaOrReference)){let l=await t.convertReferenceToTypeReference(this.schemaOrReference);return l.ok?{type:l.reference,inlinedTypes:{}}:void 0}let i=this.schemaIdOverride??t.convertBreadcrumbsToName(this.breadcrumbs),n=new Rze({breadcrumbs:this.breadcrumbs,schema:this.schemaOrReference,id:i}),a=await t.getAvailability({node:this.schemaOrReference,breadcrumbs:this.breadcrumbs,errorCollector:r}),u=await n.convert({context:t,errorCollector:r});if(u!=null){if(u.typeDeclaration.shape.type==="alias"){let d=u.typeDeclaration.shape.aliasOf;return{type:this.wrapTypeReference(d),inlinedTypes:u.inlinedTypes,availability:a}}let l=t.createNamedTypeReference(i);return{type:this.wrapTypeReference(l),schema:u.typeDeclaration,inlinedTypes:{...u.inlinedTypes,[i]:u.typeDeclaration},availability:a}}}wrapTypeReference(t){return this.wrapAsOptional&&this.wrapAsNullable?this.wrapInOptional(this.wrapInNullable(t)):this.wrapAsOptional?this.wrapInOptional(t):this.wrapAsNullable?this.wrapInNullable(t):t}wrapInOptional(t){return pd.container(Ev.optional(t))}wrapInNullable(t){return pd.container(Ev.nullable(t))}};var Epi=class e extends Oy{static STRING=pd.primitive({v1:"STRING",v2:Z_.string({default:void 0,validation:void 0})});static OPTIONAL_STRING=pd.container(Ev.optional(e.STRING));parameter;constructor({breadcrumbs:t,parameter:r}){super({breadcrumbs:t}),this.parameter=r}async convert({context:t,errorCollector:r}){let i,n={};if(this.parameter.schema!=null){let l=await new H5t({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required}).convert({context:t,errorCollector:r});l!=null&&(i=l.type,n=l.inlinedTypes??{})}let a=await t.getAvailability({node:this.parameter,breadcrumbs:this.breadcrumbs,errorCollector:r});switch(this.parameter.in){case"query":return{type:"query",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??(this.parameter.required?e.STRING:e.OPTIONAL_STRING),allowMultiple:this.parameter.explode??!1,availability:a},inlinedTypes:n};case"header":return{type:"header",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??(this.parameter.required?e.STRING:e.OPTIONAL_STRING),env:void 0,availability:a},inlinedTypes:n};case"path":return{type:"path",parameter:{name:t.casingsGenerator.generateName(this.parameter.name),docs:this.parameter.description,valueType:i??(this.parameter.required?e.STRING:e.OPTIONAL_STRING),location:"ENDPOINT",variable:void 0},inlinedTypes:n};default:r.collect({message:`Unsupported parameter location: ${this.parameter.in}`,path:this.breadcrumbs});return}}};var eNo=class extends Oy{channel;channelPath;inlinedTypes={};constructor({breadcrumbs:t,channel:r,channelPath:i}){super({breadcrumbs:t}),this.channel=r,this.channelPath=i}async convert({context:t,errorCollector:r}){let i=[],n=[],a=[];this.channel.parameters&&await this.convertQueryParameters({context:t,errorCollector:r,queryParameters:n}),this.channel.bindings?.ws!=null&&(await this.convertHeaders({context:t,errorCollector:r,headers:a}),await this.convertBindingQueryParameters({context:t,errorCollector:r,queryParameters:n}));let u;this.channel.subscribe!=null&&(u=await this.convertMessage({context:t,errorCollector:r,operation:this.channel.subscribe,defaultId:"subscribeEvent",breadcrumbName:"subscribeEvent"}));let l;this.channel.publish!=null&&(l=await this.convertMessage({context:t,errorCollector:r,operation:this.channel.publish,defaultId:"publishEvent",breadcrumbName:"publishEvent"}));let d=[];return u!=null&&d.push(u),l!=null&&d.push(l),{channel:{name:t.casingsGenerator.generateName(this.channelPath),displayName:this.channelPath,baseUrl:this.channel.servers?.[0],path:{head:this.channel.address??this.channelPath,parts:[]},auth:!1,headers:a,queryParameters:n,pathParameters:i,messages:d,examples:[],availability:await t.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.channel.description},inlinedTypes:this.inlinedTypes}}async convertMessage({context:t,errorCollector:r,operation:i,defaultId:n,breadcrumbName:a}){let u;if("$ref"in i.message){let l=await t.resolveReference(i.message);l.resolved&&(i.message=l.value)}if("oneOf"in i.message)u=await new Rze({id:i.operationId??n,breadcrumbs:[...this.breadcrumbs,a],schema:i.message}).convert({context:t,errorCollector:r});else if("payload"in i.message){let l;if(t.isReferenceObject(i.message.payload)){let d=await t.resolveReference(i.message.payload);d.resolved&&(l=d.value)}else l=i.message.payload;l!=null&&(u=await new Rze({id:i.operationId??n,breadcrumbs:[...this.breadcrumbs,a],schema:l}).convert({context:t,errorCollector:r}))}if(u!=null){this.inlinedTypes={...this.inlinedTypes,...u.inlinedTypes,[u.typeDeclaration.name.typeId]:u.typeDeclaration};let l=u.typeDeclaration,d=uc.TypeReference.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:l.name.name,typeId:l.name.typeId,default:void 0,inline:!1}),s=uc.WebSocketMessageBody.reference({bodyType:d,docs:i.description});return{type:l.name.typeId,displayName:l.name.name.originalName,origin:"server",body:s,availability:await t.getAvailability({node:i,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:i.description}}}async convertQueryParameters({context:t,errorCollector:r,queryParameters:i}){for(let[n,a]of Object.entries(this.channel.parameters??{})){let u=a;if(t.isReferenceObject(a)){let s=await t.resolveReference(a);if(s.resolved)u=s.value;else continue}let d=await new Epi({breadcrumbs:this.breadcrumbs,parameter:{...u,name:n,in:"query",description:a.description,required:a.required??!1}}).convert({context:t,errorCollector:r});d!=null&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},d.type==="query"&&i.push(d.parameter))}}async convertHeaders({context:t,errorCollector:r,headers:i}){if(this.channel.bindings?.ws?.headers!=null){let n=this.channel.bindings.ws.headers.required??[];for(let[a,u]of Object.entries(this.channel.bindings.ws.headers.properties??{})){let l=u;if(t.isReferenceObject(u)){let o=await t.resolveReference(u);if(!o.resolved)continue;l=o.value}let s=await new Epi({breadcrumbs:[...this.breadcrumbs,a],parameter:{name:a,in:"header",required:n.includes(a),schema:l,description:"description"in l?l.description:void 0}}).convert({context:t,errorCollector:r});s!=null&&s.type==="header"&&(this.inlinedTypes={...this.inlinedTypes,...s.inlinedTypes},i.push(s.parameter))}}}async convertBindingQueryParameters({context:t,errorCollector:r,queryParameters:i}){if(this.channel.bindings?.ws?.query!=null){let n=this.channel.bindings.ws.query.required??[];for(let[a,u]of Object.entries(this.channel.bindings.ws.query.properties??{})){let l=u;if(t.isReferenceObject(u)){let o=await t.resolveReference(u);if(!o.resolved)continue;l=o.value}let s=await new Epi({breadcrumbs:[...this.breadcrumbs,a],parameter:{name:a,in:"query",required:n.includes(a),schema:l,description:"description"in l?l.description:void 0}}).convert({context:t,errorCollector:r});s!=null&&s.type==="query"&&(this.inlinedTypes={...this.inlinedTypes,...s.inlinedTypes},i.push(s.parameter))}}}};var tNo=class extends Oy{servers;constructor({breadcrumbs:t,servers:r}){super({breadcrumbs:t}),this.servers=r}convert({context:t,errorCollector:r}){if(this.servers==null||Object.keys(this.servers).length===0)return;let n=Object.entries(this.servers)[0]?.[1];if(n==null)return;let a=[{id:"default",name:t.casingsGenerator.generateName("Default"),url:this.constructServerUrl(n.protocol,n.url),docs:void 0}];return{defaultEnvironment:a[0]?.id,environments:BU.singleBaseUrl({environments:a})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var _Js="$message.",RKp="#/channels/",NKp="#/servers/",rNo=class extends Oy{channel;channelPath;operations;inlinedTypes={};constructor({breadcrumbs:t,channel:r,channelPath:i,operations:n}){super({breadcrumbs:t}),this.channel=r,this.channelPath=i,this.operations=n}async convert({context:t,errorCollector:r}){let i=[],n=[],a=[];this.channel.parameters&&await this.convertChannelParameters({context:t,errorCollector:r,pathParameters:i,queryParameters:n,headers:a});let u=Object.entries(this.operations).reduce((d,[s,o])=>{try{this.getChannelPathFromOperation(o)===this.channelPath&&(d[s]=o)}catch{}return d},{}),l=[];for(let[d,s]of Object.entries(u))for(let o of s.messages){let c=await t.convertReferenceToTypeReference(o);if(c.ok){let b=uc.WebSocketMessageBody.reference({bodyType:c.reference,docs:s.description});l.push({type:d,displayName:d,origin:s.action==="send"?"client":"server",body:b,availability:await t.getAvailability({node:s,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:s.description})}}return{channel:{name:t.casingsGenerator.generateName(this.channelPath),displayName:this.channelPath,baseUrl:this.resolveChannelServersFromReference(this.channel.servers??[],r),path:{head:this.channel.address??this.channelPath,parts:[]},auth:!1,headers:a,queryParameters:n,pathParameters:i,messages:l,examples:[],availability:await t.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.channel.description},inlinedTypes:this.inlinedTypes}}async convertChannelParameters({context:t,errorCollector:r,pathParameters:i,queryParameters:n,headers:a}){for(let u of Object.values(this.channel.parameters??{})){let l=u;if(t.isReferenceObject(u)){let g=await t.resolveReference(u);if(g.resolved)l=g.value;else continue}let d=this.convertChannelParameterLocation(u.location,r);if(d==null)continue;let{type:s,parameterKey:o}=d,b=await new Epi({breadcrumbs:this.breadcrumbs,parameter:{...l,name:o,in:s,required:!0}}).convert({context:t,errorCollector:r});if(b!=null)switch(this.inlinedTypes={...this.inlinedTypes,...b.inlinedTypes},b.type){case"path":i.push(b.parameter);break;case"query":n.push(b.parameter);break;case"header":a.push(b.parameter);break}}}convertChannelParameterLocation(t,r){try{let[i,n]=t.split("#/");if(i==null||n==null){r.collect({message:`Invalid location format: ${t}; unable to parse message type and parameter key`,path:this.breadcrumbs});return}if(!i.startsWith(_Js)){r.collect({message:`Invalid location format: ${t}; expected ${_Js} prefix`,path:this.breadcrumbs});return}let a=i.substring(_Js.length);if(a!=="header"&&a!=="path"&&a!=="payload"){r.collect({message:`Invalid message type: ${a}. Must be one of: header, path, payload`,path:this.breadcrumbs});return}return a==="payload"?{type:"query",parameterKey:n}:{type:a,parameterKey:n}}catch{r.collect({message:`Invalid location format: ${t}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`,path:this.breadcrumbs});return}}resolveChannelServersFromReference(t,r){if(t==null||t.length===0||t[0]==null)return;let i=t[0];if(!i.$ref.startsWith(NKp)){r.collect({message:`Failed to resolve server name from server ref ${i.$ref}`,path:this.breadcrumbs});return}let n=i.$ref.substring(NKp.length);if(n==null){r.collect({message:`Failed to find server with name ${n}`,path:this.breadcrumbs});return}return n}getChannelPathFromOperation(t){if(!t.channel.$ref.startsWith(RKp))throw new Error(`Failed to resolve channel path from operation ${t.channel.$ref}`);return t.channel.$ref.substring(RKp.length)}};var iNo=class extends Oy{servers;constructor({breadcrumbs:t,servers:r}){super({breadcrumbs:t}),this.servers=r}convert({context:t,errorCollector:r}){if(this.servers==null||Object.keys(this.servers).length===0)return;let n=Object.entries(this.servers)[0]?.[1];if(n==null)return;let a=[{id:"default",name:t.casingsGenerator.generateName("Default"),url:this.constructServerUrl(n.protocol,n.host),docs:void 0}];return{defaultEnvironment:a[0]?.id,environments:BU.singleBaseUrl({environments:a})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var Vya=class extends Oy{ir;constructor({breadcrumbs:t,context:r}){super({breadcrumbs:t}),this.ir={auth:{docs:void 0,requirement:uc.AuthSchemesRequirement.All,schemes:[]},types:{},services:{},errors:{},webhookGroups:{},websocketChannels:void 0,headers:[],idempotencyHeaders:[],apiVersion:void 0,apiDisplayName:void 0,apiDocs:void 0,basePath:void 0,pathParameters:[],errorDiscriminationStrategy:uc.ErrorDiscriminationStrategy.statusCode(),variables:[],serviceTypeReferenceInfo:{sharedTypes:[],typesReferencedOnlyByService:{}},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,environments:void 0,fdrApiDefinitionId:void 0,rootPackage:r.createPackage(),subpackages:{},sdkConfig:{hasFileDownloadEndpoints:!1,hasPaginatedEndpoints:!1,hasStreamingEndpoints:!1,isAuthMandatory:!0,platformHeaders:{language:"",sdkName:"",sdkVersion:"",userAgent:void 0}}}}async convert({context:t,errorCollector:r}){t.spec=this.removeXFernIgnores({document:t.spec,context:t,errorCollector:r}),this.isAsyncAPIV3(t)&&(t.spec=this.deduplicateChannelMessages({document:t.spec,context:t,errorCollector:r}),await this.convertChannelMessages({context:t,errorCollector:r})),await this.convertSchemas({context:t,errorCollector:r}),await this.convertServers({context:t,errorCollector:r}),await this.convertChannels({context:t,errorCollector:r});let i={...this.ir,apiName:t.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:t.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}};return i={...i,...mNi({ir:i,exampleGeneration:{disabled:!1}})},i}isAsyncAPIV3(t){return parseFloat(t.spec.asyncapi)>=3}removeXFernIgnores({document:t,context:r,errorCollector:i,breadcrumbs:n=[]}){return Array.isArray(t)?t.filter((a,u)=>!new AG.FernIgnoreExtension({breadcrumbs:[...n,String(u)],operation:a}).convert({context:r,errorCollector:i})).map((a,u)=>this.removeXFernIgnores({document:a,context:r,errorCollector:i,breadcrumbs:[...n,String(u)]})):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([a,u])=>!new AG.FernIgnoreExtension({breadcrumbs:[...n,a],operation:u}).convert({context:r,errorCollector:i})).map(([a,u])=>[a,this.removeXFernIgnores({document:u,context:r,errorCollector:i,breadcrumbs:[...n,a]})])):t}deduplicateChannelMessages({document:t,context:r,errorCollector:i}){let n={};for(let[u,l]of Object.entries(t.channels??{}))for(let[d,s]of Object.entries(l.messages??{}))n[d]||(n[d]=[]),n[d].push({channelPath:u,message:s});let a={...t};a.channels={...t.channels};for(let[u,l]of Object.entries(n))if(l.length!==1)for(let{channelPath:d,message:s}of l){let o=a.channels[d];if(o==null||o.messages==null)continue;let c=`${d}_${u}`,b={...o.messages,[c]:s},{[u]:g,...O}=b;o.messages=O}return a}async convertChannelMessages({context:t,errorCollector:r}){let i=t.spec;for(let[n,a]of Object.entries(i.channels??{}))for(let[u,l]of Object.entries(a.messages??{})){if(l.payload==null)continue;let d;if(t.isReferenceObject(l.payload)){let c=await t.resolveReference(l.payload);c.resolved&&(d=c.value)}else d=l.payload;if(d==null)continue;let o=await new Rze({id:u,breadcrumbs:["channels",n,"messages",u],schema:d}).convert({context:t,errorCollector:r});o!=null&&(this.ir.rootPackage.types.push(u),this.ir.types={...this.ir.types,...o.inlinedTypes,[u]:o.typeDeclaration})}}async convertSchemas({context:t,errorCollector:r}){for(let[i,n]of Object.entries(t.spec.components?.schemas??{})){let u=await new Rze({id:i,breadcrumbs:["components","schemas",i],schema:n}).convert({context:t,errorCollector:r});u!=null&&(this.ir.rootPackage.types.push(i),this.ir.types={...this.ir.types,...u.inlinedTypes,[i]:u.typeDeclaration})}}async convertServers({context:t,errorCollector:r}){if(this.isAsyncAPIV3(t)){let i=t.spec.servers,a=new iNo({breadcrumbs:["servers"],servers:i}).convert({context:t,errorCollector:r});a!=null&&(this.ir.environments=a)}else{let i=t.spec.servers,a=new tNo({breadcrumbs:["servers"],servers:i}).convert({context:t,errorCollector:r});a!=null&&(this.ir.environments=a)}}async convertChannels({context:t,errorCollector:r}){for(let[i,n]of Object.entries(t.spec.channels??{}))if(this.isAsyncAPIV3(t)){let u=t.spec.operations??{},d=await new rNo({breadcrumbs:["channels",i],channel:n,channelPath:i,operations:u}).convert({context:t,errorCollector:r});d!=null&&(this.ir.websocketChannels={...this.ir.websocketChannels,[i]:d.channel},this.ir.types={...this.ir.types,...d.inlinedTypes})}else{let u=await new eNo({breadcrumbs:["channels",i],channel:n,channelPath:i}).convert({context:t,errorCollector:r});u!=null&&(this.ir.websocketChannels={...this.ir.websocketChannels,[i]:u.channel},this.ir.types={...this.ir.types,...u.inlinedTypes})}this.addWebsocketsToIr({websocketChannels:this.ir.websocketChannels,context:t})}addWebsocketsToIr({websocketChannels:t,context:r}){if(t!=null)for(let[i,n]of Object.entries(t))i!==""?(this.ir.subpackages[i]==null&&(this.ir.subpackages[i]={name:r.casingsGenerator.generateName(i),...r.createPackage({name:i})}),this.ir.subpackages[i].websocket=i,this.ir.rootPackage.subpackages.push(i)):this.ir.rootPackage.websocket=i}};var Wya=class extends PNi{isReferenceObject(t){return t!=null&&"$ref"in t}getTypeIdFromSchemaReference(t){let r=t.$ref.match(/\/schemas\/(.+)$/);if(!(!r||!r[1]))return r[1]}getTypeIdFromMessageReference(t){let r=t.$ref.match(/\/messages\/(.+)$/);if(!(!r||!r[1]))return r[1]}async convertReferenceToTypeReference(t){let r;return t.$ref.includes("schemas")?r=this.getTypeIdFromSchemaReference(t):t.$ref.includes("messages")&&(r=this.getTypeIdFromMessageReference(t)),r==null?{ok:!1}:(await this.resolveReference(t)).resolved?{ok:!0,reference:pd.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r),typeId:r,default:void 0,inline:!1})}:{ok:!1}}async getPropertyAccess(t){let r=t;for(;this.isReferenceObject(r);){let i=await this.resolveReference(r);if(!i.resolved)return;r=i.value}if(!(r.readOnly&&r.writeOnly)){if(r.readOnly)return lSe.ReadOnly;if(r.writeOnly)return lSe.WriteOnly}}async getAvailability({node:t,breadcrumbs:r,errorCollector:i}){for(;this.isReferenceObject(t);){let u=await this.resolveReference(t);if(!u.resolved)return;t=u.value}let a=await new AG.FernAvailabilityExtension({node:t,breadcrumbs:r}).convert({context:this,errorCollector:i});if(a!=null)return{status:a,message:void 0};if(t.deprecated===!0)return{status:a7.Deprecated,message:void 0}}};var B7=class extends n_a{specs;sources;loader;constructor({specs:t,...r}){super({...r,respectReadonlySchemas:t.every(i=>i.settings?.respectReadonlySchemas),respectNullableSchemas:t.every(i=>i.settings?.respectNullableSchemas),onlyIncludeReferencedSchemas:t.every(i=>i.settings?.onlyIncludeReferencedSchemas),inlinePathParameters:t.every(i=>i.settings?.inlinePathParameters),objectQueryParameters:t.every(i=>i.settings?.objectQueryParameters),exampleGeneration:t[0]?.settings?.exampleGeneration}),this.specs=t,this.sources=this.convertSpecsToIdentifiableSources(t),this.loader=new U5t(this.absoluteFilePath)}async getOpenAPIIr({context:t,relativePathToDependency:r},i){let n=await qze({context:t,specs:this.specs,relativePathToDependency:r});return YRi({context:t,documents:await this.loader.loadDocuments({context:t,specs:n}),options:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.objectQueryParameters,exampleGeneration:i?.exampleGeneration??this.exampleGeneration}})}async getIntermediateRepresentation({context:t}){let r=await qze({context:t,specs:this.specs}),i=await this.loader.loadDocuments({context:t,specs:r}),n;for(let a of i){let u=new Rya({logger:t.logger}),l;if(a.type==="openapi"){let d=new Uya({generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:a.value});l=await new Lya({context:d}).convert({context:d,errorCollector:u})}else if(a.type==="asyncapi"){let d=new Wya({generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:a.value});l=await new Vya({context:d}).convert({context:d,errorCollector:u})}else u.collect({message:`Unsupported document type: ${a}`,path:[]});u.hasErrors()&&(t.logger.info(`${a.type==="openapi"?"OpenAPI":"AsyncAPI"} Importer encountered errors:`),u.logErrors()),l!=null&&(n=n===void 0?l:lJs(n,l))}if(n===void 0)throw new Error("Failed to generate intermediate representation");return n}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new USe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion,sources:this.sources})}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.specs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(Qb)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,i=[];return t.reduce((n,a)=>{let u=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(u)||(r.add(u),n.push({type:a.type,id:fie(),absoluteFilePath:u})),n},i)}};var FKp={None:"none",Header:"header"};var DNo={};Co(DNo,{ConjureAliasDeclaration:()=>lNo,ConjureArgument:()=>jNo,ConjureArgumentWithParamType:()=>PNo,ConjureAuthDefinition:()=>FDn,ConjureAuthDefinitionType:()=>ONo,ConjureDefinitions:()=>bNo,ConjureEndpointDefinition:()=>wNo,ConjureEnumDeclaration:()=>yNo,ConjureEnumVariant:()=>hNo,ConjureEnumWithDocs:()=>_No,ConjureObjectDeclaration:()=>pNo,ConjureParamType:()=>mNo,ConjurePrimitive:()=>cNo,ConjureService:()=>SNo,ConjureServiceName:()=>sNo,ConjureType:()=>qpi,ConjureTypeDeclaration:()=>vNo,ConjureTypeReference:()=>Tpi,ConjureTypeWithDocs:()=>fNo,ConjureTypes:()=>gNo,ConjureUnionDeclaration:()=>dNo,DefinitionFile:()=>pYp,WithDocs:()=>zXt,commons:()=>gJs,conjure:()=>OJs,services:()=>mJs,types:()=>PJs});var gJs={};Co(gJs,{WithDocs:()=>zXt});var kd={};Co(kd,{JsonError:()=>zDn,ParseError:()=>RDn,any:()=>eYp,bigint:()=>UKp,boolean:()=>tYp,booleanLiteral:()=>kKp,date:()=>VKp,discriminant:()=>lYp,enum_:()=>aNo,getObjectLikeUtils:()=>$5t,getObjectUtils:()=>wNi,getSchemaUtils:()=>$A,isProperty:()=>Api,lazy:()=>WKp,lazyObject:()=>YKp,list:()=>uNo,number:()=>rYp,object:()=>oNo,objectWithoutOptionalProperties:()=>KKp,optional:()=>hJs,property:()=>$Kp,record:()=>oYp,set:()=>uYp,string:()=>iYp,stringLiteral:()=>ZKp,transform:()=>yJs,undiscriminatedUnion:()=>cYp,union:()=>dYp,unknown:()=>nYp,withParsedProperties:()=>bJs});var YP={BIGINT:"bigint",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 qM(e,t){return`Expected ${t}. Received ${KKD(e)}.`}function KKD(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function A5(e){return{...e,json:LKp(e.json),parse:LKp(e.parse)}}function LKp(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
1947
+ `}async function qze({context:e,specs:t,relativePathToDependency:r}){let i=new hzo({context:e}),n=t.filter(l=>l.type==="openapi").map(l=>({...l,relativePathToDependency:r})),a=t.filter(l=>l.type==="protobuf"),u=await Promise.all(a.map(async l=>_GD({generator:i,protobufSpec:l,relativePathToDependency:r})));return[...n,...u]}async function _GD({generator:e,protobufSpec:t,relativePathToDependency:r}){return{type:"openapi",absoluteFilepath:await e.generate({absoluteFilepathToProtobufRoot:t.absoluteFilepathToProtobufRoot,absoluteFilepathToProtobufTarget:t.absoluteFilepathToProtobufTarget,relativeFilepathToProtobufRoot:t.relativeFilepathToProtobufRoot,local:t.generateLocally}),absoluteFilepathToOverrides:t.absoluteFilepathToOverrides,settings:t.settings,source:{type:"protobuf",relativePathToDependency:r,root:t.absoluteFilepathToProtobufRoot,file:t.absoluteFilepathToProtobufTarget}}}var sKp=require("fs"),qDn=require("fs/promises");var cKp=require("os"),lKp=yi(require("path"),1),fKp=require("stream/promises"),dKp=yi(jRo(),1),pKp=yi(Lte(),1);var rJs=yi(JBi(),1);var aP;(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"})(aP||(aP={}));var HJD=BQr();async function _Kp({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:i,cliVersion:n,settings:a,loadAPIWorkspace:u}){let l,d={type:aP.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},s=t.dependencies[e];return s==null?d={type:aP.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${XJD(s)}`},async o=>{switch(s.type){case"version":l=await KJD({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;case"local":l=await JJD({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;default:Fo(s)}}),l!=null?{didSucceed:!0,definition:l}:{didSucceed:!1,failure:d}}var hKp="dependencies";var $JD="metadata.json",GJD=".fern";function QJD(e){return Xu(Wl.of((0,cKp.homedir)()),Xa.of(GJD),Xa.of(hKp),Xa.of(e.organization),Xa.of(e.apiName),Xa.of(e.version))}async function JJD({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){if(n==null){t.failWithoutThrowing("Failed to load api definition");return}t.logger.info("Parsing...");let a=await n({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:Xa.of(e.path)},i);return t.logger.info("Loaded..."),u}async function KJD({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){let a=QJD(e),u=Xu(a,Xa.of(hKp)),l=Xu(a,Xa.of($JD)),d;if(!await Cf(u)||!await Cf(l)){t.logger.info("Downloading manifest...");let c=await HJD.definitionRegistry.get(rJs.FernFiddle.OrganizationId(e.organization),rJs.FernFiddle.ApiId(e.apiName),e.version);if(!c.ok){c.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:m=>{t.failWithoutThrowing("Failed to download API manifest",m)}});return}let b=c.body.yamlSchemaVersion!=null?parseInt(c.body.yamlSchemaVersion):void 0,g=oRi(r),O=oRi(c.body.cliVersion);if(b!=null){if(b>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${c.body.cliVersion}`);return}else if(b<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(g.major!==O.major||g.minor!==O.minor){t.failWithoutThrowing(`CLI version is ${c.body.cliVersion}. Expected ${g.major}.${g.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+c.body.definitionS3DownloadUrl),await(0,qDn.mkdir)(u,{recursive:!0});try{await YJD({s3PreSignedReadUrl:c.body.definitionS3DownloadUrl,absolutePathToLocalOutput:u})}catch(m){t.failWithoutThrowing("Failed to download API",m);return}d=c.body,await(0,qDn.writeFile)(l,JSON.stringify(d))}else d=JSON.parse((await(0,qDn.readFile)(l)).toString());if(t.logger.info("Parsing..."),n==null){t.failWithoutThrowing("Failed to load API");return}let s=await n({absolutePathToWorkspace:u,context:t,cliVersion:d.cliVersion,workspaceName:void 0});if(!s.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",s.failures);return}if(s.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await s.workspace.getDefinition({context:t},i)}async function YJD({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await xR.get(e,{responseType:"stream"}),i=await pKp.default.dir(),n=lKp.default.join(i.path,"api.tgz");await(0,fKp.pipeline)(r.data,(0,sKp.createWriteStream)(n)),await(0,dKp.extract)({file:n,cwd:t})}function XJD(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:Fo(e)}}var MKp=yi(mKp(),1);function wRo(e,t){for(let[r,i]of CN(e))kJD({relativeFilepath:r,failure:i,logger:t})}function kJD({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case aP.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 aP.FILE_READ:r.error("Failed to open file: "+e);break;case aP.FILE_MISSING:r.error("Missing file: "+e);break;case aP.FILE_PARSE:t.error instanceof gna?r.error(jie({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case aP.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of eKD(i))r.error(jie({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case aP.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case aP.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${GYa}: `+t.dependencyName);break;case aP.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case aP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case aP.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(jie({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(i=>i!=="")]}));for(let i of t.error.allErrors)i!==t.error.error&&r.debug(jie({title:i.message??"Unknown error",breadcrumbs:[e,...i.instancePath.split("/").filter(n=>n!=="")]}));break;default:Fo(t)}}function eKD(e){switch(e.code){case Hl.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${Js.underline(e.expected)} but received ${Js.underline(e.received)}`}];case Hl.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${Js.underline(t)}`}));case Hl.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>Js.underline(t)).join(", ")}`}];case Hl.invalid_union:case Hl.invalid_arguments:case Hl.invalid_return_type:case Hl.invalid_date:case Hl.invalid_string:case Hl.too_small:case Hl.too_big:case Hl.invalid_intersection_types:case Hl.not_multiple_of:case Hl.custom:default:return[{title:e.message}]}}var PKp=require("fs/promises");async function jKp(e,t){let r=[];for(let i of await qBe(e,t))r.push(await tKD({relativeFilepath:aT(e,i),absoluteFilepath:i}));return r}async function tKD({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,PKp.readFile)(t)).toString()}}async function wKp(e){let t={},r={};function i(n){try{t[n.relativeFilepath]={defaultUrl:void 0,contents:Kd.load(n.fileContents,{schema:Kd.CORE_SCHEMA}),rawContents:n.fileContents}}catch(a){r[n.relativeFilepath]={type:aP.FILE_PARSE,error:a}}}return await Promise.all(e.map(i)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}async function SKp({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:i,settings:n,loadAPIWorkspace:a}){let u={},l={},d={};return await Promise.all(CN(t.packageMarkers).map(async([s,o])=>{if(o.contents.export==null)u[s]=o;else{let{export:c,...b}=o.contents;if(nY(b)>0)d[s]={type:aP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:s};else{let g=_p(s);if(D4t(t.namedDefinitionFiles).some(m=>m!==s&&m.startsWith(g)))d[s]={type:aP.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:g};else{let m=await _Kp({dependencyName:typeof o.contents.export=="string"?o.contents.export:o.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:i,settings:n,loadAPIWorkspace:a});m.didSucceed?l[_p(s)]={definition:m.definition,url:typeof o.contents.export=="object"?o.contents.export.url:void 0}:d[s]=m.failure}}}})),nY(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:u,importedDefinitions:l}}var DKp=yi(require("path"),1);var aJs={};Co(aJs,{additionalProperties:()=>aKD,default:()=>uKD,definitions:()=>oKD,properties:()=>iKD,required:()=>nKD,type:()=>rKD});var rKD="object",iKD={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"}]}},nKD=["name"],aKD=!1,oKD={"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"}]},"token-header":{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.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"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}},uKD={type:rKD,properties:iKD,required:nKD,additionalProperties:aKD,definitions:oKD};var oJs={};Co(oJs,{additionalProperties:()=>lKD,default:()=>dKD,definitions:()=>fKD,properties:()=>cKD,type:()=>sKD});var sKD="object",cKD={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"}]}},lKD=!1,fKD={"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.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{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"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{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"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"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"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{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:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},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.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"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"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{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:{$ref:"#/definitions/types.TypeReferenceSchema"}},{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"},url:{oneOf:[{type:"string"},{type:"null"}]},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}},dKD={type:sKD,properties:cKD,additionalProperties:lKD,definitions:fKD};var uJs={};Co(uJs,{additionalProperties:()=>hKD,default:()=>vKD,definitions:()=>yKD,properties:()=>_KD,type:()=>pKD});var pKD="object",_KD={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"}]}},hKD=!1,yKD={"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.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{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"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{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"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"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"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{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:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},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.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"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"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{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:{$ref:"#/definitions/types.TypeReferenceSchema"}},{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"},url:{oneOf:[{type:"string"},{type:"null"}]},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"}]}},vKD={type:pKD,properties:_KD,additionalProperties:hKD,definitions:yKD};function EKp({files:e,absolutePathToDefinition:t}){let r,i={},n={},a={};for(let[u,l]of CN(e)){let d=l.contents,s=o=>{a[u]={type:aP.JSONSCHEMA_VALIDATION,error:o}};if(u===Q3){let o=DGr(d,aJs);if(o.success){let c=l2.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:c["default-url"],contents:c,rawContents:l.rawContents}}else s(o)}else if(DKp.default.basename(u)===X1){let o=DGr(d,uJs);if(o.success){let c=l2.serialization.PackageMarkerFileSchema.parseOrThrow(d);n[u]={defaultUrl:typeof c.export=="object"?c.export.url:void 0,contents:c,rawContents:l.rawContents}}else s(o)}else{let o=DGr(d,oJs);if(o.success){let c=l2.serialization.DefinitionFileSchema.parseOrThrow(d);i[u]={defaultUrl:void 0,contents:c,rawContents:l.rawContents,absoluteFilePath:Xu(t,u)}}else s(o)}}return r==null?{didSucceed:!1,failures:{[Xa.of(Q3)]:{type:aP.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:i,rootApiFile:r,packageMarkers:n}}var wpi=class extends D5t{context;fernWorkspaces={};loadAPIWorkspace;constructor({context:t,loadAPIWorkspace:r,...i}){super(i),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 i=(0,MKp.default)(r??{}),n=this.fernWorkspaces[i];if(n==null){let a=t||this.context,u=Xu(this.absoluteFilePath,Xa.of(R8)),l=await Dys({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await jKp(u,"{yml,yaml}"),s=await wKp(d);if(!s.didSucceed)return wRo(s.failures,a.logger),a.failAndThrow();let o=EKp({files:s.files,absolutePathToDefinition:u});if(!o.didSucceed)return wRo(o.failures,a.logger),a.failAndThrow();let c=await SKp({dependenciesConfiguration:l,structuralValidationResult:o,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!c.didSucceed)return wRo(c.failures,a.logger),a.failAndThrow();n=new USe({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:l,workspaceName:this.workspaceName,definition:{absoluteFilePath:u,rootApiFile:o.rootApiFile,namedDefinitionFiles:o.namedDefinitionFiles,packageMarkers:c.packageMarkers,importedDefinitions:c.importedDefinitions},cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[i]=n}return n}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};function SV(e){let t=gKD(e),{value:r,done:i}=sJs(t,"{");return i?{head:r,parts:[]}:{head:r,parts:[...bKD(t)]}}function*bKD(e){let t;do{let{value:r}=sJs(e,"}"),i=sJs(e,"{");t=i.done,yield{pathParameter:r,tail:i.value}}while(!t)}function*gKD(e){for(let t of e)yield t}function sJs(e,t){let r="",i=e.next();for(;i.done!==!0&&i.value!==t;)r+=i.value,i=e.next();return{value:r,done:i.done??!1}}function Iya(e){let t=2166136261;function r(n,a){if(typeof n=="object"&&n!=null){if(a>64){i("[MaxDepthExceeded]");return}if(Array.isArray(n)){i("[");for(let u=0;u<n.length;u++)u>0&&i(","),r(n[u],a+1);i("]")}else i("{"),Object.keys(n).sort().forEach((l,d)=>{d>0&&i(","),i(l),i(":"),r(n[l],a+1)}),i("}")}else i(String(n))}function i(n){for(let a=0;a<n.length;a++){let u=n.charCodeAt(a);t^=u,t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24),t>>>=0}}return r(e,0),t.toString(16)}function AKp({fieldName:e,containerType:t,maxDepth:r,currentDepth:i,typeDeclarations:n,skipOptionalProperties:a}){if(i>=r)return IXt({containerType:t});switch(t.type){case"list":{let u=ZT({fieldName:e,typeReference:t.list,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?IXt({containerType:t}):{type:"success",example:GO.list({list:[u.example,u.example],itemType:t.list}),jsonExample:[u.jsonExample,u.jsonExample]}}case"literal":return{type:"success",example:GO.literal({literal:t.literal._visit({boolean:u=>n_.boolean(u),string:u=>n_.string({original:u}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:t.literal._visit({boolean:u=>u,string:u=>u,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":{if(a)return IXt({containerType:t});let u=ZT({fieldName:e,typeReference:t.optional,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?IXt({containerType:t}):{type:"success",example:GO.optional({optional:u.example,valueType:t.optional}),jsonExample:u.jsonExample}}case"nullable":{if(a)return IXt({containerType:t});let u=ZT({fieldName:e,typeReference:t.nullable,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?IXt({containerType:t}):{type:"success",example:GO.nullable({nullable:u.example,valueType:t.nullable}),jsonExample:u.jsonExample}}case"set":{let u=ZT({fieldName:e,typeReference:t.set,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?IXt({containerType:t}):{type:"success",example:GO.set({set:[u.example],itemType:t.set}),jsonExample:[u.jsonExample]}}case"map":{let u=ZT({fieldName:e,typeReference:t.keyType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a}),l=ZT({fieldName:e,typeReference:t.valueType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"||l.type==="failure"?IXt({containerType:t}):{type:"success",example:GO.map({map:[{key:u.example,value:l.example}],keyType:t.keyType,valueType:t.valueType}),jsonExample:{[u.jsonExample]:l.jsonExample}}}default:Fo(t)}}function IXt({containerType:e}){switch(e.type){case"list":return{type:"success",example:GO.list({list:[],itemType:e.list}),jsonExample:[]};case"literal":return{type:"success",example:GO.literal({literal:e.literal._visit({boolean:t=>n_.boolean(t),string:t=>n_.string({original:t}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:e.literal._visit({boolean:t=>t,string:t=>t,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":return{type:"success",example:GO.optional({optional:void 0,valueType:e.optional}),jsonExample:void 0};case"nullable":return{type:"success",example:GO.nullable({nullable:void 0,valueType:e.nullable}),jsonExample:void 0};case"set":return{type:"success",example:GO.set({set:[],itemType:e.set}),jsonExample:[]};case"map":return{type:"success",example:GO.map({map:[],keyType:e.keyType,valueType:e.valueType}),jsonExample:{}};default:Fo(e)}}function TKp({fieldName:e,primitiveType:t}){switch(t.v1){case"STRING":return jKD({fieldName:e,validation:OKD(t.v2)});case"BASE_64":return{type:"success",example:n_.base64(Sg.BASE64),jsonExample:Sg.BASE64};case"BOOLEAN":return{type:"success",example:n_.boolean(Sg.BOOLEAN),jsonExample:Sg.BOOLEAN};case"DATE":return{type:"success",example:n_.date(Sg.DATE),jsonExample:Sg.DATE};case"DATE_TIME":return{type:"success",example:n_.datetime({datetime:new Date(Sg.DATE_TIME),raw:Sg.DATE_TIME}),jsonExample:Sg.DATE_TIME};case"DOUBLE":return wKD({fieldName:e,validation:mKD(t.v2)});case"FLOAT":return{type:"success",example:n_.float(Sg.FLOAT),jsonExample:Sg.FLOAT};case"INTEGER":return SKD({fieldName:e,validation:PKD(t.v2)});case"UINT_64":return{type:"success",example:n_.uint64(Sg.INT64),jsonExample:Sg.INT64};case"UINT":return{type:"success",example:n_.uint(Sg.UINT),jsonExample:Sg.UINT};case"BIG_INTEGER":return{type:"success",example:n_.bigInteger(Sg.INT64.toString()),jsonExample:`${Sg.INT64}`};case"LONG":return{type:"success",example:n_.long(Sg.INT64),jsonExample:Sg.INT64};case"UUID":return{type:"success",example:n_.uuid(Sg.UUID),jsonExample:Sg.UUID};default:Fo(t.v1)}}function OKD(e){if(e?.type==="string")return e.validation}function mKD(e){if(e?.type==="double")return e.validation}function PKD(e){if(e?.type==="integer")return e.validation}function qKp(e){if(e<=Sg.SAMPLE_STRINGS.length){let t=Sg.SAMPLE_STRINGS[e-1];if(t)return t;throw new Error(`Unexpected undefined value in SAMPLE_STRINGS at index ${e-1}`)}return Sg.SAMPLE_STRINGS[Sg.SAMPLE_STRINGS.length-1]+".".repeat(e-Sg.SAMPLE_STRINGS.length)}function jKD({fieldName:e,validation:t}){if(t){let i=t.minLength,n=t.maxLength;if(i){let a=qKp(i);return{type:"success",example:n_.string({original:a}),jsonExample:a}}else if(n){let a=qKp(n);return{type:"success",example:n_.string({original:a}),jsonExample:a}}}let r=e??Sg.STRING;return{type:"success",example:n_.string({original:r}),jsonExample:r}}function wKD({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:n_.double(r),jsonExample:r};if(i)return{type:"success",example:n_.double(i),jsonExample:i}}return{type:"success",example:n_.double(Sg.DOUBLE),jsonExample:Sg.DOUBLE}}function SKD({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:n_.integer(r),jsonExample:r};if(i)return{type:"success",example:n_.integer(i),jsonExample:i}}return{type:"success",example:n_.integer(Sg.INT),jsonExample:Sg.INT}}function ZT({fieldName:e,typeReference:t,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){if(n>i)return{type:"failure",message:"Exceeded max depth"};switch(t.type){case"named":{let u=r[t.typeId];if(u==null)return{type:"failure",message:`Failed to find type declaration with id ${t.typeId}`};let l=BDn({fieldName:e,typeDeclaration:u,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(l==null)return{type:"failure",message:"Failed to generate example for type declaration"};if(l.type==="failure")return l;let{example:d,jsonExample:s}=l;return{type:"success",example:{jsonExample:s,shape:Ab.named({shape:d,typeName:u.name})},jsonExample:s}}case"container":{let u=AKp({fieldName:e,containerType:t.container,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(u.type==="failure"){let{example:s,jsonExample:o}=IXt({containerType:t.container});return{type:"success",example:{jsonExample:o,shape:Ab.container(s)},jsonExample:o}}let{example:l,jsonExample:d}=u;return{type:"success",example:{jsonExample:d,shape:Ab.container(l)},jsonExample:d}}case"primitive":{let{jsonExample:u,example:l}=TKp({fieldName:e,primitiveType:t.primitive});return{type:"success",example:{jsonExample:u,shape:Ab.primitive(l)},jsonExample:u}}case"unknown":{let u={key:"value"};return{type:"success",example:{jsonExample:u,shape:Ab.unknown(u)},jsonExample:u}}}}function xDn({typeReference:e,typeDeclarations:t}){if(e.type==="container"&&e.container.type==="optional")return!0;if(e.type==="named"){let r=t[e.typeId];if(r?.shape.type==="alias"&&r?.shape.resolvedType.type==="container"&&r?.shape.resolvedType.container.type==="optional")return!0}return!1}function BDn({fieldName:e,typeDeclarations:t,typeDeclaration:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){switch(r.shape.type){case"alias":{let u=ZT({fieldName:e,typeDeclarations:t,typeReference:r.shape.aliasOf,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(u.type==="failure")return u;let{example:l,jsonExample:d}=u;return{type:"success",example:tw.alias({value:l}),jsonExample:d}}case"enum":{let u=r.shape.values[0];return u==null?{type:"failure",message:"No enum values present"}:{type:"success",example:tw.enum({value:u.name}),jsonExample:u.name.wireValue}}case"object":{let u={},l=[];if(r.shape.extends!=null)for(let c of r.shape.extends){let b=t[c.typeId];if(b==null)continue;let g=BDn({fieldName:e,typeDeclaration:b,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});g!=null&&g.type==="success"&&g.example.type==="object"&&(Object.assign(u,g.jsonExample),l.push(...g.example.properties))}let d=DKD({fieldName:e,typeDeclaration:r,objectTypeDeclaration:r.shape,typeDeclarations:t,currentDepth:n,maxDepth:i,skipOptionalProperties:a});if(d.type==="failure")return d;let{example:s,jsonExample:o}=d;return{type:"success",example:tw.object({...s,properties:[...l,...s.properties]}),jsonExample:Object.assign({},u,o)}}case"undiscriminatedUnion":{let u=0;for(let l of r.shape.members){let d=ZT({fieldName:e,typeReference:l.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(d.type==="failure"){++u;continue}let{example:s,jsonExample:o}=d;return{type:"success",example:tw.undiscriminatedUnion({index:u,singleUnionType:s}),jsonExample:o}}break}case"union":{let u=r.shape.discriminant,l={};if(r.shape.baseProperties!=null)for(let d of r.shape.baseProperties){let s=ZT({fieldName:d.name.wireValue,typeReference:d.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});s.type==="success"&&(l[d.name.wireValue]=s.jsonExample)}for(let d of r.shape.types){let s=d.shape._visit({noProperties:()=>({type:"success",example:tw.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:QN.noProperties()}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,...l}}),samePropertiesAsObject:o=>{let c=t[o.typeId];if(c==null)return{type:"failure",message:`Failed to find type declaration with id ${o.typeId}`};let b=BDn({currentDepth:n,maxDepth:i,fieldName:e,typeDeclaration:c,typeDeclarations:t,skipOptionalProperties:a});if(b==null)return{type:"failure",message:"Failed to generate example for type reference"};if(b.type==="failure")return b;let{example:g,jsonExample:O}=b;return{type:"success",example:tw.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:QN.samePropertiesAsObject({typeId:c.name.typeId,object:g.type==="object"?g:{properties:[]}})}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,...typeof O=="object"?O:{},...l}}},singleProperty:o=>{let c=ZT({currentDepth:n+1,maxDepth:i,fieldName:e,typeReference:o.type,typeDeclarations:t,skipOptionalProperties:a});if(c.type==="failure")return c;let{example:b,jsonExample:g}=c;return{type:"success",example:tw.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:QN.singleProperty(b)}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,[o.name.wireValue]:g,...l}}},_other:()=>{throw new Error("Encountered unknown union type")}});if(s.type!=="failure")return s}}}return{type:"failure",message:"Failed to generate example for type reference"}}function DKD({fieldName:e,typeDeclaration:t,objectTypeDeclaration:r,typeDeclarations:i,maxDepth:n,currentDepth:a,skipOptionalProperties:u}){let l={},d=[];for(let s of[...r.properties??[],...r.extendedProperties??[]]){let o=ZT({fieldName:s.name.wireValue,typeReference:s.valueType,typeDeclarations:i,currentDepth:a+1,maxDepth:n,skipOptionalProperties:u});if(o.type==="failure"&&!xDn({typeDeclarations:i,typeReference:s.valueType}))return{type:"failure",message:`Failed to generate required property ${s.name.wireValue} b/c ${o.message}`};if(o.type==="failure")continue;let{example:c,jsonExample:b}=o;d.push({name:s.name,originalTypeDeclaration:t.name,value:c}),l[s.name.wireValue]=b}return{type:"success",example:tw.object({properties:d}),jsonExample:l}}var cJs=pd.primitive({v1:g0.String,v2:Z_.string({default:void 0,validation:void 0})});function zya({ir:e,endpoint:t,service:r,typeDeclarations:i,skipOptionalRequestProperties:n,generationResponse:a}){let u={name:void 0,endpointHeaders:[],endpointPathParameters:[],queryParameters:[],servicePathParameters:[],serviceHeaders:[],rootPathParameters:[],request:void 0,response:Cq.ok(KT.body(void 0)),docs:void 0},l=[{params:t.pathParameters,add:s=>u.endpointPathParameters.push(s)},{params:r.pathParameters,add:s=>u.servicePathParameters.push(s)},{params:e.pathParameters,add:s=>u.rootPathParameters.push(s)}];for(let s of l)for(let o of s.params){let c=ZT({fieldName:o.name.originalName,currentDepth:0,maxDepth:1,typeDeclarations:i,typeReference:o.valueType,skipOptionalProperties:n});if(c.type==="failure")return c;let{example:b}=c;s.add({name:o.name,value:b})}for(let s of t.queryParameters){if(n&&xDn({typeDeclarations:i,typeReference:s.valueType}))continue;let o=ZT({fieldName:s.name.name.originalName,currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:s.valueType,skipOptionalProperties:n});if(o.type==="failure")return o;let{example:c}=o;u.queryParameters.push({name:s.name,shape:s.allowMultiple?f2.exploded():f2.single(),value:c})}let d=[{params:t.headers,add:s=>u.endpointHeaders.push(s)},{params:r.headers,add:s=>u.serviceHeaders.push(s)}];for(let s of d)for(let o of s.params){if(n&&xDn({typeDeclarations:i,typeReference:o.valueType}))continue;let c=ZT({fieldName:o.name.name.originalName,currentDepth:0,maxDepth:1,typeDeclarations:i,typeReference:o.valueType,skipOptionalProperties:n});if(c.type==="failure")return c;let{example:b}=c;s.add({name:o.name,value:b})}if(t.requestBody!=null)switch(t.requestBody.type){case"bytes":return{type:"failure",message:"Bytes request unsupported"};case"fileUpload":return{type:"failure",message:"File upload unsupported"};case"inlinedRequestBody":{let s={},o=[];if(t.requestBody.extends!=null)for(let c of t.requestBody.extends){let b=i[c.typeId];if(b==null)throw new Error(`Failed to find extended type declaration with id ${c.typeId}`);let g=BDn({typeDeclaration:b,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});g!=null&&g.type==="success"&&Object.assign(s,g.jsonExample)}for(let c of[...t.requestBody.properties??[],...t.requestBody.extendedProperties??[]]){let b=ZT({fieldName:c.name.wireValue,typeReference:c.valueType,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});if(b.type==="failure"&&!xDn({typeDeclarations:i,typeReference:c.valueType}))return{type:"failure",message:`Failed to generate required property ${c.name.wireValue} b/c ${b.message}`};if(b.type==="failure")continue;let{example:g,jsonExample:O}=b;o.push({name:c.name,originalTypeDeclaration:void 0,value:g}),s[c.name.wireValue]=O}u.request=U$.inlinedRequestBody({jsonExample:s,properties:o});break}case"reference":{let s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.requestBody.requestBodyType,skipOptionalProperties:n});if(s.type==="failure")return s;let{example:o}=s;u.request=U$.reference(o);break}default:Fo(t.requestBody)}if(a.type==="success"&&t.response?.body!=null)switch(t.response.body.type){case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":{let s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.responseBodyType,skipOptionalProperties:!1});if(s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Cq.ok(KT.body({...o,jsonExample:c}));break}case"streamParameter":{let s;switch(t.response.body.nonStreamResponse.type){case"bytes":return{type:"failure",message:"Bytes unsupported"};case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.nonStreamResponse.value.responseBodyType,skipOptionalProperties:!1});break;case"text":s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:cJs,skipOptionalProperties:!1});break;default:Fo(t.response.body.nonStreamResponse)}if(s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Cq.ok(KT.body({...o,jsonExample:c}));break}case"streaming":{let s;switch(t.response.body.value.type){case"sse":{if(s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Cq.ok(KT.sse([{data:{...o,jsonExample:c},event:""}]));break}case"json":{if(s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Cq.ok(KT.stream([{...o,jsonExample:c}]));break}case"text":{if(s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:cJs,skipOptionalProperties:!1}),s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Cq.ok(KT.stream([{...o,jsonExample:c}]));break}default:Fo(t.response.body.value)}break}case"text":{let s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:cJs,skipOptionalProperties:!1});if(s.type==="failure")return s;let{example:o,jsonExample:c}=s;u.response=Cq.ok(KT.body({...o,jsonExample:c}));break}case"bytes":return{type:"failure",message:"Bytes unsupported"};default:Fo(t.response.body)}else if(a.type==="error")if(a.declaration.type==null)u.response=Cq.error({body:void 0,error:a.declaration.name});else{let s=ZT({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:a.declaration.type,skipOptionalProperties:n});if(s.type==="failure")return s;let{example:o}=s;u.response=Cq.error({body:o,error:a.declaration.name})}try{return{type:"success",example:{id:Iya(u),url:EKD(t,u),...u},jsonExample:void 0}}catch(s){return{type:"failure",message:`Parse failure with exceptions ${s}`}}}function EKD(e,t){let r={};[...t.rootPathParameters,...t.servicePathParameters,...t.endpointPathParameters].forEach(n=>{let a=n.value.jsonExample,u=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=u});let i=e.fullPath.head+e.fullPath.parts.map(n=>r[n.pathParameter]+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function mNi({ir:e,exampleGeneration:t}){for(let[r,i]of Object.entries(e.services))for(let n of i.endpoints){if(n.userSpecifiedExamples.length>0&&t?.skipAutogenerationIfManualExamplesExist===!0)continue;let a=zya({ir:e,service:i,endpoint:n,typeDeclarations:e.types,skipOptionalRequestProperties:!t?.includeOptionalRequestPropertyExamples,generationResponse:{type:"success"}});if(a.type==="failure")continue;let{example:u}=a;n.autogeneratedExamples=[{example:u}]}return e}function lJs(e,t){return{apiName:e.apiName,basePath:e.basePath,apiDisplayName:e.apiDisplayName??t.apiDisplayName,apiDocs:e.apiDocs??t.apiDocs,auth:e.auth??t.auth,headers:[...e.headers??[],...t.headers??[]],environments:e.environments??t.environments,types:{...e.types??{},...t.types??{}},constants:{...e.constants??{},...t.constants??{}},errors:{...e.errors??{},...t.errors??{}},services:{...e.services??{},...t.services??{}},webhookGroups:{...e.webhookGroups??{},...t.webhookGroups??{}},subpackages:{...e.subpackages??{},...t.subpackages??{}},websocketChannels:{...e.websocketChannels??{},...t.websocketChannels??{}},rootPackage:{service:e.rootPackage.service??t.rootPackage.service,types:[...e.rootPackage.types??[],...t.rootPackage.types??[]],errors:[...e.rootPackage.errors??[],...t.rootPackage.errors??[]],subpackages:[...e.rootPackage.subpackages??[],...t.rootPackage.subpackages??[]],fernFilepath:e.rootPackage.fernFilepath??t.rootPackage.fernFilepath,webhooks:e.rootPackage.webhooks??t.rootPackage.webhooks,websocket:e.rootPackage.websocket??t.rootPackage.websocket,hasEndpointsInTree:e.rootPackage.hasEndpointsInTree||t.rootPackage.hasEndpointsInTree,navigationConfig:e.rootPackage.navigationConfig??t.rootPackage.navigationConfig,docs:e.rootPackage.docs??t.rootPackage.docs},fdrApiDefinitionId:e.fdrApiDefinitionId??t.fdrApiDefinitionId,apiVersion:e.apiVersion??t.apiVersion,idempotencyHeaders:[...e.idempotencyHeaders??[],...t.idempotencyHeaders??[]],pathParameters:[...e.pathParameters??[],...t.pathParameters??[]],errorDiscriminationStrategy:e.errorDiscriminationStrategy??t.errorDiscriminationStrategy,variables:[...e.variables??[],...t.variables??[]],serviceTypeReferenceInfo:e.serviceTypeReferenceInfo??t.serviceTypeReferenceInfo,readmeConfig:e.readmeConfig??t.readmeConfig,sourceConfig:e.sourceConfig??t.sourceConfig,publishConfig:e.publishConfig??t.publishConfig,dynamic:e.dynamic??t.dynamic,sdkConfig:e.sdkConfig??t.sdkConfig}}var Oy=class{breadcrumbs=[];constructor({breadcrumbs:t=[]}={}){this.breadcrumbs=t}};var CKp={[Jb.GenerationLanguage.PHP]:new Set(["abstract","and","as","break","callable","case","catch","class","clone","const","continue","declare","default","do","echo","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","extends","final","finally","fn","for","foreach","function","global","goto","list","if","implements","include","include_once","instanceof","insteadof","interface","match","namespace","new","or","parent","Parent","print","private","protected","public","readonly","require","require_once","return","static","switch","throw","trait","try","use","var","while","xor","yield"].flatMap(e=>[e,G3(e)])),[Jb.GenerationLanguage.TYPESCRIPT]:new Set(["any","as","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","module","new","null","number","of","package","private","protected","public","require","return","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","var","void","while","with","yield","Date","Error","File","Object","Record"]),[Jb.GenerationLanguage.JAVA]:new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","try","void","volatile","while"]),[Jb.GenerationLanguage.PYTHON]:new Set(["False","None","True","and","as","assert","async","","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","float","int","complex","bool","uuid","list","set","map","long","self","all"]),[Jb.GenerationLanguage.GO]:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[Jb.GenerationLanguage.RUBY]:new Set(["__ENCODING__","__LINE__","__FILE__","alias","and","begin","break","case","class","def","defined","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","Object","JSON","Date","DateTime"]),[Jb.GenerationLanguage.CSHARP]:new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while","add","and","alias","ascending","args","async","","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","managed","nameof","nint","not","notnull","nuint","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value","var","when","where","with","yield"]),[Jb.GenerationLanguage.SWIFT]:new Set([])};var MKD=["go","ruby"];function ZSe({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let u=c=>({unsafeName:c,safeName:AKD({name:c,keywords:qKD({generationLanguage:e,keywords:t})})}),l=Dg(n),d=G3(l),s=aYa(n),o=Lra(l);return r&&(!BKD(o)&&(e==null||MKD.includes(e))&&(l=o.map((c,b)=>{if(b>0){let g=SRo(c);if(g!=null)return g;if(DRo(c))return c.toUpperCase()}return c}).join(""),d=o.map((c,b)=>{let g=SRo(c);return g??(DRo(c)?c.toUpperCase():b===0?G3(c):c)}).join("")),s=n.split(" ").map(c=>c.split(/(\d+)/).map(aYa).join("")).join("_")),{originalName:n,camelCase:u(a?.casingOverrides?.camel??l),snakeCase:u(a?.casingOverrides?.snake??s),screamingSnakeCase:u(a?.casingOverrides?.["screaming-snake"]??s.toUpperCase()),pascalCase:u(a?.casingOverrides?.pascal??d)}},generateNameAndWireValue:({name:n,wireValue:a,opts:u})=>({name:i.generateName(n,u),wireValue:a})};return i}function AKD({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":CKD(e)?"_"+e:e}function qKD({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return CKp[e]}var TKD=/^[0-9]/;function CKD(e){return TKD.test(e)}function BKD(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=SRo(i)!=null||DRo(i),a=SRo(t)!=null||DRo(t);return n&&a})}function SRo(e){return IKD.get(e.toUpperCase())}function DRo(e){return xKD.has(e.toUpperCase())}var xKD=new Set(["ACL","API","ASCII","CPU","CSS","DNS","EOF","GUID","HTML","HTTP","HTTPS","ID","IP","JSON","LHS","QPS","RAM","RHS","RPC","SAML","SCIM","SLA","SMTP","SQL","SSH","SSO","TCP","TLS","TTL","UDP","UI","UID","UUID","URI","URL","UTF8","VM","XML","XMPP","XSRF","XSS"]),IKD=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]);var PNi=class e{args;spec;settings;logger;generationLanguage;smartCasing;casingsGenerator;constructor(t){this.args=t,this.spec=t.spec,this.settings=t.settings,this.logger=t.logger,this.generationLanguage=t.generationLanguage,this.smartCasing=t.smartCasing,this.casingsGenerator=ZSe({generationLanguage:t.generationLanguage,keywords:void 0,smartCasing:t.smartCasing})}static BREADCRUMBS_TO_IGNORE=["properties","allOf","anyOf"];convertBreadcrumbsToName(t){let r=t.filter((n,a)=>!(/^\d+$/.test(n)||e.BREADCRUMBS_TO_IGNORE.includes(n)||a===0&&n==="components"||a===1&&n==="schemas"||t[0]==="paths"&&(a===0||a===1&&["get","post","put","delete","patch"].includes(n)||a===2&&t[1]!=null&&["get","post","put","delete","patch"].includes(t[1])&&n==="parameters"))),i=Dg(r.join("_"));return i.charAt(0).toUpperCase()+i.slice(1)}createPackage(t={}){return{fernFilepath:{allParts:[],packagePath:[],file:t.name!=null?this.casingsGenerator.generateName(t.name):void 0},service:void 0,types:[],errors:[],subpackages:[],docs:void 0,webhooks:void 0,websocket:void 0,hasEndpointsInTree:!1,navigationConfig:void 0}}async resolveReference(t){let r=this.spec,i;if(t.$ref.startsWith("http://")||t.$ref.startsWith("https://")){let a=t.$ref.split("#"),u=a[0];if(i=a[1],!u)return{resolved:!1};let l=await fetch(u);if(!l.ok)return{resolved:!1};try{let d=await l.text();try{r=JSON.parse(d)}catch{r=Kd.load(d)}if(r==null)return{resolved:!1}}catch{return{resolved:!1}}if(!i)return{resolved:!0,value:r}}let n=(i??t.$ref).replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(a=>a.replace(/~1/g,"/"));for(let a of n){if(typeof r!="object"||r==null)return{resolved:!1};r=r[a]}return r==null?{resolved:!1}:{resolved:!0,value:r}}createNamedTypeReference(t){return pd.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(t??"defaultName"),typeId:t,default:void 0,inline:!1})}typeReferenceToDeclaredTypeName(t){if(t.type!=="named")return;let r=t.typeId;return{typeId:r,fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r)}}removeSchemaFromInlinedTypes({id:t,inlinedTypes:r}){return Object.fromEntries(Object.entries(r).filter(([i])=>i!==t))}maybeTrimPrefix(t,r){return t.startsWith(r)?t.slice(r.length):t}isOptional(t){return t.type==="container"&&t.container.type==="optional"}isList(t){return t.type==="container"&&t.container.type==="list"}isFile(t){return t.type==="primitive"&&t.primitive.v2?.type==="string"&&t.primitive.v2.validation?.format==="binary"}getAsString(t){if(typeof t=="string")return t}getAsInteger(t){if(typeof t=="number"&&Number.isInteger(t))return t}getAsNumber(t){if(typeof t=="number")return t}getAsBoolean(t){if(typeof t=="boolean")return t}getAsArray(t){if(Array.isArray(t))return t}getAsObject(t){if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t}};var sz=class extends Oy{getExtensionValue(t){if(!(typeof t!="object"||t==null))return t[this.key]}};var Rya=class{errors=[];logger;constructor({logger:t}){this.logger=t}collect(t){this.errors.push(t)}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}logErrors(){for(let t of this.errors)this.logger.log(V0.Info,jie({title:t.message,breadcrumbs:t.path,subtitle:t.path!=null?k_.dim(t.path.join(" -> ")):void 0}))}};var AG={};Co(AG,{FernAvailabilityExtension:()=>ERo,FernEnumExtension:()=>MRo,FernIgnoreExtension:()=>ARo});var ERo=class extends sz{node;key="x-fern-availability";constructor({breadcrumbs:t,node:r}){super({breadcrumbs:t}),this.node=r}async convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.node);if(i==null||typeof i!="string")return;switch(i.toUpperCase().replace(/[-_\s]/g,"_")){case"IN_DEVELOPMENT":return a7.InDevelopment;case"PRE_RELEASE":return a7.PreRelease;case"GENERAL_AVAILABILITY":return a7.GeneralAvailability;case"DEPRECATED":return a7.Deprecated;default:return}}};var zKD=Yu.object({snake:Yu.string().optional(),camel:Yu.string().optional(),screamingSnake:Yu.string().optional(),pascal:Yu.string().optional()}),RKD=Yu.object({description:Yu.string().optional(),name:Yu.string().optional(),casing:zKD.optional()}),BKp=Yu.record(RKD);var MRo=class extends sz{schema;key="x-fern-enum";constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.schema);if(i==null)return;let n=BKp.safeParse(i);if(!n.success){r.collect({message:`Invalid x-fern-enum extension: ${n.error.message}`,path:this.breadcrumbs});return}return n.data}};var ARo=class extends sz{operation;key="x-fern-ignore";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null){if(typeof i!="boolean"){r.collect({message:"Received unexpected non-boolean value for x-fern-ignore",path:this.breadcrumbs});return}return i}}};function jNi(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","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),l=e%10;return l===0?i[u]:`${i[u]}_${t[l]}`}if(e<1e3){let u=Math.floor(e/100),l=e%100;return l===0?`${t[u]}_hundred`:`${t[u]}_hundred_${jNi(l)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${jNi(a)}`}var pJs=yi(xKp(),1);var IKp=["get","post","put","delete","patch"];var qRo=class extends sz{operation;key="x-fern-idempotent";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null){if(typeof i!="boolean"){r.collect({message:"Received unexpected non-boolean value for x-fern-idempotent",path:this.breadcrumbs});return}return i}}};var LKD=Yu.object({cursor:Yu.string(),next_cursor:Yu.string(),results:Yu.string()}),UKD=Yu.object({offset:Yu.string(),results:Yu.string(),step:Yu.string().optional(),"has-next-page":Yu.string().optional()}),fJs=Yu.union([Yu.boolean(),LKD,UKD]);var dJs="$request.",TRo="$response.",CRo=class extends sz{operation;document;key="x-fern-pagination";constructor({breadcrumbs:t,operation:r,document:i}){super({breadcrumbs:t}),this.operation=r,this.document=i}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i==null)return;let n=fJs.safeParse(i);if(!n.success){r.collect({message:`Invalid x-fern-pagination extension: ${n.error.message}`,path:this.breadcrumbs});return}if(typeof n.data=="boolean"){let a=this.getExtensionValue(this.document);if(a==null)return;if(typeof a=="boolean"){r.collect({message:"Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.",path:this.breadcrumbs});return}let u=fJs.safeParse(a);if(!u.success){r.collect({message:`Invalid x-fern-pagination extension: ${u.error.message}`,path:this.breadcrumbs});return}if(typeof u.data=="boolean"){r.collect({message:"Global pagination extension is a boolean, expected an object.",path:this.breadcrumbs});return}return this.convertPaginationConfig(u.data,t)}if(typeof n.data=="boolean"){r.collect({message:"Pagination extension is a boolean with no global configuration.",path:this.breadcrumbs});return}return this.convertPaginationConfig(n.data,t)}convertPaginationConfig(t,r){let i=t;if("cursor"in i)return{type:"cursor",cursor:r.maybeTrimPrefix(i.cursor,dJs),nextCursor:r.maybeTrimPrefix(i.next_cursor,TRo),results:r.maybeTrimPrefix(i.results,TRo)};let n=t;return{type:"offset",offset:r.maybeTrimPrefix(n.offset,dJs),results:r.maybeTrimPrefix(n.results,TRo),step:n.step!=null?r.maybeTrimPrefix(n.step,dJs):void 0,hasNextPage:n["has-next-page"]!=null?r.maybeTrimPrefix(n["has-next-page"],TRo):void 0}}};var VKD="$request.",WKD=Yu.object({"stream-condition":Yu.string().optional(),format:Yu.enum(["sse","json"]).optional(),"stream-description":Yu.string().optional(),"response-stream":Yu.any(),response:Yu.any()}),HKD=Yu.union([Yu.boolean(),WKD]),BRo=class extends sz{operation;key="x-fern-streaming";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i==null)return;let n=HKD.safeParse(i);if(!n.success){r.collect({message:`Invalid x-fern-streaming extension: ${n.error.message}`,path:this.breadcrumbs});return}if(typeof n.data=="boolean")return n.data?{type:"stream",format:"json"}:void 0;if(n.data["stream-condition"]==null&&n.data.format!=null)return{type:"stream",format:n.data.format};if(n.data["stream-condition"]==null){r.collect({message:"Missing required stream-condition property",path:this.breadcrumbs});return}return{type:"streamCondition",format:n.data.format??"json",streamDescription:n.data["stream-description"],streamConditionProperty:t.maybeTrimPrefix(n.data["stream-condition"],VKD),responseStream:n.data["response-stream"],response:n.data.response}}};var xRo=class extends sz{operation;key="x-fern-webhook";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null){if(typeof i!="boolean"){r.collect({message:"Received unexpected non-boolean value for x-fern-webhook",path:this.breadcrumbs});return}return i}}};var IRo=class extends sz{operation;key="x-fern-sdk-group-name";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i==null)return;let n=Array.isArray(i)?i.filter(a=>typeof a=="string"):typeof i=="string"?[i]:[];if(n.length!==0)return{groups:n}}};var zRo=class extends sz{operation;key="x-fern-sdk-method-name";constructor({breadcrumbs:t,operation:r}){super({breadcrumbs:t}),this.operation=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.operation);if(i!=null&&typeof i=="string")return{methodName:i}}};var RRo=class e extends Oy{static LIST_UNKNOWN=pd.container(Ev.list(pd.unknown()));schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){if(this.schema.items==null)return{typeReference:e.LIST_UNKNOWN};let n=await new cX({breadcrumbs:[...this.breadcrumbs,"items"],schemaOrReference:this.schema.items}).convert({context:t,errorCollector:r});return n!=null?{typeReference:pd.container(Ev.list(n.type)),inlinedTypes:n.inlinedTypes}:{typeReference:e.LIST_UNKNOWN}}};var NRo=class extends Oy{schema;maybeFernEnum;constructor({breadcrumbs:t,schema:r,maybeFernEnum:i}){super({breadcrumbs:t}),this.schema=r,this.maybeFernEnum=i}convert({context:t,errorCollector:r}){if(!this.schema.enum)return;let n=this.schema.enum.filter(u=>typeof u=="string").map(u=>{let l=this.maybeFernEnum?.[u],d=l?.name??u.toString();return{name:t.casingsGenerator.generateNameAndWireValue({name:d,wireValue:u.toString()}),docs:l?.description,availability:void 0,casing:l?.casing}});if(n.length===0)return;let a=t.getAsString(this.schema.default);return{enum:a0.enum({default:a!=null?n.find(u=>u.name.wireValue===a):void 0,values:n})}}};var FRo=class extends Oy{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){if(!this.schema.properties&&!this.schema.allOf)return{object:a0.object({properties:[],extends:[],extendedProperties:[],extraProperties:this.schema.additionalProperties!=null})};let i=[],n={};for(let[u,l]of Object.entries(this.schema.properties??{})){let d=[...this.breadcrumbs,"properties",u],s="nullable"in l?l.nullable:!1,o=t.convertBreadcrumbsToName(d),b=await new cX({breadcrumbs:d,schemaOrReference:l,schemaIdOverride:o,wrapAsOptional:!this.schema.required?.includes(u),wrapAsNullable:s}).convert({context:t,errorCollector:r});b!=null&&(i.push({name:t.casingsGenerator.generateNameAndWireValue({name:u,wireValue:u}),valueType:b.type,docs:l.description,availability:b.availability,propertyAccess:await t.getPropertyAccess(l)}),n={...n,...b.inlinedTypes})}let a=[];for(let[u,l]of(this.schema.allOf??[]).entries()){let d=[...this.breadcrumbs,"allOf",u.toString()];if(t.isReferenceObject(l)){let s=await t.convertReferenceToTypeReference(l);s.ok&&a.push(s.reference);continue}for(let[s,o]of Object.entries(l.properties??{})){let c=[...d,s],b=t.convertBreadcrumbsToName(c),O=await new cX({breadcrumbs:c,schemaOrReference:o,schemaIdOverride:b,wrapAsOptional:!l.required?.includes(s),wrapAsNullable:"nullable"in o?o.nullable:!1}).convert({context:t,errorCollector:r});O!=null&&(i.push({name:t.casingsGenerator.generateNameAndWireValue({name:s,wireValue:s}),valueType:O.type,docs:o.description,availability:O.availability,propertyAccess:await t.getPropertyAccess(o)}),n={...n,...O.inlinedTypes})}}return{object:a0.object({properties:i,extends:a.map(u=>t.typeReferenceToDeclaredTypeName(u)).filter(Qb),extendedProperties:[],extraProperties:this.schema.additionalProperties!=null}),inlinedTypes:n}}};var LRo=class extends Oy{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){return this.schema.discriminator!=null?await this.convertAsDiscriminatedUnion({context:t,errorCollector:r}):this.convertAsUndiscriminatedUnion({context:t,errorCollector:r})}async convertAsDiscriminatedUnion({context:t,errorCollector:r}){let i=[],n={};if(this.schema.discriminator!=null){for(let[a,u]of Object.entries(this.schema.discriminator.mapping??{})){let l=new cX({schemaOrReference:{$ref:u},breadcrumbs:[...this.breadcrumbs,"discriminator","mapping",a]}),d=t.getTypeIdFromSchemaReference({$ref:u}),s=await l.convert({context:t,errorCollector:r});if(s?.type!=null&&d!=null){let o=t.casingsGenerator.generateNameAndWireValue({name:a,wireValue:a});i.push({docs:void 0,discriminantValue:o,availability:s.availability,displayName:void 0,shape:Z8.samePropertiesAsObject({typeId:d,name:t.casingsGenerator.generateName(d),fernFilepath:{allParts:[],packagePath:[],file:void 0}})}),n={...n,...s.inlinedTypes}}}return{union:a0.union({baseProperties:[],discriminant:t.casingsGenerator.generateNameAndWireValue({name:this.schema.discriminator.propertyName,wireValue:this.schema.discriminator.propertyName}),extends:[],types:i}),inlinedTypes:n}}}async convertAsUndiscriminatedUnion({context:t,errorCollector:r}){if(!this.schema.oneOf||this.schema.oneOf.length===0)return;let i=[],n={};for(let[a,u]of this.schema.oneOf.entries()){let l=[...this.breadcrumbs,"oneOf",jNi(a)??""];if(t.isReferenceObject(u)){let c=await t.convertReferenceToTypeReference(u);c.ok&&i.push({type:c.reference,docs:u.description});continue}let d=t.convertBreadcrumbsToName(l),o=await new Dpi({id:d,breadcrumbs:l,schema:u}).convert({context:t,errorCollector:r});o!=null&&(i.push({type:t.createNamedTypeReference(d),docs:u.description}),n={...n,...o.inlinedTypes,[d]:o.typeDeclaration})}return{union:a0.undiscriminatedUnion({members:i}),inlinedTypes:n}}};var URo=class extends Oy{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}convert({context:t,errorCollector:r}){switch(this.schema.type){case"string":{let i=t.getAsString(this.schema.const);return i!=null?pd.container(Ev.literal(k8.string(i))):pd.primitive({v1:"STRING",v2:Z_.string({default:t.getAsString(this.schema.default),validation:this.getStringValidation(this.schema)})})}case"number":case"integer":switch(this.schema.format){case"double":case void 0:return pd.primitive({v1:"DOUBLE",v2:Z_.double({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return pd.primitive({v1:"FLOAT",v2:Z_.float({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return pd.primitive({v1:"INTEGER",v2:Z_.integer({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return pd.primitive({v1:"LONG",v2:Z_.long({default:t.getAsNumber(this.schema.default)})});case"uint32":return pd.primitive({v1:"UINT",v2:Z_.uint({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return pd.primitive({v1:"UINT_64",v2:Z_.uint64({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return pd.primitive({v1:"INTEGER",v2:Z_.integer({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"boolean":{let i=t.getAsBoolean(this.schema.const);return i!=null?pd.container(Ev.literal(k8.boolean(i))):pd.primitive({v1:"BOOLEAN",v2:Z_.boolean({default:this.schema.default})})}default:return}}getNumberValidation(t){return{max:t.maximum,min:t.minimum,exclusiveMax:typeof t.exclusiveMaximum=="boolean"?t.exclusiveMaximum:void 0,exclusiveMin:typeof t.exclusiveMinimum=="boolean"?t.exclusiveMinimum:void 0,multipleOf:t.multipleOf}}getStringValidation(t){return{minLength:t.minLength,maxLength:t.maxLength,pattern:t.pattern,format:t.format}}};var Dpi=class extends Oy{schema;id;inlined;constructor({breadcrumbs:t,schema:r,id:i,inlined:n=!1}){super({breadcrumbs:t}),this.schema=r,this.id=i,this.inlined=n}async convert({context:t,errorCollector:r}){if(this.schema.enum?.length){let u=new AG.FernEnumExtension({breadcrumbs:this.breadcrumbs,schema:this.schema}).convert({context:t,errorCollector:r}),d=new NRo({breadcrumbs:this.breadcrumbs,schema:this.schema,maybeFernEnum:u}).convert({context:t,errorCollector:r});if(d!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:d.enum,context:t,errorCollector:r}),inlinedTypes:{}}}let n=new URo({schema:this.schema}).convert({context:t,errorCollector:r});if(n!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:a0.alias({aliasOf:n,resolvedType:n}),context:t,errorCollector:r}),inlinedTypes:{}};if(this.schema.type==="array"){let u=await new RRo({breadcrumbs:this.breadcrumbs,schema:this.schema}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:a0.alias({aliasOf:u.typeReference,resolvedType:u.typeReference}),context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}if(this.schema.oneOf!=null){let u=await new LRo({breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:u.union,context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}if(this.schema.type==="object"||this.schema.properties!=null||this.schema.allOf!=null){let u=await new FRo({breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:u.object,context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}}async createTypeDeclaration({shape:t,context:r,errorCollector:i}){return{name:this.convertDeclaredTypeName({context:r}),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:await r.getAvailability({node:this.schema,breadcrumbs:this.breadcrumbs,errorCollector:i}),docs:this.schema.description,referencedTypes:new Set,source:void 0,inline:this.inlined}}convertDeclaredTypeName({context:t}){return{typeId:this.id,fernFilepath:{allParts:[],packagePath:[],file:void 0},name:t.casingsGenerator.generateName(this.id)}}};var cX=class extends Oy{schemaOrReference;schemaIdOverride;wrapAsOptional;wrapAsNullable;constructor({breadcrumbs:t,schemaOrReference:r,schemaIdOverride:i,wrapAsOptional:n=!1,wrapAsNullable:a=!1}){super({breadcrumbs:t}),this.schemaOrReference=r,this.schemaIdOverride=i,this.wrapAsOptional=n,this.wrapAsNullable=a}async convert({context:t,errorCollector:r}){if(t.isReferenceObject(this.schemaOrReference)){let l=await t.convertReferenceToTypeReference(this.schemaOrReference);return l.ok?{type:l.reference,inlinedTypes:{}}:void 0}let i=this.schemaIdOverride??t.convertBreadcrumbsToName(this.breadcrumbs),n=new Dpi({breadcrumbs:this.breadcrumbs,schema:this.schemaOrReference,id:i}),a=await t.getAvailability({node:this.schemaOrReference,breadcrumbs:this.breadcrumbs,errorCollector:r}),u=await n.convert({context:t,errorCollector:r});if(u!=null){if(u.typeDeclaration.shape.type==="alias"){let d=u.typeDeclaration.shape.aliasOf;return{type:this.wrapTypeReference(d),inlinedTypes:u.inlinedTypes,availability:a}}let l=t.createNamedTypeReference(i);return{type:this.wrapTypeReference(l),schema:u.typeDeclaration,inlinedTypes:{...u.inlinedTypes,[i]:u.typeDeclaration},availability:a}}}wrapTypeReference(t){return this.wrapAsOptional&&this.wrapAsNullable?this.wrapInOptional(this.wrapInNullable(t)):this.wrapAsOptional?this.wrapInOptional(t):this.wrapAsNullable?this.wrapInNullable(t):t}wrapInOptional(t){return pd.container(Ev.optional(t))}wrapInNullable(t){return pd.container(Ev.nullable(t))}};var Nya=class e extends Oy{static STRING=pd.primitive({v1:"STRING",v2:Z_.string({default:void 0,validation:void 0})});static OPTIONAL_STRING=pd.container(Ev.optional(e.STRING));parameter;constructor({breadcrumbs:t,parameter:r}){super({breadcrumbs:t}),this.parameter=r}async convert({context:t,errorCollector:r}){let i,n={};if(this.parameter.schema!=null){let l=await new cX({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required}).convert({context:t,errorCollector:r});l!=null&&(i=l.type,n=l.inlinedTypes??{})}let a=await t.getAvailability({node:this.parameter,breadcrumbs:this.breadcrumbs,errorCollector:r});switch(this.parameter.in){case"query":return{type:"query",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??e.OPTIONAL_STRING,allowMultiple:this.parameter.explode??!1,availability:a},inlinedTypes:n};case"header":return{type:"header",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??e.OPTIONAL_STRING,env:void 0,availability:a},inlinedTypes:n};case"path":return{type:"path",parameter:{name:t.casingsGenerator.generateName(this.parameter.name),docs:this.parameter.description,valueType:i??e.STRING,location:"ENDPOINT",variable:void 0},inlinedTypes:n};default:return}}};var VRo=class extends Oy{requestBody;group;method;constructor({breadcrumbs:t,requestBody:r,group:i,method:n}){super({breadcrumbs:t}),this.requestBody=r,this.group=i,this.method=n}async convert({context:t,errorCollector:r}){if(!this.requestBody.content)return;let i=Object.keys(this.requestBody.content).filter(u=>u.includes("json"));for(let u of i){let l=this.handleJsonOrFormContent({contentType:u,context:t,errorCollector:r});if(l!=null)return l}let n=Object.keys(this.requestBody.content).filter(u=>u.includes("multipart"));for(let u of n){let l=[...this.group,this.method,"Request"].join("_"),d=await this.convertRequestSchemaForMediaType({schemaId:l,contentType:u,context:t,errorCollector:r});if(d!=null&&d.schema?.shape.type==="object")return{requestBody:eI.fileUpload({docs:this.requestBody.description,name:t.casingsGenerator.generateName(l),properties:d.schema?.shape.properties.map(o=>this.convertRequestBodyProperty({context:t,property:o,contentType:u}))}),inlinedTypes:t.removeSchemaFromInlinedTypes({id:l,inlinedTypes:d.inlinedTypes}),examples:d.examples}}let a=Object.keys(this.requestBody.content).filter(u=>u.includes("urlencoded"));for(let u of a){let l=this.handleJsonOrFormContent({contentType:u,context:t,errorCollector:r});if(l!=null)return l}}async convertRequestSchemaForMediaType({schemaId:t,contentType:r,context:i,errorCollector:n}){let a=this.requestBody.content[r];if(a==null||a.schema==null)return;let l=await new cX({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:a.schema,schemaIdOverride:t}).convert({context:i,errorCollector:n});if(l==null)return;let d=a.examples!=null?Object.fromEntries(await Promise.all(Object.entries(a.examples).map(async([s,o])=>[s,i.isReferenceObject(o)?await i.resolveReference(o):o]))):void 0;return{...l,examples:d}}async handleJsonOrFormContent({contentType:t,context:r,errorCollector:i}){let n=[...this.group,this.method,"Request"].join("_"),a=await this.convertRequestSchemaForMediaType({schemaId:n,contentType:t,context:r,errorCollector:i});if(a!=null)return a.schema?.shape.type==="object"?{requestBody:eI.inlinedRequestBody({contentType:t,docs:this.requestBody.description,name:r.casingsGenerator.generateName(n),extendedProperties:a.schema?.shape.extendedProperties,extends:a.schema?.shape.extends,properties:a.schema?.shape.properties,extraProperties:a.schema?.shape.extraProperties}),inlinedTypes:r.removeSchemaFromInlinedTypes({id:n,inlinedTypes:a.inlinedTypes})}:{requestBody:eI.reference({contentType:t,docs:this.requestBody.description,requestBodyType:a.type}),inlinedTypes:r.removeSchemaFromInlinedTypes({id:n,inlinedTypes:a.inlinedTypes})}}convertRequestBodyProperty({context:t,property:r,contentType:i}){return t.isFile(r.valueType)?GN.file(xU.file({key:r.name,isOptional:!1,contentType:i,docs:r.docs})):t.isOptional(r.valueType)&&t.isFile(r.valueType.container.optional)?GN.file(xU.file({key:r.name,isOptional:!0,contentType:i,docs:r.docs})):t.isList(r.valueType)&&t.isFile(r.valueType.container.list)?GN.file(xU.fileArray({key:r.name,isOptional:!1,contentType:i,docs:r.docs})):t.isList(r.valueType)&&t.isOptional(r.valueType.container.list)&&t.isFile(r.valueType.container.list.container.optional)?GN.file(xU.fileArray({key:r.name,isOptional:!1,contentType:i,docs:r.docs})):t.isOptional(r.valueType)&&t.isList(r.valueType.container.optional)&&t.isFile(r.valueType.container.optional.container.list)?GN.file(xU.fileArray({key:r.name,isOptional:!0,contentType:i,docs:r.docs})):GN.bodyProperty({...r,contentType:i,style:void 0,name:r.name})}};var WRo=class extends Oy{responseBody;group;method;statusCode;constructor({breadcrumbs:t,responseBody:r,group:i,method:n,statusCode:a}){super({breadcrumbs:t}),this.responseBody=r,this.group=i,this.method=n,this.statusCode=a}async convert({context:t,errorCollector:r}){if(!this.responseBody.content)return;let i=Object.keys(this.responseBody.content).filter(n=>n.includes("json"));for(let n of[...i]){let a=this.responseBody.content[n];if(a==null||a.schema==null)continue;let u=[...this.group,this.method,"Response",this.statusCode].join("_"),d=await new cX({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:a.schema,schemaIdOverride:u}).convert({context:t,errorCollector:r});if(d==null)continue;let s=a.examples!=null?Object.fromEntries(await Promise.all(Object.entries(a.examples).map(async([o,c])=>[o,t.isReferenceObject(c)?await t.resolveReference(c):c]))):void 0;if(n.includes("json"))return{responseBody:cT.json(sSe.response({responseBodyType:d.type,docs:this.responseBody.description})),inlinedTypes:d.inlinedTypes,examples:s}}}};var $KD=/{([^}]+)}/g,IDn=class extends Oy{operation;method;path;inlinedTypes={};constructor({breadcrumbs:t,operation:r,method:i,path:n}){super({breadcrumbs:t}),this.operation=r,this.method=i,this.path=n}convertHttpMethod(){switch(this.method){case"get":return o7.Get;case"post":return o7.Post;case"put":return o7.Put;case"delete":return o7.Delete;case"patch":return o7.Patch;default:return}}async convertParameters({context:t,errorCollector:r,breadcrumbs:i}){let n=[],a=[],u=[];if(!this.operation.parameters)return{pathParameters:n,queryParameters:a,headers:u};for(let s of this.operation.parameters){if(t.isReferenceObject(s)){let b=await t.resolveReference(s);if(b.resolved)s=b.value;else continue}let c=await new Nya({breadcrumbs:i,parameter:s}).convert({context:t,errorCollector:r});if(c!=null)switch(this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes},c.type){case"path":n.push(c.parameter);break;case"query":a.push(c.parameter);break;case"header":u.push(c.parameter);break}}let d=[...this.path.matchAll($KD)].map(s=>s[1]).filter(s=>!n.some(o=>o.name.originalName===s));for(let s of d)s!=null&&n.push({name:t.casingsGenerator.generateName(s),valueType:Nya.STRING,docs:void 0,location:"ENDPOINT",variable:void 0});return{pathParameters:n,queryParameters:a,headers:u}}async convertRequestBody({context:t,errorCollector:r,breadcrumbs:i,group:n,method:a}){if(this.operation.requestBody==null)return;let u;if(t.isReferenceObject(this.operation.requestBody)){let s=await t.resolveReference(this.operation.requestBody);s.resolved&&(u=s.value)}else u=this.operation.requestBody;if(u==null)return null;let d=await new VRo({breadcrumbs:i,requestBody:u,group:n??[],method:a}).convert({context:t,errorCollector:r});if(d!=null)return this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},{value:d.requestBody,examples:d.examples}}async convertResponseBody({context:t,errorCollector:r,breadcrumbs:i,group:n,method:a}){if(this.operation.responses!=null)for(let[u,l]of Object.entries(this.operation.responses)){let d=parseInt(u);if(isNaN(d)||d<200||d>=300)continue;let s;if(t.isReferenceObject(l)){let b=await t.resolveReference(l);b.resolved&&(s=b.value)}else s=l;if(s==null)continue;let c=await new WRo({breadcrumbs:[...i,u],responseBody:s,group:n??[],method:a,statusCode:u}).convert({context:t,errorCollector:r});if(c!=null)return this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes},{value:{statusCode:d,body:c.responseBody},examples:c.examples}}}computeGroupNameAndLocationFromExtensions({context:t,errorCollector:r}){let n=new zRo({breadcrumbs:this.breadcrumbs,operation:this.operation}).convert({context:t,errorCollector:r})?.methodName,u=new IRo({breadcrumbs:this.breadcrumbs,operation:this.operation}).convert({context:t,errorCollector:r})?.groups??[];if(n!=null)return{group:u,method:n}}computeGroupNameFromTagAndOperationId({context:t,errorCollector:r}){let i=this.operation.tags?.[0],n=this.operation.operationId;if(n==null){let l=this.operation.summary!=null?Dg(this.operation.summary):Dg(`${this.method}_${this.path.split("/").join("_")}`);return i!=null?{group:[i],method:l}:{method:l}}if(i==null)return{method:n};let a=zKp(i),u=zKp(n);return F1e(a,u)?{method:i}:this.computeGroupAndMethodFromTokens({tag:i,tagTokens:a,operationId:n,operationIdTokens:u})}computeGroupAndMethodFromTokens({tag:t,tagTokens:r,operationId:i,operationIdTokens:n}){if(r.some((l,d)=>l!==n[d]))return{group:[t],method:i};let u=n.slice(r.length);return{group:[t],method:Dg(u.join("_"))}}};function zKp(e){let t=GKD(e)?QKD(e):JKD(e);return t=t.map(r=>r.toLowerCase()),t=vBe(t),t}function GKD(e){return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)}function QKD(e){return e.split(/(?=[A-Z])/)}function JKD(e){return e.split(/[^a-zA-Z0-9]+/)}var HRo=class extends IDn{idempotent;constructor({breadcrumbs:t,operation:r,method:i,path:n,idempotent:a}){super({breadcrumbs:t,operation:r,method:i,path:n}),this.idempotent=a}async convert({context:t,errorCollector:r}){let i=this.convertHttpMethod();if(i==null)return;let{group:n,method:a}=this.computeGroupNameAndLocationFromExtensions({context:t,errorCollector:r})??this.computeGroupNameFromTagAndOperationId({context:t,errorCollector:r}),{headers:u,pathParameters:l,queryParameters:d}=await this.convertParameters({context:t,errorCollector:r,breadcrumbs:[...this.breadcrumbs,"parameters"]}),s=await this.convertRequestBody({context:t,errorCollector:r,breadcrumbs:[...this.breadcrumbs,"requestBody"],group:n,method:a}),o=s?.value,c=await this.convertResponseBody({context:t,errorCollector:r,breadcrumbs:[...this.breadcrumbs,"responses"],group:n,method:a});return{group:n,endpoint:{id:`${n?.join(".")??""}.${a}`,displayName:this.operation.summary,method:i,name:t.casingsGenerator.generateName(a),baseUrl:void 0,path:SV(this.path),pathParameters:l,queryParameters:d,headers:u,requestBody:o,sdkRequest:void 0,response:c?.value,errors:[],auth:this.operation.security!=null||t.spec.security!=null,availability:await t.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.operation.description,userSpecifiedExamples:[],autogeneratedExamples:[],idempotent:this.idempotent??!1,basePath:void 0,fullPath:SV(this.path),allPathParameters:l,pagination:void 0,transport:void 0},inlinedTypes:this.inlinedTypes}}convertExamples({requestExamples:t,responseExamples:r,context:i}){return[]}};var $Ro=class extends IDn{constructor({breadcrumbs:t,operation:r,method:i,path:n}){super({breadcrumbs:t,operation:r,method:i,path:n})}async convert({context:t,errorCollector:r}){if(this.operation.operationId==null){r.collect({message:"Skipping webhook because no operation id present",path:this.breadcrumbs});return}if(this.operation.requestBody==null){r.collect({message:"Skipping webhook because no request body present",path:this.breadcrumbs});return}let i=this.convertHttpMethod();if(i==null)return;if(i!=="POST"&&i!=="GET"){r.collect({message:"Skipping webhook because non-POST or GET method",path:this.breadcrumbs});return}let{group:n,method:a}=this.computeGroupNameAndLocationFromExtensions({context:t,errorCollector:r})??this.computeGroupNameFromTagAndOperationId({context:t,errorCollector:r}),u=[...this.breadcrumbs,"Payload"],{headers:l,pathParameters:d,queryParameters:s}=await this.convertParameters({context:t,errorCollector:r,breadcrumbs:u}),o=await this.convertRequestBody({context:t,errorCollector:r,breadcrumbs:u,group:n,method:a}),c;if(o?.value.type==="inlinedRequestBody")c=RU.inlinedPayload({name:o.value.name,extends:o.value.extends,properties:o.value.properties});else if(o?.value.type==="reference")c=RU.reference({payloadType:o.value.requestBodyType,docs:o.value.docs});else return;return{group:n,webhook:{id:`${n?.join(".")??""}.${a}`,name:t.casingsGenerator.generateName(a),displayName:this.operation.summary,method:i,headers:l,payload:c,examples:[],availability:await t.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.operation.description},inlinedTypes:this.inlinedTypes}}};var GRo=class extends Oy{pathItem;path;constructor({breadcrumbs:t,pathItem:r,path:i}){super({breadcrumbs:t}),this.pathItem=r,this.path=i}async convert({context:t,errorCollector:r}){let i=[],n=[],a={};for(let u of IKp){let l=this.pathItem[u];if(l==null)continue;let d=[...this.breadcrumbs,u],s=await this.tryParseAsWebhook({operationBreadcrumbs:d,operation:l,method:u,context:t,errorCollector:r});if(s!=null){n.push(s),Object.assign(a,s.inlinedTypes);continue}new BRo({breadcrumbs:d,operation:l}).convert({context:t,errorCollector:r})!=null;let b=await this.tryParseAsHttpEndpoint({operationBreadcrumbs:d,operation:l,method:u,context:t,errorCollector:r});b!=null&&(i.push(b),Object.assign(a,b.inlinedTypes))}return{endpoints:i,webhooks:n,inlinedTypes:a}}async tryParseAsWebhook({operation:t,method:r,operationBreadcrumbs:i,context:n,errorCollector:a}){return new xRo({breadcrumbs:i,operation:t}).convert({context:n,errorCollector:a})?await new $Ro({breadcrumbs:i,operation:t,method:pJs.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path}).convert({context:n,errorCollector:a}):void 0}async tryParseAsHttpEndpoint({operation:t,method:r,operationBreadcrumbs:i,context:n,errorCollector:a}){new CRo({breadcrumbs:i,operation:t,document:n.spec}).convert({context:n,errorCollector:a})!=null;let s=new qRo({breadcrumbs:i,operation:t}).convert({context:n,errorCollector:a});return await new HRo({breadcrumbs:i,operation:t,method:pJs.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path,idempotent:s}).convert({context:n,errorCollector:a})}};var QRo=class extends Oy{securityScheme;constructor({breadcrumbs:t,securityScheme:r}){super({breadcrumbs:t}),this.securityScheme=r}convert({context:t,errorCollector:r}){switch(this.securityScheme.type){case"http":{if(this.securityScheme.scheme==="bearer")return DR.bearer({token:t.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description});if(this.securityScheme.scheme==="basic")return DR.basic({username:t.casingsGenerator.generateName("username"),password:t.casingsGenerator.generateName("password"),usernameEnvVar:void 0,passwordEnvVar:void 0,docs:this.securityScheme.description});break}case"apiKey":{if(this.securityScheme.in==="header")return DR.header({name:{name:t.casingsGenerator.generateName(this.securityScheme.name),wireValue:this.securityScheme.name},valueType:pd.container(Ev.optional(pd.primitive({v1:"STRING",v2:Z_.string({default:void 0,validation:void 0})}))),prefix:void 0,headerEnvVar:void 0,docs:this.securityScheme.description});break}case"oauth2":return DR.bearer({token:t.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description})}}};var Fya=class extends sz{server;key="x-fern-server-name";constructor({breadcrumbs:t,server:r}){super({breadcrumbs:t}),this.server=r}convert({context:t,errorCollector:r}){let i=this.getExtensionValue(this.server);if(!(i==null||typeof i!="string"))return i}};var JRo=class extends Oy{servers;constructor({breadcrumbs:t,servers:r}){super({breadcrumbs:t}),this.servers=r}convert({context:t,errorCollector:r}){if(this.servers==null||this.servers.length===0||this.servers[0]==null)return;let i;return this.servers.some(a=>new Fya({breadcrumbs:this.breadcrumbs,server:a}).convert({context:t,errorCollector:r})!=null)?i=this.servers.map(a=>{let l=new Fya({breadcrumbs:this.breadcrumbs,server:a}).convert({context:t,errorCollector:r});if(l!=null)return{id:l,name:t.casingsGenerator.generateName(l),url:this.getServerUrl(a),docs:a.description}}).filter(Qb):i=[{id:"default",name:t.casingsGenerator.generateName("Default"),url:this.getServerUrl(this.servers[0]),docs:this.servers[0].description}],{defaultEnvironment:i[0]?.id,environments:BU.singleBaseUrl({environments:i})}}getServerUrl(t){if(t.variables==null)return t.url;let r=t.url;for(let[i,n]of Object.entries(t.variables))n.default!=null&&(r=r.replace(`{${i}}`,n.default));return r}};var Lya=class extends Oy{ir;constructor({breadcrumbs:t,context:r}){super({breadcrumbs:t}),this.ir={auth:{docs:void 0,requirement:uc.AuthSchemesRequirement.All,schemes:[]},types:{},services:{},errors:{},webhookGroups:{},websocketChannels:void 0,headers:[],idempotencyHeaders:[],apiVersion:void 0,apiDisplayName:void 0,apiDocs:void 0,basePath:void 0,pathParameters:[],errorDiscriminationStrategy:uc.ErrorDiscriminationStrategy.statusCode(),variables:[],serviceTypeReferenceInfo:{sharedTypes:[],typesReferencedOnlyByService:{}},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,environments:void 0,fdrApiDefinitionId:void 0,rootPackage:r.createPackage(),subpackages:{},sdkConfig:{hasFileDownloadEndpoints:!1,hasPaginatedEndpoints:!1,hasStreamingEndpoints:!1,isAuthMandatory:!0,platformHeaders:{language:"",sdkName:"",sdkVersion:"",userAgent:void 0}}}}async convert({context:t,errorCollector:r}){t.spec=this.removeXFernIgnores({document:t.spec,context:t,errorCollector:r}),this.convertServers({context:t,errorCollector:r}),await this.convertSecuritySchemes({context:t,errorCollector:r}),await this.convertSchemas({context:t,errorCollector:r}),await this.convertPaths({context:t,errorCollector:r});let i={...this.ir,apiName:t.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:t.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}};return i={...i,...mNi({ir:i,exampleGeneration:{disabled:!1}})},i}removeXFernIgnores({document:t,context:r,errorCollector:i,breadcrumbs:n=[]}){return Array.isArray(t)?t.filter((a,u)=>!new AG.FernIgnoreExtension({breadcrumbs:[...n,String(u)],operation:a}).convert({context:r,errorCollector:i})).map((a,u)=>this.removeXFernIgnores({document:a,context:r,errorCollector:i,breadcrumbs:[...n,String(u)]})):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([a,u])=>!new AG.FernIgnoreExtension({breadcrumbs:[...n,a],operation:u}).convert({context:r,errorCollector:i})).map(([a,u])=>[a,this.removeXFernIgnores({document:u,context:r,errorCollector:i,breadcrumbs:[...n,a]})])):t}async convertSecuritySchemes({context:t,errorCollector:r}){let i=[];for(let[n,a]of Object.entries(t.spec.components?.securitySchemes??{})){let u;if(t.isReferenceObject(a)){let s=await t.resolveReference(a);if(!s.resolved)continue;u=s.value}else u=a;let d=new QRo({breadcrumbs:["components","securitySchemes",n],securityScheme:u}).convert({context:t,errorCollector:r});d!=null&&i.push(d)}i.length>0&&(this.ir.auth={requirement:"ANY",schemes:i,docs:void 0})}convertServers({context:t,errorCollector:r}){let n=new JRo({breadcrumbs:["servers"],servers:t.spec.servers}).convert({context:t,errorCollector:r});n!=null&&(this.ir.environments=n)}async convertSchemas({context:t,errorCollector:r}){for(let[i,n]of Object.entries(t.spec.components?.schemas??{})){let u=await new Dpi({id:i,breadcrumbs:["components","schemas",i],schema:n}).convert({context:t,errorCollector:r});u!=null&&(this.ir.rootPackage.types.push(i),this.ir.types={...this.ir.types,...u.inlinedTypes,[i]:u.typeDeclaration})}}async convertPaths({context:t,errorCollector:r}){let i={};for(let[n,a]of Object.entries(t.spec.paths??{})){if(a==null)continue;let l=await new GRo({breadcrumbs:["paths",n],pathItem:a,path:n}).convert({context:t,errorCollector:r});if(l!=null){for(let d of l.endpoints){let s=d.group?.join(".")??"";i[s]==null&&(i[s]=[]),i[s].push(d.endpoint)}for(let d of l.webhooks){let s=d.group?.join(".")??"";this.ir.webhookGroups[s]==null&&(this.ir.webhookGroups[s]=[]),this.ir.webhookGroups[s].push(d.webhook)}this.ir.types={...this.ir.types,...l.inlinedTypes}}}this.addServicesToIr({groupToEndpoints:i,context:t}),this.addWebhookGroupsToIr({webhookGroups:this.ir.webhookGroups,context:t})}addServicesToIr({groupToEndpoints:t,context:r}){for(let[i,n]of Object.entries(t)){let a=i.split(".").map(l=>r.casingsGenerator.generateName(l)),u=a[a.length-1]??r.casingsGenerator.generateName("");this.ir.services[i]={name:{fernFilepath:{allParts:a,packagePath:a.slice(0,-1),file:u}},displayName:void 0,basePath:SV(""),headers:[],pathParameters:[],availability:void 0,endpoints:n,transport:void 0,encoding:void 0},i!==""?(this.ir.subpackages[i]==null&&(this.ir.subpackages[i]={name:r.casingsGenerator.generateName(i),...r.createPackage({name:i})}),this.ir.subpackages[i].service=i,this.ir.rootPackage.subpackages.push(i)):this.ir.rootPackage.service=i}}addWebhookGroupsToIr({webhookGroups:t,context:r}){for(let[i,n]of Object.entries(t))this.ir.webhookGroups[i]=n,i!==""?(this.ir.subpackages[i]==null&&(this.ir.subpackages[i]={name:r.casingsGenerator.generateName(i),...r.createPackage({name:i})}),this.ir.subpackages[i].webhooks=i,this.ir.rootPackage.subpackages.push(i)):this.ir.rootPackage.webhooks=i}};var Uya=class extends PNi{isReferenceObject(t){return t!=null&&"$ref"in t}getTypeIdFromSchemaReference(t){let r=t.$ref.match(/\/schemas\/(.+)$/);if(!(!r||!r[1]))return r[1]}async convertReferenceToTypeReference(t){let r=this.getTypeIdFromSchemaReference(t);return r==null?{ok:!1}:(await this.resolveReference(t)).resolved?{ok:!0,reference:pd.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r),typeId:r,default:void 0,inline:!1})}:{ok:!1}}async getPropertyAccess(t){let r=t;for(;this.isReferenceObject(r);){let i=await this.resolveReference(r);if(!i.resolved)return;r=i.value}if(!(r.readOnly&&r.writeOnly)){if(r.readOnly)return lSe.ReadOnly;if(r.writeOnly)return lSe.WriteOnly}}async getAvailability({node:t,breadcrumbs:r,errorCollector:i}){for(;this.isReferenceObject(t);){let u=await this.resolveReference(t);if(!u.resolved)return;t=u.value}let a=await new AG.FernAvailabilityExtension({node:t,breadcrumbs:r}).convert({context:this,errorCollector:i});if(a!=null)return{status:a,message:void 0};if(t.deprecated===!0)return{status:a7.Deprecated,message:void 0}}};var KRo=class e extends Oy{static LIST_UNKNOWN=pd.container(Ev.list(pd.unknown()));schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){if(this.schema.items==null)return{typeReference:e.LIST_UNKNOWN};let n=await new H5t({breadcrumbs:[...this.breadcrumbs,"items"],schemaOrReference:this.schema.items}).convert({context:t,errorCollector:r});return n!=null?{typeReference:pd.container(Ev.list(n.type)),inlinedTypes:n.inlinedTypes}:{typeReference:e.LIST_UNKNOWN}}};var YRo=class extends Oy{schema;maybeFernEnum;constructor({breadcrumbs:t,schema:r,maybeFernEnum:i}){super({breadcrumbs:t}),this.schema=r,this.maybeFernEnum=i}convert({context:t,errorCollector:r}){if(!this.schema.enum)return;let n=this.schema.enum.filter(u=>typeof u=="string").map(u=>{let l=this.maybeFernEnum?.[u],d=l?.name??u.toString();return{name:t.casingsGenerator.generateNameAndWireValue({name:d,wireValue:u.toString()}),docs:l?.description,availability:void 0,casing:l?.casing}});if(n.length===0)return;let a=t.getAsString(this.schema.default);return{enum:a0.enum({default:a!=null?n.find(u=>u.name.wireValue===a):void 0,values:n})}}};var XRo=class extends Oy{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){if(!this.schema.properties&&!this.schema.allOf)return{object:a0.object({properties:[],extends:[],extendedProperties:[],extraProperties:this.schema.additionalProperties!=null})};let i=[],n={};for(let[u,l]of Object.entries(this.schema.properties??{})){let d=[...this.breadcrumbs,"properties",u],s="nullable"in l?l.nullable:!1,o=t.convertBreadcrumbsToName(d),b=await new H5t({breadcrumbs:d,schemaOrReference:l,schemaIdOverride:o,wrapAsOptional:!this.schema.required?.includes(u),wrapAsNullable:s}).convert({context:t,errorCollector:r});b!=null&&(i.push({name:t.casingsGenerator.generateNameAndWireValue({name:u,wireValue:u}),valueType:b.type,docs:l.description,availability:b.availability,propertyAccess:await t.getPropertyAccess(l)}),n={...n,...b.inlinedTypes})}let a=[];for(let[u,l]of(this.schema.allOf??[]).entries()){let d=[...this.breadcrumbs,"allOf",u.toString()];if(t.isReferenceObject(l)){let s=await t.convertReferenceToTypeReference(l);s.ok&&a.push(s.reference);continue}for(let[s,o]of Object.entries(l.properties??{})){let c=[...d,s],b=t.convertBreadcrumbsToName(c),O=await new H5t({breadcrumbs:c,schemaOrReference:o,schemaIdOverride:b,wrapAsOptional:!l.required?.includes(s),wrapAsNullable:"nullable"in o?o.nullable:!1}).convert({context:t,errorCollector:r});O!=null&&(i.push({name:t.casingsGenerator.generateNameAndWireValue({name:s,wireValue:s}),valueType:O.type,docs:o.description,availability:O.availability,propertyAccess:await t.getPropertyAccess(o)}),n={...n,...O.inlinedTypes})}}return{object:a0.object({properties:i,extends:a.map(u=>t.typeReferenceToDeclaredTypeName(u)).filter(Qb),extendedProperties:[],extraProperties:this.schema.additionalProperties!=null}),inlinedTypes:n}}};var ZRo=class extends Oy{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}async convert({context:t,errorCollector:r}){return this.schema.discriminator!=null?await this.convertAsDiscriminatedUnion({context:t,errorCollector:r}):this.convertAsUndiscriminatedUnion({context:t,errorCollector:r})}async convertAsDiscriminatedUnion({context:t,errorCollector:r}){let i=[],n={};if(this.schema.discriminator!=null){for(let[a,u]of Object.entries(this.schema.discriminator.mapping??{})){let l=new H5t({schemaOrReference:{$ref:u},breadcrumbs:[...this.breadcrumbs,"discriminator","mapping",a]}),d=t.getTypeIdFromSchemaReference({$ref:u}),s=await l.convert({context:t,errorCollector:r});if(s?.type!=null&&d!=null){let o=t.casingsGenerator.generateNameAndWireValue({name:a,wireValue:a});i.push({docs:void 0,discriminantValue:o,availability:s.availability,displayName:void 0,shape:Z8.samePropertiesAsObject({typeId:d,name:t.casingsGenerator.generateName(d),fernFilepath:{allParts:[],packagePath:[],file:void 0}})}),n={...n,...s.inlinedTypes}}}return{union:a0.union({baseProperties:[],discriminant:t.casingsGenerator.generateNameAndWireValue({name:this.schema.discriminator.propertyName,wireValue:this.schema.discriminator.propertyName}),extends:[],types:i}),inlinedTypes:n}}}async convertAsUndiscriminatedUnion({context:t,errorCollector:r}){if(!this.schema.oneOf||this.schema.oneOf.length===0)return;let i=[],n={};for(let[a,u]of this.schema.oneOf.entries()){let l=[...this.breadcrumbs,"oneOf",jNi(a)??""];if(t.isReferenceObject(u)){let c=await t.convertReferenceToTypeReference(u);c.ok&&i.push({type:c.reference,docs:u.description});continue}let d=t.convertBreadcrumbsToName(l),o=await new Rze({id:d,breadcrumbs:l,schema:u}).convert({context:t,errorCollector:r});o!=null&&(i.push({type:t.createNamedTypeReference(d),docs:u.description}),n={...n,...o.inlinedTypes,[d]:o.typeDeclaration})}return{union:a0.undiscriminatedUnion({members:i}),inlinedTypes:n}}};var kRo=class extends Oy{schema;constructor({breadcrumbs:t,schema:r}){super({breadcrumbs:t}),this.schema=r}convert({context:t,errorCollector:r}){switch(this.schema.type){case"string":{let i=t.getAsString(this.schema.const);return i!=null?pd.container(Ev.literal(k8.string(i))):pd.primitive({v1:"STRING",v2:Z_.string({default:t.getAsString(this.schema.default),validation:this.getStringValidation(this.schema)})})}case"number":case"integer":switch(this.schema.format){case"double":case void 0:return pd.primitive({v1:"DOUBLE",v2:Z_.double({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return pd.primitive({v1:"FLOAT",v2:Z_.float({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return pd.primitive({v1:"INTEGER",v2:Z_.integer({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return pd.primitive({v1:"LONG",v2:Z_.long({default:t.getAsNumber(this.schema.default)})});case"uint32":return pd.primitive({v1:"UINT",v2:Z_.uint({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return pd.primitive({v1:"UINT_64",v2:Z_.uint64({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return pd.primitive({v1:"INTEGER",v2:Z_.integer({default:t.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"boolean":{let i=t.getAsBoolean(this.schema.const);return i!=null?pd.container(Ev.literal(k8.boolean(i))):pd.primitive({v1:"BOOLEAN",v2:Z_.boolean({default:this.schema.default})})}default:return}}getNumberValidation(t){return{max:t.maximum,min:t.minimum,exclusiveMax:typeof t.exclusiveMaximum=="boolean"?t.exclusiveMaximum:void 0,exclusiveMin:typeof t.exclusiveMinimum=="boolean"?t.exclusiveMinimum:void 0,multipleOf:t.multipleOf}}getStringValidation(t){return{minLength:t.minLength,maxLength:t.maxLength,pattern:t.pattern,format:t.format}}};var Rze=class extends Oy{schema;id;inlined;constructor({breadcrumbs:t,schema:r,id:i,inlined:n=!1}){super({breadcrumbs:t}),this.schema=r,this.id=i,this.inlined=n}async convert({context:t,errorCollector:r}){if(this.schema.enum?.length){let u=new AG.FernEnumExtension({breadcrumbs:this.breadcrumbs,schema:this.schema}).convert({context:t,errorCollector:r}),d=new YRo({breadcrumbs:this.breadcrumbs,schema:this.schema,maybeFernEnum:u}).convert({context:t,errorCollector:r});if(d!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:d.enum,context:t,errorCollector:r}),inlinedTypes:{}}}let n=new kRo({schema:this.schema}).convert({context:t,errorCollector:r});if(n!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:a0.alias({aliasOf:n,resolvedType:n}),context:t,errorCollector:r}),inlinedTypes:{}};if(this.schema.type==="array"){let u=await new KRo({breadcrumbs:this.breadcrumbs,schema:this.schema}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:a0.alias({aliasOf:u.typeReference,resolvedType:u.typeReference}),context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}if(this.schema.oneOf!=null){let u=await new ZRo({breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:u.union,context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}if(this.schema.type==="object"||this.schema.properties!=null||this.schema.allOf!=null){let u=await new XRo({breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert({context:t,errorCollector:r});if(u!=null)return{typeDeclaration:await this.createTypeDeclaration({shape:u.object,context:t,errorCollector:r}),inlinedTypes:u.inlinedTypes??{}}}}async createTypeDeclaration({shape:t,context:r,errorCollector:i}){return{name:this.convertDeclaredTypeName({context:r}),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:await r.getAvailability({node:this.schema,breadcrumbs:this.breadcrumbs,errorCollector:i}),docs:this.schema.description,referencedTypes:new Set,source:void 0,inline:this.inlined}}convertDeclaredTypeName({context:t}){return{typeId:this.id,fernFilepath:{allParts:[],packagePath:[],file:void 0},name:t.casingsGenerator.generateName(this.id)}}};var H5t=class extends Oy{schemaOrReference;schemaIdOverride;wrapAsOptional;wrapAsNullable;constructor({breadcrumbs:t,schemaOrReference:r,schemaIdOverride:i,wrapAsOptional:n=!1,wrapAsNullable:a=!1}){super({breadcrumbs:t}),this.schemaOrReference=r,this.schemaIdOverride=i,this.wrapAsOptional=n,this.wrapAsNullable=a}async convert({context:t,errorCollector:r}){if(t.isReferenceObject(this.schemaOrReference)){let l=await t.convertReferenceToTypeReference(this.schemaOrReference);return l.ok?{type:l.reference,inlinedTypes:{}}:void 0}let i=this.schemaIdOverride??t.convertBreadcrumbsToName(this.breadcrumbs),n=new Rze({breadcrumbs:this.breadcrumbs,schema:this.schemaOrReference,id:i}),a=await t.getAvailability({node:this.schemaOrReference,breadcrumbs:this.breadcrumbs,errorCollector:r}),u=await n.convert({context:t,errorCollector:r});if(u!=null){if(u.typeDeclaration.shape.type==="alias"){let d=u.typeDeclaration.shape.aliasOf;return{type:this.wrapTypeReference(d),inlinedTypes:u.inlinedTypes,availability:a}}let l=t.createNamedTypeReference(i);return{type:this.wrapTypeReference(l),schema:u.typeDeclaration,inlinedTypes:{...u.inlinedTypes,[i]:u.typeDeclaration},availability:a}}}wrapTypeReference(t){return this.wrapAsOptional&&this.wrapAsNullable?this.wrapInOptional(this.wrapInNullable(t)):this.wrapAsOptional?this.wrapInOptional(t):this.wrapAsNullable?this.wrapInNullable(t):t}wrapInOptional(t){return pd.container(Ev.optional(t))}wrapInNullable(t){return pd.container(Ev.nullable(t))}};var Epi=class e extends Oy{static STRING=pd.primitive({v1:"STRING",v2:Z_.string({default:void 0,validation:void 0})});static OPTIONAL_STRING=pd.container(Ev.optional(e.STRING));parameter;constructor({breadcrumbs:t,parameter:r}){super({breadcrumbs:t}),this.parameter=r}async convert({context:t,errorCollector:r}){let i,n={};if(this.parameter.schema!=null){let l=await new H5t({breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required}).convert({context:t,errorCollector:r});l!=null&&(i=l.type,n=l.inlinedTypes??{})}let a=await t.getAvailability({node:this.parameter,breadcrumbs:this.breadcrumbs,errorCollector:r});switch(this.parameter.in){case"query":return{type:"query",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??(this.parameter.required?e.STRING:e.OPTIONAL_STRING),allowMultiple:this.parameter.explode??!1,availability:a},inlinedTypes:n};case"header":return{type:"header",parameter:{name:t.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:i??(this.parameter.required?e.STRING:e.OPTIONAL_STRING),env:void 0,availability:a},inlinedTypes:n};case"path":return{type:"path",parameter:{name:t.casingsGenerator.generateName(this.parameter.name),docs:this.parameter.description,valueType:i??(this.parameter.required?e.STRING:e.OPTIONAL_STRING),location:"ENDPOINT",variable:void 0},inlinedTypes:n};default:r.collect({message:`Unsupported parameter location: ${this.parameter.in}`,path:this.breadcrumbs});return}}};var eNo=class extends Oy{channel;channelPath;inlinedTypes={};constructor({breadcrumbs:t,channel:r,channelPath:i}){super({breadcrumbs:t}),this.channel=r,this.channelPath=i}async convert({context:t,errorCollector:r}){let i=[],n=[],a=[];this.channel.parameters&&await this.convertQueryParameters({context:t,errorCollector:r,queryParameters:n}),this.channel.bindings?.ws!=null&&(await this.convertHeaders({context:t,errorCollector:r,headers:a}),await this.convertBindingQueryParameters({context:t,errorCollector:r,queryParameters:n}));let u;this.channel.subscribe!=null&&(u=await this.convertMessage({context:t,errorCollector:r,origin:"server",operation:this.channel.subscribe,defaultId:"subscribeEvent",breadcrumbName:"subscribeEvent"}));let l;this.channel.publish!=null&&(l=await this.convertMessage({context:t,errorCollector:r,origin:"client",operation:this.channel.publish,defaultId:"publishEvent",breadcrumbName:"publishEvent"}));let d=[];return u!=null&&d.push(u),l!=null&&d.push(l),{channel:{name:t.casingsGenerator.generateName(this.channelPath),displayName:this.channelPath,baseUrl:this.channel.servers?.[0],path:{head:this.channel.address??this.channelPath,parts:[]},auth:!1,headers:a,queryParameters:n,pathParameters:i,messages:d,examples:[],availability:await t.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.channel.description},inlinedTypes:this.inlinedTypes}}async convertMessage({context:t,errorCollector:r,origin:i,operation:n,defaultId:a,breadcrumbName:u}){let l;if("$ref"in n.message){let d=await t.resolveReference(n.message);d.resolved&&(n.message=d.value)}if("oneOf"in n.message)l=await new Rze({id:n.operationId??a,breadcrumbs:[...this.breadcrumbs,u],schema:n.message}).convert({context:t,errorCollector:r});else if("payload"in n.message){let d;if(t.isReferenceObject(n.message.payload)){let s=await t.resolveReference(n.message.payload);s.resolved&&(d=s.value)}else d=n.message.payload;d!=null&&(l=await new Rze({id:n.operationId??a,breadcrumbs:[...this.breadcrumbs,u],schema:d}).convert({context:t,errorCollector:r}))}if(l!=null){this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes,[l.typeDeclaration.name.typeId]:l.typeDeclaration};let d=l.typeDeclaration,s=uc.TypeReference.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:d.name.name,typeId:d.name.typeId,default:void 0,inline:!1}),o=uc.WebSocketMessageBody.reference({bodyType:s,docs:n.description});return{type:d.name.typeId,displayName:d.name.name.originalName,origin:i,body:o,availability:await t.getAvailability({node:n,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:n.description}}}async convertQueryParameters({context:t,errorCollector:r,queryParameters:i}){for(let[n,a]of Object.entries(this.channel.parameters??{})){let u=a;if(t.isReferenceObject(a)){let s=await t.resolveReference(a);if(s.resolved)u=s.value;else continue}let d=await new Epi({breadcrumbs:this.breadcrumbs,parameter:{...u,name:n,in:"query",description:a.description,required:a.required??!1}}).convert({context:t,errorCollector:r});d!=null&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},d.type==="query"&&i.push(d.parameter))}}async convertHeaders({context:t,errorCollector:r,headers:i}){if(this.channel.bindings?.ws?.headers!=null){let n=this.channel.bindings.ws.headers.required??[];for(let[a,u]of Object.entries(this.channel.bindings.ws.headers.properties??{})){let l=u;if(t.isReferenceObject(u)){let o=await t.resolveReference(u);if(!o.resolved)continue;l=o.value}let s=await new Epi({breadcrumbs:[...this.breadcrumbs,a],parameter:{name:a,in:"header",required:n.includes(a),schema:l,description:"description"in l?l.description:void 0}}).convert({context:t,errorCollector:r});s!=null&&s.type==="header"&&(this.inlinedTypes={...this.inlinedTypes,...s.inlinedTypes},i.push(s.parameter))}}}async convertBindingQueryParameters({context:t,errorCollector:r,queryParameters:i}){if(this.channel.bindings?.ws?.query!=null){let n=this.channel.bindings.ws.query.required??[];for(let[a,u]of Object.entries(this.channel.bindings.ws.query.properties??{})){let l=u;if(t.isReferenceObject(u)){let o=await t.resolveReference(u);if(!o.resolved)continue;l=o.value}let s=await new Epi({breadcrumbs:[...this.breadcrumbs,a],parameter:{name:a,in:"query",required:n.includes(a),schema:l,description:"description"in l?l.description:void 0}}).convert({context:t,errorCollector:r});s!=null&&s.type==="query"&&(this.inlinedTypes={...this.inlinedTypes,...s.inlinedTypes},i.push(s.parameter))}}}};var tNo=class extends Oy{servers;constructor({breadcrumbs:t,servers:r}){super({breadcrumbs:t}),this.servers=r}convert({context:t,errorCollector:r}){if(this.servers==null||Object.keys(this.servers).length===0)return;let n=Object.entries(this.servers)[0]?.[1];if(n==null)return;let a=[{id:"default",name:t.casingsGenerator.generateName("Default"),url:this.constructServerUrl(n.protocol,n.url),docs:void 0}];return{defaultEnvironment:a[0]?.id,environments:BU.singleBaseUrl({environments:a})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var _Js="$message.",RKp="#/channels/",NKp="#/servers/",rNo=class extends Oy{channel;channelPath;operations;inlinedTypes={};constructor({breadcrumbs:t,channel:r,channelPath:i,operations:n}){super({breadcrumbs:t}),this.channel=r,this.channelPath=i,this.operations=n}async convert({context:t,errorCollector:r}){let i=[],n=[],a=[];this.channel.parameters&&await this.convertChannelParameters({context:t,errorCollector:r,pathParameters:i,queryParameters:n,headers:a});let u=Object.entries(this.operations).reduce((d,[s,o])=>{try{this.getChannelPathFromOperation(o)===this.channelPath&&(d[s]=o)}catch{}return d},{}),l=[];for(let[d,s]of Object.entries(u))for(let o of s.messages){let c=await t.convertReferenceToTypeReference(o);if(c.ok){let b=uc.WebSocketMessageBody.reference({bodyType:c.reference,docs:s.description});l.push({type:d,displayName:d,origin:s.action==="send"?"client":"server",body:b,availability:await t.getAvailability({node:s,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:s.description})}}return{channel:{name:t.casingsGenerator.generateName(this.channelPath),displayName:this.channelPath,baseUrl:this.resolveChannelServersFromReference(this.channel.servers??[],r),path:{head:this.channel.address??this.channelPath,parts:[]},auth:!1,headers:a,queryParameters:n,pathParameters:i,messages:l,examples:[],availability:await t.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs,errorCollector:r}),docs:this.channel.description},inlinedTypes:this.inlinedTypes}}async convertChannelParameters({context:t,errorCollector:r,pathParameters:i,queryParameters:n,headers:a}){for(let u of Object.values(this.channel.parameters??{})){let l=u;if(t.isReferenceObject(u)){let g=await t.resolveReference(u);if(g.resolved)l=g.value;else continue}let d=this.convertChannelParameterLocation(u.location,r);if(d==null)continue;let{type:s,parameterKey:o}=d,b=await new Epi({breadcrumbs:this.breadcrumbs,parameter:{...l,name:o,in:s,required:!0}}).convert({context:t,errorCollector:r});if(b!=null)switch(this.inlinedTypes={...this.inlinedTypes,...b.inlinedTypes},b.type){case"path":i.push(b.parameter);break;case"query":n.push(b.parameter);break;case"header":a.push(b.parameter);break}}}convertChannelParameterLocation(t,r){try{let[i,n]=t.split("#/");if(i==null||n==null){r.collect({message:`Invalid location format: ${t}; unable to parse message type and parameter key`,path:this.breadcrumbs});return}if(!i.startsWith(_Js)){r.collect({message:`Invalid location format: ${t}; expected ${_Js} prefix`,path:this.breadcrumbs});return}let a=i.substring(_Js.length);if(a!=="header"&&a!=="path"&&a!=="payload"){r.collect({message:`Invalid message type: ${a}. Must be one of: header, path, payload`,path:this.breadcrumbs});return}return a==="payload"?{type:"query",parameterKey:n}:{type:a,parameterKey:n}}catch{r.collect({message:`Invalid location format: ${t}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`,path:this.breadcrumbs});return}}resolveChannelServersFromReference(t,r){if(t==null||t.length===0||t[0]==null)return;let i=t[0];if(!i.$ref.startsWith(NKp)){r.collect({message:`Failed to resolve server name from server ref ${i.$ref}`,path:this.breadcrumbs});return}let n=i.$ref.substring(NKp.length);if(n==null){r.collect({message:`Failed to find server with name ${n}`,path:this.breadcrumbs});return}return n}getChannelPathFromOperation(t){if(!t.channel.$ref.startsWith(RKp))throw new Error(`Failed to resolve channel path from operation ${t.channel.$ref}`);return t.channel.$ref.substring(RKp.length)}};var iNo=class extends Oy{servers;constructor({breadcrumbs:t,servers:r}){super({breadcrumbs:t}),this.servers=r}convert({context:t,errorCollector:r}){if(this.servers==null||Object.keys(this.servers).length===0)return;let n=Object.entries(this.servers)[0]?.[1];if(n==null)return;let a=[{id:"default",name:t.casingsGenerator.generateName("Default"),url:this.constructServerUrl(n.protocol,n.host),docs:void 0}];return{defaultEnvironment:a[0]?.id,environments:BU.singleBaseUrl({environments:a})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var Vya=class extends Oy{ir;constructor({breadcrumbs:t,context:r}){super({breadcrumbs:t}),this.ir={auth:{docs:void 0,requirement:uc.AuthSchemesRequirement.All,schemes:[]},types:{},services:{},errors:{},webhookGroups:{},websocketChannels:void 0,headers:[],idempotencyHeaders:[],apiVersion:void 0,apiDisplayName:void 0,apiDocs:void 0,basePath:void 0,pathParameters:[],errorDiscriminationStrategy:uc.ErrorDiscriminationStrategy.statusCode(),variables:[],serviceTypeReferenceInfo:{sharedTypes:[],typesReferencedOnlyByService:{}},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,environments:void 0,fdrApiDefinitionId:void 0,rootPackage:r.createPackage(),subpackages:{},sdkConfig:{hasFileDownloadEndpoints:!1,hasPaginatedEndpoints:!1,hasStreamingEndpoints:!1,isAuthMandatory:!0,platformHeaders:{language:"",sdkName:"",sdkVersion:"",userAgent:void 0}}}}async convert({context:t,errorCollector:r}){t.spec=this.removeXFernIgnores({document:t.spec,context:t,errorCollector:r}),this.isAsyncAPIV3(t)&&(t.spec=this.deduplicateChannelMessages({document:t.spec,context:t,errorCollector:r}),await this.convertChannelMessages({context:t,errorCollector:r})),await this.convertSchemas({context:t,errorCollector:r}),await this.convertServers({context:t,errorCollector:r}),await this.convertChannels({context:t,errorCollector:r});let i={...this.ir,apiName:t.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:t.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}};return i={...i,...mNi({ir:i,exampleGeneration:{disabled:!1}})},i}isAsyncAPIV3(t){return parseFloat(t.spec.asyncapi)>=3}removeXFernIgnores({document:t,context:r,errorCollector:i,breadcrumbs:n=[]}){return Array.isArray(t)?t.filter((a,u)=>!new AG.FernIgnoreExtension({breadcrumbs:[...n,String(u)],operation:a}).convert({context:r,errorCollector:i})).map((a,u)=>this.removeXFernIgnores({document:a,context:r,errorCollector:i,breadcrumbs:[...n,String(u)]})):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([a,u])=>!new AG.FernIgnoreExtension({breadcrumbs:[...n,a],operation:u}).convert({context:r,errorCollector:i})).map(([a,u])=>[a,this.removeXFernIgnores({document:u,context:r,errorCollector:i,breadcrumbs:[...n,a]})])):t}deduplicateChannelMessages({document:t,context:r,errorCollector:i}){let n={};for(let[u,l]of Object.entries(t.channels??{}))for(let[d,s]of Object.entries(l.messages??{}))n[d]||(n[d]=[]),n[d].push({channelPath:u,message:s});let a={...t};a.channels={...t.channels};for(let[u,l]of Object.entries(n))if(l.length!==1)for(let{channelPath:d,message:s}of l){let o=a.channels[d];if(o==null||o.messages==null)continue;let c=`${d}_${u}`,b={...o.messages,[c]:s},{[u]:g,...O}=b;o.messages=O}return a}async convertChannelMessages({context:t,errorCollector:r}){let i=t.spec;for(let[n,a]of Object.entries(i.channels??{}))for(let[u,l]of Object.entries(a.messages??{})){if(l.payload==null)continue;let d;if(t.isReferenceObject(l.payload)){let c=await t.resolveReference(l.payload);c.resolved&&(d=c.value)}else d=l.payload;if(d==null)continue;let o=await new Rze({id:u,breadcrumbs:["channels",n,"messages",u],schema:d}).convert({context:t,errorCollector:r});o!=null&&(this.ir.rootPackage.types.push(u),this.ir.types={...this.ir.types,...o.inlinedTypes,[u]:o.typeDeclaration})}}async convertSchemas({context:t,errorCollector:r}){for(let[i,n]of Object.entries(t.spec.components?.schemas??{})){let u=await new Rze({id:i,breadcrumbs:["components","schemas",i],schema:n}).convert({context:t,errorCollector:r});u!=null&&(this.ir.rootPackage.types.push(i),this.ir.types={...this.ir.types,...u.inlinedTypes,[i]:u.typeDeclaration})}}async convertServers({context:t,errorCollector:r}){if(this.isAsyncAPIV3(t)){let i=t.spec.servers,a=new iNo({breadcrumbs:["servers"],servers:i}).convert({context:t,errorCollector:r});a!=null&&(this.ir.environments=a)}else{let i=t.spec.servers,a=new tNo({breadcrumbs:["servers"],servers:i}).convert({context:t,errorCollector:r});a!=null&&(this.ir.environments=a)}}async convertChannels({context:t,errorCollector:r}){for(let[i,n]of Object.entries(t.spec.channels??{}))if(this.isAsyncAPIV3(t)){let u=t.spec.operations??{},d=await new rNo({breadcrumbs:["channels",i],channel:n,channelPath:i,operations:u}).convert({context:t,errorCollector:r});d!=null&&(this.ir.websocketChannels={...this.ir.websocketChannels,[i]:d.channel},this.ir.types={...this.ir.types,...d.inlinedTypes})}else{let u=await new eNo({breadcrumbs:["channels",i],channel:n,channelPath:i}).convert({context:t,errorCollector:r});u!=null&&(this.ir.websocketChannels={...this.ir.websocketChannels,[i]:u.channel},this.ir.types={...this.ir.types,...u.inlinedTypes})}this.addWebsocketsToIr({websocketChannels:this.ir.websocketChannels,context:t})}addWebsocketsToIr({websocketChannels:t,context:r}){if(t!=null)for(let[i,n]of Object.entries(t))i!==""?(this.ir.subpackages[i]==null&&(this.ir.subpackages[i]={name:r.casingsGenerator.generateName(i),...r.createPackage({name:i})}),this.ir.subpackages[i].websocket=i,this.ir.rootPackage.subpackages.push(i)):this.ir.rootPackage.websocket=i}};var Wya=class extends PNi{isReferenceObject(t){return t!=null&&"$ref"in t}getTypeIdFromSchemaReference(t){let r=t.$ref.match(/\/schemas\/(.+)$/);if(!(!r||!r[1]))return r[1]}getTypeIdFromMessageReference(t){let r=t.$ref.match(/\/messages\/(.+)$/);if(!(!r||!r[1]))return r[1]}async convertReferenceToTypeReference(t){let r;return t.$ref.includes("schemas")?r=this.getTypeIdFromSchemaReference(t):t.$ref.includes("messages")&&(r=this.getTypeIdFromMessageReference(t)),r==null?{ok:!1}:(await this.resolveReference(t)).resolved?{ok:!0,reference:pd.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r),typeId:r,default:void 0,inline:!1})}:{ok:!1}}async getPropertyAccess(t){let r=t;for(;this.isReferenceObject(r);){let i=await this.resolveReference(r);if(!i.resolved)return;r=i.value}if(!(r.readOnly&&r.writeOnly)){if(r.readOnly)return lSe.ReadOnly;if(r.writeOnly)return lSe.WriteOnly}}async getAvailability({node:t,breadcrumbs:r,errorCollector:i}){for(;this.isReferenceObject(t);){let u=await this.resolveReference(t);if(!u.resolved)return;t=u.value}let a=await new AG.FernAvailabilityExtension({node:t,breadcrumbs:r}).convert({context:this,errorCollector:i});if(a!=null)return{status:a,message:void 0};if(t.deprecated===!0)return{status:a7.Deprecated,message:void 0}}};var B7=class extends n_a{specs;sources;loader;constructor({specs:t,...r}){super({...r,respectReadonlySchemas:t.every(i=>i.settings?.respectReadonlySchemas),respectNullableSchemas:t.every(i=>i.settings?.respectNullableSchemas),onlyIncludeReferencedSchemas:t.every(i=>i.settings?.onlyIncludeReferencedSchemas),inlinePathParameters:t.every(i=>i.settings?.inlinePathParameters),objectQueryParameters:t.every(i=>i.settings?.objectQueryParameters),exampleGeneration:t[0]?.settings?.exampleGeneration}),this.specs=t,this.sources=this.convertSpecsToIdentifiableSources(t),this.loader=new U5t(this.absoluteFilePath)}async getOpenAPIIr({context:t,relativePathToDependency:r},i){let n=await qze({context:t,specs:this.specs,relativePathToDependency:r});return YRi({context:t,documents:await this.loader.loadDocuments({context:t,specs:n}),options:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.objectQueryParameters,exampleGeneration:i?.exampleGeneration??this.exampleGeneration}})}async getIntermediateRepresentation({context:t}){let r=await qze({context:t,specs:this.specs}),i=await this.loader.loadDocuments({context:t,specs:r}),n;for(let a of i){let u=new Rya({logger:t.logger}),l;if(a.type==="openapi"){let d=new Uya({generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:a.value});l=await new Lya({context:d}).convert({context:d,errorCollector:u})}else if(a.type==="asyncapi"){let d=new Wya({generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:a.value});l=await new Vya({context:d}).convert({context:d,errorCollector:u})}else u.collect({message:`Unsupported document type: ${a}`,path:[]});u.hasErrors()&&(t.logger.info(`${a.type==="openapi"?"OpenAPI":"AsyncAPI"} Importer encountered errors:`),u.logErrors()),l!=null&&(n=n===void 0?l:lJs(n,l))}if(n===void 0)throw new Error("Failed to generate intermediate representation");return n}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new USe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion,sources:this.sources})}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.specs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(Qb)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,i=[];return t.reduce((n,a)=>{let u=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(u)||(r.add(u),n.push({type:a.type,id:fie(),absoluteFilePath:u})),n},i)}};var FKp={None:"none",Header:"header"};var DNo={};Co(DNo,{ConjureAliasDeclaration:()=>lNo,ConjureArgument:()=>jNo,ConjureArgumentWithParamType:()=>PNo,ConjureAuthDefinition:()=>FDn,ConjureAuthDefinitionType:()=>ONo,ConjureDefinitions:()=>bNo,ConjureEndpointDefinition:()=>wNo,ConjureEnumDeclaration:()=>yNo,ConjureEnumVariant:()=>hNo,ConjureEnumWithDocs:()=>_No,ConjureObjectDeclaration:()=>pNo,ConjureParamType:()=>mNo,ConjurePrimitive:()=>cNo,ConjureService:()=>SNo,ConjureServiceName:()=>sNo,ConjureType:()=>qpi,ConjureTypeDeclaration:()=>vNo,ConjureTypeReference:()=>Tpi,ConjureTypeWithDocs:()=>fNo,ConjureTypes:()=>gNo,ConjureUnionDeclaration:()=>dNo,DefinitionFile:()=>pYp,WithDocs:()=>zXt,commons:()=>gJs,conjure:()=>OJs,services:()=>mJs,types:()=>PJs});var gJs={};Co(gJs,{WithDocs:()=>zXt});var kd={};Co(kd,{JsonError:()=>zDn,ParseError:()=>RDn,any:()=>eYp,bigint:()=>UKp,boolean:()=>tYp,booleanLiteral:()=>kKp,date:()=>VKp,discriminant:()=>lYp,enum_:()=>aNo,getObjectLikeUtils:()=>$5t,getObjectUtils:()=>wNi,getSchemaUtils:()=>$A,isProperty:()=>Api,lazy:()=>WKp,lazyObject:()=>YKp,list:()=>uNo,number:()=>rYp,object:()=>oNo,objectWithoutOptionalProperties:()=>KKp,optional:()=>hJs,property:()=>$Kp,record:()=>oYp,set:()=>uYp,string:()=>iYp,stringLiteral:()=>ZKp,transform:()=>yJs,undiscriminatedUnion:()=>cYp,union:()=>dYp,unknown:()=>nYp,withParsedProperties:()=>bJs});var YP={BIGINT:"bigint",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 qM(e,t){return`Expected ${t}. Received ${KKD(e)}.`}function KKD(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function A5(e){return{...e,json:LKp(e.json),parse:LKp(e.parse)}}function LKp(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
1948
1948
  `)),{ok:!0,value:t}):i}}function nNo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var zDn=class e extends Error{errors;constructor(t){super(t.map(nNo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var RDn=class e extends Error{errors;constructor(t){super(t.map(nNo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function $A(e){return{optional:()=>hJs(e),transform:t=>yJs(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new RDn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new zDn(i.errors)}}}function hJs(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>YP.OPTIONAL};return{...t,...$A(t)}}function yJs(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...$A(r)}}function UKp(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:qM(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:qM(t,"bigint")}]},getType:()=>YP.BIGINT};return{...A5(e),...$A(e)}}var YKD=/^([+-]?\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 VKp(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:qM(t,"string")}]}:YKD.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:qM(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:qM(t,"Date object")}]},getType:()=>YP.DATE};return{...A5(e),...$A(e)}}function qG(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...A5(r),...$A(r)}}}function aNo(e){let t=new Set(e);return qG(YP.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:qM(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:qM(i,"enum")}]}:{ok:!0,value:i})()}function WKp(e){let t=vJs(e);return{...t,...$A(t)}}function vJs(e){return{parse:(t,r)=>NDn(e).parse(t,r),json:(t,r)=>NDn(e).json(t,r),getType:()=>NDn(e).getType()}}function NDn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function Hya(e){return Object.entries(e)}function $ya(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function Mpi(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 Gya(e){return Object.keys(e)}function HKp(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function $5t(e){return{withParsedProperties:t=>bJs(e,t)}}function bJs(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((l,[d,s])=>({...l,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!Mpi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:qM(i,"object")}]};let a=new Set(Object.keys(t)),u=$ya(i,Object.keys(i).filter(l=>!a.has(l)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...$A(r),...$5t(r)}}function $Kp(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function Api(e){return e.isProperty}function oNo(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>Api(i)?i.rawKey:r),_getParsedProperties:()=>Gya(e),parse:(r,i)=>{let n={},a=[];for(let[u,l]of Hya(e)){let d=Api(l)?l.rawKey:u,s=Api(l)?l.valueSchema:l,o={rawKey:d,parsedKey:u,valueSchema:s};n[d]=o,JKp(s)&&a.push(d)}return GKp({value:r,requiredKeys:a,getProperty:u=>{let l=n[u];if(l!=null)return{transformedKey:l.parsedKey,transform:d=>l.valueSchema.parse(d,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of Hya(e)){let l=Api(u)?u.valueSchema:u;JKp(l)&&n.push(a)}return GKp({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return Api(u)?{transformedKey:u.rawKey,transform:l=>u.valueSchema.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:l=>u.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>YP.OBJECT};return{...A5(t),...$A(t),...$5t(t),...wNi(t)}}function GKp({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!Mpi(e))return{ok:!1,errors:[{path:a,message:qM(e,"object")}]};let u=new Set(t),l=[],d={};for(let[s,o]of Object.entries(e)){let c=r(s);if(c!=null){u.delete(s);let b=c.transform(o);b.ok?d[c.transformedKey]=b.value:(d[s]=o,l.push(...b.errors))}else switch(i){case"fail":l.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=o;break}}return l.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),l.length===0||n?{ok:!0,value:d}:{ok:!1,errors:l}}function wNi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>QKp({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>QKp({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>YP.OBJECT};return{...r,...$A(r),...$5t(r),...wNi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>YP.OBJECT};return{...t,...$A(t),...$5t(t),...wNi(t)}}}}function QKp({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=HKp(Gya(t),s=>n.has(s)),l=r($ya(t,u)),d=i($ya(t,a));return l.ok&&d.ok?{ok:!0,value:{...l.value,...d.value}}:{ok:!1,errors:[...l.ok?[]:l.errors,...d.ok?[]:d.errors]}}function JKp(e){return!XKD(e)}function XKD(e){switch(e.getType()){case YP.ANY:case YP.UNKNOWN:case YP.OPTIONAL:return!0;default:return!1}}function KKp(e){return oNo(e)}function YKp(e){let t={...vJs(e),_getRawProperties:()=>NDn(e)._getRawProperties(),_getParsedProperties:()=>NDn(e)._getParsedProperties()};return{...t,...$A(t),...$5t(t),...wNi(t)}}function uNo(e){let t={parse:(r,i)=>XKp(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>XKp(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>YP.LIST};return{...A5(t),...$A(t)}}function XKp(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:qM(e,"list"),path:[]}]}}function ZKp(e){return qG(YP.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:qM(r,`"${e}"`)}]})()}function kKp(e){return qG(YP.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:qM(r,`${e.toString()}`)}]})()}var eYp=qG(YP.ANY,e=>({ok:!0,value:e}));var tYp=qG(YP.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:qM(e,"boolean")}]});var rYp=qG(YP.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:qM(e,"number")}]});var iYp=qG(YP.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:qM(e,"string")}]});var nYp=qG(YP.UNKNOWN,e=>({ok:!0,value:e}));function oYp(e,t){let r={parse:(i,n)=>aYp({value:i,isKeyNumeric:e.getType()===YP.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>aYp({value:i,isKeyNumeric:e.getType()===YP.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>YP.RECORD};return{...A5(r),...$A(r)}}function aYp({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return Mpi(e)?Hya(e).reduce((a,[u,l])=>{if(l==null)return a;let d=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),c=i(l,s);if(d.ok&&o.ok&&c.ok)return{ok:!0,value:{...d.value,[o.value]:c.value}};let b=[];return d.ok||b.push(...d.errors),o.ok||b.push(...o.errors),c.ok||b.push(...c.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:qM(e,"object")}]}}function uYp(e){let t=uNo(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:qM(i,"Set")}]},getType:()=>YP.SET};return{...A5(r),...$A(r)}}function cYp(e){let t={parse:(r,i)=>sYp((n,a)=>n.parse(r,a),e,i),json:(r,i)=>sYp((n,a)=>n.json(r,a),e,i),getType:()=>YP.UNDISCRIMINATED_UNION};return{...A5(t),...$A(t)}}function sYp(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let l of u.errors)i.push({path:l.path,message:`[Variant ${n}] ${l.message}`})}return{ok:!1,errors:i}}function lYp(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function dYp(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=aNo(Gya(t)),a={parse:(u,l)=>fYp({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:d=>n.parse(d,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),json:(u,l)=>fYp({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:d=>n.json(d,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),getType:()=>YP.UNION};return{...A5(a),...$A(a),...$5t(a)}}function fYp({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:l=[]}){if(!Mpi(e))return{ok:!1,errors:[{path:l,message:qM(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:l,message:`Missing discriminant ("${t}")`}]};let o=i(d);if(!o.ok)return{ok:!1,errors:o.errors};let c=n(o.value);if(c==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...l,t],message:"Unexpected discriminant value"}]};let b=u(s,c);return b.ok?{ok:!0,value:{[r]:d,...b.value}}:b}var zXt=kd.objectWithoutOptionalProperties({docs:kd.string().optional()});var OJs={};Co(OJs,{ConjureServiceName:()=>sNo,DefinitionFile:()=>pYp});var sNo=kd.string();var cNo=kd.enum_(["rid","string","safelong","integer","double","boolean"]);var qpi=kd.undiscriminatedUnion([cNo,kd.string()]);var lNo=kd.objectWithoutOptionalProperties({alias:qpi,docs:kd.string().optional()});var fNo=kd.objectWithoutOptionalProperties({type:qpi,docs:kd.string().optional()});var Tpi=kd.undiscriminatedUnion([qpi,fNo]);var dNo=kd.objectWithoutOptionalProperties({union:kd.record(kd.string(),Tpi)});var pNo=kd.objectWithoutOptionalProperties({fields:kd.record(kd.string(),Tpi)});var _No=kd.objectWithoutOptionalProperties({value:kd.string()}).extend(zXt);var hNo=kd.undiscriminatedUnion([kd.string(),_No]);var yNo=kd.objectWithoutOptionalProperties({values:kd.list(hNo)});var vNo=kd.undiscriminatedUnion([lNo,dNo,pNo,yNo]);var bNo=kd.objectWithoutOptionalProperties({objects:kd.record(kd.string(),vNo).optional()});var gNo=kd.objectWithoutOptionalProperties({conjureImports:kd.property("conjure-imports",kd.record(kd.string(),kd.string()).optional()),definitions:bNo.optional()});var ONo=kd.enum_(["none","header"]);var FDn=kd.undiscriminatedUnion([ONo,kd.string()]);var mNo=kd.enum_(["path","query","body"]);var PNo=kd.objectWithoutOptionalProperties({paramType:kd.property("param-type",mNo),type:kd.string()}).extend(zXt);var jNo=kd.undiscriminatedUnion([kd.string(),PNo]);var wNo=kd.objectWithoutOptionalProperties({http:kd.string(),auth:FDn.optional(),args:kd.record(kd.string(),jNo).optional(),returns:Tpi.optional()}).extend(zXt);var SNo=kd.objectWithoutOptionalProperties({name:kd.string().optional(),package:kd.string().optional(),basePath:kd.property("base-path",kd.string().optional()),defaultAuth:kd.property("default-auth",FDn.optional()),endpoints:kd.record(kd.string(),wNo).optional()}).extend(zXt);var pYp=kd.objectWithoutOptionalProperties({types:gNo.optional(),services:kd.record(sNo,SNo).optional()});var mJs={};Co(mJs,{ConjureArgument:()=>jNo,ConjureArgumentWithParamType:()=>PNo,ConjureAuthDefinition:()=>FDn,ConjureAuthDefinitionType:()=>ONo,ConjureEndpointDefinition:()=>wNo,ConjureParamType:()=>mNo,ConjureService:()=>SNo});var PJs={};Co(PJs,{ConjureAliasDeclaration:()=>lNo,ConjureDefinitions:()=>bNo,ConjureEnumDeclaration:()=>yNo,ConjureEnumVariant:()=>hNo,ConjureEnumWithDocs:()=>_No,ConjureObjectDeclaration:()=>pNo,ConjurePrimitive:()=>cNo,ConjureType:()=>qpi,ConjureTypeDeclaration:()=>vNo,ConjureTypeReference:()=>Tpi,ConjureTypeWithDocs:()=>fNo,ConjureTypes:()=>gNo,ConjureUnionDeclaration:()=>dNo});var _Yp=require("fs/promises");async function hYp(e,t){let r=[];for(let i of await qBe(e,t))r.push(await ZKD({relativeFilepath:aT(e,i),absoluteFilepath:i}));return r}async function ZKD({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,_Yp.readFile)(t)).toString().replaceAll(/: rid(?:$|\s)/g,`: string
1949
1949
  `).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:DNo.DefinitionFile.parseOrThrow(Kd.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}function yYp(e,t){if(kKD(e))return t.alias(e);if(eYD(e))return t.enum(e);if(tYD(e))return t.object(e);if(rYD(e))return t.union(e);Fo(e)}function kKD(e){return e?.alias!=null}function eYD(e){return e?.values!=null}function tYD(e){return e?.fields!=null}function rYD(e){return e?.union!=null}var Qya=class extends Jpa{fernDefinitionBuilder=new hRi(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:i,globalHeaderOverrides:n}){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(i!=null){for(let[a,u]of Object.entries(i.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:u});i["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(i["default-environment"]),i["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(i["default-url"])}return await vYp(t,(a,u,l)=>{for(let[o,c]of Object.entries(l.services??{})){let b=uYa({value:o,suffix:"Service"});this.conjureFilepathToFernFilepath[u]=Xa.of(`${b}/__package__.yml`);return}let s=uys(u)?.split(".")[0];s!=null&&(this.conjureFilepathToFernFilepath[u]=Xa.of(`${s}/__package__.yml`))}),await vYp(t,(a,u,l)=>{if(l.services==null||Object.keys(l.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[s,o]of Object.entries(l.types?.conjureImports??{})){let c=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Xa.of(o)});this.fernDefinitionBuilder.addImport({file:d,fileToImport:Xa.of(c),alias:s})}this.importAllTypes({conjureFile:l,fernFilePath:d});return}for(let[d,s]of Object.entries(l.services)){let o=uYa({value:d,suffix:"Service"}),c=Xa.of(`${o}/__package__.yml`),b={};s.basePath!=null&&(b["base-path"]=s.basePath),s.docs!=null&&(b.docs=s.docs),this.fernDefinitionBuilder.setServiceInfo(c,b),this.importAllTypes({conjureFile:l,fernFilePath:c});for(let[g,O]of Object.entries(l.types?.conjureImports??{})){let m=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Xa.of(O)});this.fernDefinitionBuilder.addImport({file:c,fileToImport:Xa.of(m),alias:g})}for(let[g,O]of Object.entries(s.endpoints??{})){let m=vds(O.http);if(m.type==="failure"){this.context?.logger.error(`Failed to parse ${O.http}. Skipping.`);continue}let E={auth:(O.auth??s.defaultAuth)!==FKp.None,path:m.path,method:m.method,response:O.returns==="binary"?"file":O.returns};O.docs!=null&&(E.docs=O.docs);let A={};if(O.args!=null)for(let q of m.pathParameters){let D=O.args[q];if(D==null)throw new Error(`Failed to find path parameter ${q} in ${O.http}`);A[q]=typeof D=="string"?D:{type:D.type}}Object.entries(A).length>0&&(E["path-parameters"]=A);for(let[q,D]of Object.entries(O.args??{}))if(A[q]==null)if(typeof D=="string")E.request?typeof E.request=="string"&&(E.request={body:E.request}):E.request={},E.request.body=D==="binary"?"bytes":D;else switch(D.paramType){case"body":E.request={body:D.type==="binary"?"bytes":D.type};break;case"query":E.request==null?E.request={"query-parameters":{[q]:D.type}}:typeof E.request!="string"&&E.request?.["query-parameters"]==null?E.request["query-parameters"]={[q]:D.type}:typeof E.request!="string"&&E.request?.["query-parameters"]!=null&&(E.request["query-parameters"][q]=D.type)}E.request!=null&&typeof E.request!="string"&&E.request?.["query-parameters"]!=null&&(E.request.name=`${g}Request`),this.fernDefinitionBuilder.addEndpoint(c,{name:g,schema:E,source:void 0})}}}),this.fernDefinitionBuilder.build()}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[i,n]of Object.entries(t.types?.definitions?.objects??{}))yYp(n,{alias:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{type:a.alias,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{properties:a.fields}})},enum:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{enum:a.values}})},union:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{union:Object.fromEntries(Object.entries(a.union).map(([u,l])=>[u,{type:typeof l=="string"?l:l.type,docs:typeof l=="string"?void 0:l.docs,key:u}]))}})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:i}){let n=Xu(_p(t),Xa.of(r)),a=gui(i,n),u=this.conjureFilepathToFernFilepath[a];if(u==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return u}};async function vYp(e,t){for(let r of await hYp(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}function bYp(e,t){return rd(e,t)}var ENo=class extends D5t{absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=Xu(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new USe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion,sources:void 0})}async getDefinition({context:t},r){let n=await new Qya(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:Wl.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:n.rootApiFile["default-url"],contents:n.rootApiFile,rawContents:Kd.dump(n.rootApiFile)},namedDefinitionFiles:{...bYp(n.definitionFiles,a=>({absoluteFilepath:Wl.of("/DUMMY_PATH"),rawContents:Kd.dump(a),contents:a})),[Xa.of(X1)]:{absoluteFilepath:Wl.of("/DUMMY_PATH"),rawContents:Kd.dump(n.packageMarkerFile),contents:n.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};function jJs(e,t){for(let[r,i]of CN(e.failures))iYD({relativeFilepath:r,failure:i,logger:t})}function iYD({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case aP.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 aP.FILE_READ:r.error("Failed to open file: "+e);break;case aP.FILE_MISSING:r.error("Missing file: "+e);break;case aP.FILE_PARSE:t.error instanceof gna?r.error(jie({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case aP.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of nYD(i))r.error(jie({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case aP.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case aP.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${GYa}: `+t.dependencyName);break;case aP.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case aP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case aP.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(jie({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(i=>i!=="")]}));break;default:Fo(t)}}function nYD(e){switch(e.code){case Hl.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${Js.underline(e.expected)} but received ${Js.underline(e.received)}`}];case Hl.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${Js.underline(t)}`}));case Hl.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>Js.underline(t)).join(", ")}`}];case Hl.invalid_union:case Hl.invalid_arguments:case Hl.invalid_return_type:case Hl.invalid_date:case Hl.invalid_string:case Hl.too_small:case Hl.too_big:case Hl.invalid_intersection_types:case Hl.not_multiple_of:case Hl.custom:default:return[{title:e.message}]}}var gYp=require("fs/promises");async function OYp(e,t){let r=[];for(let i of await qBe(e,t))r.push(await aYD({relativeFilepath:aT(e,i),absoluteFilepath:i}));return r}async function aYD({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,gYp.readFile)(t)).toString()}}async function mYp({absolutePathToWorkspace:e}){let t=Xu(e,Xa.of(uLf));if(!await Cf(t))return;let i=await OYp(t,"{md,mdx}");return{files:await Promise.all(i.map(n=>({absoluteFilepath:n.absoluteFilepath,contents:n.fileContents})))}}async function wJs({absolutePathToWorkspace:e,namespace:t,definitions:r}){let i=[];for(let n of r){let a=n.overrides!=null?Xu(e,Xa.of(n.overrides)):void 0;if(n.schema.type==="protobuf"){let l=Xa.of(n.schema.root),d=Xu(e,l);if(!await Cf(d))return{didSucceed:!1,failures:{[Xa.of(n.schema.root)]:{type:aP.FILE_MISSING}}};let s=Xu(e,Xa.of(n.schema.target));if(!await Cf(s))return{didSucceed:!1,failures:{[Xa.of(n.schema.target)]:{type:aP.FILE_MISSING}}};i.push({type:"protobuf",absoluteFilepathToProtobufRoot:d,absoluteFilepathToProtobufTarget:s,absoluteFilepathToOverrides:a,relativeFilepathToProtobufRoot:l,generateLocally:n.schema.localGeneration,settings:{audiences:n.audiences??[],useTitlesAsName:n.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,shouldUseIdiomaticRequestNames:n.settings?.shouldUseIdiomaticRequestNames??!1,optionalAdditionalProperties:n.settings?.shouldUseOptionalAdditionalProperties??!0,coerceEnumsToLiterals:n.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:n.settings?.objectQueryParameters??!1,respectReadonlySchemas:n.settings?.respectReadonlySchemas??!1,respectNullableSchemas:n.settings?.respectNullableSchemas??!1,onlyIncludeReferencedSchemas:n.settings?.onlyIncludeReferencedSchemas??!1,inlinePathParameters:n.settings?.inlinePathParameters??!1,disableExamples:!1,discriminatedUnionV2:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,preserveSchemaIds:!1,asyncApiNaming:n.settings?.asyncApiMessageNaming??"v1",filter:n.settings?.filter,exampleGeneration:void 0,defaultFormParameterEncoding:n.settings?.defaultFormParameterEncoding}});continue}let u=Xu(e,Xa.of(n.schema.path));if(!await Cf(u))return{didSucceed:!1,failures:{[Xa.of(n.schema.path)]:{type:aP.FILE_MISSING}}};if(n.overrides!=null&&a!=null&&!await Cf(a))return{didSucceed:!1,failures:{[Xa.of(n.overrides)]:{type:aP.FILE_MISSING}}};i.push({type:"openapi",absoluteFilepath:u,absoluteFilepathToOverrides:a,settings:{audiences:n.audiences??[],useTitlesAsName:n.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,shouldUseIdiomaticRequestNames:n.settings?.shouldUseIdiomaticRequestNames??!1,optionalAdditionalProperties:n.settings?.shouldUseOptionalAdditionalProperties??!0,coerceEnumsToLiterals:n.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:n.settings?.objectQueryParameters??!1,respectReadonlySchemas:n.settings?.respectReadonlySchemas??!1,respectNullableSchemas:n.settings?.respectNullableSchemas??!1,onlyIncludeReferencedSchemas:n.settings?.onlyIncludeReferencedSchemas??!1,inlinePathParameters:n.settings?.inlinePathParameters??!1,disableExamples:!1,discriminatedUnionV2:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,preserveSchemaIds:!1,asyncApiNaming:n.settings?.asyncApiMessageNaming??"v1",filter:n.settings?.filter,exampleGeneration:n.settings?.exampleGeneration,defaultFormParameterEncoding:n.settings?.defaultFormParameterEncoding},source:{type:"openapi",file:u},namespace:t})}return i}async function Jya({absolutePathToWorkspace:e,context:t,cliVersion:r,workspaceName:i}){let n=await v8t({absolutePathToWorkspace:e,context:t}),a;try{a=await mYp({absolutePathToWorkspace:e})}catch{}if(n?.api!=null&&n?.api.type==="conjure")return{didSucceed:!0,workspace:new ENo({workspaceName:i,absoluteFilePath:e,generatorsConfiguration:n,changelog:a,cliVersion:r,context:t,relativePathToConjureDirectory:Xa.of(n.api.pathToConjureDefinition)})};if(n?.api!=null&&(n.api.type==="singleNamespace"&&n.api.definitions.length>0||n.api.type==="multiNamespace")){let u=[];if(n.api.type==="singleNamespace"){let l=await wJs({absolutePathToWorkspace:e,namespace:void 0,definitions:n.api.definitions});if(!Array.isArray(l))return l;u.push(...l)}else{for(let[l,d]of Object.entries(n.api.definitions)){let s=await wJs({absolutePathToWorkspace:e,namespace:l,definitions:d});if(!Array.isArray(s))return s;u.push(...s)}if(n.api.rootDefinitions!=null){let l=await wJs({absolutePathToWorkspace:e,namespace:void 0,definitions:n.api.rootDefinitions});if(!Array.isArray(l))return l;u.push(...l)}}return{didSucceed:!0,workspace:new B7({specs:u,workspaceName:i,absoluteFilePath:e,generatorsConfiguration:n,changelog:a,cliVersion:r})}}return await Cf(Xu(e,Xa.of(R8)))?{didSucceed:!0,workspace:new wpi({absoluteFilePath:e,generatorsConfiguration:n,workspaceName:i,changelog:a,context:t,cliVersion:r,loadAPIWorkspace:Jya})}:{didSucceed:!1,failures:{[Xa.of(QTi)]:{type:aP.MISCONFIGURED_DIRECTORY}}}}var PYp=require("fs/promises");var SJs={};Co(SJs,{additionalProperties:()=>cYD,default:()=>fYD,definitions:()=>lYD,properties:()=>uYD,required:()=>sYD,type:()=>oYD});var oYD="object",uYD={instances:{type:"array",items:{$ref:"#/definitions/docs.DocsInstance"}},title:{oneOf:[{type:"string"},{type:"null"}]},analytics:{oneOf:[{$ref:"#/definitions/docs.AnalyticsConfig"},{type:"null"}]},announcement:{oneOf:[{$ref:"#/definitions/docs.AnnouncementConfig"},{type:"null"}]},roles:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.RoleId"}},{type:"null"}]},tabs:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/docs.TabConfig"}},{type:"null"}]},versions:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.VersionConfig"}},{type:"null"}]},"landing-page":{oneOf:[{$ref:"#/definitions/docs.PageConfiguration"},{type:"null"}]},navigation:{oneOf:[{$ref:"#/definitions/docs.NavigationConfig"},{type:"null"}]},"navbar-links":{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.NavbarLink"}},{type:"null"}]},"footer-links":{oneOf:[{$ref:"#/definitions/docs.FooterLinksConfig"},{type:"null"}]},experimental:{oneOf:[{$ref:"#/definitions/docs.ExperimentalConfig"},{type:"null"}]},"default-language":{oneOf:[{$ref:"#/definitions/docs.ProgrammingLanguage"},{type:"null"}]},metadata:{oneOf:[{$ref:"#/definitions/docs.MetadataConfig"},{type:"null"}]},redirects:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.RedirectConfig"}},{type:"null"}]},logo:{oneOf:[{$ref:"#/definitions/docs.LogoConfiguration"},{type:"null"}]},favicon:{oneOf:[{type:"string"},{type:"null"}]},"background-image":{oneOf:[{$ref:"#/definitions/docs.BackgroundImageConfiguration"},{type:"null"}]},colors:{oneOf:[{$ref:"#/definitions/docs.ColorsConfiguration"},{type:"null"}]},typography:{oneOf:[{$ref:"#/definitions/docs.DocsTypographyConfig"},{type:"null"}]},layout:{oneOf:[{$ref:"#/definitions/docs.LayoutConfig"},{type:"null"}]},integrations:{oneOf:[{$ref:"#/definitions/docs.IntegrationsConfig"},{type:"null"}]},css:{oneOf:[{$ref:"#/definitions/docs.CssConfig"},{type:"null"}]},js:{oneOf:[{$ref:"#/definitions/docs.JsConfig"},{type:"null"}]}},sYD=["instances"],cYD=!1,lYD={"docs.CustomDomain":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"docs.GithubEditThisPageConfig":{type:"object",properties:{host:{oneOf:[{type:"string"},{type:"null"}]},owner:{type:"string"},repo:{type:"string"},branch:{oneOf:[{type:"string"},{type:"null"}]}},required:["owner","repo"],additionalProperties:!1},"docs.EditThisPageConfig":{type:"object",properties:{github:{oneOf:[{$ref:"#/definitions/docs.GithubEditThisPageConfig"},{type:"null"}]}},additionalProperties:!1},"docs.DocsInstance":{type:"object",properties:{url:{type:"string"},"custom-domain":{oneOf:[{$ref:"#/definitions/docs.CustomDomain"},{type:"null"}]},private:{oneOf:[{type:"boolean"},{type:"null"}]},"edit-this-page":{oneOf:[{$ref:"#/definitions/docs.EditThisPageConfig"},{type:"null"}]}},required:["url"],additionalProperties:!1},"docs.SegmentConfig":{type:"object",properties:{"write-key":{type:"string"}},required:["write-key"],additionalProperties:!1},"docs.FullStoryAnalyticsConfig":{type:"object",properties:{"org-id":{type:"string"}},required:["org-id"],additionalProperties:!1},"docs.IntercomConfig":{type:"object",properties:{"app-id":{type:"string"},"api-base":{oneOf:[{type:"string"},{type:"null"}]}},required:["app-id"],additionalProperties:!1},"docs.PostHogConfig":{type:"object",properties:{"api-key":{type:"string"},endpoint:{oneOf:[{type:"string"},{type:"null"}]}},required:["api-key"],additionalProperties:!1},"docs.GTMConfig":{type:"object",properties:{"container-id":{type:"string"}},required:["container-id"],additionalProperties:!1},"docs.GoogleAnalytics4Config":{type:"object",properties:{"measurement-id":{type:"string"}},required:["measurement-id"],additionalProperties:!1},"docs.AnalyticsConfig":{type:"object",properties:{segment:{oneOf:[{$ref:"#/definitions/docs.SegmentConfig"},{type:"null"}]},fullstory:{oneOf:[{$ref:"#/definitions/docs.FullStoryAnalyticsConfig"},{type:"null"}]},intercom:{oneOf:[{$ref:"#/definitions/docs.IntercomConfig"},{type:"null"}]},posthog:{oneOf:[{$ref:"#/definitions/docs.PostHogConfig"},{type:"null"}]},gtm:{oneOf:[{$ref:"#/definitions/docs.GTMConfig"},{type:"null"}]},ga4:{oneOf:[{$ref:"#/definitions/docs.GoogleAnalytics4Config"},{type:"null"}]}},additionalProperties:!1},"docs.AnnouncementConfig":{type:"object",properties:{message:{type:"string"}},required:["message"],additionalProperties:!1},"docs.RoleId":{type:"string"},"docs.Role":{anyOf:[{$ref:"#/definitions/docs.RoleId"},{type:"array",items:{$ref:"#/definitions/docs.RoleId"}}]},"docs.FeatureFlag":{type:"object",properties:{flag:{type:"string"},"fallback-value":{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},match:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]}},required:["flag"],additionalProperties:!1},"docs.FeatureFlagConfiguration":{anyOf:[{type:"string",description:"The name of the feature flag, We assume that it is a boolean feature flag that needs to be evaluated to true."},{$ref:"#/definitions/docs.FeatureFlag",description:"A single feature flag with a configurable name, fallback value, and match value. Especially useful for non boolean feature flags."},{type:"array",items:{$ref:"#/definitions/docs.FeatureFlag"},description:"A list of feature flags. If any of the feature flags are satisfied, we will show all content."}]},"docs.ChangelogFolderRelativePath":{type:"string"},"docs.TabConfig":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},"display-name":{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},changelog:{oneOf:[{$ref:"#/definitions/docs.ChangelogFolderRelativePath"},{type:"null"}]}},required:["display-name"],additionalProperties:!1},"docs.VersionAvailability":{type:"string",enum:["deprecated","ga","stable","beta"]},"docs.VersionConfig":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},"display-name":{type:"string"},path:{type:"string"},slug:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.VersionAvailability"},{type:"null"}]}},required:["display-name","path"],additionalProperties:!1},"docs.PageConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},page:{type:"string"},path:{type:"string"},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},noindex:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["page","path"],additionalProperties:!1},"docs.SectionConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},section:{type:"string"},path:{oneOf:[{type:"string"},{type:"null"}]},contents:{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["section","contents"],additionalProperties:!1},"docs.AudienceId":{type:"string"},"docs.VersionedSnippetLanguageConfiguration":{type:"object",properties:{version:{type:"string"},package:{type:"string"}},required:["version","package"],additionalProperties:!1},"docs.SnippetLanguageConfiguration":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.VersionedSnippetLanguageConfiguration"}]},"docs.SnippetsConfiguration":{type:"object",properties:{python:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},typescript:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},go:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},java:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},ruby:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},csharp:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]}},additionalProperties:!1},"docs.PlaygroundButtonSettings":{type:"object",properties:{href:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.PlaygroundSettings":{type:"object",properties:{environments:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},button:{oneOf:[{$ref:"#/definitions/docs.PlaygroundButtonSettings"},{type:"null"}]},oauth:{oneOf:[{type:"boolean"},{type:"null"}]},"limit-websocket-messages-per-connection":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"docs.ApiReferencePackageConfigurationWithOptions":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},title:{oneOf:[{type:"string"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},contents:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},additionalProperties:!1},"docs.ApiReferencePackageConfiguration":{anyOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{$ref:"#/definitions/docs.ApiReferencePackageConfigurationWithOptions"}]},"docs.ApiReferenceSectionConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},section:{type:"string"},"referenced-packages":{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},contents:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["section"],additionalProperties:!1},"docs.ApiReferenceEndpointConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},endpoint:{type:"string"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"docs.LinkConfiguration":{type:"object",properties:{link:{type:"string"},href:{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]}},required:["link","href"],additionalProperties:!1},"docs.ApiReferenceLayoutItem":{anyOf:[{type:"string",description:"This should be either an endpoint, websocket, webhook, or subpackage ID"},{type:"object",additionalProperties:{$ref:"#/definitions/docs.ApiReferencePackageConfiguration"},description:"Keyed by subpackage name, this object allows you to group endpoints and pages together."},{$ref:"#/definitions/docs.ApiReferenceSectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceEndpointConfiguration"},{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"}]},"docs.ApiReferenceConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},api:{type:"string"},"api-name":{oneOf:[{type:"string"},{type:"null"}]},openrpc:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.AudienceId"}},{type:"null"}]},"display-errors":{oneOf:[{type:"boolean"},{type:"null"}]},snippets:{oneOf:[{$ref:"#/definitions/docs.SnippetsConfiguration"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},alphabetized:{oneOf:[{type:"boolean"},{type:"null"}]},flattened:{oneOf:[{type:"boolean"},{type:"null"}]},paginated:{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["api"],additionalProperties:!1},"docs.ChangelogConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},changelog:{$ref:"#/definitions/docs.ChangelogFolderRelativePath"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["changelog"],additionalProperties:!1},"docs.NavigationItem":{anyOf:[{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.SectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"},{$ref:"#/definitions/docs.ChangelogConfiguration"}]},"docs.UntabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},"docs.TabId":{type:"string"},"docs.TabbedNavigationItem":{type:"object",properties:{tab:{$ref:"#/definitions/docs.TabId"},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},{type:"null"}]}},required:["tab"],additionalProperties:!1},"docs.TabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.TabbedNavigationItem"}},"docs.NavigationConfig":{anyOf:[{$ref:"#/definitions/docs.UntabbedNavigationConfig"},{$ref:"#/definitions/docs.TabbedNavigationConfig"}]},"docs.NavbarGithubConfig":{type:"string"},"docs.NavbarLink":{type:"object",properties:{type:{type:"string",enum:["filled","outlined","minimal","github","primary","secondary"]}},required:["type"],oneOf:[{properties:{type:{const:"filled"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]},{properties:{type:{const:"outlined"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]},{properties:{type:{const:"minimal"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]},{properties:{type:{const:"github"},value:{$ref:"#/definitions/docs.NavbarGithubConfig"}},required:["type"]},{properties:{type:{const:"primary"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]},{properties:{type:{const:"secondary"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]}]},"docs.FooterLinksConfig":{type:"object",properties:{github:{oneOf:[{type:"string"},{type:"null"}]},twitter:{oneOf:[{type:"string"},{type:"null"}]},x:{oneOf:[{type:"string"},{type:"null"}]},linkedin:{oneOf:[{type:"string"},{type:"null"}]},youtube:{oneOf:[{type:"string"},{type:"null"}]},instagram:{oneOf:[{type:"string"},{type:"null"}]},facebook:{oneOf:[{type:"string"},{type:"null"}]},discord:{oneOf:[{type:"string"},{type:"null"}]},slack:{oneOf:[{type:"string"},{type:"null"}]},hackernews:{oneOf:[{type:"string"},{type:"null"}]},medium:{oneOf:[{type:"string"},{type:"null"}]},website:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.ExperimentalConfig":{type:"object",properties:{"mdx-components":{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"disable-stream-toggle":{oneOf:[{type:"boolean"},{type:"null"}]},"openapi-parser-v2":{oneOf:[{type:"boolean"},{type:"null"}]},"openapi-parser-v3":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"docs.ProgrammingLanguage":{type:"string",enum:["typescript","javascript","python","java","go","ruby","csharp","nodets","nodejs","dotnet","curl","jvm","ts","js"]},"docs.TwitterCardSetting":{type:"string",enum:["summary","summary_large_image","app","player"]},"docs.MetadataConfig":{type:"object",properties:{"og:site_name":{oneOf:[{type:"string"},{type:"null"}]},"og:title":{oneOf:[{type:"string"},{type:"null"}]},"og:description":{oneOf:[{type:"string"},{type:"null"}]},"og:url":{oneOf:[{type:"string"},{type:"null"}]},"og:image":{oneOf:[{type:"string"},{type:"null"}]},"og:image:width":{oneOf:[{type:"number"},{type:"null"}]},"og:image:height":{oneOf:[{type:"number"},{type:"null"}]},"og:locale":{oneOf:[{type:"string"},{type:"null"}]},"og:logo":{oneOf:[{type:"string"},{type:"null"}]},"twitter:title":{oneOf:[{type:"string"},{type:"null"}]},"twitter:description":{oneOf:[{type:"string"},{type:"null"}]},"twitter:handle":{oneOf:[{type:"string"},{type:"null"}]},"twitter:image":{oneOf:[{type:"string"},{type:"null"}]},"twitter:site":{oneOf:[{type:"string"},{type:"null"}]},"twitter:url":{oneOf:[{type:"string"},{type:"null"}]},"twitter:card":{oneOf:[{$ref:"#/definitions/docs.TwitterCardSetting"},{type:"null"}]}},additionalProperties:!1},"docs.RedirectConfig":{type:"object",properties:{source:{type:"string"},destination:{type:"string"},permanent:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["source","destination"],additionalProperties:!1},"docs.LogoConfiguration":{type:"object",properties:{dark:{oneOf:[{type:"string"},{type:"null"}]},light:{oneOf:[{type:"string"},{type:"null"}]},height:{oneOf:[{type:"number"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.BackgroundImageThemedConfig":{type:"object",properties:{dark:{oneOf:[{type:"string"},{type:"null"}]},light:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.BackgroundImageConfiguration":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.BackgroundImageThemedConfig"}]},"docs.ColorThemedConfig":{type:"object",properties:{dark:{oneOf:[{type:"string"},{type:"null"}]},light:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.ColorConfig":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.ColorThemedConfig"}]},"docs.ColorsConfiguration":{type:"object",properties:{"accent-primary":{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},accentPrimary:{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},background:{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},border:{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},"sidebar-background":{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},"header-background":{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},"card-background":{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]}},additionalProperties:!1},"docs.FontWeight":{anyOf:[{type:"string"},{type:"integer"}]},"docs.FontStyle":{type:"string",enum:["normal","italic"]},"docs.FontConfigVariant":{type:"object",properties:{path:{type:"string"},weight:{oneOf:[{$ref:"#/definitions/docs.FontWeight"},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/docs.FontStyle"},{type:"null"}]}},required:["path"],additionalProperties:!1},"docs.FontConfigPath":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.FontConfigVariant"}]},"docs.FontDisplay":{type:"string",enum:["auto","block","swap","fallback","optional"]},"docs.FontConfig":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},path:{oneOf:[{type:"string"},{type:"null"}]},weight:{oneOf:[{$ref:"#/definitions/docs.FontWeight"},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/docs.FontStyle"},{type:"null"}]},paths:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.FontConfigPath"}},{type:"null"}]},display:{oneOf:[{$ref:"#/definitions/docs.FontDisplay"},{type:"null"}]},fallback:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"font-variation-settings":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.DocsTypographyConfig":{type:"object",properties:{headingsFont:{oneOf:[{$ref:"#/definitions/docs.FontConfig"},{type:"null"}]},bodyFont:{oneOf:[{$ref:"#/definitions/docs.FontConfig"},{type:"null"}]},codeFont:{oneOf:[{$ref:"#/definitions/docs.FontConfig"},{type:"null"}]}},additionalProperties:!1},"docs.SearchbarPlacement":{type:"string",enum:["header","header-tabs","sidebar"]},"docs.TabsPlacement":{type:"string",enum:["header","sidebar"]},"docs.ContentAlignment":{type:"string",enum:["center","left"]},"docs.HeaderPosition":{type:"string",enum:["fixed","static"]},"docs.LayoutConfig":{type:"object",properties:{"page-width":{oneOf:[{type:"string"},{type:"null"}]},"content-width":{oneOf:[{type:"string"},{type:"null"}]},"sidebar-width":{oneOf:[{type:"string"},{type:"null"}]},"header-height":{oneOf:[{type:"string"},{type:"null"}]},"searchbar-placement":{oneOf:[{$ref:"#/definitions/docs.SearchbarPlacement"},{type:"null"}]},"tabs-placement":{oneOf:[{$ref:"#/definitions/docs.TabsPlacement"},{type:"null"}]},"content-alignment":{oneOf:[{$ref:"#/definitions/docs.ContentAlignment"},{type:"null"}]},"header-position":{oneOf:[{$ref:"#/definitions/docs.HeaderPosition"},{type:"null"}]},"disable-header":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"docs.IntegrationsConfig":{type:"object",properties:{intercom:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.CssConfig":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"docs.JsScriptStrategy":{type:"string",enum:["beforeInteractive","afterInteractive","lazyOnload"]},"docs.JsRemoteConfig":{type:"object",properties:{url:{type:"string"},strategy:{oneOf:[{$ref:"#/definitions/docs.JsScriptStrategy"},{type:"null"}]}},required:["url"],additionalProperties:!1},"docs.JsFileConfigSettings":{type:"object",properties:{path:{type:"string"},strategy:{oneOf:[{$ref:"#/definitions/docs.JsScriptStrategy"},{type:"null"}]}},required:["path"],additionalProperties:!1},"docs.JsFileConfig":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.JsFileConfigSettings"}]},"docs.JsConfigOptions":{anyOf:[{$ref:"#/definitions/docs.JsRemoteConfig"},{$ref:"#/definitions/docs.JsFileConfig"}]},"docs.JsConfig":{anyOf:[{$ref:"#/definitions/docs.JsConfigOptions"},{type:"array",items:{$ref:"#/definitions/docs.JsConfigOptions"}}]}},fYD={type:oYD,properties:uYD,required:sYD,additionalProperties:cYD,definitions:lYD};async function DJs({fernDirectory:e,context:t}){let r=Xu(e,Xa.of(B4t));if(!await Cf(r))return;let i=await dYD({absolutePathToDocsDefinition:e,context:t});if(i!=null)return{type:"docs",absoluteFilePath:e,config:i,workspaceName:void 0,absoluteFilepathToDocsConfig:Xu(e,Xa.of(B4t))}}async function dYD({absolutePathToDocsDefinition:e,context:t}){if(!await Cf(e))return;let r=Xu(e,Xa.of(B4t));return await pYD({absolutePathOfConfiguration:r,context:t})}async function pYD({absolutePathOfConfiguration:e,context:t}){let r=await(0,PYp.readFile)(e),i=Kd.load(r.toString()),n=DGr(i,SJs);if(n.success)return z4t.RawSchemas.Serializer.DocsConfiguration.parseOrThrow(i);throw new Error(`Failed to parse docs.yml because of ${n.error?.message??"Unknown error"}`)}async function EJs({context:e,nameOverride:t,...r}){let i=await H4t(t);return i==null?e.failAndThrow(`Directory "${t??hU}" not found.`):await wYp({absolutePathToFernDirectory:i,context:e,nameOverride:t,...r})}async function wYp({absolutePathToFernDirectory:e,cliName:t,cliVersion:r,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:n,context:a}){let u=[];return(await Cf(Xu(e,Xa.of(Xoi)))||await Cf(Xu(e,Xa.of(R8)))||await Cf(Xu(e,Xa.of(xN)))||await Cf(Xu(e,Xa.of(QTi)))||await Cf(Xu(e,Xa.of(sLf))))&&(u=await SYp({cliName:t,fernDirectory:e,cliVersion:r,context:a,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:n})),{config:await nQr({directory:e,context:a}),apiWorkspaces:u,docsWorkspaces:await DJs({fernDirectory:e,context:a}),loadAPIWorkspace:l=>l==null?u[0]:u.find(d=>d.workspaceName===l)}}async function SYp({cliName:e,fernDirectory:t,context:r,cliVersion:i,commandLineApiWorkspace:n,defaultToAllApiWorkspaces:a}){let u=Xu(t,Xa.of(Xoi));if(await Cf(u)){let o=(await(0,jYp.readdir)(u,{withFileTypes:!0})).reduce((g,O)=>(O.isDirectory()&&g.push(O.name),g),[]);if(n!=null){if(!o.includes(n))return r.failAndThrow("API does not exist: "+n)}else{if(o.length===0)return r.failAndThrow("No APIs found.");if(o.length>1&&!a){let g=`There are multiple workspaces. You must specify one with --api:
1950
1950
  `,O=Math.max(...o.map(m=>m.length));return g+=o.map(m=>{let w=`${e} ${process.argv.slice(2).join(" ")} --api ${m}`;return` \u203A ${Js.bold(m.padEnd(O))} ${Js.dim(w)}`}).join(`