fern-api 0.42.0 → 0.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle.cjs +3 -3
- package/package.json +1 -1
package/bundle.cjs
CHANGED
|
@@ -1784,7 +1784,7 @@ ${l.indent}`:""}${i4c(o)}:${f.indent?" ":""}`;return u=!1,c=!0,f.objectItem=void
|
|
|
1784
1784
|
`}),r.replaceAll(/\n$/g,"")}function UZP(e){return e?cl.green(n8r.radioOn):n8r.radioOff}var mpa=yu(Bje(),1);function rQl(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var Wdi=class extends dR{_run(t){this.done=t;let r=sW(this.rl),n=r.line.pipe((0,mpa.map)(this.filterInput.bind(this))),i=this.handleSubmitEvents(n);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),r.keypress.pipe((0,mpa.takeUntil)(i.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),n="";r+=this.status==="answered"?this.getMaskedValue(this.answer):this.getMaskedValue(this.rl.line||""),t&&(n=`
|
|
1785
1785
|
`+cl.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?cl.cyan(rQl(t,this.opt.mask)):cl.italic.dim("[hidden]"):this.opt.mask?rQl(t,this.opt.mask):cl.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(){var t;(t=this.opt).default&&(t.default=void 0),this.render()}};var MZl=yu(EZl(),1),xZl=yu(Bje(),1);var kdi=class extends dR{_run(t){this.done=t,this.editorResult=new xZl.Subject;let r=sW(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let n=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,i=this.handleSubmitEvents(this.editorResult);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,n?this.render():this.startExternalEditor(),this}render(t){let r="",n=this.getQuestion();n+=this.status==="answered"?cl.dim("Received"):cl.dim("Press <enter> to launch your preferred editor."),t&&(r=cl.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),(0,MZl.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 IZl=yu(CZl(),1);var zZl=yu(require("readline"),1),BZl=yu(NZl(),1),Hkr=class{constructor(t){this.rl||(this.rl=zZl.default.createInterface(qkP(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 qkP(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let i=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw i.isTtyError=!0,i}let r=new BZl.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var epi=class extends Hkr{constructor(t={}){super(t),this.log=(0,IZl.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return zdi(this.rl,this.bottomBar.split(`
|
|
1786
1786
|
`).length),this}updateBottomBar(t){return zdi(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+`
|
|
1787
|
-
`}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&&ypa(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var GZl=yu(LZl(),1),KZl=yu(anu(),1),YZl=yu($Zl(),1),iq=yu(Bje(),1),XZl=yu(Wfi(),1);var Vpa=yu(Bje(),1),JZl=yu(Wfi(),1),Wpa=function(e,t,r){return typeof e[t]!="function"?(0,Vpa.of)(e):(0,Vpa.from)((0,JZl.default)(e[t])(r).then(n=>(e[t]=n,e)))};var tpi={isPlainObject:GZl.default,set:YZl.default,get:KZl.default},KAn=class extends Hkr{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=tpi.isPlainObject(r)?{...r}:{},tpi.isPlainObject(t)&&(t=Object.values(t).every(i=>tpi.isPlainObject(i)&&i.name===void 0)?Object.entries(t).map(([i,a])=>({name:i,...a})):[t]);let n=Array.isArray(t)?(0,iq.from)(t):t;return this.process=n.pipe((0,iq.concatMap)(this.processQuestion.bind(this)),(0,iq.publish)()),this.process.connect(),this.process.pipe((0,iq.reduce)((i,a)=>(tpi.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,iq.defer)(()=>(0,iq.of)(t).pipe((0,iq.concatMap)(this.setDefaultType.bind(this)),(0,iq.concatMap)(this.filterIfRunnable.bind(this)),(0,iq.concatMap)(()=>Wpa(t,"message",this.answers)),(0,iq.concatMap)(()=>Wpa(t,"default",this.answers)),(0,iq.concatMap)(()=>Wpa(t,"choices",this.answers)),(0,iq.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,iq.defer)(()=>(0,iq.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,iq.defer)(()=>(0,iq.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&tpi.get(this.answers,t.name)!==void 0)return(0,iq.empty)();if(t.when===!1)return(0,iq.empty)();if(typeof t.when!="function")return(0,iq.of)(t);let{answers:r}=this;return(0,iq.defer)(()=>(0,iq.from)((0,XZl.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,iq.filter)(n=>n!=null)))}};function QZl(e){let t=function(r,n){let i;try{i=new KAn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",Idi),this.registerPrompt("input",Ikr),this.registerPrompt("number",Rdi),this.registerPrompt("confirm",Fdi),this.registerPrompt("rawlist",Ldi),this.registerPrompt("expand",Udi),this.registerPrompt("checkbox",Vdi),this.registerPrompt("password",Wdi),this.registerPrompt("editor",kdi)},t.restoreDefaultPrompts(),t}var Ziu=QZl();function YkP(e,t){Ziu.registerPrompt(e,t)}function XkP(){Ziu.restoreDefaultPrompts()}var QkP={prompt:Ziu,ui:{BottomBar:epi,Prompt:KAn},createPromptModule:QZl,registerPrompt:YkP,restoreDefaultPrompts:XkP,Separator:gne},Hpa=QkP;var pkl=yu(iau(),1),Jpa=class{posthog;constructor({posthogApiKey:t}){this.posthog=new pkl.PostHog(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.42.
|
|
1787
|
+
`}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&&ypa(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var GZl=yu(LZl(),1),KZl=yu(anu(),1),YZl=yu($Zl(),1),iq=yu(Bje(),1),XZl=yu(Wfi(),1);var Vpa=yu(Bje(),1),JZl=yu(Wfi(),1),Wpa=function(e,t,r){return typeof e[t]!="function"?(0,Vpa.of)(e):(0,Vpa.from)((0,JZl.default)(e[t])(r).then(n=>(e[t]=n,e)))};var tpi={isPlainObject:GZl.default,set:YZl.default,get:KZl.default},KAn=class extends Hkr{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=tpi.isPlainObject(r)?{...r}:{},tpi.isPlainObject(t)&&(t=Object.values(t).every(i=>tpi.isPlainObject(i)&&i.name===void 0)?Object.entries(t).map(([i,a])=>({name:i,...a})):[t]);let n=Array.isArray(t)?(0,iq.from)(t):t;return this.process=n.pipe((0,iq.concatMap)(this.processQuestion.bind(this)),(0,iq.publish)()),this.process.connect(),this.process.pipe((0,iq.reduce)((i,a)=>(tpi.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,iq.defer)(()=>(0,iq.of)(t).pipe((0,iq.concatMap)(this.setDefaultType.bind(this)),(0,iq.concatMap)(this.filterIfRunnable.bind(this)),(0,iq.concatMap)(()=>Wpa(t,"message",this.answers)),(0,iq.concatMap)(()=>Wpa(t,"default",this.answers)),(0,iq.concatMap)(()=>Wpa(t,"choices",this.answers)),(0,iq.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,iq.defer)(()=>(0,iq.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,iq.defer)(()=>(0,iq.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&tpi.get(this.answers,t.name)!==void 0)return(0,iq.empty)();if(t.when===!1)return(0,iq.empty)();if(typeof t.when!="function")return(0,iq.of)(t);let{answers:r}=this;return(0,iq.defer)(()=>(0,iq.from)((0,XZl.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,iq.filter)(n=>n!=null)))}};function QZl(e){let t=function(r,n){let i;try{i=new KAn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",Idi),this.registerPrompt("input",Ikr),this.registerPrompt("number",Rdi),this.registerPrompt("confirm",Fdi),this.registerPrompt("rawlist",Ldi),this.registerPrompt("expand",Udi),this.registerPrompt("checkbox",Vdi),this.registerPrompt("password",Wdi),this.registerPrompt("editor",kdi)},t.restoreDefaultPrompts(),t}var Ziu=QZl();function YkP(e,t){Ziu.registerPrompt(e,t)}function XkP(){Ziu.restoreDefaultPrompts()}var QkP={prompt:Ziu,ui:{BottomBar:epi,Prompt:KAn},createPromptModule:QZl,registerPrompt:YkP,restoreDefaultPrompts:XkP,Separator:gne},Hpa=QkP;var pkl=yu(iau(),1),Jpa=class{posthog;constructor({posthogApiKey:t}){this.posthog=new pkl.PostHog(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.42.1",usingAccessToken:!0}})}flush(){this.posthog.flush()}};var api=class{async sendEvent(){}async identify(){}async flush(){}};var XAn=require("fs/promises"),Akl=require("os"),Nkl=require("path"),zkl=yu(iau(),1);var hRt=yu(Ckl(),1),bU7=hRt.default.v1,gU7=hRt.default.v3,Jkr=hRt.default.v4,mU7=hRt.default.v5,OU7=hRt.default.NIL,PU7=hRt.default.version,jU7=hRt.default.validate,wU7=hRt.default.stringify,DU7=hRt.default.parse;var St1="id",Et1=".fern",cpi=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new zkl.PostHog(r),this.userId=t==null?void 0:yZo(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.42.1",...t,...t.properties}})}flush(){this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=pf(I_.of((0,Akl.homedir)()),zs.of(Et1),zs.of(St1));await Vh(t)||(await(0,XAn.mkdir)((0,Nkl.dirname)(t),{recursive:!0}),await(0,XAn.writeFile)(t,Jkr())),this.persistedDistinctId=(await(0,XAn.readFile)(t)).toString()}return this.persistedDistinctId}};var dau;async function QAn(){return dau==null&&(dau=await Mt1()),dau}async function Mt1(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new api;let r=await mua();return r!=null?new cpi({token:r,posthogApiKey:e}):await gua()!=null?new Jpa({posthogApiKey:e}):new cpi({token:void 0,posthogApiKey:e})}catch{return new api}}var uou=yu(vRt(),1);var dpi=yu(require("process"),1);var xtf=yu(Iau(),1),Ttf=yu(Mtf(),1);function N9(e,t={}){if(typeof e!="string"||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=Kqt(e),e.length===0))return 0;e=e.replace((0,Ttf.default)()," ");let r=t.ambiguousIsNarrow?1:2,n=0;for(let i of e){let a=i.codePointAt(0);if(a<=31||a>=127&&a<=159||a>=768&&a<=879)continue;switch(xtf.default.eastAsianWidth(i)){case"F":case"W":n+=2;break;case"A":n+=r;break;default:n+=1}}return n}function g_a(e){let t=0;for(let r of e.split(`
|
|
1788
1788
|
`))t=Math.max(t,N9(r));return t}var Xtf=yu(Fau(),1);var wn1=/[\p{Lu}]/u,Dn1=/[\p{Ll}]/u,Atf=/^[\p{Lu}](?![\p{Lu}])/gu,Btf=/([\p{Alpha}\p{N}_]|$)/u,Lau=/[_.\- ]+/,Sn1=new RegExp("^"+Lau.source),Ntf=new RegExp(Lau.source+Btf.source,"gu"),ztf=new RegExp("\\d+"+Btf.source,"gu"),En1=(e,t,r,n)=>{let i=!1,a=!1,u=!1,f=!1;for(let d=0;d<e.length;d++){let c=e[d];f=d>2?e[d-3]==="-":!0,i&&wn1.test(c)?(e=e.slice(0,d)+"-"+e.slice(d),i=!1,u=a,a=!0,d++):a&&u&&Dn1.test(c)&&(!f||n)?(e=e.slice(0,d-1)+"-"+e.slice(d-1),u=a,a=!1,i=!0):(i=t(c)===c&&r(c)!==c,u=a,a=r(c)===c&&t(c)!==c)}return e},Mn1=(e,t)=>(Atf.lastIndex=0,e.replace(Atf,r=>t(r))),xn1=(e,t)=>(Ntf.lastIndex=0,ztf.lastIndex=0,e.replace(Ntf,(r,n)=>t(n)).replace(ztf,r=>t(r)));function Uau(e,t){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(e)?e=e.map(a=>a.trim()).filter(a=>a.length).join("-"):e=e.trim(),e.length===0)return"";let r=t.locale===!1?a=>a.toLowerCase():a=>a.toLocaleLowerCase(t.locale),n=t.locale===!1?a=>a.toUpperCase():a=>a.toLocaleUpperCase(t.locale);return e.length===1?Lau.test(e)?"":t.pascalCase?n(e):r(e):(e!==r(e)&&(e=En1(e,r,n,t.preserveConsecutiveUppercase)),e=e.replace(Sn1,""),e=t.preserveConsecutiveUppercase?Mn1(e,r):r(e),t.pascalCase&&(e=n(e.charAt(0))+e.slice(1)),xn1(e,n))}var $au=yu(Rtf(),1);var Ftf=(e=0)=>t=>`\x1B[${t+e}m`,Ltf=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Utf=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function An1(){let e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[r,n]of Object.entries(t)){for(let[i,a]of Object.entries(n))t[i]={open:`\x1B[${a[0]}m`,close:`\x1B[${a[1]}m`},n[i]=t[i],e.set(a[0],a[1]);Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=Ftf(),t.color.ansi256=Ltf(),t.color.ansi16m=Utf(),t.bgColor.ansi=Ftf(10),t.bgColor.ansi256=Ltf(10),t.bgColor.ansi16m=Utf(10),Object.defineProperties(t,{rgbToAnsi256:{value:(r,n,i)=>r===n&&n===i?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(n/255*5)+Math.round(i/255*5),enumerable:!1},hexToRgb:{value:r=>{let n=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!n)return[0,0,0];let{colorString:i}=n.groups;i.length===3&&(i=i.split("").map(u=>u+u).join(""));let a=Number.parseInt(i,16);return[a>>16&255,a>>8&255,a&255]},enumerable:!1},hexToAnsi256:{value:r=>t.rgbToAnsi256(...t.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:r=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let n,i,a;if(r>=232)n=((r-232)*10+8)/255,i=n,a=n;else{r-=16;let d=r%36;n=Math.floor(r/36)/5,i=Math.floor(d/6)/5,a=d%6/5}let u=Math.max(n,i,a)*2;if(u===0)return 30;let f=30+(Math.round(a)<<2|Math.round(i)<<1|Math.round(n));return u===2&&(f+=60),f},enumerable:!1},rgbToAnsi:{value:(r,n,i)=>t.ansi256ToAnsi(t.rgbToAnsi256(r,n,i)),enumerable:!1},hexToAnsi:{value:r=>t.ansi256ToAnsi(t.hexToAnsi256(r)),enumerable:!1}}),t}var Nn1=An1(),Vtf=Nn1;var m_a=new Set(["\x1B","\x9B"]),zn1=39,Wau="\x07",$tf="[",Bn1="]",Jtf="m",Hau=`${Bn1}8;;`,Wtf=e=>`${m_a.values().next().value}${$tf}${e}${Jtf}`,Htf=e=>`${m_a.values().next().value}${Hau}${e}${Wau}`,In1=e=>e.split(" ").map(t=>N9(t)),Vau=(e,t,r)=>{let n=[...t],i=!1,a=!1,u=N9(Kqt(e[e.length-1]));for(let[f,d]of n.entries()){let c=N9(d);if(u+c<=r?e[e.length-1]+=d:(e.push(d),u=0),m_a.has(d)&&(i=!0,a=n.slice(f+1).join("").startsWith(Hau)),i){a?d===Wau&&(i=!1,a=!1):d===Jtf&&(i=!1);continue}u+=c,u===r&&f<n.length-1&&(e.push(""),u=0)}!u&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Rn1=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(N9(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Fn1=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",i,a,u=In1(e),f=[""];for(let[c,o]of e.split(" ").entries()){r.trim!==!1&&(f[f.length-1]=f[f.length-1].trimStart());let l=N9(f[f.length-1]);if(c!==0&&(l>=t&&(r.wordWrap===!1||r.trim===!1)&&(f.push(""),l=0),(l>0||r.trim===!1)&&(f[f.length-1]+=" ",l++)),r.hard&&u[c]>t){let g=t-l,O=1+Math.floor((u[c]-g-1)/t);Math.floor((u[c]-1)/t)<O&&f.push(""),Vau(f,o,t);continue}if(l+u[c]>t&&l>0&&u[c]>0){if(r.wordWrap===!1&&l<t){Vau(f,o,t);continue}f.push("")}if(l+u[c]>t&&r.wordWrap===!1){Vau(f,o,t);continue}f[f.length-1]+=o}r.trim!==!1&&(f=f.map(c=>Rn1(c)));let d=[...f.join(`
|
|
1789
1789
|
`)];for(let[c,o]of d.entries()){if(n+=o,m_a.has(o)){let{groups:g}=new RegExp(`(?:\\${$tf}(?<code>\\d+)m|\\${Hau}(?<uri>.*)${Wau})`).exec(d.slice(c).join(""))||{groups:{}};if(g.code!==void 0){let O=Number.parseFloat(g.code);i=O===zn1?void 0:O}else g.uri!==void 0&&(a=g.uri.length===0?void 0:g.uri)}let l=Vtf.codes.get(Number(i));d[c+1]===`
|
|
1790
1790
|
`?(a&&(n+=Htf("")),i&&l&&(n+=Wtf(l))):o===`
|
|
@@ -1901,7 +1901,7 @@ errors:
|
|
|
1901
1901
|
Run ${cl.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1902
1902
|
Run ${cl.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),u6n(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function Tsu({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!luf(e))return;let i=t??"",a=e.filter(f=>f.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((f,d)=>f.generatorName.localeCompare(d.generatorName)||f.currentVersion.localeCompare(d.currentVersion));for(let f of u)i+=`
|
|
1903
1903
|
${await Rp1(f.generatorName)} (${f.apiName!=null?"API: "+f.apiName+", ":""}Group: ${f.generatorGroup}) `+cl.dim(f.currentVersion)+cl.reset(" \u2192 ")+cl.green(f.latestVersion);return i+=`
|
|
1904
|
-
`,n?u6n(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function Rp1(e){let r=await new cuf.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 Fp1({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let f={type:"singleApi",versions:{}};return await duf({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,c,o,l)=>{f.versions[c]==null&&(f.versions[c]={});let g=pg.getGeneratorNameOrThrow(o.name,l),O=await pg.getLatestGeneratorVersion({generatorName:g,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:i,includeMajor:a,context:l});O!=null&&(f.versions[c][o.name]={previousVersion:o.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),f}let u={type:"multiApi",versions:{}};return await duf({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,d,c,o)=>{if(f==null)return;u.versions[f]==null&&(u.versions[f]={}),u.versions[f][d]==null&&(u.versions[f][d]={});let l=pg.getGeneratorNameOrThrow(c.name,o),g=await pg.getLatestGeneratorVersion({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:c.version,channel:i,includeMajor:a,context:o});g!=null&&(u.versions[f][d][c.name]={previousVersion:c.version,latestVersion:g})},generatorFilter:r,groupFilter:n}),u}async function duf({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let f=await pg.loadGeneratorsConfiguration({absolutePathToWorkspace:a.absoluteFilepath,context:u});if(!(f==null||f.groups==null)){for(let d of f.groups)if(!(i!=null&&d.groupName!==i))for(let c of d.generators)n!=null&&c.name!==n||await r(a.workspaceName,d.groupName,c,u)}})}))}function puf(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[u,f]of Object.entries(a)){r.debug(`Checking if ${u} in group ${i} has an upgrade available...`);let d=Pne(f.latestVersion,f.previousVersion);r.debug(`Latest version: ${f.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:u,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:f.previousVersion,latestVersion:f.latestVersion})}return n}async function Sha({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let f=await Fp1({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(f.type==="multiApi")for(let[d,c]of Object.entries(f.versions))u.push(...puf(c,d,t.logger));else u.push(...puf(f.versions,void 0,t.logger))}return u}var kpi=class extends Error{constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${i} ${a}`.trim(),f=u?`status code ${u}`:"an unknown error";super(`Request failed with ${f}`),Object.defineProperty(this,"response",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var F6n=class extends Error{constructor(t){super("Request timed out"),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="TimeoutError",this.request=t}};var e_i=e=>e!==null&&typeof e=="object";var t_i=(...e)=>{for(let t of e)if((!e_i(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Eha({},...e)},qsu=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,u]of i.entries())n&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r},Eha=(...e)=>{let t={},r={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(e_i(n)){for(let[i,a]of Object.entries(n))e_i(a)&&i in t&&(a=Eha(t[i],a)),t={...t,[i]:a};e_i(n.headers)&&(r=qsu(r,n.headers),t.headers=r)}return t};var _uf=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";return r&&n&&(t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")),e&&!t})(),huf=typeof globalThis.AbortController=="function",yuf=typeof globalThis.ReadableStream=="function",vuf=typeof globalThis.FormData=="function",Mha=["get","post","put","patch","head","delete"],Lp1=()=>{};Lp1();var buf={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},xha=2147483647,Tha=Symbol("stop"),guf={json:!0,parseJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},muf={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};var Puf=e=>Mha.includes(e)?e.toUpperCase():e,Up1=["get","put","head","delete","options","trace"],Vp1=[408,413,429,500,502,503,504],juf=[413,429,503],Ouf={limit:2,methods:Up1,statusCodes:Vp1,afterStatusCodes:juf,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},wuf=(e={})=>{if(typeof e=="number")return{...Ouf,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{...Ouf,...e,afterStatusCodes:juf}};async function Csu(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new F6n(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function Asu(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t==null||t.removeEventListener("abort",i),r()},e)})}var Duf=(e,t)=>{let r={};for(let n in t)!(n in muf)&&!(n in guf)&&!(n in e)&&(r[n]=t[n]);return r};var pen=class{static create(t,r){let n=new pen(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>xha)throw new RangeError(`The \`timeout\` option cannot be greater than ${xha}`);await Promise.resolve();let f=await n._fetch();for(let d of n._options.hooks.afterResponse){let c=await d(n.request,n._options,n._decorateResponse(f.clone()));c instanceof globalThis.Response&&(f=c)}if(n._decorateResponse(f),!f.ok&&n._options.throwHttpErrors){let d=new kpi(f,n.request,n._options);for(let c of n._options.hooks.beforeError)d=await c(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!yuf)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(f.clone(),n._options.onDownloadProgress)}return f},u=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i();for(let[f,d]of Object.entries(buf))u[f]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let o=(await u).clone();if(f==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[f]()};return u}constructor(t,r={}){Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"abortController",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_retryCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._input=t;let n="credentials"in Request.prototype;if(this._options={credentials:n?this._input.credentials:void 0,...r,headers:qsu(this._input.headers,r.headers),hooks:Eha({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Puf(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:wuf(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(huf){if(this.abortController=new globalThis.AbortController,this._options.signal){let i=this._options.signal;this._options.signal.addEventListener("abort",()=>{this.abortController.abort(i.reason)})}this._options.signal=this.abortController.signal}if(_uf&&(this._options.duplex="half"),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let i=typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString(),a="?"+i,u=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,a);(vuf&&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(u,{...this.request}),this._options)}this._options.json!==void 0&&(this._options.body=JSON.stringify(this._options.json),this.request.headers.set("content-type",this._options.headers.get("content-type")??"application/json"),this.request=new globalThis.Request(this.request,{body:this._options.body}))}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount<=this._options.retry.limit&&!(t instanceof F6n)){if(t instanceof kpi){if(!this._options.retry.statusCodes.includes(t.response.status))return 0;let n=t.response.headers.get("Retry-After");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n);return Number.isNaN(i)?i=Date.parse(n)-Date.now():i*=1e3,this._options.retry.maxRetryAfter!==void 0&&i>this._options.retry.maxRetryAfter?0:i}if(t.response.status===413)return 0}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}return 0}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),xha);if(n!==0&&this._retryCount>0){await Asu(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===Tha)return;return this._retry(t)}throw r}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=Duf(this.request,this._options);return this._options.timeout===!1?this._options.fetch(this.request.clone(),t):Csu(this.request.clone(),t,this.abortController,this._options)}_stream(t,r){let n=Number(t.headers.get("content-length"))||0,i=0;return t.status===204?(r&&r({percent:1,totalBytes:n,transferredBytes:i},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array);async function f(){let{done:d,value:c}=await u.read();if(d){a.close();return}if(r){i+=c.byteLength;let o=n===0?0:i/n;r({percent:o,transferredBytes:i,totalBytes:n},c)}a.enqueue(c),await f()}await f()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var Nsu=e=>{let t=(r,n)=>pen.create(r,t_i(e,n));for(let r of Mha)t[r]=(n,i)=>pen.create(n,t_i(e,i,{method:r}));return t.create=r=>Nsu(t_i(r)),t.extend=r=>Nsu(t_i(e,r)),t.stop=Tha,t},Wp1=Nsu(),Suf=Wp1;var Yuf=yu(Kuf(),1);function Fsu(e){let t=(0,Yuf.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var $sf=yu(Hsf(),1),Jsf=yu(ZQr(),1),Qsu=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Zsu=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function ksu(e,t={}){var l;let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??Fsu(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),f=(0,$sf.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,f&&(d.authorization=`${f.type} ${f.token}`);let c;try{c=await Suf(u,{headers:d,keepalive:!0}).json()}catch(g){throw((l=g==null?void 0:g.response)==null?void 0:l.status)===404?new Qsu(e):g}if(t.allVersions)return c;let o=new Zsu(e,r);if(c["dist-tags"][r]){let{time:g}=c;c=c.versions[c["dist-tags"][r]],c.time=g}else if(r){let g=Boolean(c.versions[r]);if(n&&!g)for(let[j,S]of Object.entries(c.versions))S.deprecated&&delete c.versions[j];if(!g){let j=Object.keys(c.versions);if(r=Jsf.default.maxSatisfying(j,r),!r)throw o}let{time:O}=c;if(c=c.versions[r],c.time=O,!c)throw o}return c}async function o_i(e,t){let{version:r}=await ksu(e.toLowerCase(),t);return r}async function J6n({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:o_i(e.packageName,{version:t?"prerelease":"latest"})}var Gsf=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Wha=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=hM.Info;constructor(t){this.ttyAwareLogger=new Dha(t);let r=this.getPackageName(),n=this.getPackageVersion(),i=this.getCliName();(r==null||n==null||i==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:n,cliName:i}}getPackageName(){return"fern-api"==null&&this.logger.error("CLI_PACKAGE_NAME is not defined"),"fern-api"}getPackageVersion(){return"0.42.0"==null&&this.logger.error("CLI_VERSION is not defined"),"0.42.0"}getCliName(){return"fern"==null&&this.logger.error("CLI_NAME is not defined"),"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${cl.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Gte}failWithoutThrowing(t,r){this.didSucceed=!1,Oha({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),(await QAn()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await fuf({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1904
|
+
`,n?u6n(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function Rp1(e){let r=await new cuf.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 Fp1({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let f={type:"singleApi",versions:{}};return await duf({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,c,o,l)=>{f.versions[c]==null&&(f.versions[c]={});let g=pg.getGeneratorNameOrThrow(o.name,l),O=await pg.getLatestGeneratorVersion({generatorName:g,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:i,includeMajor:a,context:l});O!=null&&(f.versions[c][o.name]={previousVersion:o.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),f}let u={type:"multiApi",versions:{}};return await duf({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,d,c,o)=>{if(f==null)return;u.versions[f]==null&&(u.versions[f]={}),u.versions[f][d]==null&&(u.versions[f][d]={});let l=pg.getGeneratorNameOrThrow(c.name,o),g=await pg.getLatestGeneratorVersion({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:c.version,channel:i,includeMajor:a,context:o});g!=null&&(u.versions[f][d][c.name]={previousVersion:c.version,latestVersion:g})},generatorFilter:r,groupFilter:n}),u}async function duf({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let f=await pg.loadGeneratorsConfiguration({absolutePathToWorkspace:a.absoluteFilepath,context:u});if(!(f==null||f.groups==null)){for(let d of f.groups)if(!(i!=null&&d.groupName!==i))for(let c of d.generators)n!=null&&c.name!==n||await r(a.workspaceName,d.groupName,c,u)}})}))}function puf(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[u,f]of Object.entries(a)){r.debug(`Checking if ${u} in group ${i} has an upgrade available...`);let d=Pne(f.latestVersion,f.previousVersion);r.debug(`Latest version: ${f.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:u,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:f.previousVersion,latestVersion:f.latestVersion})}return n}async function Sha({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let f=await Fp1({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(f.type==="multiApi")for(let[d,c]of Object.entries(f.versions))u.push(...puf(c,d,t.logger));else u.push(...puf(f.versions,void 0,t.logger))}return u}var kpi=class extends Error{constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${i} ${a}`.trim(),f=u?`status code ${u}`:"an unknown error";super(`Request failed with ${f}`),Object.defineProperty(this,"response",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var F6n=class extends Error{constructor(t){super("Request timed out"),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="TimeoutError",this.request=t}};var e_i=e=>e!==null&&typeof e=="object";var t_i=(...e)=>{for(let t of e)if((!e_i(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Eha({},...e)},qsu=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,u]of i.entries())n&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r},Eha=(...e)=>{let t={},r={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(e_i(n)){for(let[i,a]of Object.entries(n))e_i(a)&&i in t&&(a=Eha(t[i],a)),t={...t,[i]:a};e_i(n.headers)&&(r=qsu(r,n.headers),t.headers=r)}return t};var _uf=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";return r&&n&&(t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")),e&&!t})(),huf=typeof globalThis.AbortController=="function",yuf=typeof globalThis.ReadableStream=="function",vuf=typeof globalThis.FormData=="function",Mha=["get","post","put","patch","head","delete"],Lp1=()=>{};Lp1();var buf={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},xha=2147483647,Tha=Symbol("stop"),guf={json:!0,parseJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},muf={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};var Puf=e=>Mha.includes(e)?e.toUpperCase():e,Up1=["get","put","head","delete","options","trace"],Vp1=[408,413,429,500,502,503,504],juf=[413,429,503],Ouf={limit:2,methods:Up1,statusCodes:Vp1,afterStatusCodes:juf,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},wuf=(e={})=>{if(typeof e=="number")return{...Ouf,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{...Ouf,...e,afterStatusCodes:juf}};async function Csu(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new F6n(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function Asu(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t==null||t.removeEventListener("abort",i),r()},e)})}var Duf=(e,t)=>{let r={};for(let n in t)!(n in muf)&&!(n in guf)&&!(n in e)&&(r[n]=t[n]);return r};var pen=class{static create(t,r){let n=new pen(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>xha)throw new RangeError(`The \`timeout\` option cannot be greater than ${xha}`);await Promise.resolve();let f=await n._fetch();for(let d of n._options.hooks.afterResponse){let c=await d(n.request,n._options,n._decorateResponse(f.clone()));c instanceof globalThis.Response&&(f=c)}if(n._decorateResponse(f),!f.ok&&n._options.throwHttpErrors){let d=new kpi(f,n.request,n._options);for(let c of n._options.hooks.beforeError)d=await c(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!yuf)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(f.clone(),n._options.onDownloadProgress)}return f},u=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i();for(let[f,d]of Object.entries(buf))u[f]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let o=(await u).clone();if(f==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[f]()};return u}constructor(t,r={}){Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"abortController",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_retryCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._input=t;let n="credentials"in Request.prototype;if(this._options={credentials:n?this._input.credentials:void 0,...r,headers:qsu(this._input.headers,r.headers),hooks:Eha({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Puf(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:wuf(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(huf){if(this.abortController=new globalThis.AbortController,this._options.signal){let i=this._options.signal;this._options.signal.addEventListener("abort",()=>{this.abortController.abort(i.reason)})}this._options.signal=this.abortController.signal}if(_uf&&(this._options.duplex="half"),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let i=typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString(),a="?"+i,u=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,a);(vuf&&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(u,{...this.request}),this._options)}this._options.json!==void 0&&(this._options.body=JSON.stringify(this._options.json),this.request.headers.set("content-type",this._options.headers.get("content-type")??"application/json"),this.request=new globalThis.Request(this.request,{body:this._options.body}))}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount<=this._options.retry.limit&&!(t instanceof F6n)){if(t instanceof kpi){if(!this._options.retry.statusCodes.includes(t.response.status))return 0;let n=t.response.headers.get("Retry-After");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n);return Number.isNaN(i)?i=Date.parse(n)-Date.now():i*=1e3,this._options.retry.maxRetryAfter!==void 0&&i>this._options.retry.maxRetryAfter?0:i}if(t.response.status===413)return 0}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}return 0}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),xha);if(n!==0&&this._retryCount>0){await Asu(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===Tha)return;return this._retry(t)}throw r}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=Duf(this.request,this._options);return this._options.timeout===!1?this._options.fetch(this.request.clone(),t):Csu(this.request.clone(),t,this.abortController,this._options)}_stream(t,r){let n=Number(t.headers.get("content-length"))||0,i=0;return t.status===204?(r&&r({percent:1,totalBytes:n,transferredBytes:i},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array);async function f(){let{done:d,value:c}=await u.read();if(d){a.close();return}if(r){i+=c.byteLength;let o=n===0?0:i/n;r({percent:o,transferredBytes:i,totalBytes:n},c)}a.enqueue(c),await f()}await f()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var Nsu=e=>{let t=(r,n)=>pen.create(r,t_i(e,n));for(let r of Mha)t[r]=(n,i)=>pen.create(n,t_i(e,i,{method:r}));return t.create=r=>Nsu(t_i(r)),t.extend=r=>Nsu(t_i(e,r)),t.stop=Tha,t},Wp1=Nsu(),Suf=Wp1;var Yuf=yu(Kuf(),1);function Fsu(e){let t=(0,Yuf.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var $sf=yu(Hsf(),1),Jsf=yu(ZQr(),1),Qsu=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Zsu=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function ksu(e,t={}){var l;let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??Fsu(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),f=(0,$sf.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,f&&(d.authorization=`${f.type} ${f.token}`);let c;try{c=await Suf(u,{headers:d,keepalive:!0}).json()}catch(g){throw((l=g==null?void 0:g.response)==null?void 0:l.status)===404?new Qsu(e):g}if(t.allVersions)return c;let o=new Zsu(e,r);if(c["dist-tags"][r]){let{time:g}=c;c=c.versions[c["dist-tags"][r]],c.time=g}else if(r){let g=Boolean(c.versions[r]);if(n&&!g)for(let[j,S]of Object.entries(c.versions))S.deprecated&&delete c.versions[j];if(!g){let j=Object.keys(c.versions);if(r=Jsf.default.maxSatisfying(j,r),!r)throw o}let{time:O}=c;if(c=c.versions[r],c.time=O,!c)throw o}return c}async function o_i(e,t){let{version:r}=await ksu(e.toLowerCase(),t);return r}async function J6n({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:o_i(e.packageName,{version:t?"prerelease":"latest"})}var Gsf=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Wha=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=hM.Info;constructor(t){this.ttyAwareLogger=new Dha(t);let r=this.getPackageName(),n=this.getPackageVersion(),i=this.getCliName();(r==null||n==null||i==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:n,cliName:i}}getPackageName(){return"fern-api"==null&&this.logger.error("CLI_PACKAGE_NAME is not defined"),"fern-api"}getPackageVersion(){return"0.42.1"==null&&this.logger.error("CLI_VERSION is not defined"),"0.42.1"}getCliName(){return"fern"==null&&this.logger.error("CLI_NAME is not defined"),"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${cl.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Gte}failWithoutThrowing(t,r){this.didSucceed=!1,Oha({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),(await QAn()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await fuf({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1905
1905
|
`)||(r+=`
|
|
1906
1906
|
`),this.logger.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram(){process.exit(this.didSucceed?0:1)}longestWorkspaceName;registerWorkspaces(t){let r=OWo(t.map(n=>n.type==="docs"?"docs":n.workspaceName??"api"),n=>n.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new Vpi(t);return this.ttyAwareLogger.registerTask(r),r}async runTaskWithInit(t,r){let n=this.addTaskWithInit(t).start(),i;try{i=await r(n)}catch(a){throw n.failWithoutThrowing(void 0,a),new Gte}finally{n.finish()}return i}async instrumentPostHogEvent(t){(await QAn()).sendEvent(t)}logger=Zui(this.log.bind(this));constructTaskInitForWorkspace(t){let r=Ksf(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?Ksf(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=Gsf[this.numTasks++%Gsf.length],u=cl.hex(a)(i);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===D4.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logImmediately(t){let r=t.filter(n=>_4r.indexOf(n.level)>=_4r.indexOf(this.logLevel));this.ttyAwareLogger.log(r,{includeDebugInfo:this.logLevel===hM.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 J6n({cliEnvironment:this.environment,includePreReleases:t}),n=Pne(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await Sha({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}};function Ksf(e){return`[${e}]:`}var tC;(function(e){e.FILE_READ="FILE_READ",e.FILE_PARSE="FILE_PARSE",e.FILE_MISSING="FILE_MISSING",e.STRUCTURE_VALIDATION="STRUCTURE_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"})(tC||(tC={}));function ecu(e,t){for(let[r,n]of v3(e.failures))Ysf({relativeFilepath:r,failure:n,logger:t})}function Hha(e,t){for(let[r,n]of v3(e))Ysf({relativeFilepath:r,failure:n,logger:t})}function Ysf({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case tC.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 tC.FILE_READ:r.error("Failed to open file: "+e);break;case tC.FILE_MISSING:r.error("Missing file: "+e);break;case tC.FILE_PARSE:t.error instanceof PLo?r.error(wMn({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case tC.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of J_1(n))r.error(wMn({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case tC.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case tC.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${t7c}: `+t.dependencyName);break;case tC.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case tC.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;default:Ol(t)}}function J_1(e){switch(e.code){case L_.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${cl.underline(e.expected)} but received ${cl.underline(e.received)}`}];case L_.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${cl.underline(t)}`}));case L_.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>cl.underline(t)).join(", ")}`}];case L_.invalid_union:case L_.invalid_arguments:case L_.invalid_return_type:case L_.invalid_date:case L_.invalid_string:case L_.too_small:case L_.too_big:case L_.invalid_intersection_types:case L_.not_multiple_of:case L_.custom:default:return[{title:e.message}]}}var Xsf=require("fs/promises");async function $ha(e,t){let r=[];for(let n of await u4r(e,t))r.push(await G_1({relativeFilepath:YN(e,n),absoluteFilepath:n}));return r}async function G_1({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,Xsf.readFile)(t)).toString()}}async function Qsf({absolutePathToWorkspace:e}){let t=pf(e,zs.of(k6c));if(!await Vh(t))return;let n=await $ha(t,"{md,mdx}");return{files:await Promise.all(n.map(i=>({absoluteFilepath:i.absoluteFilepath,contents:i.fileContents})))}}var pdf=yu(ncu(),1);async function ncf(e){let t={},r={};function n(i){try{t[i.relativeFilepath]={defaultUrl:void 0,contents:av.load(i.fileContents,{schema:av.CORE_SCHEMA}),rawContents:i.fileContents}}catch(a){r[i.relativeFilepath]={type:tC.FILE_PARSE,error:a}}}return await Promise.all(e.map(n)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}var Hlu=yu(gZr(),1),tdf=yu(vRt(),1),rdf=require("fs"),v7n=require("fs/promises");var ndf=require("os"),idf=yu(require("path"),1),adf=require("stream/promises"),odf=yu(Zya(),1),udf=yu(Jte(),1);var w01=QDr();async function sdf({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:n,cliVersion:i,settings:a}){let u,f={type:tC.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},d=t.dependencies[e];return d==null?f={type:tC.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${q01(d)}`},async c=>{switch(d.type){case"version":u=await x01({context:c,dependency:d,cliVersion:i,settings:a});return;case"local":u=await M01({context:c,dependency:d,cliVersion:i,settings:a});return;default:Ol(d)}}),u!=null?{didSucceed:!0,definition:u}:{didSucceed:!1,failure:f}}var cdf="dependencies";var D01="metadata.json",S01=".fern";function E01(e){return pf(I_.of((0,ndf.homedir)()),zs.of(S01),zs.of(cdf),zs.of(e.organization),zs.of(e.apiName),zs.of(e.version))}async function M01({dependency:e,context:t,cliVersion:r,settings:n}){t.logger.info("Parsing...");let i=await Nen({absolutePathToWorkspace:e.absoluteFilepath,context:t,cliVersion:r,workspaceName:void 0});if(!i.didSucceed){t.failWithoutThrowing("Failed to load api definition",i.failures);return}t.logger.info("Modifying source filepath ...");let a=await i.workspace.getDefinition({context:t,relativePathToDependency:zs.of(e.path)},n);return t.logger.info("Loaded..."),a}async function x01({dependency:e,context:t,cliVersion:r,settings:n}){let i=E01(e),a=pf(i,zs.of(cdf)),u=pf(i,zs.of(D01)),f;if(!await Vh(a)||!await Vh(u)){t.logger.info("Downloading manifest...");let o=await w01.definitionRegistry.get(Hlu.FernFiddle.OrganizationId(e.organization),Hlu.FernFiddle.ApiId(e.apiName),e.version);if(!o.ok){o.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:j=>{t.failWithoutThrowing("Failed to download API manifest",j)}});return}let l=o.body.yamlSchemaVersion!=null?parseInt(o.body.yamlSchemaVersion):void 0,g=cen(r),O=cen(o.body.cliVersion);if(l!=null){if(l>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${o.body.cliVersion}`);return}else if(l<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 ${o.body.cliVersion}. Expected ${g.major}.${g.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+o.body.definitionS3DownloadUrl),await(0,v7n.mkdir)(a,{recursive:!0});try{await T01({s3PreSignedReadUrl:o.body.definitionS3DownloadUrl,absolutePathToLocalOutput:a})}catch(j){t.failWithoutThrowing("Failed to download API",j);return}f=o.body,await(0,v7n.writeFile)(u,JSON.stringify(f))}else f=JSON.parse((await(0,v7n.readFile)(u)).toString());t.logger.info("Parsing...");let d=await Nen({absolutePathToWorkspace:a,context:t,cliVersion:f.cliVersion,workspaceName:void 0});if(!d.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",d.failures);return}if(d.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await d.workspace.getDefinition({context:t},n)}async function T01({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await tdf.default.get(e,{responseType:"stream"}),n=await udf.default.dir(),i=idf.default.join(n.path,"api.tgz");await(0,adf.pipeline)(r.data,(0,rdf.createWriteStream)(i)),await odf.default.extract({file:i,cwd:t})}function q01(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:Ol(e)}}async function ldf({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:n,settings:i}){let a={},u={},f={};return await Promise.all(v3(t.packageMarkers).map(async([d,c])=>{if(c.contents.export==null)a[d]=c;else{let{export:o,...l}=c.contents;if(Q8t(l)>0)f[d]={type:tC.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:d};else{let g=Hg(d);if(E8t(t.namedDefinitionFiles).some(j=>j!==d&&j.startsWith(g)))f[d]={type:tC.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:g};else{let j=await sdf({dependencyName:typeof c.contents.export=="string"?c.contents.export:c.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:n,settings:i});j.didSucceed?u[Hg(d)]={definition:j.definition,url:typeof c.contents.export=="object"?c.contents.export.url:void 0}:f[d]=j.failure}}}})),Q8t(f)>0?{didSucceed:!1,failures:f}:{didSucceed:!0,packageMarkers:a,importedDefinitions:u}}var fdf=yu(require("path"),1);function ddf({files:e,absolutePathToDefinition:t}){let r,n={},i={},a={};for(let[u,f]of v3(e)){let d=f.contents,c=o=>{a[u]={type:tC.STRUCTURE_VALIDATION,error:o}};if(u===nB){let o=eta.safeParse(d);o.success?r={defaultUrl:o.data["default-url"],contents:o.data,rawContents:f.rawContents}:c(o.error)}else if(fdf.default.basename(u)===HT){let o=Yea.safeParse(d);o.success?i[u]={defaultUrl:typeof o.data.export=="object"?o.data.export.url:void 0,contents:o.data,rawContents:f.rawContents}:c(o.error)}else{let o=s2n.safeParse(d);o.success?n[u]={defaultUrl:void 0,contents:o.data,rawContents:f.rawContents,absoluteFilepath:pf(t,u)}:c(o.error)}}return r==null?{didSucceed:!1,failures:{[zs.of(nB)]:{type:tC.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:n,rootApiFile:r,packageMarkers:i}}var zen=class{};var y5r=class extends zen{type="fern";workspaceName;absoluteFilepath;generatorsConfiguration;dependenciesConfiguration;definition;changelog;sources;cliVersion;constructor({absoluteFilepath:t,workspaceName:r,generatorsConfiguration:n,dependenciesConfiguration:i,definition:a,changelog:u,sources:f,cliVersion:d}){super(),this.absoluteFilepath=t,this.workspaceName=r,this.changelog=u,this.generatorsConfiguration=n,this.dependenciesConfiguration=i,this.definition=a,this.sources=f??[],this.cliVersion=d}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getAbsoluteFilepaths(){return[this.absoluteFilepath]}getSources(){return this.sources}},Ben=class extends zen{type="fern";workspaceName;absoluteFilepath;generatorsConfiguration;changelog;context;cliVersion;fernWorkspaces={};constructor({absoluteFilepath:t,workspaceName:r,generatorsConfiguration:n,changelog:i,cliVersion:a,context:u}){super(),this.absoluteFilepath=t,this.workspaceName=r,this.changelog=i,this.generatorsConfiguration=n,this.cliVersion=a,this.context=u}async getDefinition({context:t},r){return(await this.toFernWorkspace({context:t},r)).definition}async toFernWorkspace({context:t},r){let n=(0,pdf.default)(r??{}),i=this.fernWorkspaces[n];if(i==null){let a=t||this.context,u=pf(this.absoluteFilepath,zs.of(p9)),f=await RGi.loadDependenciesConfiguration({absolutePathToWorkspace:this.absoluteFilepath,context:a}),d=await $ha(u,"{yml,yaml}"),c=await ncf(d);if(!c.didSucceed)return Hha(c.failures,a.logger),a.failAndThrow();let o=ddf({files:c.files,absolutePathToDefinition:u});if(!o.didSucceed)return Hha(o.failures,a.logger),a.failAndThrow();let l=await ldf({dependenciesConfiguration:f,structuralValidationResult:o,context:a,cliVersion:this.cliVersion,settings:r});if(!l.didSucceed)return Hha(l.failures,a.logger),a.failAndThrow();i=new y5r({absoluteFilepath:this.absoluteFilepath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:f,workspaceName:this.workspaceName,definition:{absoluteFilepath:u,rootApiFile:o.rootApiFile,namedDefinitionFiles:o.namedDefinitionFiles,packageMarkers:l.packageMarkers,importedDefinitions:l.importedDefinitions},changelog:this.changelog,sources:void 0,cliVersion:this.cliVersion}),this.fernWorkspaces[n]=i}return i}getAbsoluteFilepaths(){return[this.absoluteFilepath]}};var HSr={openapi:e=>({...e,type:"openapi",_visit:function(t){return HSr._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return HSr._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 b7n={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return b7n._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var F9={basic:e=>({...e,type:"basic",_visit:function(t){return F9._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return F9._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return F9._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return F9._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return F9._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 RP={primitive:e=>({value:e,type:"primitive",_visit:function(t){return RP._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return RP._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return RP._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return RP._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return RP._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return RP._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return RP._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return RP._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 t0={int:e=>({value:e,type:"int",_visit:function(t){return t0._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return t0._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return t0._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return t0._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return t0._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return t0._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return t0._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return t0._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return t0._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return t0._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return t0._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 g7n={boolean:e=>({value:e,type:"boolean",_visit:function(t){return g7n._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return g7n._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 v5r={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return v5r._visit(this,t)}}),undisciminated:e=>({value:e,type:"undisciminated",_visit:function(t){return v5r._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undisciminated":return t.undisciminated(e.value);default:return t._other(e)}}};var yW={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case yW.GenerallyAvailable:return t.generallyAvailable();case yW.Beta:return t.beta();case yW.Deprecated:return t.deprecated();default:return t._other()}}};var $Sr={cursor:e=>({...e,type:"cursor",_visit:function(t){return $Sr._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return $Sr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);default:return t._other(e)}}};var JSr={language:e=>({...e,type:"language",_visit:function(t){return JSr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return JSr._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 vW={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 vW.Curl:return t.curl();case vW.Python:return t.python();case vW.Javascript:return t.javascript();case vW.Typescript:return t.typescript();case vW.Go:return t.go();case vW.Ruby:return t.ruby();case vW.Csharp:return t.csharp();case vW.Java:return t.java();case vW.Js:return t.js();case vW.Node:return t.node();case vW.Ts:return t.ts();case vW.Nodets:return t.nodets();case vW.Golang:return t.golang();case vW.Dotnet:return t.dotnet();case vW.Jvm:return t.jvm();default:return t._other()}}};var pAt={unknown:e=>({value:e,type:"unknown",_visit:function(t){return pAt._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return pAt._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 GJ={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case GJ.Get:return t.get();case GJ.Post:return t.post();case GJ.Put:return t.put();case GJ.Patch:return t.patch();case GJ.Delete:return t.delete();case GJ.Head:return t.head();case GJ.Options:return t.options();case GJ.Trace:return t.trace();default:return t._other()}}};var b5r={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return b5r._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return b5r._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return b5r._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 D2e={file:e=>({...e,type:"file",_visit:function(t){return D2e._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return D2e._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 Sne={file:e=>({...e,type:"file",_visit:function(t){return Sne._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Sne._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Sne._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return Sne._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return Sne._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return Sne._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 ib={primitive:e=>({...e,type:"primitive",_visit:function(t){return ib._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ib._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return ib._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return ib._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return ib._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return ib._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return ib._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return ib._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return ib._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return ib._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return ib._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 Xw={int:e=>({...e,type:"int",_visit:function(t){return Xw._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Xw._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Xw._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Xw._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Xw._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Xw._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Xw._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Xw._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Xw._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Xw._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Xw._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 E7={boolean:e=>({value:e,type:"boolean",_visit:function(t){return E7._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return E7._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 GSr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return GSr._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return GSr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undisciminated":return t.undisciminated(e);default:return t._other(e)}}};var S2e={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return S2e._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return S2e._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return S2e._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 T3={file:e=>({...e,type:"file",_visit:function(t){return T3._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return T3._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return T3._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return T3._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return T3._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return T3._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 Lp={primitive:e=>({...e,type:"primitive",_visit:function(t){return Lp._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Lp._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Lp._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Lp._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Lp._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Lp._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Lp._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Lp._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Lp._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Lp._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Lp._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 jQ={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return jQ._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return jQ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undisciminated":return t.undisciminated(e);default:return t._other(e)}}};var by={int:e=>({...e,type:"int",_visit:function(t){return by._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return by._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return by._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return by._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return by._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return by._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return by._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return by._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return by._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return by._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return by._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 Ag={};Wb(Ag,{AllOfPropertyConflict:()=>I7n,ArraySchema:()=>lva,ArraySchemaWithExample:()=>Fva,Availability:()=>s0a,Base64WithExample:()=>Nva,BasicSecurityScheme:()=>f0a,BearerSecurityScheme:()=>d0a,BooleanSchema:()=>iva,BooleanWithExample:()=>zva,CasingOverrides:()=>h0a,CommonProperty:()=>bva,CommonPropertyWithExample:()=>Kva,CursorPagination:()=>W0a,CustomCodeSample:()=>U0a,CustomCodeSampleLanguage:()=>R0a,CustomCodeSampleSdk:()=>L0a,DateWithExample:()=>Ava,DatetimeWithExample:()=>Cva,DiscriminatedOneOfSchema:()=>yva,DiscriminatedOneOfSchemaWithExample:()=>Jva,DoubleSchema:()=>rva,DoubleWithExample:()=>Tva,Encoding:()=>u0a,Endpoint:()=>$0a,EndpointExample:()=>N7n,EndpointSdkName:()=>M5r,EndpointWithExample:()=>Vdf,EnumSchema:()=>P7n,EnumSchemaWithExample:()=>Iva,EnumValue:()=>j5r,ErrorExample:()=>N0a,FernExample:()=>B0a,FileResponse:()=>T7n,FileSchema:()=>M0a,FloatWithExample:()=>xva,FullEndpointExample:()=>V0a,FullExample:()=>yA,FullObjectExample:()=>j0a,FullOneOfExample:()=>D0a,GlobalHeader:()=>ova,Header:()=>E5r,HeaderExample:()=>A7n,HeaderSecurityScheme:()=>p0a,HeaderWithExample:()=>L7n,HttpEndpointServer:()=>q7n,HttpError:()=>z0a,HttpErrorWithExample:()=>wva,HttpMethod:()=>D7n,IdempotencyHeader:()=>uva,Int64WithExample:()=>Sva,IntSchema:()=>eva,IntWithExample:()=>Dva,JsonRequest:()=>q0a,JsonRequestWithExample:()=>mva,JsonResponse:()=>KSr,JsonResponseWithExample:()=>Pva,KeyValuePair:()=>w0a,LiteralExample:()=>P0a,LiteralSchema:()=>B7n,LiteralSchemaValue:()=>sva,LongSchema:()=>tva,MapSchema:()=>fva,MapSchemaWithExample:()=>Lva,MultipartRequest:()=>x7n,MultipartRequestProperty:()=>T0a,MultipartSchema:()=>x0a,NamedFullExample:()=>BRt,Namespace:()=>y0a,NamespaceId:()=>O0a,NullableSchema:()=>pva,NullableSchemaWithExample:()=>Vva,OauthSecurityScheme:()=>b0a,ObjectProperty:()=>hva,ObjectPropertyConflictInfo:()=>R7n,ObjectPropertyWithExample:()=>$va,ObjectSchema:()=>cva,ObjectSchemaWithExample:()=>Wva,OctetStreamRequest:()=>M7n,OffsetPagination:()=>H0a,OneOfSchema:()=>_va,OneOfSchemaWithExample:()=>Hva,OpenApiIntermediateRepresentation:()=>Ldf,OpenApiSource:()=>n0a,OptionalSchema:()=>dva,OptionalSchemaWithExample:()=>Uva,Pagination:()=>z7n,PathParameter:()=>S7n,PathParameterExample:()=>I0a,PathParameterWithExample:()=>gva,PrimitiveExample:()=>w7n,PrimitiveSchema:()=>T5r,PrimitiveSchemaValue:()=>ava,PrimitiveSchemaValueWithExample:()=>Bva,PrimitiveSchemaWithExample:()=>U7n,PropertyKey:()=>j7n,ProtobufEncoding:()=>o0a,ProtobufSource:()=>i0a,QueryParameter:()=>E7n,QueryParameterExample:()=>C7n,QueryParameterWithExample:()=>F7n,QuerySecurityScheme:()=>_0a,ReferencedSchema:()=>zRt,Request:()=>C0a,RequestWithExample:()=>Ova,Response:()=>A0a,ResponseWithExample:()=>jva,Schema:()=>D1,SchemaId:()=>wQ,SchemaWithExample:()=>aq,Schemas:()=>k0a,SdkGroup:()=>v0a,SdkGroupInfo:()=>S0a,SdkGroupName:()=>w5r,SecurityScheme:()=>g0a,SecuritySchemeId:()=>l0a,Server:()=>m0a,Source:()=>a0a,StatusCode:()=>D5r,StringSchema:()=>nva,StringSchemaWithExample:()=>qva,SupportedSdkLanguage:()=>F0a,Tag:()=>c0a,TagId:()=>Kje,Tags:()=>E0a,TextResponse:()=>x5r,Uint64WithExample:()=>Mva,UintWithExample:()=>Eva,UnDiscriminatedOneOfSchema:()=>vva,UnDiscriminatedOneOfSchemaWithExample:()=>Gva,UnknownSchemaWithExample:()=>Rva,Webhook:()=>K0a,WebhookExampleCall:()=>G0a,WebhookHttpMethod:()=>J0a,WebsocketChannel:()=>Z0a,WebsocketHandshake:()=>Y0a,WebsocketHandshakeWithExample:()=>Udf,WebsocketMessageExample:()=>X0a,WebsocketSessionExample:()=>Q0a,WithAvailability:()=>Z0,WithDescription:()=>O_,WithEncoding:()=>Ene,WithName:()=>Ym,WithNamespace:()=>S5r,WithSdkGroupName:()=>w1,WithSource:()=>hb,WithTitle:()=>j1,commons:()=>Ylu,example:()=>Xlu,finalIr:()=>Qlu,parseIr:()=>Zlu});var Ylu={};Wb(Ylu,{BasicSecurityScheme:()=>f0a,BearerSecurityScheme:()=>d0a,Encoding:()=>u0a,HeaderSecurityScheme:()=>p0a,Namespace:()=>y0a,NamespaceId:()=>O0a,OauthSecurityScheme:()=>b0a,OpenApiSource:()=>n0a,ProtobufEncoding:()=>o0a,ProtobufSource:()=>i0a,QuerySecurityScheme:()=>_0a,SchemaId:()=>wQ,SdkGroup:()=>v0a,SdkGroupName:()=>w5r,SecurityScheme:()=>g0a,SecuritySchemeId:()=>l0a,Server:()=>m0a,Source:()=>a0a,StatusCode:()=>D5r,Tag:()=>c0a,TagId:()=>Kje,WithAvailability:()=>Z0,WithDescription:()=>O_,WithEncoding:()=>Ene,WithName:()=>Ym,WithNamespace:()=>S5r,WithSdkGroupName:()=>w1,WithSource:()=>hb,WithTitle:()=>j1});var Wn={};Wb(Wn,{JsonError:()=>g5r,ParseError:()=>m5r,any:()=>Edf,boolean:()=>Mdf,booleanLiteral:()=>Sdf,date:()=>hdf,discriminant:()=>Idf,enum_:()=>e0a,getObjectLikeUtils:()=>NRt,getObjectUtils:()=>O7n,getSchemaUtils:()=>hA,isProperty:()=>P5r,lazy:()=>ydf,lazyObject:()=>jdf,list:()=>r0a,number:()=>xdf,object:()=>t0a,objectWithoutOptionalProperties:()=>Pdf,optional:()=>$lu,property:()=>bdf,record:()=>Adf,set:()=>Ndf,string:()=>Tdf,stringLiteral:()=>Ddf,transform:()=>Jlu,undiscriminatedUnion:()=>Bdf,union:()=>Fdf,unknown:()=>qdf,withParsedProperties:()=>Klu});var VS={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 rC(e,t){return`Expected ${t}. Received ${C01(e)}.`}function C01(e){if(Array.isArray(e))return"list";if(e===null)return"null";switch(typeof e){case"string":return`"${e}"`;case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function KJ(e){return{...e,json:_df(e.json),parse:_df(e.parse)}}function _df(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1907
1907
|
`)),{ok:!0,value:t}):n}}function kya(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var g5r=class extends Error{errors;constructor(t){super(t.map(kya).join("; ")),this.errors=t,Object.setPrototypeOf(this,g5r.prototype)}};var m5r=class extends Error{errors;constructor(t){super(t.map(kya).join("; ")),this.errors=t,Object.setPrototypeOf(this,m5r.prototype)}};function hA(e){return{optional:()=>$lu(e),transform:t=>Jlu(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new m5r(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new g5r(n.errors)}}}function $lu(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>(n==null?void 0:n.omitUndefined)&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>VS.OPTIONAL};return{...t,...hA(t)}}function Jlu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...hA(r)}}var A01=/^([+-]?\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 hdf(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:rC(t,"string")}]}:A01.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:rC(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:rC(t,"Date object")}]},getType:()=>VS.DATE};return{...KJ(e),...hA(e)}}function YJ(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...KJ(r),...hA(r)}}}function e0a(e){let t=new Set(e);return YJ(VS.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:rC(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:rC(n,"enum")}]}:{ok:!0,value:n})()}function ydf(e){let t=Glu(e);return{...t,...hA(t)}}function Glu(e){return{parse:(t,r)=>m7n(e).parse(t,r),json:(t,r)=>m7n(e).json(t,r),getType:()=>m7n(e).getType()}}function m7n(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function x_i(e){return Object.entries(e)}function T_i(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function O5r(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 q_i(e){return Object.keys(e)}function vdf(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function NRt(e){return{withParsedProperties:t=>Klu(e,t)}}function Klu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let u=Object.entries(t).reduce((f,[d,c])=>({...f,[d]:typeof c=="function"?c(a.value):c}),{});return{ok:!0,value:{...a.value,...u}}},json:(n,i)=>{if(!O5r(n))return{ok:!1,errors:[{path:(i==null?void 0:i.breadcrumbsPrefix)??[],message:rC(n,"object")}]};let a=new Set(Object.keys(t)),u=T_i(n,Object.keys(n).filter(f=>!a.has(f)));return e.json(u,i)},getType:()=>e.getType()};return{...r,...hA(r),...NRt(r)}}function bdf(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function P5r(e){return e.isProperty}function t0a(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>P5r(n)?n.rawKey:r),_getParsedProperties:()=>q_i(e),parse:(r,n)=>{let i={},a=[];for(let[u,f]of x_i(e)){let d=P5r(f)?f.rawKey:u,c=P5r(f)?f.valueSchema:f,o={rawKey:d,parsedKey:u,valueSchema:c};i[d]=o,Odf(c)&&a.push(d)}return gdf({value:r,requiredKeys:a,getProperty:u=>{let f=i[u];if(f!=null)return{transformedKey:f.parsedKey,transform:d=>f.valueSchema.parse(d,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],u]})}},unrecognizedObjectKeys:n==null?void 0:n.unrecognizedObjectKeys,skipValidation:n==null?void 0:n.skipValidation,breadcrumbsPrefix:n==null?void 0:n.breadcrumbsPrefix,omitUndefined:n==null?void 0:n.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,u]of x_i(e)){let f=P5r(u)?u.valueSchema:u;Odf(f)&&i.push(a)}return gdf({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return P5r(u)?{transformedKey:u.rawKey,transform:f=>u.valueSchema.json(f,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],a]})}:{transformedKey:a,transform:f=>u.json(f,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],a]})}},unrecognizedObjectKeys:n==null?void 0:n.unrecognizedObjectKeys,skipValidation:n==null?void 0:n.skipValidation,breadcrumbsPrefix:n==null?void 0:n.breadcrumbsPrefix,omitUndefined:n==null?void 0:n.omitUndefined})},getType:()=>VS.OBJECT};return{...KJ(t),...hA(t),...NRt(t),...O7n(t)}}function gdf({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!O5r(e))return{ok:!1,errors:[{path:a,message:rC(e,"object")}]};let u=new Set(t),f=[],d={};for(let[c,o]of Object.entries(e)){let l=r(c);if(l!=null){u.delete(c);let g=l.transform(o);g.ok?d[l.transformedKey]=g.value:(d[c]=o,f.push(...g.errors))}else switch(n){case"fail":f.push({path:[...a,c],message:`Unexpected key "${c}"`});break;case"strip":break;case"passthrough":d[c]=o;break}}return f.push(...t.filter(c=>u.has(c)).map(c=>({path:a,message:`Missing required key "${c}"`}))),f.length===0||i?{ok:!0,value:d}:{ok:!1,errors:f}}function O7n(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>mdf({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>mdf({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>VS.OBJECT};return{...r,...hA(r),...NRt(r),...O7n(r)}}}}function mdf({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=vdf(q_i(t),c=>i.has(c)),f=r(T_i(t,u)),d=n(T_i(t,a));return f.ok&&d.ok?{ok:!0,value:{...f.value,...d.value}}:{ok:!1,errors:[...f.ok?[]:f.errors,...d.ok?[]:d.errors]}}function Odf(e){return!N01(e)}function N01(e){switch(e.getType()){case VS.ANY:case VS.UNKNOWN:case VS.OPTIONAL:return!0;default:return!1}}function Pdf(e){return t0a(e)}function jdf(e){let t={...Glu(e),_getRawProperties:()=>m7n(e)._getRawProperties(),_getParsedProperties:()=>m7n(e)._getParsedProperties()};return{...t,...hA(t),...NRt(t),...O7n(t)}}function r0a(e){let t={parse:(r,n)=>wdf(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],`[${a}]`]})),json:(r,n)=>wdf(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...(n==null?void 0:n.breadcrumbsPrefix)??[],`[${a}]`]})),getType:()=>VS.LIST};return{...KJ(t),...hA(t)}}function wdf(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:rC(e,"list"),path:[]}]}}function Ddf(e){return YJ(VS.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:rC(r,`"${e}"`)}]})()}function Sdf(e){return YJ(VS.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:rC(r,`${e.toString()}`)}]})()}var Edf=YJ(VS.ANY,e=>({ok:!0,value:e}));var Mdf=YJ(VS.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"boolean")}]});var xdf=YJ(VS.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"number")}]});var Tdf=YJ(VS.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:rC(e,"string")}]});var qdf=YJ(VS.UNKNOWN,e=>({ok:!0,value:e}));function Adf(e,t){let r={parse:(n,i)=>Cdf({value:n,isKeyNumeric:e.getType()===VS.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...(i==null?void 0:i.breadcrumbsPrefix)??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...i,breadcrumbsPrefix:[...(i==null?void 0:i.breadcrumbsPrefix)??[],`${u}`]}),breadcrumbsPrefix:i==null?void 0:i.breadcrumbsPrefix}),json:(n,i)=>Cdf({value:n,isKeyNumeric:e.getType()===VS.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...(i==null?void 0:i.breadcrumbsPrefix)??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...i,breadcrumbsPrefix:[...(i==null?void 0:i.breadcrumbsPrefix)??[],`${u}`]}),breadcrumbsPrefix:i==null?void 0:i.breadcrumbsPrefix}),getType:()=>VS.RECORD};return{...KJ(r),...hA(r)}}function Cdf({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return O5r(e)?x_i(e).reduce((a,[u,f])=>{if(f==null)return a;let d=a,c=u;if(t){let O=u.length>0?Number(u):NaN;isNaN(O)||(c=O)}let o=r(c),l=n(f,c);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let g=[];return d.ok||g.push(...d.errors),o.ok||g.push(...o.errors),l.ok||g.push(...l.errors),{ok:!1,errors:g}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:rC(e,"object")}]}}function Ndf(e){let t=r0a(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:(i==null?void 0:i.breadcrumbsPrefix)??[],message:rC(n,"Set")}]},getType:()=>VS.SET};return{...KJ(r),...hA(r)}}function Bdf(e){let t={parse:(r,n)=>zdf((i,a)=>i.parse(r,a),e,n),json:(r,n)=>zdf((i,a)=>i.json(r,a),e,n),getType:()=>VS.UNDISCRIMINATED_UNION};return{...KJ(t),...hA(t)}}function zdf(e,t,r){let n=[];for(let[i,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let f of u.errors)n.push({path:f.path,message:`[Variant ${i}] ${f.message}`})}return{ok:!1,errors:n}}function Idf(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Fdf(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=e0a(q_i(t)),a={parse:(u,f)=>Rdf({value:u,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:f==null?void 0:f.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(f==null?void 0:f.breadcrumbsPrefix)??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f==null?void 0:f.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.parse(d,f),breadcrumbsPrefix:f==null?void 0:f.breadcrumbsPrefix}),json:(u,f)=>Rdf({value:u,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:f==null?void 0:f.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...(f==null?void 0:f.breadcrumbsPrefix)??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f==null?void 0:f.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.json(d,f),breadcrumbsPrefix:f==null?void 0:f.breadcrumbsPrefix}),getType:()=>VS.UNION};return{...KJ(a),...hA(a),...NRt(a)}}function Rdf({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:f=[]}){if(!O5r(e))return{ok:!1,errors:[{path:f,message:rC(e,"object")}]};let{[t]:d,...c}=e;if(d==null)return{ok:!1,errors:[{path:f,message:`Missing discriminant ("${t}")`}]};let o=n(d);if(!o.ok)return{ok:!1,errors:o.errors};let l=i(o.value);if(l==null)return a?{ok:!0,value:{[r]:o.value,...c}}:{ok:!1,errors:[{path:[...f,t],message:"Unexpected discriminant value"}]};let g=u(c,l);return g.ok?{ok:!0,value:{[r]:d,...g.value}}:g}var j1=Wn.objectWithoutOptionalProperties({title:Wn.string().optional()});var n0a=Wn.objectWithoutOptionalProperties({file:Wn.string()});var i0a=Wn.objectWithoutOptionalProperties({file:Wn.string()});var a0a=Wn.union("type",{openapi:n0a,protobuf:i0a}).transform({transform:e=>{switch(e.type){case"openapi":return HSr.openapi(e);case"protobuf":return HSr.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var hb=Wn.objectWithoutOptionalProperties({source:a0a.optional()});var o0a=Wn.objectWithoutOptionalProperties({typeName:Wn.string()});var u0a=Wn.union("type",{protobuf:o0a}).transform({transform:e=>{switch(e.type){case"protobuf":return b7n.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Ene=Wn.objectWithoutOptionalProperties({encoding:u0a.optional()});var O_=Wn.objectWithoutOptionalProperties({description:Wn.string().optional()});var s0a=Wn.enum_(["GenerallyAvailable","Beta","Deprecated"]);var Z0=Wn.objectWithoutOptionalProperties({availability:s0a.optional()});var Ym=Wn.objectWithoutOptionalProperties({nameOverride:Wn.string().optional(),generatedName:Wn.string()});var wQ=Wn.string();var Kje=Wn.string();var c0a=Wn.objectWithoutOptionalProperties({id:Kje}).extend(O_);var l0a=Wn.string();var f0a=Wn.objectWithoutOptionalProperties({usernameVariableName:Wn.string().optional(),usernameEnvVar:Wn.string().optional(),passwordVariableName:Wn.string().optional(),passwordEnvVar:Wn.string().optional()});var d0a=Wn.objectWithoutOptionalProperties({tokenVariableName:Wn.string().optional(),tokenEnvVar:Wn.string().optional()});var p0a=Wn.objectWithoutOptionalProperties({headerName:Wn.string(),prefix:Wn.string().optional(),headerVariableName:Wn.string().optional(),headerEnvVar:Wn.string().optional()});var _0a=Wn.objectWithoutOptionalProperties({queryParameterName:Wn.string()});var h0a=Wn.objectWithoutOptionalProperties({snake:Wn.string().optional(),camel:Wn.string().optional(),screamingSnake:Wn.string().optional(),pascal:Wn.string().optional()});var j5r=Wn.objectWithoutOptionalProperties({nameOverride:Wn.string().optional(),generatedName:Wn.string(),value:Wn.string(),casing:h0a.optional()}).extend(O_).extend(Z0);var y0a=Wn.objectWithoutOptionalProperties({type:Wn.stringLiteral("namespace"),name:Wn.string()});var v0a=Wn.undiscriminatedUnion([Wn.string(),y0a]);var w5r=Wn.list(v0a);var w1=Wn.objectWithoutOptionalProperties({groupName:w5r.optional()});var P7n=Wn.objectWithoutOptionalProperties({default:j5r.optional(),values:Wn.list(j5r)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var b0a=Wn.objectWithoutOptionalProperties({scopesEnum:P7n.optional()});var g0a=Wn.union("type",{basic:f0a,bearer:d0a,header:p0a,query:_0a,oauth:b0a}).transform({transform:e=>{switch(e.type){case"basic":return F9.basic(e);case"bearer":return F9.bearer(e);case"header":return F9.header(e);case"query":return F9.query(e);case"oauth":return F9.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var D5r=Wn.number();var m0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),url:Wn.string(),audiences:Wn.list(Wn.string()).optional()}).extend(O_);var O0a=Wn.string();var S5r=Wn.objectWithoutOptionalProperties({namespace:Wn.string().optional()});var Xlu={};Wb(Xlu,{FullExample:()=>yA,FullObjectExample:()=>j0a,FullOneOfExample:()=>D0a,KeyValuePair:()=>w0a,LiteralExample:()=>P0a,PrimitiveExample:()=>w7n,PropertyKey:()=>j7n});var j7n=Wn.string();var w7n=Wn.union("type",{int:Wn.object({value:Wn.number()}),int64:Wn.object({value:Wn.number()}),uint:Wn.object({value:Wn.number()}),uint64:Wn.object({value:Wn.number()}),float:Wn.object({value:Wn.number()}),double:Wn.object({value:Wn.number()}),string:Wn.object({value:Wn.string()}),datetime:Wn.object({value:Wn.string()}),date:Wn.object({value:Wn.string()}),base64:Wn.object({value:Wn.string()}),boolean:Wn.object({value:Wn.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return t0.int(e.value);case"int64":return t0.int64(e.value);case"uint":return t0.uint(e.value);case"uint64":return t0.uint64(e.value);case"float":return t0.float(e.value);case"double":return t0.double(e.value);case"string":return t0.string(e.value);case"datetime":return t0.datetime(e.value);case"date":return t0.date(e.value);case"base64":return t0.base64(e.value);case"boolean":return t0.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var P0a=Wn.union("type",{boolean:Wn.object({value:Wn.boolean()}),string:Wn.object({value:Wn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return g7n.boolean(e.value);case"string":return g7n.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var yA=Wn.union("type",{primitive:Wn.object({value:w7n}),object:Wn.lazyObject(()=>j0a),array:Wn.object({value:Wn.list(Wn.lazy(()=>yA))}),map:Wn.object({value:Wn.list(Wn.lazyObject(()=>w0a))}),enum:Wn.object({value:Wn.string()}),literal:Wn.object({value:P0a}),oneOf:Wn.object({value:Wn.lazy(()=>D0a)}),unknown:Wn.object({value:Wn.lazy(()=>yA)})}).transform({transform:e=>{switch(e.type){case"primitive":return RP.primitive(e.value);case"object":return RP.object(e);case"array":return RP.array(e.value);case"map":return RP.map(e.value);case"enum":return RP.enum(e.value);case"literal":return RP.literal(e.value);case"oneOf":return RP.oneOf(e.value);case"unknown":return RP.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var j0a=Wn.objectWithoutOptionalProperties({properties:Wn.record(j7n,Wn.lazy(()=>yA))});var w0a=Wn.objectWithoutOptionalProperties({key:w7n,value:Wn.lazy(()=>yA)});var D0a=Wn.union("type",{discriminated:Wn.object({value:Wn.record(j7n,Wn.lazy(()=>yA))}),undisciminated:Wn.object({value:Wn.lazy(()=>yA)})}).transform({transform:e=>{switch(e.type){case"discriminated":return v5r.discriminated(e.value);case"undisciminated":return v5r.undisciminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Qlu={};Wb(Qlu,{AllOfPropertyConflict:()=>I7n,ArraySchema:()=>lva,Availability:()=>s0a,BooleanSchema:()=>iva,CasingOverrides:()=>h0a,CommonProperty:()=>bva,CursorPagination:()=>W0a,CustomCodeSample:()=>U0a,CustomCodeSampleLanguage:()=>R0a,CustomCodeSampleSdk:()=>L0a,DiscriminatedOneOfSchema:()=>yva,DoubleSchema:()=>rva,Endpoint:()=>$0a,EndpointExample:()=>N7n,EndpointSdkName:()=>M5r,EnumSchema:()=>P7n,EnumValue:()=>j5r,ErrorExample:()=>N0a,FernExample:()=>B0a,FileResponse:()=>T7n,FileSchema:()=>M0a,FullEndpointExample:()=>V0a,GlobalHeader:()=>ova,Header:()=>E5r,HeaderExample:()=>A7n,HttpEndpointServer:()=>q7n,HttpError:()=>z0a,HttpMethod:()=>D7n,IdempotencyHeader:()=>uva,IntSchema:()=>eva,JsonRequest:()=>q0a,JsonResponse:()=>KSr,LiteralSchema:()=>B7n,LiteralSchemaValue:()=>sva,LongSchema:()=>tva,MapSchema:()=>fva,MultipartRequest:()=>x7n,MultipartRequestProperty:()=>T0a,MultipartSchema:()=>x0a,NullableSchema:()=>pva,ObjectProperty:()=>hva,ObjectPropertyConflictInfo:()=>R7n,ObjectSchema:()=>cva,OctetStreamRequest:()=>M7n,OffsetPagination:()=>H0a,OneOfSchema:()=>_va,OpenApiIntermediateRepresentation:()=>Ldf,OptionalSchema:()=>dva,Pagination:()=>z7n,PathParameter:()=>S7n,PathParameterExample:()=>I0a,PrimitiveSchema:()=>T5r,PrimitiveSchemaValue:()=>ava,QueryParameter:()=>E7n,QueryParameterExample:()=>C7n,ReferencedSchema:()=>zRt,Request:()=>C0a,Response:()=>A0a,Schema:()=>D1,Schemas:()=>k0a,SdkGroupInfo:()=>S0a,StringSchema:()=>nva,SupportedSdkLanguage:()=>F0a,Tags:()=>E0a,TextResponse:()=>x5r,UnDiscriminatedOneOfSchema:()=>vva,Webhook:()=>K0a,WebhookExampleCall:()=>G0a,WebhookHttpMethod:()=>J0a,WebsocketChannel:()=>Z0a,WebsocketHandshake:()=>Y0a,WebsocketMessageExample:()=>X0a,WebsocketSessionExample:()=>Q0a});var S0a=Wn.objectWithoutOptionalProperties({summary:Wn.string().optional(),description:Wn.string().optional()});var E0a=Wn.objectWithoutOptionalProperties({tagsById:Wn.record(Kje,c0a),orderedTagIds:Wn.list(Kje).optional()});var D7n=Wn.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var S7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),variableReference:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var E7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var E5r=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>D1),env:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var M5r=Wn.objectWithoutOptionalProperties({groupName:w5r,methodName:Wn.string()});var M7n=Wn.objectWithoutOptionalProperties({}).extend(O_).extend(hb);var M0a=Wn.objectWithoutOptionalProperties({isOptional:Wn.boolean(),isArray:Wn.boolean()});var x0a=Wn.union("type",{file:M0a,json:Wn.object({value:Wn.lazy(()=>D1)})}).transform({transform:e=>{switch(e.type){case"file":return D2e.file(e);case"json":return D2e.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var T0a=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:x0a}).extend(O_);var x7n=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),properties:Wn.list(T0a)}).extend(O_).extend(hb);var q0a=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1),contentType:Wn.string().optional(),additionalProperties:Wn.boolean()}).extend(O_).extend(hb);var C0a=Wn.union("type",{octetStream:M7n,multipart:x7n,json:q0a}).transform({transform:e=>{switch(e.type){case"octetStream":return b5r.octetStream(e);case"multipart":return b5r.multipart(e);case"json":return b5r.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var T7n=Wn.objectWithoutOptionalProperties({}).extend(O_).extend(hb);var KSr=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1),responseProperty:Wn.string().optional()}).extend(O_).extend(hb);var x5r=Wn.objectWithoutOptionalProperties({}).extend(O_).extend(hb);var A0a=Wn.union("type",{file:T7n,json:KSr,text:x5r,streamingSse:KSr,streamingText:x5r,streamingJson:KSr}).transform({transform:e=>{switch(e.type){case"file":return Sne.file(e);case"json":return Sne.json(e);case"text":return Sne.text(e);case"streamingSse":return Sne.streamingSse(e);case"streamingText":return Sne.streamingText(e);case"streamingJson":return Sne.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var N0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),description:Wn.string().optional(),example:Wn.lazy(()=>yA)});var z0a=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>D1).optional(),examples:Wn.list(N0a).optional()}).extend(O_).extend(Ym).extend(hb);var q7n=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),url:Wn.string().optional(),audiences:Wn.list(Wn.string()).optional()});var B0a=Wn.unknown();var I0a=Wn.objectWithoutOptionalProperties({name:Wn.string(),parameterNameOverride:Wn.string().optional(),value:Wn.lazy(()=>yA)});var C7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),value:Wn.lazy(()=>yA)});var A7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),value:Wn.lazy(()=>yA)});var R0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),language:Wn.string(),code:Wn.string(),install:Wn.string().optional()}).extend(O_);var F0a=Wn.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var L0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),sdk:F0a,code:Wn.string()}).extend(O_);var U0a=Wn.union("type",{language:R0a,sdk:L0a}).transform({transform:e=>{switch(e.type){case"language":return JSr.language(e);case"sdk":return JSr.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var V0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),pathParameters:Wn.list(I0a).optional(),queryParameters:Wn.list(C7n).optional(),headers:Wn.list(A7n).optional(),request:Wn.lazy(()=>yA).optional(),response:Wn.lazy(()=>yA).optional(),codeSamples:Wn.list(U0a)}).extend(O_);var N7n=Wn.union("type",{unknown:Wn.object({value:B0a}),full:V0a}).transform({transform:e=>{switch(e.type){case"unknown":return pAt.unknown(e.value);case"full":return pAt.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var W0a=Wn.objectWithoutOptionalProperties({cursor:Wn.string(),nextCursor:Wn.property("next_cursor",Wn.string()),results:Wn.string()});var H0a=Wn.objectWithoutOptionalProperties({offset:Wn.string(),results:Wn.string(),step:Wn.string().optional(),hasNextPage:Wn.string().optional()});var z7n=Wn.union("type",{cursor:W0a,offset:H0a}).transform({transform:e=>{switch(e.type){case"cursor":return $Sr.cursor(e);case"offset":return $Sr.offset(e);default:return e}},untransform:({_visit:e,...t})=>t});var $0a=Wn.objectWithoutOptionalProperties({authed:Wn.boolean(),internal:Wn.boolean().optional(),idempotent:Wn.boolean().optional(),method:D7n,audiences:Wn.list(Wn.string()),path:Wn.string(),summary:Wn.string().optional(),operationId:Wn.string().optional(),tags:Wn.list(Kje),pathParameters:Wn.list(S7n),queryParameters:Wn.list(E7n),headers:Wn.list(E5r),sdkName:M5r.optional(),generatedRequestName:Wn.string(),requestNameOverride:Wn.string().optional(),request:C0a.optional(),response:A0a.optional(),errors:Wn.record(D5r,z0a),server:Wn.list(q7n),examples:Wn.list(N7n),pagination:z7n.optional()}).extend(O_).extend(Z0).extend(hb).extend(S5r);var J0a=Wn.enum_(["GET","POST"]);var G0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),payload:Wn.lazy(()=>yA)}).extend(O_);var K0a=Wn.objectWithoutOptionalProperties({sdkName:M5r.optional(),method:J0a,summary:Wn.string().optional(),operationId:Wn.string(),tags:Wn.list(Kje),headers:Wn.list(E5r),generatedPayloadName:Wn.string(),payload:Wn.lazy(()=>D1),examples:Wn.list(G0a)}).extend(O_).extend(hb).extend(S5r);var Y0a=Wn.objectWithoutOptionalProperties({queryParameters:Wn.list(E7n),headers:Wn.list(E5r),pathParameters:Wn.list(S7n)});var X0a=Wn.objectWithoutOptionalProperties({messageType:Wn.string(),payload:Wn.lazy(()=>yA)}).extend(O_);var Q0a=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),queryParameters:Wn.list(C7n).optional(),headers:Wn.list(A7n).optional(),messages:Wn.list(X0a)}).extend(O_);var Z0a=Wn.objectWithoutOptionalProperties({path:Wn.string(),groupName:w5r,summary:Wn.string().optional(),handshake:Y0a,publish:Wn.lazy(()=>D1).optional(),subscribe:Wn.lazy(()=>D1).optional(),examples:Wn.list(Q0a)}).extend(O_).extend(hb);var k0a=Wn.objectWithoutOptionalProperties({rootSchemas:Wn.record(wQ,Wn.lazy(()=>D1)),namespacedSchemas:Wn.record(O0a,Wn.record(wQ,Wn.lazy(()=>D1)))});var eva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),minimum:Wn.number().optional(),maximum:Wn.number().optional(),exclusiveMinimum:Wn.boolean().optional(),exclusiveMaximum:Wn.boolean().optional(),multipleOf:Wn.number().optional()});var tva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional()});var rva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),minimum:Wn.number().optional(),maximum:Wn.number().optional(),exclusiveMinimum:Wn.boolean().optional(),exclusiveMaximum:Wn.boolean().optional(),multipleOf:Wn.number().optional()});var nva=Wn.objectWithoutOptionalProperties({default:Wn.string().optional(),pattern:Wn.string().optional(),format:Wn.string().optional(),minLength:Wn.number().optional(),maxLength:Wn.number().optional()});var iva=Wn.objectWithoutOptionalProperties({default:Wn.boolean().optional()});var ava=Wn.union("type",{int:eva,int64:tva,uint:Wn.object({}),uint64:Wn.object({}),float:Wn.object({}),double:rva,string:nva,datetime:Wn.object({}),date:Wn.object({}),base64:Wn.object({}),boolean:iva}).transform({transform:e=>{switch(e.type){case"int":return Xw.int(e);case"int64":return Xw.int64(e);case"uint":return Xw.uint();case"uint64":return Xw.uint64();case"float":return Xw.float();case"double":return Xw.double(e);case"string":return Xw.string(e);case"datetime":return Xw.datetime();case"date":return Xw.date();case"base64":return Xw.base64();case"boolean":return Xw.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var T5r=Wn.objectWithoutOptionalProperties({schema:ava}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var ova=Wn.objectWithoutOptionalProperties({header:Wn.string(),name:Wn.string().optional(),optional:Wn.boolean().optional(),env:Wn.string().optional(),schema:Wn.lazy(()=>D1).optional()});var uva=Wn.objectWithoutOptionalProperties({header:Wn.string(),name:Wn.string().optional(),env:Wn.string().optional(),schema:Wn.lazy(()=>D1).optional()});var Ldf=Wn.objectWithoutOptionalProperties({apiVersion:Wn.unknown().optional(),title:Wn.string().optional(),description:Wn.string().optional(),basePath:Wn.string().optional(),servers:Wn.list(m0a),groups:Wn.record(Wn.string(),S0a),tags:E0a,hasEndpointsMarkedInternal:Wn.boolean(),endpoints:Wn.list($0a),webhooks:Wn.list(K0a),channel:Wn.list(Z0a),groupedSchemas:k0a,variables:Wn.record(Wn.string(),T5r),nonRequestReferencedSchemas:Wn.set(wQ),securitySchemes:Wn.record(l0a,g0a),globalHeaders:Wn.list(ova).optional(),idempotencyHeaders:Wn.list(uva).optional()});var zRt=Wn.objectWithoutOptionalProperties({schema:wQ}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var sva=Wn.union("type",{boolean:Wn.object({value:Wn.boolean()}),string:Wn.object({value:Wn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return E7.boolean(e.value);case"string":return E7.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var B7n=Wn.objectWithoutOptionalProperties({value:sva}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var D1=Wn.union("type",{primitive:T5r,object:Wn.lazyObject(()=>cva),array:Wn.lazyObject(()=>lva),map:Wn.lazyObject(()=>fva),optional:Wn.lazyObject(()=>dva),enum:P7n,reference:zRt,literal:B7n,oneOf:Wn.object({value:Wn.lazy(()=>_va)}),nullable:Wn.lazyObject(()=>pva),unknown:Ym}).transform({transform:e=>{switch(e.type){case"primitive":return ib.primitive(e);case"object":return ib.object(e);case"array":return ib.array(e);case"map":return ib.map(e);case"optional":return ib.optional(e);case"enum":return ib.enum(e);case"reference":return ib.reference(e);case"literal":return ib.literal(e);case"oneOf":return ib.oneOf(e.value);case"nullable":return ib.nullable(e);case"unknown":return ib.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var I7n=Wn.objectWithoutOptionalProperties({propertyKey:Wn.string(),allOfSchemaIds:Wn.list(wQ),conflictingTypeSignatures:Wn.boolean()});var cva=Wn.objectWithoutOptionalProperties({allOf:Wn.list(zRt),properties:Wn.list(Wn.lazyObject(()=>hva)),allOfPropertyConflicts:Wn.list(I7n),additionalProperties:Wn.boolean()}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var R7n=Wn.objectWithoutOptionalProperties({differentSchema:Wn.boolean()});var hva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>D1),conflict:Wn.record(wQ,R7n),generatedName:Wn.string(),nameOverride:Wn.string().optional(),audiences:Wn.list(Wn.string())}).extend(Z0);var lva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var fva=Wn.objectWithoutOptionalProperties({key:T5r,value:Wn.lazy(()=>D1)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(j1);var dva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var pva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>D1)}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var _va=Wn.union("type",{discriminated:Wn.lazyObject(()=>yva),undisciminated:Wn.lazyObject(()=>vva)}).transform({transform:e=>{switch(e.type){case"discriminated":return GSr.discriminated(e);case"undisciminated":return GSr.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var yva=Wn.objectWithoutOptionalProperties({discriminantProperty:Wn.string(),commonProperties:Wn.list(Wn.lazyObject(()=>bva)),schemas:Wn.record(Wn.string(),Wn.lazy(()=>D1))}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var bva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>D1)});var vva=Wn.objectWithoutOptionalProperties({schemas:Wn.list(Wn.lazy(()=>D1))}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var Zlu={};Wb(Zlu,{ArraySchemaWithExample:()=>Fva,Base64WithExample:()=>Nva,BooleanWithExample:()=>zva,CommonPropertyWithExample:()=>Kva,DateWithExample:()=>Ava,DatetimeWithExample:()=>Cva,DiscriminatedOneOfSchemaWithExample:()=>Jva,DoubleWithExample:()=>Tva,EndpointWithExample:()=>Vdf,EnumSchemaWithExample:()=>Iva,FloatWithExample:()=>xva,HeaderWithExample:()=>L7n,HttpErrorWithExample:()=>wva,Int64WithExample:()=>Sva,IntWithExample:()=>Dva,JsonRequestWithExample:()=>mva,JsonResponseWithExample:()=>Pva,MapSchemaWithExample:()=>Lva,NamedFullExample:()=>BRt,NullableSchemaWithExample:()=>Vva,ObjectPropertyWithExample:()=>$va,ObjectSchemaWithExample:()=>Wva,OneOfSchemaWithExample:()=>Hva,OptionalSchemaWithExample:()=>Uva,PathParameterWithExample:()=>gva,PrimitiveSchemaValueWithExample:()=>Bva,PrimitiveSchemaWithExample:()=>U7n,QueryParameterWithExample:()=>F7n,RequestWithExample:()=>Ova,ResponseWithExample:()=>jva,SchemaWithExample:()=>aq,StringSchemaWithExample:()=>qva,Uint64WithExample:()=>Mva,UintWithExample:()=>Eva,UnDiscriminatedOneOfSchemaWithExample:()=>Gva,UnknownSchemaWithExample:()=>Rva,WebsocketHandshakeWithExample:()=>Udf});var BRt=Wn.objectWithoutOptionalProperties({name:Wn.string().optional(),value:Wn.unknown()}).extend(O_);var F7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>aq),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var L7n=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>aq),env:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var Udf=Wn.objectWithoutOptionalProperties({queryParameters:Wn.list(F7n),headers:Wn.list(L7n)});var gva=Wn.objectWithoutOptionalProperties({name:Wn.string(),schema:Wn.lazy(()=>aq),variableReference:Wn.string().optional(),parameterNameOverride:Wn.string().optional()}).extend(O_).extend(Z0).extend(hb);var mva=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>aq),contentType:Wn.string().optional(),fullExamples:Wn.list(BRt).optional(),additionalProperties:Wn.boolean()}).extend(O_).extend(hb);var Ova=Wn.union("type",{octetStream:M7n,multipart:x7n,json:mva}).transform({transform:e=>{switch(e.type){case"octetStream":return S2e.octetStream(e);case"multipart":return S2e.multipart(e);case"json":return S2e.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var Pva=Wn.objectWithoutOptionalProperties({schema:Wn.lazy(()=>aq),responseProperty:Wn.string().optional(),fullExamples:Wn.list(BRt).optional()}).extend(O_).extend(hb);var jva=Wn.union("type",{file:T7n,json:Pva,text:x5r,streamingSse:KSr,streamingText:x5r,streamingJson:KSr}).transform({transform:e=>{switch(e.type){case"file":return T3.file(e);case"json":return T3.json(e);case"text":return T3.text(e);case"streamingSse":return T3.streamingSse(e);case"streamingText":return T3.streamingText(e);case"streamingJson":return T3.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var wva=Wn.objectWithoutOptionalProperties({statusCode:D5r,schema:Wn.lazy(()=>aq),fullExamples:Wn.list(BRt).optional()}).extend(O_).extend(Ym).extend(hb);var Vdf=Wn.objectWithoutOptionalProperties({authed:Wn.boolean(),internal:Wn.boolean().optional(),idempotent:Wn.boolean().optional(),method:D7n,audiences:Wn.list(Wn.string()),path:Wn.string(),summary:Wn.string().optional(),operationId:Wn.string().optional(),tags:Wn.list(Kje),pathParameters:Wn.list(gva),queryParameters:Wn.list(F7n),headers:Wn.list(L7n),sdkName:M5r.optional(),generatedRequestName:Wn.string(),requestNameOverride:Wn.string().optional(),request:Ova.optional(),response:jva.optional(),errors:Wn.record(D5r,wva),server:Wn.list(q7n),examples:Wn.list(N7n),pagination:z7n.optional()}).extend(O_).extend(Z0).extend(hb).extend(S5r);var Dva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),minimum:Wn.number().optional(),maximum:Wn.number().optional(),exclusiveMinimum:Wn.boolean().optional(),exclusiveMaximum:Wn.boolean().optional(),multipleOf:Wn.number().optional(),example:Wn.number().optional()});var Sva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var Eva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var Mva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),example:Wn.number().optional()});var xva=Wn.objectWithoutOptionalProperties({example:Wn.number().optional()});var Tva=Wn.objectWithoutOptionalProperties({default:Wn.number().optional(),minimum:Wn.number().optional(),maximum:Wn.number().optional(),exclusiveMinimum:Wn.boolean().optional(),exclusiveMaximum:Wn.boolean().optional(),multipleOf:Wn.number().optional(),example:Wn.number().optional()});var qva=Wn.objectWithoutOptionalProperties({default:Wn.string().optional(),pattern:Wn.string().optional(),format:Wn.string().optional(),minLength:Wn.number().optional(),maxLength:Wn.number().optional(),example:Wn.string().optional()});var Cva=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var Ava=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var Nva=Wn.objectWithoutOptionalProperties({example:Wn.string().optional()});var zva=Wn.objectWithoutOptionalProperties({default:Wn.boolean().optional(),example:Wn.boolean().optional()});var Bva=Wn.union("type",{int:Dva,int64:Sva,uint:Eva,uint64:Mva,float:xva,double:Tva,string:qva,datetime:Cva,date:Ava,base64:Nva,boolean:zva}).transform({transform:e=>{switch(e.type){case"int":return by.int(e);case"int64":return by.int64(e);case"uint":return by.uint(e);case"uint64":return by.uint64(e);case"float":return by.float(e);case"double":return by.double(e);case"string":return by.string(e);case"datetime":return by.datetime(e);case"date":return by.date(e);case"base64":return by.base64(e);case"boolean":return by.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var U7n=Wn.objectWithoutOptionalProperties({schema:Bva}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(j1);var Iva=Wn.objectWithoutOptionalProperties({default:j5r.optional(),values:Wn.list(j5r),example:Wn.string().optional()}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var Rva=Wn.objectWithoutOptionalProperties({example:Wn.unknown()}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(j1);var aq=Wn.union("type",{primitive:U7n,object:Wn.lazyObject(()=>Wva),array:Wn.lazyObject(()=>Fva),map:Wn.lazyObject(()=>Lva),optional:Wn.lazyObject(()=>Uva),enum:Iva,reference:zRt,literal:B7n,oneOf:Wn.object({value:Wn.lazy(()=>Hva)}),nullable:Wn.lazyObject(()=>Vva),unknown:Rva}).transform({transform:e=>{switch(e.type){case"primitive":return Lp.primitive(e);case"object":return Lp.object(e);case"array":return Lp.array(e);case"map":return Lp.map(e);case"optional":return Lp.optional(e);case"enum":return Lp.enum(e);case"reference":return Lp.reference(e);case"literal":return Lp.literal(e);case"oneOf":return Lp.oneOf(e.value);case"nullable":return Lp.nullable(e);case"unknown":return Lp.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var Fva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>aq),example:Wn.list(Wn.unknown()).optional()}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(j1);var Lva=Wn.objectWithoutOptionalProperties({key:U7n,value:Wn.lazy(()=>aq),example:Wn.unknown().optional()}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(Ene).extend(j1);var Uva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>aq)}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(j1);var Vva=Wn.objectWithoutOptionalProperties({value:Wn.lazy(()=>aq)}).extend(w1).extend(Ym).extend(O_).extend(Z0).extend(j1);var Wva=Wn.objectWithoutOptionalProperties({allOf:Wn.list(zRt),properties:Wn.list(Wn.lazyObject(()=>$va)),allOfPropertyConflicts:Wn.list(I7n),fullExamples:Wn.list(BRt).optional(),additionalProperties:Wn.boolean()}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(hb).extend(j1);var $va=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>aq),audiences:Wn.list(Wn.string()),conflict:Wn.record(wQ,R7n),nameOverride:Wn.string().optional(),generatedName:Wn.string()}).extend(Z0);var Hva=Wn.union("type",{discriminated:Wn.lazyObject(()=>Jva),undisciminated:Wn.lazyObject(()=>Gva)}).transform({transform:e=>{switch(e.type){case"discriminated":return jQ.discriminated(e);case"undisciminated":return jQ.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Jva=Wn.objectWithoutOptionalProperties({discriminantProperty:Wn.string(),commonProperties:Wn.list(Wn.lazyObject(()=>Kva)),schemas:Wn.record(Wn.string(),Wn.lazy(()=>aq))}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);var Kva=Wn.objectWithoutOptionalProperties({key:Wn.string(),schema:Wn.lazy(()=>aq)});var Gva=Wn.objectWithoutOptionalProperties({schemas:Wn.list(Wn.lazy(()=>aq))}).extend(O_).extend(Ym).extend(w1).extend(Z0).extend(Ene).extend(hb).extend(j1);function Yva(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:Ol(e.type)}}function V7n(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:Ol(e)}}function A2(e){return typeof e=="string"?e:e.type}function C_i(e){if(typeof e!="string")return e.docs}function Wdf(e){if(typeof e!="string")return e.default}function Hdf(e){if(typeof e!="string")return e.validation}function $df(e){if(e==null||e.length===0)return zui;let t=[];for(let[r,n]of e.entries())if(typeof n=="string")t.push(FE(n));else if(typeof n=="object")switch(n.type){case"namespace":{r<e.length-1?t.push(FE(n.name)):t.push(n.name,zui);break}default:Ol(n.type)}else Ol(n);return t.join("/")}function W7n(e){return zs.of(`${$df(e)}.yml`)}function klu({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?zui:(t!=null?r=[{type:"namespace",name:t}]:r=e.groupName,$df(r))}function Jdf({sdkName:e,namespaceOverride:t}){return zs.of(`${klu({sdkName:e,namespaceOverride:t})}.yml`)}function Gdf({location:e,namespaceOverride:t}){return t!=null?pf(zs.of(t),e):e}function q3(e){switch(e){case yW.Deprecated:return"deprecated";case yW.Beta:return"pre-release";case yW.GenerallyAvailable:return"generally-available";default:return}}var z01=-2147483648,B01=2147483647,I01=-17976931348623157e292,R01=17976931348623157e292;function S1({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i}){switch(e.type){case"primitive":return Xva(e);case"array":return rfu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"map":return nfu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"reference":return tfu({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return afu();case"optional":case"nullable":return ifu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"enum":return G01({schema:e,fileContainingReference:t,context:n,declarationFile:r});case"literal":return e.value,ofu(e);case"object":return K01({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"oneOf":return Y01({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i});default:Ol(e)}}function Xva(e){switch(e.schema.type){case"string":return U01({description:e.description,schema:e.schema});case"int":return V01({description:e.description,schema:e.schema});case"float":return W01({description:e.description,schema:e.schema});case"double":return H01({description:e.description,schema:e.schema});case"boolean":return F01({description:e.description,schema:e.schema});case"int64":return L01({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:{...e.title!=null?{"display-name":e.title}:{},type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function F01({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function L01({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function U01({description:e,schema:t}){let r="string",n=$01(t);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function V01({description:e,schema:t}){let r="integer",n=Kdf(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function W01({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function H01({description:e,schema:t}){let r="double",n=Kdf(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function $01(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,a=J01(t);if(!(a==null&&r==null&&n==null&&i==null))return{format:a,pattern:r,minLength:n,maxLength:i}}function J01(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 Kdf(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=efu(r,t),n=efu(n,t),i=efu(i,t),!(r==null&&n==null&&a==null&&u==null&&i==null))return{min:r,max:n,exclusiveMin:a,exclusiveMax:u,multipleOf:i}}function efu(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[z01,B01]:[I01,R01];return e<r||e>n?void 0:e}function tfu({schema:e,fileContainingReference:t,context:r,namespace:n}){let i=r.getSchema(e.schema,n);if(i==null)return"unknown";let a=X01(i)??e.schema,u=V7n(i),f=Q01(i),d=Qva({context:r,fileContainingReference:t,declarationFile:W7n(u),type:a}),c=i.type==="nullable"?`optional<${d}>`:d;return e.description==null&&f==null?c:{...f!=null?{"display-name":f}:{},type:i.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function rfu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=S1({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),u=`list<${A2(a)}>`;return e.description==null&&e.title==null?u:{...e.title!=null?{"display-name":e.title}:{},...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{},type:u}}function nfu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=Xva(e.key),u=S1({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),f=e.encoding!=null?Yva(e.encoding):void 0,d=`map<${A2(a)}, ${A2(u)}>`;if(e.description==null&&f==null&&e.title==null)return d;let c={type:d};return e.description!=null&&(c.docs=e.description),e.encoding!=null&&(c.encoding=f),e.title!=null&&(c["display-name"]=e.title),e.availability!=null&&(c.availability=q3(e.availability)),c}function ifu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=S1({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),u=A2(a),f=C_i(a),d=Wdf(a),c=Hdf(a),o=u.startsWith("optional<")?u:`optional<${u}>`;if(e.availability==null&&e.description==null&&f==null&&d==null&&c==null&&e.title==null)return o;let l={type:o};return(e.description!=null||f!=null)&&(l.docs=e.description??f),d!=null&&(l.default=d),c!=null&&(l.validation=c),e.title!=null&&(l["display-name"]=e.title),e.availability!=null&&(l.availability=q3(e.availability)),l}function afu(){return"unknown"}function ofu(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:Ol(e.value)}return e.description==null&&e.title==null?t:{...e.title!=null?{"display-name":e.title}:{},type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function G01({schema:e,fileContainingReference:t,declarationFile:r,context:n}){let i=A_i(e),a=e.nameOverride??e.generatedName;n.builder.addType(r,{name:a,schema:i.schema});let u=Qva({type:a,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return u;let f={type:u};return e.description!=null&&(f.docs=e.description),e.default!=null&&(f.default=e.default.value),e.title!=null&&(f["display-name"]=e.title),e.availability!=null&&(f.availability=q3(e.availability)),f}function K01({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=ufu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=Qva({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{...e.title!=null?{"display-name":e.title}:{},type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function Y01({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=sfu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=Qva({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{...e.title!=null?{"display-name":e.title}:{},type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:q3(e.availability)}:{}}}function Qva({type:e,fileContainingReference:t,declarationFile:r,context:n}){if(r===t)return e;let i=n.builder.addImport({file:t,fileToImport:r});return i!=null?`${i}.${e}`:e}function X01(e){return ib._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 Q01(e){return ib._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 Ien(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Ol(e)}}function Xdf({schema:e,context:t,declarationFile:r,namespace:n}){switch(e.type){case"primitive":return ev1(e);case"array":return Z01({schema:e,context:t,declarationFile:r,namespace:n});case"map":return k01({schema:e,context:t,declarationFile:r,namespace:n});case"reference":return tv1({schema:e,context:t,declarationFile:r,namespace:n});case"unknown":return nv1(e.nameOverride,e.generatedName);case"optional":case"nullable":return rv1({schema:e,context:t,declarationFile:r,namespace:n});case"enum":return A_i(e);case"literal":return iv1(e,e.nameOverride,e.generatedName);case"object":return ufu({schema:e,context:t,declarationFile:r,namespace:n});case"oneOf":return sfu({schema:e.value,context:t,declarationFile:r,namespace:n});default:Ol(e)}}function ufu({schema:e,context:t,declarationFile:r,namespace:n}){let i={},a=new Set;for(let c of e.properties){if(Object.keys(c.conflict).length>0){if(Object.entries(c.conflict).every(([S,x])=>!x.differentSchema))continue;Object.entries(c.conflict).forEach(([S])=>{cfu({property:c.key,schemaId:S,context:t,namespace:n}).forEach(A=>{a.add(A)})})}let o=S1({schema:c.schema,context:t,fileContainingReference:r,namespace:n}),l=c.audiences,g=c.nameOverride,O=q3(c.availability);i[c.key]=uv1(o,l,g,O)}let u=new Set;for(let c of e.allOfPropertyConflicts)c.allOfSchemaIds.forEach(o=>a.add(o)),c.conflictingTypeSignatures&&u.add(c.propertyKey);let f=[];for(let c of e.allOf){let o=Qdf({schema:c.schema,context:t,namespace:n});if(o==null||a.has(c.schema)||a.has(o))continue;let l=S1({schema:ib.reference(c),context:t,fileContainingReference:r,namespace:n});f.push(A2(l))}for(let c of a){let o=lfu(t,c,n);for(let l of o.properties)i[l.key]==null&&(u.has(l.key)&&(i[l.key]="unknown"),i[l.key]=S1({schema:l.schema,context:t,fileContainingReference:r,namespace:n}));for(let l of o.allOf){if(a.has(l.schema))continue;let g=S1({schema:ib.reference(l),context:t,fileContainingReference:r,namespace:n});f.push(A2(g))}}let d={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(i).map(([c,o])=>ov1(c)?[c,typeof o=="string"?{type:o,name:`_${c}`}:{...o,name:`_${c}`}]:[c,o]))};return f.length>0&&(d.extends=f),e.additionalProperties&&(d["extra-properties"]=!0),e.availability!=null&&(d.availability=q3(e.availability)),e.source!=null&&(d.source=Ien(e.source)),{name:e.nameOverride??e.generatedName,schema:d}}function cfu({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return cfu({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:a,allOf:u}=lfu(r,t,n),f=a.some(c=>c.key===e),d=[...u.flatMap(c=>cfu({property:e,context:r,schemaId:c.schema,namespace:n}))];if(f||d.length>0)return[t,...d]}return[]}function lfu(e,t,r){let n=e.getSchema(t,r);if(n==null)return{properties:[],allOf:[]};if(n.type==="object")return{properties:n.properties,allOf:n.allOf};if(n.type==="reference")return lfu(e,n.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${n.type}`)}function Z01({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:rfu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function k01({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:nfu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function ev1(e){let t=Xva(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...n}=t;return{name:e.nameOverride??e.generatedName,schema:{...n}}}function Ydf(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function A_i(e){let t={enum:e.values.map(i=>{let a=i.nameOverride??i.generatedName,u=i.value;if(a===u&&i.description==null&&(i.casing==null||Ydf(i.casing)))return a;let f={value:i.value};if(a!==u&&(f.name=a),i.description!=null&&(f.docs=i.description),i.casing!=null&&!Ydf(i.casing)){let d={},c=!1;i.casing.camel!=null&&(d.camel=i.casing.camel,c=!0),i.casing.screamingSnake!=null&&(d["screaming-snake"]=i.casing.screamingSnake,c=!0),i.casing.snake!=null&&(d.snake=i.casing.snake,c=!0),i.casing.pascal!=null&&(d.pascal=i.casing.pascal,c=!0),c&&(f.casing=d)}return f})};e.description!=null&&(t.docs=e.description),e.default!=null&&(t.default=e.default.value);let r=new Set,n={...t,enum:[],source:e.source!=null?Ien(e.source):void 0};for(let i of t.enum){let a=typeof i=="string"?i:i.name??i.value;r.has(a.toLowerCase())||(n.enum.push(i),r.add(a.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function tv1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:tfu({schema:e,context:t,fileContainingReference:r,namespace:n})}}function rv1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:ifu({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n})}}function nv1(e,t){return{name:e??t,schema:afu()}}function iv1(e,t,r){return{name:t??r,schema:ofu(e)}}function sfu({schema:e,context:t,declarationFile:r,namespace:n}){let i=e.encoding!=null?Yva(e.encoding):void 0;if(e.type==="discriminated"){let u={};for(let d of e.commonProperties)u[d.key]=S1({schema:d.schema,fileContainingReference:r,context:t,namespace:n});let f={};for(let[d,c]of Object.entries(e.schemas))f[d]=S1({schema:c,context:t,fileContainingReference:r,namespace:n});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":u,docs:e.description??void 0,availability:e.availability!=null?q3(e.availability):void 0,union:f,encoding:i,source:e.source!=null?Ien(e.source):void 0}}}let a=[];for(let u of e.schemas)a.push(S1({schema:u,fileContainingReference:r,context:t,namespace:n}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:a,encoding:i,source:e.source!=null?Ien(e.source):void 0}}}var av1=/^[0-9]/;function ov1(e){return av1.test(e)}function Qdf({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?Qdf({context:t,schema:n.schema,namespace:r}):e}function uv1(e,t,r,n){return t.length===0&&r==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...n!=null?{availability:n}:{}}}function Zdf(e){let t=e.replace(/^x-|^X-/,"");return FE(t)}var kdf="BasicAuthScheme",Zva="BearerAuthScheme";function epf(e){if(e.authOverrides!=null){for(let[r,n]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:n});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,n]of Object.entries(e.ir.securitySchemes))if(n.type==="basic"){let i={scheme:"basic"};n.usernameVariableName!=null&&(i.username===void 0?i.username={name:n.usernameVariableName}:i.username.name=n.usernameVariableName),n.usernameEnvVar!=null&&(i.username===void 0?i.username={env:n.usernameEnvVar}:i.username.env=n.usernameEnvVar),n.passwordVariableName!=null&&(i.password===void 0?i.password={name:n.passwordVariableName}:i.password.name=n.passwordVariableName),n.passwordEnvVar!=null&&(i.password===void 0?i.password={env:n.passwordEnvVar}:i.password.env=n.passwordEnvVar),e.builder.addAuthScheme({name:kdf,schema:i}),t||(e.builder.setAuth(kdf),t=!0)}else if(n.type==="bearer"){let i={scheme:"bearer"};n.tokenVariableName!=null&&(i.token===void 0?i.token={name:n.tokenVariableName}:i.token.name=n.tokenVariableName),n.tokenEnvVar!=null&&(i.token===void 0?i.token={env:n.tokenEnvVar}:i.token.env=n.tokenEnvVar),e.builder.addAuthScheme({name:Zva,schema:i}),t||(e.builder.setAuth(Zva),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??Zdf(n.headerName),env:n.headerEnvVar}});else{let i={header:n.headerName,name:n.headerVariableName??"apiKey",type:"string"};n.headerEnvVar!=null&&(i.env=n.headerEnvVar),n.prefix!=null&&(i.prefix=n.prefix),e.builder.addAuthScheme({name:r,schema:i}),e.builder.setAuth(r),t=!0}else if(n.type==="oauth"){let i={scheme:"bearer"};e.builder.addAuthScheme({name:Zva,schema:i}),t||(e.builder.setAuth(Zva),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(zs.of("__package__.yml"),{name:"OauthScope",schema:A_i(n.scopesEnum).schema})}}function IRt({header:e,context:t,fileContainingReference:r,namespace:n}){let i=S1({schema:e.schema,context:t,fileContainingReference:r,namespace:n}),a=A2(i),u=e.name.replace(/^x-|^X-/,""),f=e.parameterNameOverride!=null?e.parameterNameOverride:FE(u);if(e.description==null&&e.name===f&&e.env==null&&e.availability==null)return a;let d={type:a};return f!==e.name&&(d.name=f),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=q3(e.availability)),d}function kva({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=S1({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(e.variableReference==null&&e.description==null&&e.availability==null)return A2(i);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:A2(i)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=q3(e.availability)),a}var Zmu=require("fs/promises");var tpf={naming:"v1"};function Lh(e,t){let r=Array.isArray(t)?t:[t];for(let n of r){let i=e[n];if(i!=null)return i}}function RRt(e,t,r,n,i=[]){try{let a=Lh(e,t);if(a!=null)return r.parse(a)}catch{let u=X8t(i).join(" -> ");n.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}var eba={of(e){return e}};var kh={SDK_METHOD_NAME:eba.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:eba.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:eba.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport"};function gy(e){return e.$ref!=null}function E2e(e){switch(Lh(e,kh.AVAILABILITY)){case"deprecated":return yW.Deprecated;case"beta":return yW.Beta;case"generally-available":return yW.GenerallyAvailable;default:break}if(!gy(e)&&e.deprecated)return yW.Deprecated}var Yje={BEARER_FORMAT:"x-bearer-format",ENUM_VAR_NAMES:"x-enum-varnames",INTERNAL:"x-internal",EXAMPLES:"x-examples",TAGS:"x-tags",REDOCLY_CODE_SAMPLES_KEBAB:"x-code-samples",REDOCLY_CODE_SAMPLES_CAMEL:"x-codeSamples"};function rpf({schema:e,logger:t}){return RRt(e,kh.ENCODING,h5.EncodingSchema,t)??void 0}function npf(e){return Lh(e,kh.FERN_ENUM)}function ipf({nameOverride:e,generatedName:t,title:r,schema:n,description:i,availability:a}){let u=Lh(n,kh.SDK_GROUP_NAME),f=Lh(n,kh.TYPE_DEFINITION);if(f!=null)return N_i({fernType:f,nameOverride:e,generatedName:t,title:r,description:i,availability:a,groupName:typeof u=="string"?[u]:u})}function N_i({fernType:e,nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u}){return BJ({type:e,_default:void 0,validation:void 0,visitor:{primitive:f=>{switch(f.v1){case"BASE_64":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.base64({example:void 0})});case"BOOLEAN":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.boolean({default:void 0,example:void 0})});case"DATE":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.date({example:void 0})});case"DATE_TIME":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.datetime({example:void 0})});case"FLOAT":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.float({example:void 0})});case"DOUBLE":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.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 Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.uint({default:void 0,example:void 0})});case"INTEGER":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.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 Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.uint64({default:void 0,example:void 0})});case"LONG":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return Lp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:by.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:Ol(f.v1)}},unknown:()=>Lp.unknown({nameOverride:t,generatedName:r,title:n,example:void 0,description:i,availability:a,groupName:u}),map:({keyType:f,valueType:d})=>(f==null?void 0:f.type)==="primitive"&&d!=null?Lp.map({nameOverride:t,generatedName:r,title:n,key:f,value:d,description:i,availability:a,groupName:u,encoding:void 0,example:void 0}):void 0,list:f=>f!=null?Lp.array({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u,example:void 0}):void 0,optional:f=>f!=null?Lp.optional({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u}):void 0,set:f=>f!=null?Lp.array({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u,example:void 0}):void 0,literal:f=>Lp.literal({nameOverride:t,generatedName:r,title:n,value:f._visit({string:d=>E7.string(d),boolean:d=>E7.boolean(d),_other:()=>{throw new Error("Unexpected literal type")}}),description:i,availability:a,groupName:u}),named:()=>{}}})}function Ren(e){if(e!=null&&typeof e=="boolean")return e}function apf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,additionalProperties:i,description:a,availability:u,wrapAsNullable:f,context:d,groupName:c,example:o,encoding:l,source:g,namespace:O}){return typeof i=="boolean"||H7n(i)?tba({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:by.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:Lp.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:void 0}),groupName:c,example:o,encoding:l}):tba({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:by.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:L1(i,d.options.optionalAdditionalProperties?f:!1,d,[...n,"Value"],g,O),groupName:c,example:o,encoding:l})}function tba({nameOverride:e,generatedName:t,title:r,keySchema:n,valueSchema:i,wrapAsNullable:a,description:u,availability:f,groupName:d,example:c,encoding:o}){return a?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.map({nameOverride:e,generatedName:t,title:r,description:u,availability:n.availability,key:n,value:i,groupName:d,encoding:o,example:c}),description:u,availability:f,groupName:d}):Lp.map({nameOverride:e,generatedName:t,title:r,description:u,availability:f,key:n,value:i,groupName:d,encoding:o,example:c})}function H7n(e){return e==null?!1:typeof e=="boolean"?e:!gy(e)&&Object.keys(e).length===0}function opf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,item:i,description:a,availability:u,wrapAsNullable:f,context:d,groupName:c,example:o,source:l,namespace:g}){let O=i==null?Lp.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,groupName:c}):L1(i,!1,d,[...n,"Item"],l,g);return sv1({nameOverride:e,generatedName:t,title:r,groupName:c,itemSchema:O,wrapAsNullable:f,description:a,availability:u,example:o})}function sv1({nameOverride:e,generatedName:t,title:r,itemSchema:n,wrapAsNullable:i,description:a,availability:u,groupName:f,example:d}){return i?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,groupName:f,example:d}),description:a,availability:u,groupName:f}):Lp.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,groupName:f,example:d})}function ffu({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:f,wrapAsNullable:d,discriminator:c,context:o,groupName:l,encoding:g,source:O,namespace:j}){let S=c.propertyName,x=Object.fromEntries(Object.entries(c.mapping??{}).map(([z,N])=>{let C=$7n({$ref:N},!1,o,[N],g,O,j);return o.markReferencedByDiscriminatedUnion({$ref:N},S,1),[z,C]})),A=Object.entries(i).filter(([z])=>z!==S).map(([z,N])=>{let C=f!=null&&f.includes(z),U=L1(N,!C,o,[...n,z],O,j);return{key:z,schema:U}});return upf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:A,description:a,availability:u,discriminant:S,subtypes:x,groupName:l,source:O})}function dfu({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:f,wrapAsNullable:d,discriminant:c,variants:o,context:l,groupName:g,encoding:O,source:j,namespace:S}){let x=Object.fromEntries(Object.entries(o).map(([z,N])=>{if(gy(N)){let C=$7n(N,!1,l,[N.$ref],O,j,S);return l.markReferencedByDiscriminatedUnion(N,c,1),[z,C]}else{let C=q5r(N,!1,l,[...n,z],O,j,S,new Set([c]));return[z,C]}})),A=Object.entries(i).filter(([z])=>z!==c).map(([z,N])=>{let C=f!=null&&f.includes(z),U=L1(N,!C,l,[...n,z],j,S);return{key:z,schema:U}});return upf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:A,description:a,availability:u,discriminant:c,subtypes:x,groupName:g,source:j})}function upf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,availability:u,discriminant:f,subtypes:d,groupName:c,source:o}){return n?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.oneOf(jQ.discriminated({description:a,availability:u,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:i,groupName:c,encoding:void 0,source:o})),groupName:c,description:a,availability:u}):Lp.oneOf(jQ.discriminated({description:a,availability:u,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:i,groupName:c,encoding:void 0,source:o}))}function spf(e){if(e.proto!=null)return b7n.protobuf({typeName:e.proto.type})}var cv1=/^(\d+)/;function rba(e){let t=e.match(cv1);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let a=J7n(i);return n.length>0?`${a}_${n}`:a}}}function J7n(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],n=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let u=Math.floor(e/10),f=e%10;return f===0?n[u]:`${n[u]}_${t[f]}`}if(e<1e3){let u=Math.floor(e/100),f=e%100;return f===0?`${t[u]}_hundred`:`${t[u]}_hundred_${J7n(f)}`}let i=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[i]}_thousand`:`${t[i]}_thousand_${J7n(a)}`}var G7n=/^[a-zA-Z][a-zA-Z0-9_]*$/;function C5r({nameOverride:e,generatedName:t,title:r,fernEnum:n,enumVarNames:i,enumValues:a,_default:u,description:f,availability:d,wrapAsNullable:c,groupName:o,context:l,source:g}){let O=dv1(i??[]),j=new Set(a),S=Array.from(j).map((A,z)=>{var G,$,ee,Ve;let N=n==null?void 0:n[A],C=O[z],U=G7n.test(A),Y=(N==null?void 0:N.name)??C,te=U?A:z_i(A);return Y!=null&&!G7n.test(Y)&&(l==null||l.logger.warn(`Enum name override ${Y} is not a valid name. Falling back on ${te}.`),Y=void 0),{nameOverride:Y,generatedName:te,value:A,description:N==null?void 0:N.description,availability:d,casing:{snake:((G=N==null?void 0:N.casing)==null?void 0:G.snake)??void 0,pascal:(($=N==null?void 0:N.casing)==null?void 0:$.pascal)??void 0,screamingSnake:((ee=N==null?void 0:N.casing)==null?void 0:ee.screamingSnake)??void 0,camel:((Ve=N==null?void 0:N.casing)==null?void 0:Ve.camel)??void 0}}}),x=u!=null?S.find(A=>A.value===u):void 0;return lv1({wrapAsNullable:c,nameOverride:e,generatedName:t,title:r,values:S,_default:x,description:f,availability:d,groupName:o,source:g})}function lv1({wrapAsNullable:e,nameOverride:t,generatedName:r,title:n,values:i,_default:a,description:u,availability:f,groupName:d,source:c}){return e?Lp.nullable({nameOverride:t,generatedName:r,title:n,value:Lp.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,default:a,availability:f,example:void 0,groupName:d,source:c}),description:u,availability:f,groupName:d}):Lp.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,availability:f,default:a,example:void 0,groupName:d,source:c})}var fv1={"<":"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 z_i(e){let t=rba(e),r=fv1[e];return t!=null?ZX(FE(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":ZX(FE(e)))}function dv1(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(n=>n[r]===t[r]);)r++;return e.map(n=>n.substring(r))}function cpf({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,description:o,availability:l,wrapAsNullable:g,example:O,groupName:j}){return n==="int64"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.int64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="uint32"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.uint({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="uint64"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.uint64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):L9({nameOverride:e,generatedName:t,title:r,primitive:by.int({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j})}function lpf(e){return typeof e=="string"?E7.string(e):typeof e=="boolean"?E7.boolean(e):E7.string(`${e}`)}function fpf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,value:i,description:a,availability:u,groupName:f}){return n?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.literal({nameOverride:e,generatedName:t,title:r,value:lpf(i),description:a,availability:u,groupName:f}),description:a,availability:u,groupName:f}):Lp.literal({nameOverride:e,generatedName:t,title:r,value:lpf(i),description:a,availability:u,groupName:f})}function pfu({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,description:o,availability:l,wrapAsNullable:g,example:O,groupName:j}){return n==null||n==="double"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.double({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="float"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.float({example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="int32"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.int({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="int64"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.int64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="uint32"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.uint({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="uint64"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.uint64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):n==="time-delta"?L9({nameOverride:e,generatedName:t,title:r,primitive:by.float({example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j}):L9({nameOverride:e,generatedName:t,title:r,primitive:by.float({example:O}),wrapAsNullable:g,description:o,availability:l,groupName:j})}var pv1={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},_v1={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}}},hv1={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}}},yv1={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},vv1={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},bv1={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},gv1={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},mv1={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function nba(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],n=[pv1,_v1,hv1,yv1,vv1,bv1,gv1,mv1],i;do{i=t;for(let a of n)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:f}=a.applyStrategy(t);t=u,r=[...r,...f]}}while(t.join("")!==i.join(""));return r}function yR(e){let t=e.join("_"),r=ZX(FE(t));return/^\d/.test(r)?rba(r)??r:r}function _fu(e){let t=e.join("_");return FE(t)}function oq(e){switch(e.type){case"object":return ib.object({allOf:e.allOf,properties:e.properties.map(t=>Pv1(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source});case"array":return ib.array({description:e.description,availability:e.availability,value:oq(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"enum":return ib.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,groupName:e.groupName,source:e.source});case"literal":return ib.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 ib.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:oq(e.value),groupName:e.groupName});case"optional":return ib.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:oq(e.value),groupName:e.groupName});case"primitive":return ib.primitive({description:e.description,availability:e.availability,schema:dpf(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return ib.map({description:e.description,availability:e.availability,key:ib.primitive({description:e.key.description,availability:e.key.availability,schema:dpf(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,groupName:e.groupName}),value:oq(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,encoding:e.encoding});case"reference":return ib.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 ib.oneOf(Ov1(e.value));case"unknown":return ib.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:Ol(e)}}function Ov1(e){switch(e.type){case"discriminated":return GSr.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:oq(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,oq(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return GSr.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>oq(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:Ol(e)}}function dpf(e){switch(e.type){case"string":return Xw.string(e);case"base64":return Xw.base64();case"boolean":return Xw.boolean(e);case"date":return Xw.date();case"datetime":return Xw.datetime();case"double":return Xw.double(e);case"float":return Xw.float();case"int":return Xw.int(e);case"int64":return Xw.int64(e);case"uint":return Xw.uint();case"uint64":return Xw.uint64();default:Ol(e)}}function Pv1(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:oq(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability}}function iba(e,t){return FRt(oq(e),oq(t))}function FRt(e,t){return e.type==="primitive"&&t.type==="primitive"?ppf(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?jv1(e.values,t.values):e.type==="array"&&t.type==="array"?FRt(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"?FRt(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?wv1(e.value,t.value):e.type==="object"&&t.type==="object"?Dv1(e,t):e.type==="map"&&t.type==="map"?ppf(e.key.schema,t.key.schema)&&FRt(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function ppf(e,t){return e.type===t.type}function jv1(e,t){let r=new Set(...e.map(i=>i.value)),n=new Set(...t.map(i=>i.value));return iDr(r,n)}function wv1(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,n])=>{let i=t.schemas[r];return i==null?!1:FRt(n,i)}):e.type==="undisciminated"&&t.type==="undisciminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,n)=>{let i=t.schemas[n];return i==null?!1:FRt(r,i)}):!1}function Dv1(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(n=>[n.key,n.schema]));return Object.entries(t.properties).every(([n,i])=>{let a=r[n];return a==null?!1:FRt(a,i.schema)})}function _pf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,required:u,wrapAsNullable:f,allOf:d,context:c,propertiesToExclude:o,groupName:l,fullExamples:g,additionalProperties:O,availability:j,encoding:S,source:x,namespace:A}){let z=[...u??[]],N={...i},C=[],U=[];for(let $ of d)if(gy($)){let ee=c.resolveSchemaReference($);if(ee.discriminator!=null&&ee.discriminator.mapping!=null)continue;if(ee.oneOf!=null){for(let $e of ee.oneOf){let Dt=gy($e)?c.resolveSchemaReference($e):$e,Tt=L1(Dt,!1,c.DUMMY,n,x,A);Tt.type==="object"&&C.push(...Tt.properties.map(Wt=>Wt.schema.type!=="optional"&&Wt.schema.type!=="nullable"?{...Wt,schema:Lp.optional({nameOverride:void 0,generatedName:"",title:void 0,value:Wt.schema,description:void 0,availability:Wt.availability,groupName:void 0})}:Wt))}continue}let Ve=A5r($);if(Ve==null)continue;U.push({schemaId:Ve,convertedSchema:hfu($,[Ve],x),properties:hpf({schema:$,context:c,breadcrumbs:n,source:x,namespace:A})}),c.markSchemaAsReferencedByNonRequest(Ve)}else{let ee=L1($,!1,c,n,x,A);ee.type==="object"&&C.push(...ee.properties)}let Y={};for(let $ of U)for(let[ee,Ve]of Object.entries($.properties)){let $e=Y[ee];$e!=null?($e.schemaIds.push($.schemaId),$e.schemas.some(Tt=>iba(Tt,Ve))||$e.schemas.push(Ve)):Y[ee]={schemaIds:[$.schemaId],schemas:[Ve]}}let te=[];for(let[$,ee]of Object.entries(Y))ee.schemaIds.length>1&&te.push({propertyKey:$,allOfSchemaIds:ee.schemaIds,conflictingTypeSignatures:ee.schemas.length>1});let G=Object.entries(N).map(([$,ee])=>{let Ve=z.includes($),$e=Lh(ee,kh.AUDIENCES)??[],Dt=E2e(ee),Tt=Lh(ee,kh.FERN_PROPERTY_NAME),Wt=[...n,$],Nt=_fu(Wt),ur=Ve?L1(ee,!1,c,Wt,x,A):Lp.optional({nameOverride:e,generatedName:Nt,title:r,description:void 0,availability:Dt,value:L1(ee,!1,c,Wt,x,A),groupName:l}),Ar={};for(let Gr of U){let zt=Gr.properties[$];zt!=null&&!iba(ur,zt)?Ar[Gr.schemaId]={differentSchema:!0}:zt!=null&&(Ar[Gr.schemaId]={differentSchema:!1})}return{key:$,schema:ur,nameOverride:Tt,audiences:$e,conflict:Ar,generatedName:_fu([...n,$]),availability:Dt}});return G.push(...C.map($=>{let ee=$.conflict;for(let Ve of U){let $e=Ve.properties[$.key];$e!=null&&!iba($.schema,$e)?ee[Ve.schemaId]={differentSchema:!0}:$e!=null&&(ee[Ve.schemaId]={differentSchema:!1})}return{...$,conflict:ee}})),Sv1({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,properties:G.filter($=>!o.has($.key)),description:a,allOf:U.map($=>$.convertedSchema),allOfPropertyConflicts:te,groupName:l,fullExamples:g,additionalProperties:O,availability:j,source:x})}function Sv1({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:o,availability:l,source:g}){return n?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:H7n(o),availability:void 0,source:g}),description:a,availability:l,groupName:d}):Lp.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:H7n(o),availability:l,source:g})}function hpf({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let a={},[u,f]=gy(e)?[t.resolveSchemaReference(e),nba(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...hpf({schema:d,context:t,breadcrumbs:f,source:n,namespace:i})};for(let[d,c]of Object.entries(u.properties??{})){let o=L1(c,!1,t,[...f,d],n,i);a[d]=o}return a}function K7n({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,description:i,availability:a,wrapAsNullable:u,context:f,subtypes:d,groupName:c,encoding:o,source:l,subtypePrefixOverrides:g,namespace:O}){let j=Ev1({schemas:d}),S=d.flatMap((z,N)=>{if(!gy(z)&&z.enum!=null)return z.enum.map(U=>Lp.literal({nameOverride:void 0,generatedName:yR([t,U]),title:void 0,value:E7.string(U),groupName:void 0,description:void 0,availability:U.availability}));let C=j[N];if(g!=null){let U=g[N];U!=null&&"name"in U&&(C=U.name)}return[L1(z,!1,f,[...n,C??`${N}`],l,O)]}),x=[];for(let z=0;z<S.length;++z){let N=S[z],C=!1;for(let U=z+1;U<S.length;++U){let Y=S[U];if(N!=null&&Y!=null&&FRt(N,Y)){C=!0;break}}N!=null&&!C&&x.push(N)}if(Object.entries(x).every(([z,N])=>N.type==="literal")){let z={},N=[];return Object.entries(x).forEach(([C,U])=>{U.type==="literal"&&U.value.type==="string"&&(N.push(U.value.value),U.description!=null&&(z[U.value.value]={description:U.description}))}),C5r({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,fernEnum:z,enumVarNames:void 0,enumValues:N,_default:void 0,groupName:c,context:f,source:l})}return x.length===1&&x[0]!=null?x[0]:ypf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,subtypes:x,groupName:c,encoding:o,source:l})}function yfu({nameOverride:e,generatedName:t,title:r,description:n,availability:i,wrapAsNullable:a,context:u,groupName:f,discriminator:d,encoding:c,source:o,namespace:l}){let g=Object.entries(d.mapping??{}).map(([S,x],A)=>{let z={$ref:x},N=$7n(z,!1,u,[x],c,o,l);return u.markSchemaWithDiscriminantValue(z,d.propertyName,S),N.type==="object"&&(N.properties={[d.propertyName]:Lp.literal({nameOverride:void 0,generatedName:yR([t,S]),title:void 0,value:E7.string(S),groupName:void 0,description:void 0,availability:void 0}),...N.properties.filter(C=>C.key!==d.propertyName)}),N}),O=[];for(let S=0;S<g.length;++S){let x=g[S],A=!1;for(let z=S+1;z<g.length;++z){let N=g[z];if(x!=null&&N!=null&&FRt(x,N)){A=!0;break}}x!=null&&!A&&O.push(x)}if(Object.entries(O).every(([S,x])=>x.type==="literal")){let S={},x=[];return Object.entries(O).forEach(([A,z])=>{z.type==="literal"&&z.value.type==="string"&&(x.push(z.value.value),z.description!=null&&(S[z.value.value]={description:z.description}))}),C5r({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,fernEnum:S,enumVarNames:void 0,enumValues:x,_default:void 0,groupName:f,context:u,source:o})}return O.length===1&&O[0]!=null?O[0]:ypf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,subtypes:O,groupName:f,encoding:c,source:o})}function Ev1({schemas:e}){let t={},r=0;for(let a of e){if(!gy(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),f={},d=u;for(let[c,o]of Object.entries(t)){let l=qXi(o,u);d=qXi(d,o),f[c]=l}f[r]=d,t=f}}r++}let n=[],i=0;for(let a of e){let u=t[i];if(u!=null&&u.length>0){let f=u.sort();if(f[0]!=null){n.push(f[0]),++i;continue}}gy(a)?n.push(J7n(i)??`${i}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?n.push(""):n.push(J7n(i)??`${i}`),++i}return n}function ypf({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,description:i,availability:a,subtypes:u,groupName:f,encoding:d,source:c}){return n?Lp.nullable({nameOverride:e,generatedName:t,title:r,value:Lp.oneOf(jQ.undisciminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:f,encoding:d,source:c})),description:i,availability:a,groupName:f}):Lp.oneOf(jQ.undisciminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:f,encoding:d,source:c}))}function Y7n(e){if(e.default!=null&&typeof e.default=="string")return e.default}function aba({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;if(r&&typeof r=="number")return r;r&&t.warn(`Expected fallback to be a number, but got ${typeof r}`)}function vpf({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;if(r&&typeof r=="boolean")return r;r&&t.warn(`Expected fallback to be a boolean, but got ${typeof r}`)}function LRt({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;if(r&&typeof r=="string")return r;r&&t.warn(`Expected fallback to be a string, but got ${typeof r}`)}function bpf({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;if(r&&Array.isArray(r))return r;r&&t.warn(`Expected fallback to be a array, but got ${typeof r}`)}var Fen="#/components/schemas/";function L1(e,t,r,n,i,a,u=!1,f=new Set,d){let c=Nv1({schema:e,logger:r.logger});if(gy(e)){let o=A5r(e);return o!=null?(u?r.markSchemaAsReferencedByRequest(o):r.markSchemaAsReferencedByNonRequest(o),$7n(e,t,r,n,c,i,a)):q5r(r.resolveSchemaReference(e),t,r,nba(e.$ref),c,i,a,f,u,d)}return q5r(e,t,r,n,c,i,a,f,u,d)}function $7n(e,t,r,n,i,a,u){let f=e.$ref.includes("properties")?q5r(r.resolveSchemaReference(e),t,r,n,i,a,u,new Set):Lp.reference(hfu(e,n,a));return t?Lp.nullable({title:void 0,nameOverride:void 0,generatedName:yR(n),value:f,description:void 0,availability:void 0,groupName:void 0}):f}function Mv1(e){if(e!=null&&!e.includes(" ")&&!!/^[a-zA-Z]+$/.test(e))return e}function q5r(e,t,r,n,i,a,u,f=new Set,d=!1,c){var C;let o=Lh(e,kh.TYPE_NAME)??(r.options.useTitlesAsName?Mv1(e.title):void 0),l=Lh(e,kh.SDK_GROUP_NAME)??((C=Lh(e,Yje.TAGS))==null?void 0:C[0]),g=(typeof l=="string"?[l]:l)??[];g=r.resolveGroupName(g);let O=yR(n),j=e.title,S=e.description,x=E2e(e),A=Lh(e,Yje.EXAMPLES),z=[];e.example!=null&&z.push({name:void 0,value:e.example,description:void 0}),A!=null&&Object.keys(A).length>0&&z.push(...Object.entries(A).map(([U,Y])=>({name:Y.summary??U,value:Y.value,description:Y.description})));let N=ipf({schema:e,description:S,title:j,nameOverride:o,generatedName:O,availability:x});if(N!=null)return N;if(!t&&e.nullable===!0)return q5r(e,!0,r,n,i,a,u,f,d,c);if(e.enum!=null&&(e.type==="string"||e.type==null)){if(!B_i(e.enum))return L9({nameOverride:o,generatedName:O,title:j,primitive:by.string({default:Y7n(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:LRt({schema:e,logger:r.logger,fallback:c})}),groupName:g,wrapAsNullable:t,description:S,availability:x});let U=npf(e);return e.enum.length===1&&e.enum[0]!=null&&U==null?fpf({nameOverride:o,generatedName:O,title:j,wrapAsNullable:t,value:e.enum[0],description:S,availability:x,groupName:g}):C5r({nameOverride:o,generatedName:O,title:j,fernEnum:U,enumVarNames:Lh(e,[Yje.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:S,availability:x,wrapAsNullable:t,groupName:g,context:r,source:a})}if(B_i(e.type)&&e.type[1]!=null&&e.type[0]!=null){let U=e.type[0],Y=e.type[1];if(U==="null")return Lp.nullable({nameOverride:o,generatedName:O,title:j,value:q5r({...e,type:Y},t,r,n,i,a,u,f,d,c),groupName:g,description:e.description,availability:x});if(Y==="null")return Lp.nullable({nameOverride:o,generatedName:O,title:j,value:q5r({...e,type:U},t,r,n,i,a,u,f,d,c),groupName:g,description:e.description,availability:x})}if(B_i(e.type)&&e.type.length>1){let U=e.type.includes("null"),Y=e.type.filter(te=>te!=="null").map(te=>({type:te,nullable:U}));return K7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,wrapAsNullable:t,context:r,subtypes:Y,groupName:g,encoding:i,source:a,namespace:u})}if(e==="boolean"||e.type==="boolean"){let U=Lh(e,kh.BOOLEAN_LITERAL);return U!=null?mpf({nameOverride:o,generatedName:O,title:j,literal:E7.boolean(U),wrapAsNullable:t,description:S,availability:x,groupName:g}):L9({nameOverride:o,generatedName:O,title:j,primitive:by.boolean({default:e.default,example:vpf({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:S,availability:x,groupName:g})}if(e==="number"||e.type==="number")return pfu({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Ren(e.exclusiveMinimum),exclusiveMaximum:Ren(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:aba({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="integer"||e.type==="integer")return cpf({nameOverride:o,generatedName:O,title:j,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Ren(e.exclusiveMinimum),exclusiveMaximum:Ren(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:aba({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="float")return pfu({nameOverride:o,generatedName:O,title:j,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Ren(e.exclusiveMinimum),exclusiveMaximum:Ren(e.exclusiveMaximum),multipleOf:e.multipleOf,description:S,availability:x,wrapAsNullable:t,example:aba({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="string"||e.type==="string"){if(e.format==="date-time")return L9({nameOverride:o,generatedName:O,title:j,primitive:by.datetime({example:LRt({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:S,availability:x,groupName:g});if(e.format==="json-string")return Lp.unknown({nameOverride:o,generatedName:O,title:j,description:S,availability:x,groupName:g,example:void 0});let U=jpf(e,"const");return U!=null?mpf({nameOverride:o,generatedName:O,title:j,literal:E7.string(U),wrapAsNullable:t,description:S,availability:x,groupName:g}):L9({nameOverride:o,generatedName:O,title:j,primitive:by.string({default:Y7n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:LRt({schema:e,logger:r.logger,fallback:c})}),groupName:g,wrapAsNullable:t,description:S,availability:x})}if(e.type==="array")return opf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,item:e.items,description:S,availability:x,wrapAsNullable:t,context:r,groupName:g,example:bpf({schema:e,logger:r.logger,fallback:c}),source:a,namespace:u});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&gpf(e))return apf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,additionalProperties:e.additionalProperties,description:S,availability:x,wrapAsNullable:t,context:r,groupName:g,encoding:i,example:e.example,source:a,namespace:u});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?yfu({nameOverride:o,generatedName:O,title:j,description:S,availability:x,wrapAsNullable:t,context:r,groupName:g,discriminator:e.discriminator,encoding:i,source:a,namespace:u}):ffu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:g,encoding:i,source:a,namespace:u});if(Array.isArray(e.type)&&(e.oneOf==null?e.oneOf=e.type:e.oneOf.push(...e.type)),e.oneOf!=null&&e.oneOf.length>0){let U=Lh(e,kh.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||U?yfu({nameOverride:o,generatedName:O,title:j,description:S,availability:x,wrapAsNullable:t,context:r,groupName:g,discriminator:e.discriminator,encoding:i,source:a,namespace:u}):ffu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:g,encoding:i,source:a,namespace:u});if(e.oneOf.length===1&&e.oneOf[0]!=null){let Y=L1(e.oneOf[0],t,r,n,a,u,d);return X7n(Y,S,g)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let $=e.oneOf[0],ee=e.oneOf[1];if(!gy($)&&$.type==="null")return L1(ee,!0,r,n,a,u);if(!gy(ee)&&ee.type==="null")return L1($,!0,r,n,a,u)}let Y=qv1({schemas:e.oneOf});if(Y!=null)return C5r({nameOverride:o,generatedName:O,title:j,fernEnum:void 0,enumVarNames:void 0,enumValues:Y,_default:e.default,description:S,availability:x,wrapAsNullable:t,groupName:g,context:r,source:a});let te=Opf({schemas:e.oneOf,context:r});if(te!=null&&!r.options.discriminatedUnionV2&&!U)return dfu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},required:e.required,description:S,availability:x,wrapAsNullable:t,discriminant:te.discriminant,variants:te.schemas,context:r,groupName:g,encoding:i,source:a,namespace:u});let G=e.oneOf.filter($=>!gy($)&&$.type==="null").length>0;return K7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,wrapAsNullable:t||G,context:r,subtypes:e.oneOf.filter($=>gy($)||$.type!=="null"),encoding:i,groupName:g,source:a,namespace:u})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let te=L1(e.anyOf[0],t,r,n,a,u,d);return X7n(te,S,g)}if(e.anyOf.length===2){let[te,G]=e.anyOf;if(te!=null&&G!=null){if(!gy(te)&&te.type==="null"){let $=L1(G,!0,r,n,a,u);return X7n($,S,g)}else if(!gy(G)&&G.type==="null"){let $=L1(te,!0,r,n,a,u);return X7n($,S,g)}}}let U=Opf({schemas:e.anyOf,context:r});if(U!=null&&!r.options.discriminatedUnionV2)return dfu({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},required:e.required,description:S,availability:x,wrapAsNullable:t,discriminant:U.discriminant,variants:U.schemas,context:r,groupName:g,encoding:i,source:a,namespace:u});let Y=e.anyOf.filter(te=>!gy(te)&&te.type==="null").length>0;return K7n({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,description:S,availability:x,wrapAsNullable:t||Y,context:r,subtypes:e.anyOf.filter(te=>gy(te)||te.type!=="null"),encoding:i,groupName:g,source:a,namespace:u})}if(e.allOf!=null||e.properties!=null){let U=[];for(let te of e.allOf??[])(gy(te)||Object.keys(te).length>0)&&U.push(te);if((e.properties==null||e.properties.length===0)&&U.length===1&&U[0]!=null){let te=L1(U[0],t,r,n,a,u,d);return X7n(te,S,g)}let Y=U.filter(te=>{let G=oba(te);return G||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify(te)}`),G});if((e.properties==null||e.properties.length===0)&&Y.length===1&&Y[0]!=null){let te=L1(Y[0],t,r,n,a,u,d);return X7n(te,S,g)}return _pf({nameOverride:o,generatedName:O,title:j,breadcrumbs:n,properties:e.properties??{},description:S,required:e.required,wrapAsNullable:t,allOf:Y,context:r,propertiesToExclude:f,groupName:g,fullExamples:z,additionalProperties:e.additionalProperties,availability:x,encoding:i,source:a,namespace:u})}if(e.type==="object"&&xv1(e)&&Tv1(e)&&gpf(e))return tba({nameOverride:o,generatedName:O,title:j,description:S,availability:x,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${O}Key`,title:void 0,description:void 0,availability:void 0,schema:by.string({default:Y7n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:LRt({schema:e,logger:r.logger,fallback:c})}),groupName:g},valueSchema:Lp.unknown({nameOverride:void 0,generatedName:`${O}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:g}),groupName:g,encoding:i,example:e.example});if(e.type==null){let U=e.example??e.default;return Lp.unknown({nameOverride:o,generatedName:O,title:j,description:S,availability:x,groupName:g,example:U})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(n)} value=${JSON.stringify(e)}`)}function A5r(e){if(!!e.$ref.startsWith(Fen))return e.$ref.replace(Fen,"")}function hfu(e,t,r){let n=Lh(e,kh.TYPE_NAME),i=yR(t),a=e.description,u=E2e(e),f=A5r(e);if(f==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return ib.reference({generatedName:i,nameOverride:n,title:void 0,schema:f,description:a??void 0,availability:u,groupName:void 0,source:r})}function xv1(e){return e.oneOf==null||e.oneOf.length===0}function Tv1(e){return e.allOf==null||e.allOf.length===0}function gpf(e){return e.properties==null||Object.keys(e.properties).length===0}function B_i(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function X7n(e,t,r){return e.type==="reference"?Lp.reference({...e,description:t,availability:e.availability,groupName:r}):e.type==="optional"?Lp.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r}):e.type==="nullable"?Lp.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r}):e}function oba(e){return gy(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>oba(t)):e.oneOf!=null?e.oneOf.every(t=>oba(t)):e.anyOf!=null?e.anyOf.every(t=>oba(t)):!1}function mpf({literal:e,wrapAsNullable:t,groupName:r,description:n,availability:i,nameOverride:a,generatedName:u,title:f}){return t?Lp.nullable({nameOverride:a,generatedName:u,title:f,value:Lp.literal({nameOverride:a,generatedName:u,title:f,value:e,description:n,availability:i,groupName:r}),groupName:r,description:n,availability:i}):Lp.literal({nameOverride:a,generatedName:u,title:f,value:e,groupName:r,description:n,availability:i})}function L9({primitive:e,wrapAsNullable:t,groupName:r,description:n,availability:i,generatedName:a,nameOverride:u,title:f}){return r=typeof r=="string"?[r]:r,t?Lp.nullable({nameOverride:u,generatedName:a,title:f,value:Lp.primitive({nameOverride:u,generatedName:a,title:f,schema:e,description:n,availability:i,groupName:r}),groupName:r,description:n,availability:i}):Lp.primitive({nameOverride:u,generatedName:a,title:f,schema:e,description:n,availability:i,groupName:r})}function qv1({schemas:e}){let t=new Set;for(let r of e){if(gy(r))return;if(r.enum!=null&&B_i(r.enum))r.enum.forEach(n=>t.add(n));else return}return Array.from(t)}function Opf({schemas:e,context:t}){let r={};for(let n of e){let i=Ppf({schema:n,context:t});for(let[a,u]of Object.entries(i)){let f=r[a];f!=null?f[u]=n:r[a]={[u]:n}}}for(let[n,i]of Object.entries(r))if(Object.keys(i).length===e.length)return{discriminant:n,schemas:i}}function Ppf({schema:e,context:t}){let r=gy(e)?t.resolveSchemaReference(e):e;return Cv1({schema:r,context:t})}function Cv1({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let n of e.anyOf){let i=Ppf({schema:n,context:t});for(let[a,u]of Object.entries(i??{}))r[a]=u}return r}for(let[n,i]of Object.entries(e.properties??{})){let a=gy(i)?t.resolveSchemaReference(i):i;a.type==="string"&&a.enum!=null&&B_i(a.enum)&&Av1(a.enum).length===1&&a.enum[0]!=null&&(r[n]=a.enum[0]);let u=jpf(a,"const");a.type==="string"&&u!=null&&(r[n]=u),n==="type"&&a.example!=null&&(r[n]=a.example)}return r}function Av1(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 jpf(e,t){let r=e[t];if(r!=null)return r}function Nv1({schema:e,logger:t}){let r=rpf({schema:e,logger:t});if(r!=null)return spf(r)}function uba(e,t){let r={},n={};return e==null?r=t:n={[e]:t},{rootSchemas:r,namespacedSchemas:n}}var wpf="#/components/messages/",vfu=class{logger;document;taskContext;DUMMY;options;namespace;constructor({document:t,taskContext:r,options:n,namespace:i}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=n,this.namespace=i}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let n=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};n.push(i)}return n.concat(t??[])}resolveSchemaReference(t){var a;if(this.document.components==null||this.document.components.schemas==null||!t.$ref.startsWith(Fen))throw new Error(`Failed to resolve ${t.$ref}`);let n=t.$ref.substring(Fen.length).split("/");if(n[0]==null)throw new Error(`${t.$ref} is undefined`);let i=this.document.components.schemas[n[0]];if(i==null)throw new Error(`${n[0]} is undefined`);if(gy(i)&&(i=this.resolveSchemaReference(i)),n[1]==="properties"&&n[2]!=null){let u=(a=i.properties)==null?void 0:a[n[2]];if(u==null)throw new Error(`${t.$ref} is undefiened. Property does not exist on object.`);gy(u)?i=this.resolveSchemaReference(u):i=u}return i}resolveMessageReference(t){if(this.document.components==null||this.document.components.messages==null||!t.$ref.startsWith(wpf))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(wpf.length),n=this.document.components.messages[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}},sba=class extends vfu{constructor({document:t,taskContext:r,options:n,namespace:i}){super({document:t,taskContext:r,options:n,namespace:i})}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,n){}markSchemaWithDiscriminantValue(t,r,n){}};function N5r(e){if(typeof e=="string")return RP.primitive(t0.string(e));if(typeof e=="number")return Number.isInteger(e)?RP.primitive(t0.int(e)):RP.primitive(t0.double(e));if(typeof e=="boolean")return RP.primitive(t0.boolean(e));if(Array.isArray(e)){let t=e.map(r=>N5r(r));return t.length===0?void 0:RP.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,n]of Object.entries(e)){let i=N5r(n);i!=null&&t.push({key:t0.string(r),value:i})}return RP.map(t)}}function I_i(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function Dpf(e){if(e!=null&&Array.isArray(e))return e}var Q7n=class{schemas;constructor(t){this.schemas=t}buildExample({schema:t,exampleId:r,example:n,options:i}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:n,options:{...i,maxCheckerDepth:i.maxCheckerDepth??5},depth:0})}buildExampleHelper({exampleId:t,example:r,schema:n,depth:i,visitedSchemaIds:a,options:u}){var f,d,c,o;switch(n.type){case"enum":return typeof r=="string"&&Spf({schema:n,value:r})?RP.enum(r):n.values[0]!=null?RP.enum((f=n.values[0])==null?void 0:f.value):void 0;case"literal":return RP.literal(n.value);case"nullable":{if(r==null&&!this.hasExample(n.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(i,u)))return;let l=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:u});return l!=null&&l.type==="array"&&l.value.length===0||l!=null&&l.type==="map"&&l.value.length===0||l!=null&&l.type==="object"&&Object.keys(l.properties).length===0?void 0:l}case"optional":{if(r==null&&!this.hasExample(n.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(i,u)))return;let l=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:u});return l!=null&&l.type==="array"&&l.value.length===0||l!=null&&l.type==="map"&&l.value.length===0||l!=null&&l.type==="object"&&Object.keys(l.properties).length===0?void 0:l}case"primitive":{let l=this.buildExampleFromPrimitive({schema:n.schema,example:r,options:u});return RP.primitive(l)}case"reference":{let l=this.schemas[n.schema];if(l!=null&&!a.has(n.schema)){a.add(n.schema);let g=this.buildExampleHelper({example:r,schema:l,exampleId:t,visitedSchemaIds:a,depth:i,options:u});return a.delete(n.schema),g}return}case"oneOf":switch(n.value.type){case"discriminated":{let l={},g={},O={},j=I_i(r),S=j==null?void 0:j[n.value.discriminantProperty],x=n.value.schemas[S],A=[],z=this.getDiscriminatedUnionVariantSchema(n.value,j);z!=null&&A.push(z),A.push(...Object.entries(n.value.schemas));for(let N of A)if(S!=null&&x!=null&&x.type==="object"){g=this.getAllProperties(x),O=this.getAllRequiredProperties(x),l[n.value.discriminantProperty]=RP.primitive(t0.string(S));break}else{let C=this.getObjectSchema(N[1]);if(C==null)continue;g=this.getAllProperties(C),O=this.getAllRequiredProperties(C),l[n.value.discriminantProperty]=RP.primitive(t0.string(N[0]))}for(let N of n.value.commonProperties){g[N.key]=N.schema;let C=this.getResolvedSchema(N.schema);C.type!=="optional"&&C.type!=="nullable"&&(O[N.key]=N.schema)}for(let[N,C]of Object.entries(g)){let U=N in O;if(U&&(j==null?void 0:j[N])!=null){let Y=this.buildExampleHelper({schema:C,exampleId:t,example:j[N],visitedSchemaIds:a,depth:i+1,options:u});if(Y!=null)l[N]=Y;else return}else{let Y=this.buildExampleHelper({exampleId:t,schema:C,example:j==null?void 0:j[N],visitedSchemaIds:a,depth:i+1,options:u});if(Y!=null)l[N]=Y;else if(U)return}}return RP.oneOf(v5r.discriminated(l))}case"undisciminated":{let l=this.getUnDiscriminatedUnionVariantSchema(n.value,r);if(l!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:l,visitedSchemaIds:a,depth:i,options:u});break}}return;case"unknown":if(r!=null){let l=N5r(r);if(l!=null)return RP.unknown(l)}return u.ignoreOptionals||this.exceedsMaxDepth(i,u)?void 0:u.isParameter?RP.primitive(t0.string(u.name??"string")):RP.map([{key:t0.string("key"),value:RP.primitive(t0.string("value"))}]);case"array":{let l=Dpf(r),g=[];if(l!=null&&l.length>0)for(let O of l){let j=this.buildExampleHelper({exampleId:t,example:O,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u});j!=null&&g.push(j)}else if(n.example!=null&&n.example.length>0)for(let O of n.example){let j=this.buildExampleHelper({exampleId:t,example:O,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u});j!=null&&g.push(j)}else{let O=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u});O!=null&&g.push(O)}return RP.array(g)}case"map":{let l=I_i(r??n.example);if(l!=null&&Object.entries(l).length>0){let j=[];for(let[S,x]of Object.entries(l)){let A=this.buildExampleFromPrimitive({schema:n.key.schema,example:S,options:u}),z=this.buildExampleHelper({exampleId:t,example:x,schema:n.value,visitedSchemaIds:a,depth:i+1,options:u});z!=null&&j.push({key:A,value:z})}return RP.map(j)}if(n.key.schema.type==="string"&&n.value.type==="unknown")return RP.map([{key:t0.string("key"),value:RP.unknown(RP.primitive(t0.string("value")))}]);let g=this.buildExampleFromPrimitive({schema:n.key.schema,example:void 0,options:{...u,name:"key"}}),O=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,visitedSchemaIds:a,depth:i+1,options:{...u,name:"value"}});return O!=null?RP.map([{key:g,value:O}]):RP.map([])}case"object":{let l={},g=((d=n.fullExamples)==null?void 0:d.find(x=>x.name===t))??((c=n.fullExamples)==null?void 0:c.find(x=>x.name==null))??((o=n.fullExamples)==null?void 0:o[0]),O=I_i(r)??(g!=null?I_i(g.value):{})??{},j=this.getAllProperties(n),S=this.getAllRequiredProperties(n);for(let[x,A]of Object.entries(j)){let z=x in S,N=Object.keys(O).includes(x),C=this.buildExampleHelper({schema:A,exampleId:t,example:O[x],visitedSchemaIds:a,depth:i+1,options:{...u,name:x}});if(z&&C!=null)l[x]=C;else{if(z)return;(N&&C!=null||!u.ignoreOptionals&&C!=null)&&(l[x]=C)}}return RP.object({properties:l})}default:Ol(n)}}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let n=r==null?void 0:r[t.discriminantProperty];if(n==null||typeof n!="string")return Object.entries(t.schemas)[0];let i=t.schemas[n];return i==null?Object.entries(t.schemas)[0]:[n,i]}getUnDiscriminatedUnionVariantSchema(t,r){var a;return r==null?t.schemas[0]:(a=t.schemas.map(u=>({schema:u,heuristic:this.calcExampleHeuristic(u,r)})).sort((u,f)=>f.heuristic-u.heuristic)[0])==null?void 0:a.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return Spf({schema:t,value:r})?5:0;case"object":{if(!RO(r))return 0;let n=this.getAllProperties(t),i=0;for(let[a,u]of Object.entries(n))r[a]!=null?(i++,i+=this.calcExampleHeuristic(u,r[a])):i--;return i}case"array":{if(!Array.isArray(r))return 0;let n=0;for(let i of r)n+=this.calcExampleHeuristic(t.value,i);return n}case"map":{if(!RO(r))return 0;let n=0;for(let[,i]of Object.entries(r))n+=this.calcExampleHeuristic(t.value,i);return n}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let n=this.getResolvedSchema(t);return n==null?0:this.calcExampleHeuristic(n,r)}case"oneOf":return Object.values(t.value.schemas).map(i=>this.calcExampleHeuristic(i,r)).sort((i,a)=>a-i)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,n=new Set,i){if(this.exceedsMaxCheckerDepth(r,i))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,n,i);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,n,i);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let u of t.properties)if(this.hasExample(u.schema,r+1,n,i))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!n.has(t.schema)){n.add(t.schema);let u=this.hasExample(a,r,n,i);return n.delete(t.schema),u}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,n,i));default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let n of t.properties)r[n.key]=n.schema;for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let n of t.properties){let i=this.getResolvedSchema(n.schema);i.type!=="optional"&&i.type!=="nullable"&&(r[n.key]=n.schema)}for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:n}){switch(r.type){case"string":return t!=null&&typeof t=="string"?t0.string(t):r.example!=null?t0.string(r.example):t0.string(n.name??DC.STRING);case"base64":return t!=null&&typeof t=="string"?t0.base64(t):r.example!=null?t0.base64(r.example):t0.base64(DC.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?t0.boolean(t):r.example!=null?t0.boolean(r.example):t0.boolean(DC.BOOLEAN);case"date":return t!=null&&typeof t=="string"?t0.date(t):r.example!=null?t0.date(r.example):t0.date(DC.DATE);case"datetime":return t!=null&&typeof t=="string"?t0.datetime(t):r.example!=null?t0.datetime(r.example):t0.datetime(DC.DATE_TIME);case"double":return t!=null&&typeof t=="number"?t0.double(t):r.example!=null?t0.double(r.example):t0.double(DC.DOUBLE);case"float":return t!=null&&typeof t=="number"?t0.float(t):r.example!=null?t0.float(r.example):t0.float(DC.FLOAT);case"int":return t!=null&&typeof t=="number"?t0.int(t):r.example!=null?t0.int(r.example):t0.int(DC.INT);case"int64":return t!=null&&typeof t=="number"?t0.int64(t):r.example!=null?t0.int64(r.example):t0.int64(DC.INT64);case"uint":return t!=null&&typeof t=="number"?t0.uint(t):r.example!=null?t0.uint(r.example):t0.uint(DC.UINT);case"uint64":return t!=null&&typeof t=="number"?t0.uint64(t):r.example!=null?t0.uint64(r.example):t0.uint64(DC.UINT64);default:Ol(r)}}};function Spf({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function URt(e){switch(e.type){case"object":return Lp.object({allOf:e.allOf,properties:e.properties.map(t=>Bv1(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source});case"array":return Lp.array({description:e.description,availability:e.availability,value:URt(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0});case"enum":return Lp.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,groupName:e.groupName,example:void 0,source:e.source});case"literal":return Lp.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 Lp.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:URt(e.value),groupName:e.groupName});case"optional":return Lp.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:URt(e.value),groupName:e.groupName});case"primitive":return Lp.primitive({description:e.description,availability:e.availability,schema:Epf(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return Lp.map({description:e.description,availability:e.availability,key:Lp.primitive({description:e.key.description,availability:e.key.availability,schema:Epf(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,groupName:e.groupName}),value:URt(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,encoding:e.encoding,example:void 0});case"reference":return Lp.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 Lp.oneOf(zv1(e.value));case"unknown":return Lp.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,groupName:void 0,description:void 0,availability:void 0});default:Ol(e)}}function zv1(e){switch(e.type){case"discriminated":return jQ.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:URt(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,URt(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return jQ.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>URt(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:Ol(e)}}function Epf(e){switch(e.type){case"string":return by.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return by.base64({example:void 0});case"boolean":return by.boolean({default:e.default,example:void 0});case"date":return by.date({example:void 0});case"datetime":return by.datetime({example:void 0});case"double":return by.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 by.float({example:void 0});case"int":return by.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 by.int64({default:e.default,example:void 0});case"uint":return by.uint({default:void 0,example:void 0});case"uint64":return by.uint64({default:void 0,example:void 0});default:Ol(e)}}function Bv1(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:URt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability}}function cba(e){return e.type!=="optional"&&e.type!=="nullable"}function R_i(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 lba=class{exampleTypeFactory;logger;schemas;constructor(t,r){this.schemas=t,this.exampleTypeFactory=new Q7n(t),this.logger=r}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=Rv1(t.request),n=Fv1(t.response);if((r==null?void 0:r.type)==="unsupported"||(n==null?void 0:n.type)==="unsupported")return[];let i=[];if(r!=null&&r.type==="present"){let l=this.isSchemaRequired(r.schema);if(r.examples.length===0){let g=this.exampleTypeFactory.buildExample({schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});g!=null&&i.push([void 0,g])}else for(let{name:g,value:O}of r.examples){let j=this.exampleTypeFactory.buildExample({schema:r.schema,exampleId:g,example:O,options:{isParameter:!1,ignoreOptionals:!0}});j!=null&&i.push([g,j])}if(l&&i.length===0)return this.logger.warn(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(n!=null&&n.type==="present"){let l=this.isSchemaRequired(n.schema);if(n.examples.length===0){let g=this.exampleTypeFactory.buildExample({schema:n.schema,exampleId:void 0,example:void 0,options:{maxDepth:3,isParameter:!1,ignoreOptionals:!1}});g!=null&&a.push([void 0,g])}else for(let{name:g,value:O}of n.examples){let j=this.exampleTypeFactory.buildExample({schema:n.schema,exampleId:g,example:O,options:{maxDepth:3,isParameter:!1,ignoreOptionals:!1}});j!=null&&a.push([g,j])}if(l&&a.length===0)return this.logger.warn(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let l of t.pathParameters){let g=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!VRt(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for path parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),g&&O==null)return[];O!=null&&u.push({name:l.name,parameterNameOverride:l.parameterNameOverride,value:O})}let f=[];for(let l of t.queryParameters){let g=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!VRt(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for query parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),g&&O==null)return[];O!=null&&f.push({name:l.name,value:O})}let d=[];for(let l of t.headers){let g=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!VRt(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for header ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),g&&O==null)return[];O!=null&&d.push({name:l.name,value:O})}let c=[];t.request!=null&&t.response!=null?c=Iv1(i,a):t.request!=null?c=i.map(([l,g])=>({id:l,request:g,response:void 0})):t.response!=null&&(c=a.map(([l,g])=>({id:l,request:void 0,response:g})));let o=t.examples.filter(l=>R_i(l)).flatMap(l=>{if(l.type==="unknown"){if(l.value!=null){let g=l.value["code-samples"];if(g!=null)return this.convertCodeSamples(g)}return}else return l.codeSamples}).filter(l=>RS(l));return c.length===0?[pAt.full({name:void 0,description:void 0,pathParameters:u,queryParameters:f,headers:d,request:void 0,response:void 0,codeSamples:o})]:c.map(({id:l,request:g,response:O})=>pAt.full({name:l,description:void 0,pathParameters:u,queryParameters:f,headers:d,request:g,response:O,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?JSr.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):JSr.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?vW.Csharp:r.sdk,code:r.code})).filter(RS)}isSchemaRequired(t){return cba(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function Iv1(e,t){var i,a,u,f;let r=[];if(e.length<=1){let[d,c]=e[0]??[];if(t.length===0)return r.push({id:d,request:c,response:void 0}),r;for(let[o,l]of t)r.push({id:o??d,request:c,response:l});return r}if(t.length<=1){let[d,c]=t[0]??[];if(t.length===0)return r.push({id:d,request:void 0,response:c}),r;for(let[o,l]of e)r.push({id:o??d,request:l,response:c});return r}let n=new Set;for(let[d,c]of e){let o=((i=t.find(([g])=>g==null))==null?void 0:i[1])??((a=t[0])==null?void 0:a[1]);if(d==null){if(o==null)continue;r.push({id:void 0,request:c,response:o});continue}let l=!1;for(let g=0;g<t.length;g++){let[O,j]=t[g];O!=null||n.has(g)||d===O&&(r.push({id:d,request:c,response:j}),O!=null&&n.add(g),l=!0)}!l&&o!=null&&r.push({id:d,request:c,response:o})}for(let d=0;d<t.length;d++){if(n.has(d))continue;let[c,o]=t[d],l=((u=e.find(([g])=>g==null))==null?void 0:u[1])??((f=e[0])==null?void 0:f[1]);l!=null&&r.push({id:c,request:l,response:o})}return r}function Rv1(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:Lv1(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function Fv1(e){if(e!=null)return e.type!=="json"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function VRt(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return VRt(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undisciminated":return VRt(e.value.value);default:return!1}default:Ol(e)}}function Lv1(e){return Lp.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:URt(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0}).filter(RS),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source})}var fba=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new Q7n(t),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,publish:n,subscribe:i,handshake:a,source:u,namespace:f}){var c,o;let d=[];for(let l of r){let g=[];for(let S of a.queryParameters){let x=this.isSchemaRequired(S.schema),A=this.exampleTypeFactory.buildExample({schema:S.schema,exampleId:void 0,example:(c=l.queryParameters)==null?void 0:c[S.name],options:{name:S.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!VRt(A)&&(A=void 0),!(x&&A==null)&&A!=null&&g.push({name:S.name,value:A})}let O=[];for(let S of a.headers){let x=this.isSchemaRequired(S.schema),A=this.exampleTypeFactory.buildExample({schema:S.schema,exampleId:void 0,example:(o=l.headers)==null?void 0:o[S.name],options:{name:S.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!VRt(A)&&(A=void 0),!(x&&A==null)&&A!=null&&O.push({name:S.name,value:A})}let j=[];for(let S of l.messages){let x=t.resolveMessageReference({$ref:`#/components/messages/${S.messageId}`}),A=gy(x.payload)?t.resolveSchemaReference(x.payload):x.payload,z=this.exampleTypeFactory.buildExample({schema:L1(A,!1,t,[S.messageId],u,f),exampleId:void 0,example:S.value,options:{isParameter:!1,ignoreOptionals:!0}});z!=null&&j.push({messageType:S.type,payload:z,description:void 0})}d.push({name:l.summary,queryParameters:g,headers:O,description:l.description,messages:j})}return d}buildWebsocketSessionExample({publish:t,subscribe:r,handshake:n}){let i={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},a=[];for(let f of n.queryParameters){let d=this.isSchemaRequired(f.schema),c=this.exampleTypeFactory.buildExample({schema:f.schema,exampleId:void 0,example:void 0,options:{name:f.name,isParameter:!0,ignoreOptionals:!0}});if(c!=null&&!VRt(c)&&(c=void 0),d&&c==null)return;c!=null&&a.push({name:f.name,value:c})}let u=[];for(let f of n.headers){let d=this.isSchemaRequired(f.schema),c=this.exampleTypeFactory.buildExample({schema:f.schema,exampleId:void 0,example:void 0,options:{name:f.name,isParameter:!0,ignoreOptionals:!0}});if(c!=null&&!VRt(c)&&(c=void 0),d&&c==null)return;c!=null&&u.push({name:f.name,value:c})}if(t!=null){let f=this.exampleTypeFactory.buildExample({schema:t,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});f!=null&&i.messages.push({messageType:"publish",payload:f,description:void 0})}if(r!=null){let f=this.exampleTypeFactory.buildExample({schema:r,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});f!=null&&i.messages.push({messageType:"subscribe",payload:f,description:void 0})}return i}isSchemaRequired(t){return cba(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 F_i={FERN_DISPLAY_NAME:"x-fern-display-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path"};function Mpf(e){return Lh(e,F_i.FERN_EXAMPLES)??[]}function Tpf({document:e,taskContext:t,options:r,source:n,asyncApiOptions:i,namespace:a}){var l,g,O,j,S,x;let u=[];a!=null&&u.push(a),((l=e.tags)==null?void 0:l[0])!=null?u.push(e.tags[0].name):i.naming!=="v2"&&u.push("websocket");let f=new sba({document:e,taskContext:t,options:r,namespace:a}),d={},c;for(let[A,z]of Object.entries(((g=e.components)==null?void 0:g.schemas)??{})){let N=L1(z,!1,f,[A],n,a);d[A]=N}let o=new fba(d,t.logger);for(let[A,z]of Object.entries(e.channels??{})){if(((O=z.bindings)==null?void 0:O.ws)==null){f.logger.error(`Channel ${A} does not have websocket bindings. Skipping.`);continue}let N=[];if(z.parameters!=null)for(let[G,$]of Object.entries(z.parameters??{}))N.push({name:G,description:$.description,parameterNameOverride:void 0,schema:$.schema!=null?L1($.schema,!1,f,u,n,a):Lp.primitive({schema:by.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:E2e($),source:n});let C=[];if(z.bindings.ws.headers!=null){let G=z.bindings.ws.headers.required??[];for(let[$,ee]of Object.entries(z.bindings.ws.headers.properties??{})){let Ve=gy(ee)?f.resolveSchemaReference(ee):ee;C.push({name:$,schema:L1(Ve,!G.includes($),f,u,n,a),description:Ve.description,parameterNameOverride:void 0,env:void 0,availability:E2e(Ve),source:n})}}let U=[];if(z.bindings.ws.query!=null){let G=z.bindings.ws.query.required??[];for(let[$,ee]of Object.entries(z.bindings.ws.query.properties??{})){let Ve=gy(ee)?f.resolveSchemaReference(ee):ee;U.push({name:$,schema:L1(Ve,!G.includes($),f,u,n,a),description:Ve.description,parameterNameOverride:void 0,availability:E2e(Ve),source:n})}}let Y;z.publish!=null&&(Y=xpf({generatedName:z.publish.operationId??"PublishEvent",event:z.publish,breadcrumbs:u,context:f,source:n,options:r,asyncApiOptions:i}));let te;if(z.subscribe!=null&&(te=xpf({generatedName:z.subscribe.operationId??"SubscribeEvent",event:z.subscribe,breadcrumbs:u,context:f,source:n,options:r,asyncApiOptions:i})),C.length>0||U.length>0||Y!=null||te!=null){let G=Mpf(z),$=[];if(G.length>0)$=o.buildWebsocketSessionExamplesForExtension({context:f,extensionExamples:G,handshake:{headers:C,queryParameters:U},publish:Y,subscribe:te,source:n,namespace:a});else{let Ve=o.buildWebsocketSessionExample({handshake:{headers:C,queryParameters:U},publish:Y,subscribe:te});Ve!=null&&$.push(Ve)}let ee=((S=(j=e.tags)==null?void 0:j[0])==null?void 0:S.name)!=null?[(x=e.tags)==null?void 0:x[0].name]:void 0;c={handshake:{headers:C.map(Ve=>({...Ve,schema:oq(Ve.schema),env:Ve.env})),queryParameters:U.map(Ve=>({...Ve,schema:oq(Ve.schema)})),pathParameters:N.map(Ve=>({...Ve,parameterNameOverride:void 0,schema:oq(Ve.schema)}))},groupName:f.resolveTags(ee,"Websocket"),publish:Y!=null?oq(Y):Y,subscribe:te!=null?oq(te):te,summary:Lh(z,F_i.FERN_DISPLAY_NAME),path:A,description:void 0,examples:$,source:n};break}}return{groupedSchemas:uba(a,d),channel:c,basePath:Lh(e,F_i.BASE_PATH)}}function xpf({generatedName:e,event:t,context:r,breadcrumbs:n,source:i,options:a,asyncApiOptions:u}){if(t.message.oneOf!=null){let f=[],d=[];for(let c of t.message.oneOf){let o,l={type:"notFound"};if(gy(c)){let g=r.resolveMessageReference(c);!gy(g.payload)&&u.naming==="v2"?(l=g.name?{type:"name",name:g.name}:l,o={...g.payload,title:g.name??g.payload.title,description:g.name??g.payload.description}):o=g.payload}else o=c;d.push(l),f.push(o)}return K7n({description:t.description??t.message.description,availability:E2e(t.message),subtypes:f,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:n,context:r,encoding:void 0,source:i,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?d:[]})}}var IEf=yu(Vbf(),1);var Rtn=yu(NEf(),1);var zEf=require("fs/promises");async function PPa({absoluteFilepathToOverrides:e,data:t,context:r}){let n=null;try{let u=(await(0,zEf.readFile)(e,"utf8")).toString();try{n=JSON.parse(u)}catch{n=av.load(u,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}let i=TXi(t,TXi,n,(u,f)=>Array.isArray(u)&&Array.isArray(f)?f.every(d=>typeof d=="object")&&u.every(d=>typeof d=="object")?void 0:[...f]:void 0);return Wbu(i,gWo)}var Wbu=(e,t)=>{function r(n){if(!Array.isArray(n)&&!Lsi(n))return n;if(Array.isArray(n))return n.map(a=>Wbu(a,t));let i={};for(let[a,u]of Object.entries(n))i[a]=Wbu(u,t);return PWo(i,t)}return r(e)};var jH1={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},wH1={id:"",typeExtension:{oas3:e=>{var t;return{...e,XFernStreaming:jH1,Operation:{...e.Operation,properties:{...(t=e.Operation)==null?void 0:t.properties,"x-fern-streaming":"XFernStreaming"}}}}}};async function REf({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,context:r}){let n=await BEf({absolutePathToOpenAPI:e}),i;if(t!=null?i=t:typeof n=="object"&&n[kh.OPENAPI_OVERIDES_FILEPATH]!=null&&(i=pf(Hg(e),zs.of(n[kh.OPENAPI_OVERIDES_FILEPATH]))),i!=null){let a=await PPa({absoluteFilepathToOverrides:i,context:r,data:n});return await BEf({absolutePathToOpenAPI:e,parsed:a})}return n}async function BEf({absolutePathToOpenAPI:e,parsed:t}){let r={config:new Rtn.Config({apis:{},styleguide:{plugins:[wH1],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0},n=t!=null?await(0,Rtn.bundle)({...r,doc:{source:new Rtn.Source(e,"<openapi>"),parsed:t}}):await(0,Rtn.bundle)({...r,ref:e});return await IEf.default.parse(n.bundle.parsed)}var Cqf=yu(L2f(),1);function U2f(e){return Lh(e,kh.ASYNC_CONFIG)}var V2f="$request.";function W2f(e){let t=Lh(e,kh.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",streamConditionProperty:BX1(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function BX1(e){return e.startsWith(V2f)?e.slice(V2f.length):e}function H2f(e){let t=e;if(t.cursor!=null)return $Sr.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});let r=e;return $Sr.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}function $2f(e,t){let r=Lh(t,kh.PAGINATION);if(r!=null){if(typeof r=="boolean"){let n=Lh(e,kh.PAGINATION);if(typeof n=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return n==null?void 0:H2f(n)}return H2f(r)}}function J2f(e){let t=IX1(e),r={};return Hmu({obj:t,occurrences:r,breadcrumbs:[]}),r}function Hmu({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let n of e)Hmu({obj:n,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let n=e.$ref;t[n]==null?t[n]=1:t[n]+=1;return}for(let n in e)Hmu({obj:e[n],occurrences:t,breadcrumbs:[...r,n]})}}}function IX1(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:(r==null?void 0:r.get)!=null?q0i(r.get):void 0,put:(r==null?void 0:r.put)!=null?q0i(r.put):void 0,post:(r==null?void 0:r.post)!=null?q0i(r.post):void 0,patch:(r==null?void 0:r.patch)!=null?q0i(r.patch):void 0,delete:(r==null?void 0:r.delete)!=null?q0i(r.delete):void 0}]))}}function q0i(e){return{...e,requestBody:e.requestBody!=null?gy(e.requestBody)?e.requestBody:RX1(e.requestBody):void 0}}function RX1(e){let t,r;for(let n in e.content){let i=sA.parse(n);i!=null&&(i.isJSON()?t=e.content[n]:i.isMultipart()&&(r=e.content[n]))}return r!=null&&t!=null?{...e,content:{[sA.MULTIPART_FORM_DATA]:r}}:e}var G2f="#/components/parameters/",K2f="#/components/responses/",Y2f="#/components/examples/",X2f="#/components/requestBodies/",V3n=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;namespace;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=n,this.refOccurrences=J2f(t),this.options=i,this.source=a,this.DUMMY=this.getDummy(),this.namespace=u}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};r.push(n)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return{"x-fern-type":"unknown",additionalProperties:!0};n=n[i]}return n==null?{"x-fern-type":"unknown",additionalProperties:!0}:(gy(n)&&(n=this.resolveSchemaReference(n)),n)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(G2f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(G2f.length),n=this.document.components.parameters[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return gy(n)?this.resolveParameterReference(n):n}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(X2f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(X2f.length),n=this.document.components.requestBodies[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return gy(n)?this.resolveRequestBodyReference(n):n}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(K2f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(K2f.length),n=this.document.components.responses[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return gy(n)?this.resolveResponseReference(n):n}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(Y2f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(Y2f.length),n=this.document.components.examples[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return gy(n)?this.resolveExampleReference(n):n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}};var W3n=class extends V3n{constructor({document:t,taskContext:r,options:n,source:i,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:n,source:i,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,n){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,n){}getDiscriminatedUnionMetadata(t){}};var FX1=ir.object({lang:ir.string(),label:ir.optional(ir.string()),source:ir.string()}),$mu=ir.array(FX1);var Q2f={README_EXT:"x-readme"};function LX1(e){if(!Array.isArray(e))return!1;for(let t of e)if(!RO(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function Z2f(e){let t=Lh(e,Q2f.README_EXT);if(!RO(t))return[];let r=t["code-samples"];if(!LX1(r))return[];let n=[];for(let i of r)n.push({name:i.name,language:i.language,code:i.code,install:i.install,docs:void 0});return n}function k2f(e,t,r){let n=RRt(t,kh.EXAMPLES,h5.ExampleEndpointCallArraySchema,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],i=RRt(t,Yje.REDOCLY_CODE_SAMPLES_KEBAB,$mu,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],u=[...RRt(t,Yje.REDOCLY_CODE_SAMPLES_CAMEL,$mu,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...i];u.length>0&&n.push({"code-samples":u.map(d=>({name:d.label??d.lang,language:d.lang,code:d.source,install:void 0,docs:void 0}))});let f=Z2f(t);return f.length>0&&n.push({"code-samples":f}),n.map(pAt.unknown)}function eqf(e){let t=Lh(e,kh.AVAILABILITY);if(t==="ga"||t==="generally-available")return yW.GenerallyAvailable;if(t==="beta"||t==="pre-release")return yW.Beta;if(t==="deprecated")return yW.Deprecated;if(e.deprecated)return yW.Deprecated}function M1a(e){return{url:UX1({url:e.url,variables:e.variables??{}}),description:e.description,name:VX1(e),audiences:Lh(e,kh.AUDIENCES)}}function UX1({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([n,i])=>[n,i.default]));for(let[n,i]of Object.entries(r))e=e.replace(`{${n}}`,i);return e}function VX1(e){var r,n;let t=Lh(e,[kh.SERVER_NAME_V1,kh.SERVER_NAME_V2]);if(t!=null)return t;if(((r=e.description)==null?void 0:r.toLowerCase())==="production")return"Production";if(((n=e.description)==null?void 0:n.toLowerCase())==="sandbox")return"Sandbox"}function tqf(e){return Lh(e,kh.PARAMETER_NAME)}function rqf(e){return Lh(e,kh.SDK_VARIABLE)}function x1a({path:e,httpMethod:t,parameters:r,context:n,requestBreadcrumbs:i,source:a}){var f;let u={pathParameters:[],queryParameters:[],headers:[]};for(let d of r){let c=gy(d)?n.resolveParameterReference(d):d,o=c.required??!1,l=E2e(c),g=[...i,c.name],O=yR(g);(f=LRt({schema:c,logger:n.logger}))!=null&&f.includes(" ")&&n.logger.warn("Parameter example contains a space, which is ambiguous. Consider using enums for multiple examples, or use an encoding if a space is part of the parameter.");let j=c.schema!=null?L1(c.schema,!o,n,g,a,n.namespace,!1,new Set,LRt({schema:c,logger:n.logger})):o?Lp.primitive({nameOverride:void 0,generatedName:O,title:void 0,schema:by.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:LRt({schema:c,logger:n.logger})}),description:void 0,availability:l,groupName:void 0}):Lp.optional({nameOverride:void 0,generatedName:O,title:void 0,value:Lp.primitive({nameOverride:void 0,generatedName:O,title:void 0,schema:by.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:LRt({schema:c,logger:n.logger})}),description:void 0,availability:void 0,groupName:void 0}),description:void 0,availability:l,groupName:void 0});if(c.in==="header"&&c.schema!=null&&!gy(c.schema)&&c.schema.default!=null){let x=c.schema.default;typeof x=="string"&&x.length>0&&(j=Lp.literal({nameOverride:void 0,generatedName:O,title:void 0,value:E7.string(x),description:void 0,availability:l,groupName:void 0}))}let S={name:c.name,schema:j,description:c.description,parameterNameOverride:tqf(c),availability:l,source:a};c.in==="query"?u.queryParameters.push(S):c.in==="path"?u.pathParameters.push({...S,variableReference:rqf(c)}):c.in==="header"?!WX1.has(c.name)&&!n.authHeaders.has(c.name)?u.headers.push({...S,env:void 0}):n.logger.debug(`Ignoring ${c.name} header, in ${t.toUpperCase()} ${e}`):n.logger.warn(`Skipping ${c.in} parameter, ${c.name}, in ${t.toUpperCase()} ${e}`)}return u}var WX1=new Set(["User-Agent","Content-Length","Content-Type","X-Forwarded-For","Cookie","Origin","Content-Disposition","X-Ping-Custom-Domain"]);function H3n(e,t){for(let r of Object.keys(e))if(r.includes("json")){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:iqf(n,t)}}}function nqf(e,t){for(let r of Object.keys(e)){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:iqf(n,t)}}}function iqf(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let n=Lh(e,Yje.EXAMPLES);return n!=null&&Object.keys(n).length>0&&r.push(...Object.entries(n).map(([i,a])=>({name:a.summary??i,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([i,a])=>{let u=gy(a)?t.resolveExampleReference(a):a;return{name:u.summary??i,value:u.value,description:u.description}})),r}function HX1(e){var t;for(let[r,n]of Object.entries(e.content))if((t=sA.parse(r))!=null&&t.isMultipart())return n.schema}function $X1(e){var t;for(let r in e.content)if((t=sA.parse(r))!=null&&t.isOctetStream())return!0;return!1}function JX1(e,t){let r=gy(e)?Jmu(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([n,i])=>!gy(i)&&i.type==="string"&&i.format==="binary")!=null}function $3n({requestBody:e,document:t,context:r,requestBreadcrumbs:n,source:i,namespace:a}){let u=gy(e)?r.resolveRequestBodyReference(e):e,f=HX1(u),d=H3n(u.content,r);if($X1(u))return S2e.octetStream({description:void 0,source:i});if(f!=null&&d==null||f!=null&&JX1(f,t)){let o=gy(f)?Jmu(f,t):{id:void 0,schema:f},l=L1(o.schema,!1,r,n,i,a),g=[];if(l.type==="object")for(let O of l.properties){if(O.schema.type==="primitive"&&O.schema.schema.type==="string"&&O.schema.schema.format==="binary"){g.push({key:O.key,schema:D2e.file({isOptional:!1,isArray:!1}),description:O.schema.description});continue}if(O.schema.type==="optional"&&O.schema.value.type==="primitive"&&O.schema.value.schema.type==="string"&&O.schema.value.schema.format==="binary"){g.push({key:O.key,schema:D2e.file({isOptional:!0,isArray:!1}),description:O.schema.description});continue}if(O.schema.type==="array"&&O.schema.value.type==="primitive"&&O.schema.value.schema.type==="string"&&O.schema.value.schema.format==="binary"){g.push({key:O.key,schema:D2e.file({isOptional:!1,isArray:!0}),description:O.schema.description});continue}if(O.schema.type==="optional"&&O.schema.value.type==="array"&&O.schema.value.value.type==="primitive"&&O.schema.value.value.schema.type==="string"&&O.schema.value.value.schema.format==="binary"){g.push({key:O.key,schema:D2e.file({isOptional:!0,isArray:!0}),description:O.schema.description});continue}g.push({key:O.key,schema:D2e.json(O.schema),description:void 0})}return S2e.multipart({name:gy(f)&&r.getNumberOfOccurrencesForRef(f)===1?o.id:void 0,description:void 0,properties:g,source:i})}if(d==null)return;let c=L1(d.schema,!1,r,n,i,a,!0);return S2e.json({description:void 0,schema:c,contentType:void 0,fullExamples:d.examples,additionalProperties:!gy(d.schema)&&H7n(d.schema.additionalProperties),source:i})}function Jmu(e,t){var i,a;if(!e.$ref.startsWith(Fen))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=A5r(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let n=(a=(i=t.components)==null?void 0:i.schemas)==null?void 0:a[r];if(n==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return gy(n)?Jmu(n,t):{id:r,schema:n}}var Gmu={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},aqf=new Set(Object.values(Gmu));var GX1=["200","201","202","204"];function uqf({operationContext:e,responses:t,context:r,responseBreadcrumbs:n,responseStatusCode:i,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let f=KX1({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,c;for(let o of i!=null?[i]:GX1){let l=t[o];l!=null&&(d=!0,c==null&&(c=oqf({operationContext:e,response:l,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})))}if(c==null&&!d&&t.default!=null&&(c=oqf({operationContext:e,response:t.default,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})),c!=null)switch(c.type){case"json":return{value:c,errors:f};case"streamingJson":case"streamingSse":return{value:c,errors:f};case"file":case"text":case"streamingText":return{value:c,errors:f};default:Ol(c)}return{value:void 0,errors:f}}function oqf({operationContext:e,streamFormat:t,response:r,context:n,responseBreadcrumbs:i,source:a,namespace:u}){let f=gy(r)?n.resolveResponseReference(r):r;if(f.content!=null&&Object.entries(f.content).find(([o,l])=>{if(l.schema==null)return!1;let g=gy(l.schema)?n.resolveSchemaReference(l.schema):l.schema;return g.type==="string"&&g.format==="binary"}))return T3.file({description:f.description,source:a});let d=H3n(f.content??{},n);if(d!=null){if(t!=null)switch(t){case"json":return T3.streamingJson({description:f.description,responseProperty:void 0,schema:oq(L1(d.schema,!1,n,i,a,u)),source:a});case"sse":return T3.streamingSse({description:f.description,responseProperty:void 0,schema:oq(L1(d.schema,!1,n,i,a,u)),source:a})}return T3.json({description:f.description,schema:L1(d.schema,!1,n,i,a,u),responseProperty:Lh(e.operation,kh.RESPONSE_PROPERTY),fullExamples:d.examples,source:a})}for(let[c,o]of Object.entries(f.content??{})){let l=sA.parse(c);if(l!=null){if(l.isOctetStream()||l.isPDF()||l.isAudio()||l.isImage()||l.isVideo())return T3.file({description:f.description,source:a});if(l.isPlainText()){let g=o.schema;if(g==null)return T3.text({description:f.description,source:a});let O=gy(g)?n.resolveSchemaReference(g):g;return O.type==="string"&&O.format==="byte"?T3.file({description:f.description,source:a}):T3.text({description:f.description,source:a})}}}}function KX1({responses:e,context:t,source:r,namespace:n}){let i={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let f=parseInt(a);if(f<400||f>600)continue;let d=gy(u)?t.resolveResponseReference(u):u,c=nqf(d.content??{},t),o=Gmu[f];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}i[f]={statusCode:f,nameOverride:void 0,generatedName:o,description:d.description,schema:L1((c==null?void 0:c.schema)??{},!1,t,[o,"Body"],r,n),fullExamples:c==null?void 0:c.examples,source:r}}return i}function vEr({operationContext:e,context:t,responseStatusCode:r,suffix:n,streamFormat:i,source:a}){let{document:u,operation:f,path:d,method:c,baseBreadcrumbs:o,sdkMethodName:l}=e,g=Lh(f,kh.IDEMPOTENT),O=Lh(f,[kh.REQUEST_NAME_V1,kh.REQUEST_NAME_V2]),j=[...o,"Request"],S=x1a({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:j,path:d,httpMethod:c,source:a}),x=f.requestBody!=null?$3n({requestBody:f.requestBody,document:u,context:new W3n({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:j,source:a,namespace:t.namespace}):void 0;(S.queryParameters.length>0||S.headers.length>0)&&x!=null&&x.type==="json"&&x.schema.type!=="object"&&f.requestBody!=null?x=$3n({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j,"Body"],source:a,namespace:t.namespace}):f.requestBody!=null&&(x=$3n({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...j],source:a,namespace:t.namespace}));let A=[...o,"Response"],z=uqf({operationContext:e,streamFormat:i,responses:f.responses,context:t,responseBreadcrumbs:A,responseStatusCode:r,source:a}),N=eqf(f),C=k2f(e,f,t),U=Lh(f,kh.SERVER_NAME_V2);return{summary:f.summary,internal:Lh(f,Yje.INTERNAL),idempotent:g,audiences:Lh(f,kh.AUDIENCES)??[],operationId:f.operationId!=null&&n!=null?f.operationId+"_"+n:f.operationId,tags:t.resolveTagsToTagIds(f.tags),namespace:t.namespace,sdkName:l,pathParameters:S.pathParameters,queryParameters:S.queryParameters,headers:S.headers,requestNameOverride:O??void 0,generatedRequestName:yR(j),request:x,response:z.value,errors:z.errors,server:U!=null?[{name:U,url:void 0,audiences:void 0}]:(f.servers??[]).map(Y=>M1a(Y)),description:f.description,authed:YX1(f,u),availability:N,method:c,path:d,examples:C,pagination:e.pagination,source:a}}function YX1(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function cqf({operationContext:e,context:t,asyncExtension:r,source:n}){let{operation:i,pathItemParameters:a,operationParameters:u}=e,f=r.discriminant.name,d=r.discriminant.value,c=r["response-status-code"],o=sqf({context:t,headerToIgnore:f,parameters:a}),l=sqf({context:t,headerToIgnore:f,parameters:u}),g=vEr({operationContext:{...e,pathItemParameters:o,operationParameters:l,operation:{...i,responses:Object.fromEntries(Object.entries(i.responses).filter(([j])=>parseInt(j)!==c))}},context:t,streamFormat:void 0,source:n}),O=vEr({operationContext:{...e,pathItemParameters:o,operationParameters:l,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:c,streamFormat:void 0,source:n});return O.headers.push({name:f,schema:Lp.literal({nameOverride:void 0,generatedName:yR([f]),title:void 0,description:void 0,availability:void 0,value:E7.string(d),groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:n}),{sync:g,async:O}}function sqf({context:e,headerToIgnore:t,parameters:r}){return r.filter(n=>{let i=gy(n)?e.resolveParameterReference(n):n;return!(i.in==="header"&&i.name===t)})}var Kmu="stream";function pqf({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:vEr({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let n=lqf({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if((n==null?void 0:n.schemaReference)!=null){let c=A5r(n.schemaReference);c!=null&&t.excludeSchema(c)}let i=fqf({operation:e.operation,response:r.responseStream}),a=vEr({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+Kmu}:void 0,operation:{...e.operation,requestBody:n==null?void 0:n.requestBody,responses:i},baseBreadcrumbs:[...e.baseBreadcrumbs,Kmu]},context:t,streamFormat:r.format,suffix:Kmu,source:t.source});a.examples=a.examples.filter(c=>dqf(c,t)!==!1);let u=lqf({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),f=fqf({operation:e.operation,response:r.response}),d=vEr({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u==null?void 0:u.requestBody,responses:f}},context:t,source:t.source});return d.examples=d.examples.filter(c=>dqf(c,t)!==!0),{streaming:a,nonStreaming:d}}default:Ol(r)}}function lqf({context:e,operation:t,streamingExtension:r,isStreaming:n}){var c;if(t.requestBody==null)return;let i=gy(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=H3n(i.content,e);if(a==null)return;let u=gy(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let f=(c=u.properties)==null?void 0:c[r.streamConditionProperty];f!=null&&gy(f)&&(f=void 0);let d={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":n,...f??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[sA.APPLICATION_JSON]:{schema:d}}},schemaReference:gy(a.schema)?a.schema:void 0}}function fqf({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[sA.APPLICATION_JSON]:{schema:t}}}}}function dqf(e,t){return e._visit({unknown:r=>{let n=h5.ExampleEndpointCallSchema.safeParse(r);if(!n.success){t.logger.error("Failed to parse example",n.error.toString());return}if(n.data.response!=null)return n.data.response.stream!=null},full:()=>{},_other:()=>{}})}function _qf({context:e,operationContext:t,source:r}){let{document:n,operation:i,path:a,method:u,baseBreadcrumbs:f,sdkMethodName:d}=t,c=[...f,"Payload"],o=x1a({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:c,path:a,httpMethod:u,source:r});if(i.requestBody==null){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Missing a request body`);return}if(u!=="POST"&&u!=="GET"){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Not POST or GET`);return}let l=$3n({requestBody:i.requestBody,document:n,context:e,requestBreadcrumbs:[...f,"Payload"],source:r,namespace:e.namespace});if(l==null||l.type!=="json"){e.logger.error(`Skipping webhook ${a} because non-json request body`);return}if(i.operationId==null){e.logger.error(`Skipping webhook ${a} because no operation id present`);return}return{summary:i.summary,sdkName:d,namespace:e.namespace,method:u,operationId:i.operationId,tags:e.resolveTagsToTagIds(i.tags),headers:o.headers,generatedPayloadName:yR(c),payload:l.schema,description:i.description,examples:XX1(l.fullExamples),source:r}}function XX1(e){if(e==null)return[];let t=[];for(let r of e){let n=N5r(r.value);n!=null&&t.push({description:r.description,name:r.name,payload:n})}return t}function Ymu({context:e,pathItemContext:t,operation:r,convertToWebhook:n}){let i=Lh(r,kh.IGNORE);if(i!=null&&i){e.logger.info(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=QX1(r,e),u=$2f(e.document,r),f={...t,sdkMethodName:a,baseBreadcrumbs:ZX1({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path}),operation:r,operationParameters:r.parameters??[],pagination:u};if(n){let l=_qf({context:e,operationContext:f,source:e.source});return l!=null?{type:"webhook",value:l}:void 0}let d=W2f(r);if(d!=null){let l=pqf({context:e,operationContext:f,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let c=U2f(r);if(c!=null){let l=cqf({context:e,operationContext:f,asyncExtension:c,source:e.source});return{type:"async",async:l.async,sync:l.sync}}let o=vEr({context:e,operationContext:f,streamFormat:void 0,source:e.source});return{type:"http",value:o}}function QX1(e,t){let r=Lh(e,kh.SDK_METHOD_NAME),n=Lh(e,kh.SDK_GROUP_NAME)??[];if(r!=null){let i=typeof n=="string"?[n]:n;return i=t.resolveGroupName(i),{groupName:i,methodName:r}}}function ZX1({sdkMethodName:e,operation:t,httpMethod:r,path:n}){let i=[];if(e!=null){if(e.groupName.length>0){let a=e.groupName[e.groupName.length-1];a!=null&&i.push(typeof a=="string"?a:a.name)}i.push(e.methodName)}else t.operationId!=null?i.push(t.operationId):i.push(FE(`${r}_${n.split("/").join("_")}`));return i}function hqf(e,t,r,n){let i=[],a=vqf(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=kX1({operation:f.operation}),c=Ymu({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:d});c!=null&&i.push(c)}return i}function yqf(e,t,r,n){let i=[],a=vqf(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=Ymu({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:!0});d!=null&&i.push(d)}return i}function vqf(e){let t=[];return e.get!=null&&t.push({method:GJ.Get,operation:e.get}),e.post!=null&&t.push({method:GJ.Post,operation:e.post}),e.put!=null&&t.push({method:GJ.Put,operation:e.put}),e.delete!=null&&t.push({method:GJ.Delete,operation:e.delete}),e.patch!=null&&t.push({method:GJ.Patch,operation:e.patch}),t}function kX1({operation:e}){return Lh(e,[kh.WEBHOOK])??!1}function bqf(e){let t=Lh(e,kh.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=Lh(e,kh.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function gqf(e){return Lh(e,kh.FERN_BASIC_AUTH)}function Xmu(e,t){if(gy(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return eQ1(e,t)}function eQ1(e,t){var r,n,i,a;if(e.type==="apiKey"&&e.in==="header"){let u=Lh(e,Yje.BEARER_FORMAT),f=Lh(e,kh.FERN_HEADER_AUTH);return F9.header({headerName:e.name,prefix:u!=null?"Bearer":f==null?void 0:f.prefix,headerVariableName:(f==null?void 0:f.name)??Lh(e,kh.HEADER_VARIABLE_NAME),headerEnvVar:f==null?void 0:f.env})}else if(e.type==="http"&&e.scheme==="bearer"){let u=Lh(e,kh.FERN_BEARER_TOKEN);return F9.bearer({tokenVariableName:(u==null?void 0:u.name)??Lh(e,kh.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:u==null?void 0:u.env})}else if(e.type==="http"&&e.scheme==="basic"){let u=gqf(e),f=bqf(e);return F9.basic({usernameVariableName:((r=u==null?void 0:u.username)==null?void 0:r.name)??f.usernameVariable,usernameEnvVar:(n=u==null?void 0:u.username)==null?void 0:n.env,passwordVariableName:((i=u==null?void 0:u.password)==null?void 0:i.name)??f.passwordVariable,passwordEnvVar:(a=u==null?void 0:u.password)==null?void 0:a.env})}else{if(e.type==="openIdConnect")return F9.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return F9.oauth({scopesEnum:tQ1(e,t)})}throw new Error(`Failed to convert security scheme ${JSON.stringify(e)}`)}function tQ1(e,t){var n,i,a,u;let r=((n=e.flows.authorizationCode)==null?void 0:n.scopes)??((i=e.flows.clientCredentials)==null?void 0:i.scopes)??((a=e.flows.implicit)==null?void 0:a.scopes)??((u=e.flows.password)==null?void 0:u.scopes);if(r!=null){let f=C5r({nameOverride:void 0,generatedName:"OauthScope",title:void 0,enumValues:Object.keys(r),fernEnum:Object.fromEntries(Object.entries(r).map(([c,o])=>[c,{description:o}])),_default:void 0,description:void 0,availability:void 0,enumVarNames:void 0,wrapAsNullable:!1,groupName:void 0,context:void 0,source:t}),d=oq(f);if(d.type==="enum")return d}}function mqf(e){return Lh(e,kh.BASE_PATH)}var rQ1=ir.record(ir.string(),ir.object({summary:ir.string().optional(),description:ir.string().optional()}));function Oqf({document:e,context:t}){return RRt(e,kh.GROUPS,rQ1,t.logger)}function Pqf({context:e,document:t}){return RRt(t,kh.FERN_VERSION,h5.VersionDeclarationSchema,e.logger)??void 0}function jqf(e){let t=Lh(e,kh.FERN_GLOBAL_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?N_i({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function wqf(e){let t=Lh(e,kh.FERN_IDEMPOTENCY_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?N_i({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function Dqf(e){let t=Lh(e,kh.SDK_VARIABLES);return t==null?{}:Object.fromEntries(Object.entries(t).map(([r,n])=>{if(n.type==="string")return[r,{nameOverride:void 0,generatedName:yR([r]),title:n.title,schema:Xw.string({default:Y7n(n),pattern:n.pattern,format:n.format,minLength:n.minLength,maxLength:n.maxLength}),description:n.description,availability:void 0,groupName:void 0}];throw new Error(`Variable ${r} has unsupported schema ${JSON.stringify(n)}`)}))}var nQ1="webhooks";function Sqf(e){return Lh(e,nQ1)??{}}var T1a=class extends V3n{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discrminatedUnionReferences={};discrminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u})}getDummy(){return new W3n({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,n){let i=this.discrminatedUnionReferences[t.$ref];i!=null?(i.discriminants.add(r),i.numReferences+=n):this.discrminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:n}}getReferencesFromDiscriminatedUnion(t){return this.discrminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,n){let i=this.discrminatedUnionMetadata[t.$ref];i!=null?i.discriminants.set(r,n):this.discrminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,n]])}}getDiscriminatedUnionMetadata(t){return this.discrminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function Eqf(e){return Lh(e,kh.RESOLUTIONS)}function Mqf({openapi:e}){let t=Eqf(e);if(t==null)return e;let r={};for(let n of t){let i=`#/components/schemas/${n.name}`;for(let a of n.resolutions)e=iQ1({openapi:e,schemaReference:a,schemaName:n.name}),e=xqf({openapi:e,replaceReference:a,schemaReference:i,replacedReferences:r}),r={...r,...Object.fromEntries(n.resolutions.map(u=>[i,u]))}}return e}function iQ1({openapi:e,schemaReference:t,schemaName:r}){let n=t.replace("#/","").split("/").map(a=>a.replace("~1","/")),i=e;for(let a of n){let u=i[a];if(u==null)return e;i=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=i,e}function xqf({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:n}){let i=Object.keys(n).filter(d=>t.startsWith(d)).sort((d,c)=>c.length-d.length)[0];if(i!=null){let d=n[i];if(d!=null){let c=r.replace(i,d);return xqf({openapi:e,replaceReference:t,schemaReference:c,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replace("~1","/")),u=e;for(let d of a.slice(0,-1)){let c=u[d];if(c==null)return e;u=c}let f=a[a.length-1];return f==null||(u[f]={$ref:r}),e}function q1a({openApi:e,taskContext:t,options:r,source:n,namespace:i}){var Y,te,G;e=Mqf({openapi:e});let a=Object.fromEntries(Object.entries(((Y=e.components)==null?void 0:Y.securitySchemes)??{}).map(([$,ee])=>Xmu(ee,n)==null?[]:[$,Xmu(ee,n)])),u=new Set(...Object.entries(a).map(([$,ee])=>ee.type==="basic"||ee.type==="bearer"?"Authorization":ee.type==="header"?ee.headerName:null)),f=new T1a({document:e,taskContext:t,authHeaders:u,options:r,source:n,namespace:i}),d=Dqf(e),c=jqf(e),o=wqf(e),l=r.audiences??[],g=[],O=[];Object.entries(e.paths??{}).forEach(([$,ee])=>{if(ee==null)return;t.logger.debug(`Converting path ${$}`);let Ve=hqf($,ee,e,f);for(let $e of Ve){let Dt=Tqf({operation:$e});if(!(l.length>0&&!l.some(Tt=>Dt.includes(Tt))))switch($e.type){case"async":g.push($e.sync),g.push($e.async);break;case"http":g.push($e.value);break;case"streaming":g.push($e.streaming),$e.nonStreaming&&g.push($e.nonStreaming);break;case"webhook":O.push($e.value);break;default:Ol($e)}}}),Object.entries(Sqf(e)).forEach(([$,ee])=>{if(ee==null)return;t.logger.debug(`Converting path ${$}`);let Ve=yqf($,ee,e,f);for(let $e of Ve){let Dt=Tqf({operation:$e});l.length>0&&!l.some(Tt=>Dt.includes(Tt))||O.push($e.value)}});let j=Object.fromEntries(Object.entries(((te=e.components)==null?void 0:te.schemas)??{}).map(([$,ee])=>{if(!gy(ee)){let Ve=Lh(ee,kh.IGNORE);if(Ve!=null&&Ve)return[];if(aqf.has($))return[$,L1({...ee,"x-fern-type-name":`${$}Body`},!1,f,[$],n,i)]}return[$,L1(ee,!1,f,[$],n,i)]}).filter($=>$.length>0)),S=aQ1(j,f,n),x=oQ1(S,f),A={};for(let[$,ee]of Object.entries(x)){let Ve=oq(ee);f.isSchemaExcluded($)||(A[$]=Ve,t.logger.debug(`Converted schema ${$}`))}let z=new lba(x,f.logger),N=g.map($=>{let ee=$.examples,Ve=ee;if(!r.disableExamples&&(ee.length===0||ee.every(R_i))){let Tt=z.buildEndpointExample($);Tt.length>0&&(Ve=[...Tt,...ee.filter(Wt=>!R_i(Wt))])}let $e=$.request,Dt=$.response;return{...$,request:($e==null?void 0:$e.type)==="json"?{...$e,schema:oq($e.schema)}:$e,response:(Dt==null?void 0:Dt.type)==="json"?{...Dt,schema:oq(Dt.schema)}:Dt,queryParameters:$.queryParameters.map(Tt=>({description:Tt.description,name:Tt.name,schema:oq(Tt.schema),parameterNameOverride:Tt.parameterNameOverride,availability:Tt.availability,source:Tt.source})),pathParameters:$.pathParameters.map(Tt=>({description:Tt.description,name:Tt.name,schema:oq(Tt.schema),parameterNameOverride:Tt.parameterNameOverride,variableReference:Tt.variableReference,availability:Tt.availability,source:Tt.source})),headers:$.headers.map(Tt=>({description:Tt.description,name:Tt.name,schema:oq(Tt.schema),parameterNameOverride:Tt.parameterNameOverride,env:Tt.env,availability:Tt.availability,source:Tt.source})),examples:Ve,errors:sy($.errors,Tt=>{var Wt;return{generatedName:Tt.generatedName,nameOverride:Tt.nameOverride,schema:oq(Tt.schema),description:Tt.description,source:Tt.source,examples:(Wt=Tt.fullExamples)==null?void 0:Wt.map(Nt=>{let ur=N5r(Nt.value);if(ur!=null)return{name:Nt.name,description:Nt.description,example:ur}}).filter(RS)}})}}),C=Oqf({document:e,context:f});return{apiVersion:Pqf({context:f,document:e}),basePath:mqf(e),title:e.info.title,description:e.info.description,groups:Object.fromEntries(Object.entries(C??{}).map(([$,ee])=>[$,{summary:ee.summary??void 0,description:ee.description??void 0}])),servers:(e.servers??[]).map($=>M1a($)),tags:{tagsById:Object.fromEntries((e.tags??[]).map($=>[$.name,{id:$.name,description:$.description}])),orderedTagIds:(G=e.tags)==null?void 0:G.map($=>$.name)},endpoints:N,webhooks:O,channel:[],groupedSchemas:uba(i,A),securitySchemes:a,hasEndpointsMarkedInternal:N.some($=>$.internal),nonRequestReferencedSchemas:f.getReferencedSchemas(),variables:d,globalHeaders:c,idempotencyHeaders:o}}function aQ1(e,t,r){let n={};for(let[i,a]of Object.entries(e)){if(a.type!=="object"){n[i]=a;continue}let u={$ref:`#/components/schemas/${i}`},f=t.getReferencesFromDiscriminatedUnion(u);if(f==null){n[i]=a;continue}let d={...a,type:"object",properties:a.properties.filter(o=>!f.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!f.discriminants.has(o.propertyKey)),source:r};n[i]=d;let c=qqf({schema:a,schemas:e});for(let o of[...new Set(c)]){let l=n[o]??e[o];l==null||l.type!=="object"||(n[o]={...l,type:"object",properties:l.properties.filter(g=>!f.discriminants.has(g.key)),allOfPropertyConflicts:l.allOfPropertyConflicts.filter(g=>!f.discriminants.has(g.propertyKey))})}}return n}function oQ1(e,t){let r={};for(let[n,i]of Object.entries(e)){if(i.type!=="object"){r[n]=i;continue}let a={$ref:`#/components/schemas/${n}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[n]=i;continue}let f=[];for(let c of i.properties)if(u.discriminants.has(c.key)){let o=u.discriminants.get(c.key);o!=null&&f.push({...c,schema:Lp.literal({nameOverride:void 0,generatedName:yR([i.generatedName,o]),title:void 0,value:E7.string(o),groupName:void 0,description:void 0,availability:i.availability})})}else f.push(c);let d={...i,type:"object",properties:f};r[n]=d}return r}function qqf({schema:e,schemas:t}){let r=[];for(let n of e.allOf){r.push(n.schema);let i=t[n.schema];i!=null&&i.type==="object"&&r.push(...qqf({schema:i,schemas:t}))}return r}function Tqf({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:Ol(e)}return t}async function Aqf({openApi:e,taskContext:t,options:r,source:n,namespace:i}){let a=await(0,Cqf.convertObj)(e,{});return q1a({openApi:a.openapi,taskContext:t,options:r,source:n,namespace:i})}var J3n={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0};async function Ktn({absoluteFilePathToWorkspace:e,specs:t,taskContext:r,optionOverrides:n}){let i={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channel:[],groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}};for(let a of t){let u=(await(0,Zmu.readFile)(a.absoluteFilepath)).toString(),f=YN(e,a.source.file);a.source.relativePathToDependency!=null&&(f=pf(a.source.relativePathToDependency,f));let d=a.source.type==="protobuf"?HSr.protobuf({file:f}):HSr.openapi({file:f});if(u.includes("openapi")||u.includes("swagger")){let c=await REf({absolutePathToOpenAPI:a.absoluteFilepath,context:r,absolutePathToOpenAPIOverrides:a.absoluteFilepathToOverrides});if(cQ1(c)){let o=q1a({openApi:c,taskContext:r,options:Qmu({specSettings:a.settings,overrides:n}),source:d,namespace:a.namespace});i=Nqf(i,o)}else if(lQ1(c)){let o=await Aqf({openApi:c,taskContext:r,options:Qmu({specSettings:a.settings}),source:d,namespace:a.namespace});i=Nqf(i,o)}}else if(u.includes("asyncapi")){let c=await sQ1({absoluteFilePathToAsyncAPI:a.absoluteFilepath,context:r,absoluteFilePathToAsyncAPIOverrides:a.absoluteFilepathToOverrides}),o=Tpf({document:c,taskContext:r,options:Qmu({specSettings:a.settings}),source:d,asyncApiOptions:uQ1({specSettings:a.settings}),namespace:a.namespace});o.channel!=null&&i.channel.push(o.channel),o.groupedSchemas!=null&&(i.groupedSchemas=zqf(i.groupedSchemas,o.groupedSchemas)),o.basePath!=null&&(i.basePath=o.basePath)}else r.failAndThrow(`${a.absoluteFilepath} is not a valid OpenAPI or AsyncAPI file`)}return i}function Qmu({specSettings:e,overrides:t}){return{disableExamples:(t==null?void 0:t.disableExamples)??J3n.disableExamples,discriminatedUnionV2:(t==null?void 0:t.discriminatedUnionV2)??(e==null?void 0:e.shouldUseUndiscriminatedUnionsWithLiterals)??J3n.discriminatedUnionV2,useTitlesAsName:(t==null?void 0:t.useTitlesAsName)??(e==null?void 0:e.shouldUseTitleAsName)??J3n.useTitlesAsName,audiences:(t==null?void 0:t.audiences)??(e==null?void 0:e.audiences)??J3n.audiences,optionalAdditionalProperties:(t==null?void 0:t.optionalAdditionalProperties)??(e==null?void 0:e.optionalAdditionalProperties)??J3n.optionalAdditionalProperties}}function uQ1({specSettings:e,overrides:t}){return{naming:(t==null?void 0:t.naming)??(e==null?void 0:e.asyncApiNaming)??tpf.naming}}function Nqf(e,t){return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channel:[...e.channel,...t.channel],groupedSchemas:zqf(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 zqf(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,n]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...n}:e.namespacedSchemas[r]=n;return e}async function sQ1({absoluteFilePathToAsyncAPI:e,absoluteFilePathToAsyncAPIOverrides:t,context:r}){let n=(await(0,Zmu.readFile)(e)).toString(),i=await av.load(n);return t!=null?await PPa({absoluteFilepathToOverrides:t,context:r,data:i}):i}function cQ1(e){return e.openapi!=null}function lQ1(e){return e.swagger!=null}function A1a({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=kmu({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let a=A2(i.value);if(a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>"),e.description==null&&!i.allowMultiple&&e.parameterNameOverride==null&&e.availability==null)return a;let u={type:a};return i.allowMultiple&&(u["allow-multiple"]=!0),e.description!=null&&(u.docs=e.description),e.parameterNameOverride!=null&&(u.name=e.parameterNameOverride),e.availability!=null&&(u.availability=q3(e.availability)),u}function kmu({schema:e,context:t,fileContainingReference:r,namespace:n}){if(e.type==="reference"){let i=t.getSchema(e.schema,n);if(i==null)return;if(i.type==="array")return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,groupName:void 0}),context:t,declarationFile:zs.of(HT),fileContainingReference:r,namespace:n}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undisciminated"){let a=[];for(let[u,f]of Object.entries(i.value.schemas))f.type==="literal"&&f.value.type==="string"&&(G7n.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:z_i(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),{value:e.generatedName,allowMultiple:!1};if(i.value.schemas.length===2){let[u,f]=i.value.schemas;if(u!=null&&f!=null&&C1a({array:u,primitive:f}))return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(u!=null&&f!=null&&C1a({array:u,primitive:f}))return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}}for(let[u,f]of Object.entries(i.value.schemas))return kmu({schema:f,context:t,fileContainingReference:r,namespace:n})}else if(i.type==="object")return}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let i=t.getSchema(e.value.schema,n);if(i==null)return;if(i.type==="array")return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,declarationFile:zs.of(HT),namespace:n}),allowMultiple:!0}}if(e.value.type==="array")return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undisciminated"){let i=[];for(let[a,u]of Object.entries(e.value.value.schemas))u.type==="literal"&&u.value.type==="string"&&(G7n.test(u.value.value)?i.push(u.value.value):i.push({value:u.value.value,name:z_i(u.value.value)}));if(i.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:i}}),{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[a,u]=e.value.value.schemas;if(a!=null&&u!=null&&C1a({array:a,primitive:u}))return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(a!=null&&u!=null&&C1a({array:u,primitive:a}))return{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}}for(let[a,u]of Object.entries(e.value.value.schemas))return kmu({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:void 0,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return;return{value:S1({schema:e,context:t,fileContainingReference:r,namespace:n}),allowMultiple:!1}}return e.type==="array"?{value:S1({schema:ib.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}:{value:S1({schema:e,context:t,fileContainingReference:r,namespace:n}),allowMultiple:!1}}function C1a({array:e,primitive:t}){return(e==null?void 0:e.type)==="array"&&e.value.type==="primitive"&&(t==null?void 0:t.type)==="primitive"&&e.value.schema.type===t.schema.type}function Bqf({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"]=fQ1(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=dQ1({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=Rzr(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function fQ1(e){let t={};return e.forEach(r=>{let n=Rzr(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function dQ1({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=Rzr(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function Rzr(e){switch(e.type){case"primitive":return Iqf(e.value);case"object":return Rqf(e.properties);case"array":return pQ1(e.value);case"map":return _Q1(e.value);case"oneOf":return hQ1(e.value);case"enum":return e.value;case"literal":return yQ1(e.value);case"unknown":return Rzr(e.value);default:Ol(e)}}function Iqf(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:Ol(e)}}function Rqf(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Rzr(r)]))}function pQ1(e){return e.map(t=>Rzr(t))}function _Q1(e){return Object.fromEntries(e.map(t=>[Iqf(t.key),Rzr(t.value)]))}function hQ1(e){return e.type==="discriminated"?Rqf(e.value):Rzr(e.value)}function yQ1(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Ol(e)}}function bEr(e){var t;return(t=e.find(r=>typeof r!="string"&&r.type==="namespace"))==null?void 0:t.name}function N1a(e,t){return t??((e==null?void 0:e.groupName)!=null?bEr(e.groupName):void 0)}function Fqf({channel:e,context:t,declarationFile:r}){let n={path:e.path,auth:!1};e.summary!=null&&(n["display-name"]=e.summary);let i=bEr(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=kva({pathParameter:d,context:t,fileContainingReference:r,namespace:i});Object.keys(a).length>0&&(n["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let c=A1a({queryParameter:d,context:t,fileContainingReference:r,namespace:i});c!=null&&(u[d.name]=c)}Object.keys(u).length>0&&(n["query-parameters"]=u);let f={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let c=IRt({header:d,context:t,fileContainingReference:r,namespace:i});f[d.name]=c}Object.keys(f).length>0&&(n.headers=f),t.builder.addChannel(r,{channel:n}),e.subscribe!=null&&t.builder.addChannelMessage(r,{messageId:"subscribe",message:{origin:"server",body:S1({schema:e.subscribe,context:t,fileContainingReference:r,namespace:i})}}),e.publish!=null&&t.builder.addChannelMessage(r,{messageId:"publish",message:{origin:"client",body:S1({schema:e.publish,context:t,fileContainingReference:r,namespace:i})}});for(let d of e.examples){let c=Bqf({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:c})}}var Lqf="Production",Uqf="Default";function Vqf(e){return Object.entries(e).reduce((t,[r,n])=>(U2n(n)?Object.entries(n.urls).forEach(([i,a])=>{t[i]=a}):t[r]=typeof n=="string"?n:n.url,t),{})}function Wqf(e){var f,d;if(e.environmentOverrides!=null){for(let[c,o]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:c,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 c of e.ir.servers){let o=c.audiences?{url:c.url,audiences:c.audiences}:c.url;if(c.name==null){r.push(o);continue}t[c.name]=o}let n={},i=[];for(let c of e.ir.endpoints)for(let o of c.server){if(o.url==null)continue;let l=o.audiences?{url:o.url,audiences:o.audiences}:o.url;if(o.name==null){i.push(l);continue}n[o.name]=l}let a=Object.keys(t).length,u=Object.keys(n).length;if(a===0&&u===0){let c=(f=e.ir.servers[0])==null?void 0:f.url,o=(d=e.ir.servers[0])==null?void 0:d.audiences;c!=null&&(e.builder.addEnvironment({name:Uqf,schema:o?{url:c,audiences:o}:c}),e.builder.setDefaultEnvironment(Uqf))}else if(a>0&&u===0){let c=0;r.length>0&&e.logger.error(`Skipping servers ${r.map(o=>typeof o=="string"?o:o.url).join(", ")} because x-fern-server-name was not provided.`);for(let[o,l]of Object.entries(t))c===0&&e.builder.setDefaultEnvironment(o),e.builder.addEnvironment({name:o,schema:l}),c+=1}else if(u>0){(r.length>0||i.length>0)&&e.logger.error(`Skipping servers ${[...r,...i].map(o=>typeof o=="string"?o:o.url).join(", ")} because x-fern-server-name was not provided.`);let c=Object.entries(t)[0];if(c!=null){let[o,l]=c;e.setDefaultServerName(o)}e.builder.addEnvironment({name:Lqf,schema:{urls:{...Vqf(t),...Vqf(n)}}}),e.builder.setDefaultEnvironment(Lqf)}}function z1a(e){return A2(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var eOu=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},vQ1=.75,bQ1=new Set("authorization");function Hqf(e){let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,n]of Object.entries(t)){let i="optional<string>";if(n.name==null&&n.env==null&&typeof n.schema=="string")i=n.schema;else if(n!=null){let a=n.schema?V7n(n.schema):void 0,u=a!=null?bEr(a):void 0,f=zs.of("api.yml");i={name:n.name,env:n.env,type:n.schema!=null?A2(S1({schema:n.schema,context:e,fileContainingReference:u?pf(zs.of(FE(u)),f):f,namespace:u}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:i})}if(e.detectGlobalHeaders){let r={};for(let i of e.ir.endpoints)for(let a of i.headers){if(bQ1.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let f=t[a.name],d=IRt({header:{...a,schema:(f==null?void 0:f.schema)??a.schema,name:(f==null?void 0:f.name)??a.name},fileContainingReference:zs.of(nB),context:e,namespace:void 0});u=new eOu(d),r[a.name]=u}u.increment()}let n=e.ir.endpoints.length*vQ1;for(let[i,a]of Object.entries(r)){let u=t[i],f=a.count===e.ir.endpoints.length,d=a.count>=n;u==null&&(f?e.builder.addGlobalHeader({name:i,schema:a.schema}):d&&e.builder.addGlobalHeader({name:i,schema:z1a(a.schema)}))}}}function $qf(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?V7n(t.schema):void 0,n=r!=null?bEr(r):void 0,i=IRt({header:{...t,schema:t.schema??ib.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0,schema:Xw.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:zs.of(nB),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:z1a(i)})}}function cG(e){switch(e.type){case"primitive":return Jqf(e.value);case"object":return Gqf(e.properties);case"array":return gQ1(e.value);case"map":return mQ1(e.value);case"oneOf":return OQ1(e.value);case"enum":return e.value;case"literal":return PQ1(e.value);case"unknown":return cG(e.value);default:Ol(e)}}function Jqf(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:Ol(e)}}function Gqf(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,cG(r)]))}function gQ1(e){return e.map(t=>cG(t))}function mQ1(e){return Object.fromEntries(e.map(t=>[Jqf(t.key),cG(t.value)]))}function OQ1(e){return e.type==="discriminated"?Gqf(e.value):cG(e.value)}function PQ1(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Ol(e)}}function Kqf({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"]=jQ1(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=wQ1(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=DQ1({context:t,namedFullExamples:e.headers})),e.request!=null&&(r.request=cG(e.request)),e.response!=null&&(r.response={body:cG(e.response)}),e.response!=null&&(r.response={body:cG(e.response)}),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(n=>n.type==="language"?{name:n.name??void 0,docs:n.description??void 0,language:n.language,code:n.code,install:n.install??void 0}:{name:n.name??void 0,docs:n.description??void 0,sdk:n.sdk,code:n.code}).filter(RS)),r)}function jQ1(e){let t={};return e.forEach(r=>{let n=cG(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function wQ1(e){let t={};return e.forEach(r=>{let n=cG(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function DQ1({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=cG(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function Yqf(e){return GJ._visit(e,{get:()=>h5.HttpMethodSchema.Enum.GET,post:()=>h5.HttpMethodSchema.Enum.POST,put:()=>h5.HttpMethodSchema.Enum.PUT,patch:()=>h5.HttpMethodSchema.Enum.PATCH,delete:()=>h5.HttpMethodSchema.Enum.DELETE,head:()=>{throw new Error("HEAD is unsupported")},options:()=>{throw new Error("HEAD is unsupported")},trace:()=>{throw new Error("HEAD is unsupported")},_other:()=>{throw new Error("Unkown http method is unsupported")}})}function Xqf({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],a=new Set,u=e.path,f=N1a(e.sdkName,e.namespace),d={};for(let S of e.pathParameters)S.parameterNameOverride&&(u=u.replace(S.name,S.parameterNameOverride)),d[S.parameterNameOverride??S.name]=kva({pathParameter:S,context:r,fileContainingReference:t,namespace:f}),a.add(S.name);let c={};for(let S of e.queryParameters){let x=A1a({queryParameter:S,context:r,fileContainingReference:t,namespace:f});x!=null&&(c[S.name]=x,a.add(S.name))}let o;e.pagination!=null&&(e.pagination.type==="cursor"?o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results}:o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage});let l={path:u,method:Yqf(e.method),auth:e.authed,docs:e.description??void 0,pagination:o};Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let g={},O=r.builder.getGlobalHeaderNames(),j=e.headers.filter(S=>!O.has(S.name));for(let S of j){let x=IRt({header:S,context:r,fileContainingReference:t,namespace:f});g[S.name]=x,a.add(typeof x=="string"?S.name:x.name??S.name)}if(e.request!=null){let S=EQ1({context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,queryParameters:Object.keys(c).length>0?c:void 0,nonRequestReferencedSchemas:Array.from(n),headers:Object.keys(g).length>0?g:void 0,usedNames:a,namespace:f});l.request=S.value,i=[...i,...S.schemaIdsToExclude??[]]}else{let S=Object.keys(c).length>0,x=Object.keys(g).length>0,A={};(S||x)&&(A.name=e.requestNameOverride??e.generatedRequestName),S&&(A["query-parameters"]=c),x&&(A.headers=g),Object.keys(A).length>0&&(l.request=A)}if(e.response!=null&&e.response._visit({json:S=>{let x=S1({schema:S.schema,context:r,fileContainingReference:t,namespace:f});l.response={docs:S.description??void 0,type:A2(x)},S.responseProperty!=null&&(l.response.property=S.responseProperty)},streamingJson:S=>{let x=S1({schema:S.schema,context:r,fileContainingReference:t,namespace:f});l["response-stream"]={docs:S.description??void 0,type:A2(x),format:"json"}},streamingSse:S=>{let x=S1({schema:S.schema,context:r,fileContainingReference:t,namespace:f});l["response-stream"]={docs:S.description??void 0,type:A2(x),format:"sse"}},file:S=>{l.response={docs:S.description??void 0,type:"file"}},streamingText:S=>{l["response-stream"]={docs:S.description??void 0,type:"text"}},text:S=>{l.response={docs:S.description??void 0,type:"text"}},_other:()=>{var S;throw new Error("Unrecognized Response type: "+((S=e.response)==null?void 0:S.type))}}),r.builder.getEnvironmentType()==="multi"){let S=r.getDefaultServerName(),x=e.server[0];x==null?S!=null&&(l.url=S):l.url=x.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=q3(e.availability)),Object.entries(e.errors).forEach(([S,x])=>{var te;let A=x.generatedName,z=zs.of(HT);r.builder.enableUniqueErrorsPerEndpoint&&(A=`${e.generatedRequestName}${x.generatedName}`,x.schema!=null&&(x.schema.type!=="reference"&&x.schema.type!=="oneOf"?x.schema.generatedName=`${e.generatedRequestName}${x.schema.generatedName}`:x.schema.type==="oneOf"&&(x.schema.value.generatedName=`${e.generatedRequestName}${x.schema.value.generatedName}`)));let N={"status-code":parseInt(S)};if(x.schema!=null){let G=S1({schema:x.schema,context:r,fileContainingReference:z,namespace:f});N.type=A2(G),N.docs=x.description}let C=Gdf({location:Qqf,namespaceOverride:f});r.builder.addError(C,{name:A,schema:N}),l.errors==null&&(l.errors=[]);let U=r.builder.addImport({file:t,fileToImport:C});l.errors.push(U!=null?`${U}.${A}`:A),N.type!=null&&((te=x.examples)==null||te.forEach(G=>{let $={value:cG(G.example),name:G.name,docs:G.description};r.builder.addErrorExample(C,{name:A,example:$})}))}),e.examples.length>0&&(l.examples=SQ1({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[tOu,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:i}}function SQ1({endpointExamples:e,context:t}){return e.map(r=>{try{return Kqf({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function EQ1({declarationFile:e,context:t,request:r,requestNameOverride:n,generatedRequestName:i,queryParameters:a,nonRequestReferencedSchemas:u,headers:f,usedNames:d,namespace:c}){if(r.type==="json"){let o=r.schema.type==="reference"?r.schema.schema:void 0,l=r.schema.type==="reference"?t.getSchema(r.schema.schema,c):r.schema;if((l==null?void 0:l.type)!=="object"||o!=null&&u.includes(o)){let x=S1({schema:r.schema,fileContainingReference:e,context:t,namespace:c}),A={schemaIdsToExclude:[],value:{body:x}},z=Object.keys(a??{}).length>0,N=Object.keys(f??{}).length>0;return z&&(A.value["query-parameters"]=a),N&&(A.value.headers=f),(z||N)&&(A.value.name=n??i),r.contentType!=null&&(A.value["content-type"]=r.contentType),A}let g=Object.fromEntries(l.properties.map(x=>{let A=S1({schema:x.schema,fileContainingReference:e,context:t,namespace:c}),z=x.nameOverride??x.key,N=q3(x.availability);if(!d.has(z)&&x.audiences.length<=0)return d.add(z),x.nameOverride!=null?[x.key,{type:A2(A),docs:C_i(A),name:x.nameOverride,availability:N}]:[x.key,N?{...typeof A=="string"?{type:A}:A,availability:N}:A];let C={type:A2(A),docs:C_i(A)};return d.has(z)&&(C.name=x.generatedName),x.audiences.length>0&&(C.audiences=x.audiences),N!=null&&(C.availability=N),d.add(z),[x.key,C]})),O=l.allOf.map(x=>{let A=S1({schema:ib.reference(x),fileContainingReference:e,context:t,namespace:c});return A2(A)}),j={properties:g};O.length>0&&(j.extends=O),r.additionalProperties&&(j["extra-properties"]=!0);let S={name:n??l.nameOverride??l.generatedName,"query-parameters":a,headers:f,body:j};return r.contentType!=null&&(S["content-type"]=r.contentType),{schemaIdsToExclude:o!=null?[o]:[],value:S}}else{if(r.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":sA.APPLICATION_OCTET_STREAM}};if(r.type==="multipart"){let o=Object.fromEntries(r.properties.map(l=>{if(l.schema.type==="file"){let g=l.schema.isArray?"list<file>":"file";return[l.key,l.schema.isOptional?`optional<${g}>`:g]}else{let g=S1({schema:l.schema.value,fileContainingReference:e,context:t,namespace:c});return[l.key,g]}}));return{schemaIdsToExclude:r.name==null?[]:[r.name],value:{name:n??r.name??i,"query-parameters":a,headers:f,body:{properties:o},"content-type":sA.MULTIPART_FORM_DATA}}}else Ol(r)}}function MQ1({location:e,namespaceOverride:t}){return t!=null?{...e,file:pf(zs.of(t),e.file)}:e}function xQ1(e){let t=e.tags[0],r=e.operationId;if(r==null)return t!=null?{file:zs.of(`${FE(t)}.yml`),endpointId:e.summary!=null?FE(e.summary):FE(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:zs.of(HT),endpointId:FE(e.summary)}:{file:zs.of(HT),endpointId:FE(`${e.method}_${e.path.split("/").join("_")}`)};if(t==null)return{file:zs.of(HT),endpointId:r};let n=C0i(t),i=C0i(r);if(iDr(n,i))return{file:zs.of("__package__.yml"),endpointId:t};let a=CQ1({operationId:r,tag:t,path:e.path,method:e.method});if(a!=null)return a;let u=[];for(let f=0;f<n.length;++f){let d=n[f];if(d!=null&&d===i[f])u.push(d);else{let c=FE(t);return{file:zs.of(`${c}.yml`),endpointId:r,tag:t}}}if(u.length>=i.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:zs.of(FE(u.join("_"))+".yml"),endpointId:FE(i.slice(u.length).join("_")),tag:t}}function A0i(e){let t=e.tags[0];if(e.sdkName!=null){let r=klu({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===(t==null?void 0:t.toLowerCase().replaceAll(" ",""));return{file:zs.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return MQ1({namespaceOverride:e.namespace,location:xQ1(e)})}function C0i(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=X8t(t),t}var TQ1=new RegExp("[^a-zA-Z0-9{}]+"),qQ1=new RegExp("[{}]","g");function CQ1({operationId:e,tag:t,path:r,method:n}){let a=`${r.split(TQ1).join("_").replaceAll(qQ1,"_")}_${n.toLowerCase()}`;if(e.endsWith(a))return{file:zs.of(FE(t)+".yml"),endpointId:FE(e.slice(0,-1*a.length)),tag:t}}function Zqf(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let a of r){let{endpointId:u,file:f,tag:d}=A0i(a),c=f.split(".")[0];c!=null&&t.add(c);let o;if(a.sdkName!=null){let O=e.ir.groups;for(let j of a.sdkName.groupName){let S=typeof j=="string"?j:j.name,x=O[S];if(x==null)break;if(x.summary!=null||x.description!=null){o=O[S];break}}}let l=d==null?void 0:n.tagsById[d],g=Xqf({context:e,endpoint:a,declarationFile:f});i=[...i,...g.schemaIdsToExclude],e.builder.addEndpoint(f,{name:u,schema:g.value,source:a.source}),((l==null?void 0:l.id)!=null||(l==null?void 0:l.description)!=null)&&e.builder.setServiceInfo(f,{displayName:(o==null?void 0:o.summary)??(l==null?void 0:l.id),docs:(o==null?void 0:o.description)??(l==null?void 0:l.description)??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}function kqf(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?bEr(r.groupName):void 0,i=S1({schema:ib.primitive(r),context:e,fileContainingReference:zs.of(HT),namespace:n});e.builder.addVariable({name:t,schema:{type:A2(i),docs:r.description??void 0}})}}function eCf(e){for(let t of e.ir.webhooks){let r=zQ1({webhook:t,context:e});if(r==null)continue;let n=N1a(t.sdkName,t.namespace),i={};for(let u of t.headers)i[u.name]=IRt({header:u,context:e,fileContainingReference:r.file,namespace:n});let a={method:t.method,"display-name":t.summary??void 0,headers:i,payload:S1({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:cG(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function AQ1({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:pf(zs.of(t),e.file)}:e}function NQ1({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:zs.of(HT),endpointId:n};let i=C0i(r),a=C0i(n);if(iDr(i,a))return{file:zs.of("__package__.yml"),endpointId:r};let u=[];for(let f=0;f<i.length;++f){let d=i[f];if(d!=null&&d===a[f])u.push(d);else{let c=FE(r);return{file:zs.of(`${c}.yml`),endpointId:n,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:zs.of(FE(u.join("_"))+".yml"),endpointId:FE(a.slice(u.length).join("_")),tag:r}}function zQ1({webhook:e,context:t}){return e.sdkName!=null?{file:Jdf({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:AQ1({namespaceOverride:e.namespace,location:NQ1({webhook:e,context:t})})}var BQ1=zs.of(HT);function tCf(e){switch(e.type){case"object":return bFt(e.groupName);case"enum":return bFt(e.groupName);case"oneOf":return bFt(e.value.groupName);case"array":return bFt(e.groupName);case"map":return bFt(e.groupName);case"reference":return bFt(e.groupName);case"literal":return bFt(e.groupName);case"optional":return bFt(e.groupName);case"nullable":return bFt(e.groupName);case"primitive":return bFt(e.groupName);case"unknown":return BQ1;default:Ol(e)}}function bFt(e){return W7n(e)}var tOu="external",Qqf=zs.of(HT);function rCf({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,a]of Object.entries(e)){if(t.includes(i))continue;let u=tCf(a),f=Xdf({schema:a,context:n,declarationFile:u,namespace:r});if(W2n(f.schema)){let d=A2(f.schema);if(d===(f.name??i)||d===`optional<${f.name??i}>`)continue}n.builder.addType(u,{name:f.name??i,schema:f.schema})}}function nCf(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),Wqf(e),Hqf(e),$qf(e),epf(e),kqf(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(tOu);let{schemaIdsToExclude:t,sdkGroups:r}=Zqf(e);eCf(e);for(let n of e.ir.channel){let i=W7n(n.groupName);Fqf({channel:n,context:e,declarationFile:i})}rCf({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:t,namespace:void 0,context:e});for(let[n,i]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))rCf({schemas:i,schemaIdsToExclude:t,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(i=>r.has(i))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}var Fzr=yu(require("path"),1);var B1a=yu(require("path"),1),G3n=class{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[u,f]of Object.entries(n.files)){let d=i!=null?zs.of(`${i}${B1a.default.sep}${u}`):zs.of(u);t[d]=f}let a=Object.keys(n.directories).sort();for(let u of a){let f=i!=null?`${i}${B1a.default.sep}${u}`:u,d=n.directories[u];r(d,f)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(B1a.default.sep))}getOrCreateFileRecursive(t){var i,a;if(t.length===1)return(i=this.files)[a=zs.of(t[0])]??(i[a]={});let[r,...n]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new G3n),this.directories[r].getOrCreateFileRecursive(n)}};var I1a=class{modifyBasePaths;enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t,r,n){this.modifyBasePaths=r,this.enableUniqueErrorsPerEndpoint=n,this.root=new G3n,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}},t.title!=null&&(this.rootApiFile["display-name"]=t.title)}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{displayName:r,docs:n}){let i=this.getOrCreateFile(t);i.service==null&&(i.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(i.service["display-name"]=r),n!=null&&(i.docs=n)}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 ADr(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{}),r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}addGlobalHeader({name:t,schema:r}){let n=this.getVersionHeader();n!=null&&n===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r}){if(t===r)return;let n=FE((0,Fzr.basename)(r,(0,Fzr.extname)(r)).replaceAll("__package__","root"));if(t===zs.of(nB))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=YN(Hg(I_.of(`/${t}`)),I_.of(`/${r}`)),n;let i=this.getOrCreateFile(t);return i.imports==null&&(i.imports={}),i.imports[n]=YN(Hg(I_.of(`/${t}`)),I_.of(`/${r}`)),n}addType(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.types==null&&(i.types={}),i.types[r]=n}addTypeExample(t,r,n){let i=this.getOrCreateFile(t);i.types==null&&(i.types={});let a=i.types[r];a!=null&&(typeof a=="string"?i.types[r]={type:a,examples:[n]}:(a.examples==null&&(a.examples=[]),a.examples.push(n)))}addError(t,{name:r,schema:n}){var a;let i=this.getOrCreateFile(t);i.errors==null&&(i.errors={}),i.errors[r]==null?i.errors[r]=n:((a=i.errors[r])==null?void 0:a.type)!==n.type&&(i.errors[r]={"status-code":n["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:n}){var f;let i=this.getOrCreateFile(t);if(i.errors==null)return;let a=i.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(d=>iDr(d,n))??!1)||(f=a.examples)==null||f.push(n)}addEndpoint(t,{name:r,schema:n,source:i}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),i!=null&&(a.service.source=Ien(i)),a.service.endpoints[r]=n}addWebhook(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.webhooks==null&&(i.webhooks={}),i.webhooks[r]=n}addChannel(t,{channel:r}){let n=this.getOrCreateFile(t);n.channel=r;let i=this.basePath;i!=null&&(n.channel.path=Fzr.default.join(i,r.path))}addChannelExample(t,{example:r}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.examples==null&&(n.channel.examples=[]),n.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:n}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.messages[r]=n}build(){let t=this.root.getAllFiles();if(this.modifyBasePaths){let i=IQ1(this.rootApiFile);this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([a,u])=>[a,{...u,path:`${i}${u.path}`}]))});for(let a of Object.values(t))a.service!=null&&(a.service={...a.service,endpoints:Object.fromEntries(Object.entries(a.service.endpoints).map(([u,f])=>[u,{...f,path:`${i}${f.path}`}]))});this.rootApiFile.environments!=null&&(this.rootApiFile.environments={...Object.fromEntries(Object.entries(this.rootApiFile.environments).map(([a,u])=>typeof u=="string"?[a,u.substring(0,u.length-i.length)]:iCf(u)?[a,{url:u.url.substring(0,u.url.length-i.length)}]:[a,{urls:Object.fromEntries(Object.entries(u.urls).map(([f,d])=>[f,d.substring(0,d.length-i.length)]))}]))})}let r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([i,a])=>[i,{...a,path:Fzr.default.join(r,a.path)}]))});for(let i of Object.values(t))i.service!=null&&(i.service={...i.service,endpoints:Object.fromEntries(Object.entries(i.service.endpoints).map(([a,u])=>[a,{...u,path:Fzr.default.join(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===HT?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 IQ1(e){if(e.environments==null)return"";let t=Object.entries(e.environments).flatMap(([r,n])=>typeof n=="string"?[n]:iCf(n)?[n.url]:Object.values(n.urls));return FQ1(t.map(RQ1))}function RQ1(e){try{let r=new URL(e).pathname;return r.endsWith("/")?r.slice(0,-1):r}catch{return""}}function FQ1(e){let t="";for(;;){let r=e.map(i=>i[i.length-t.length-1]),n=r[0];if(n==null||r.some(i=>i!==n))break;t=n+t}return t}function iCf(e){return e.url!=null}var R1a=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;detectGlobalHeaders;defaultServerName=void 0;constructor({taskContext:t,ir:r,enableUniqueErrorsPerEndpoint:n,detectGlobalHeaders:i,environmentOverrides:a,authOverrides:u}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.builder=new I1a(r,!1,n),this.detectGlobalHeaders=i,this.environmentOverrides=a,this.authOverrides=u}getSchema(t,r){var n;return r==null?this.ir.groupedSchemas.rootSchemas[t]:(n=this.ir.groupedSchemas.namespacedSchemas[r])==null?void 0:n[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}};function rOu(e){let t=new R1a(e);return nCf(t)}var CAf=yu(qAf(),1);async function iwe(e,t,r=[],{doNotPipeOutput:n=!1,secrets:i=[],substitutions:a={},...u}={}){var o,l;let f=i.reduce((g,O)=>({...g,[O]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[g,O]of Object.entries(f))d=d.replaceAll(g,O);e==null||e.debug(`+ ${d}`);let c=(0,CAf.default)(t,r,u);return n||((o=c.stdout)==null||o.pipe(process.stdout),(l=c.stderr)==null||l.pipe(process.stderr)),c}function J1a(e,{logger:t,...r}={}){return(n,i)=>iwe(t,e,n,{...r,...i})}var K1a=require("fs/promises"),AAf=yu(Jte(),1),Ck1="buf.gen.yaml",NAf="output",Ak1=`${NAf}/openapi.yaml`,Nk1=`
|
|
@@ -2277,7 +2277,7 @@ error-discriminant: error`;await(0,v4o.writeFile)(r,i)}}};var BkA={version:"0.0.
|
|
|
2277
2277
|
`));if(await r.takeOverTerminal(async()=>{await Tn6(n)||r.failAndThrow("Canceled.")}),r.getResult()===D4.Failure)return;let i=n.flatMap(({migrations:a,version:u})=>a.map(f=>({migration:f,context:r.addInteractiveTask({name:`${u} ${f.name}`})})));for(let{migration:a,context:u}of i){let f=u.start();if(await a.run({context:f}),f.finish(),f.getResult()===D4.Failure){r.logger.error("Failed to run migrations. You may need to undo changes to files.");return}}}async function Tn6(e){let t="wantsToContinue",r=["Some migrations need to be run:"];for(let{migrations:i}of e)for(let a of i)r.push(UX({prefix:" \u25E6 ",content:`${a.name}
|
|
2278
2278
|
${cl.dim(a.summary)}`}));r.push("Do you wish to continue?");let{[t]:n}=await Hpa.prompt({name:t,type:"confirm",message:r.join(`
|
|
2279
2279
|
`)});return n}var vjg=require("fs/promises");function w$(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(process.env.NODE_ENV!=="production"){var i=Rn6[e],a=i?typeof i=="function"?i.apply(null,r):i:"unknown error nr: "+e;throw Error("[Immer] "+a)}throw Error("[Immer] minified error nr: "+e+(r.length?" "+r.map(function(u){return"'"+u+"'"}).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function lti(e){return!!e&&!!e[OEe]}function Rjn(e){return!!e&&(function(t){if(!t||typeof t!="object")return!1;var r=Object.getPrototypeOf(t);if(r===null)return!0;var n=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return n===Object||typeof n=="function"&&Function.toString.call(n)===Fn6}(e)||Array.isArray(e)||!!e[fjg]||!!e.constructor[fjg]||ADc(e)||NDc(e))}function rUi(e,t,r){r===void 0&&(r=!1),dti(e)===0?(r?Object.keys:FDc)(e).forEach(function(n){r&&typeof n=="symbol"||t(n,e[n],e)}):e.forEach(function(n,i){return t(i,n,e)})}function dti(e){var t=e[OEe];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:ADc(e)?2:NDc(e)?3:0}function MDc(e,t){return dti(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function qn6(e,t){return dti(e)===2?e.get(t):e[t]}function djg(e,t,r){var n=dti(e);n===2?e.set(t,r):n===3?(e.delete(t),e.add(r)):e[t]=r}function Cn6(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function ADc(e){return Bn6&&e instanceof Map}function NDc(e){return In6&&e instanceof Set}function Ijn(e){return e.o||e.t}function zDc(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=Ln6(e);delete t[OEe];for(var r=FDc(t),n=0;n<r.length;n++){var i=r[n],a=t[i];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(t[i]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[i]})}return Object.create(Object.getPrototypeOf(e),t)}function BDc(e,t){return t===void 0&&(t=!1),IDc(e)||lti(e)||!Rjn(e)||(dti(e)>1&&(e.set=e.add=e.clear=e.delete=An6),Object.freeze(e),t&&rUi(e,function(r,n){return BDc(n,!0)},!0)),e}function An6(){w$(2)}function IDc(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function Y1r(e){var t=Un6[e];return t||w$(18,e),t}function ijg(){return process.env.NODE_ENV==="production"||fti||w$(0),fti}function wDc(e,t){t&&(Y1r("Patches"),e.u=[],e.s=[],e.v=t)}function x3o(e){xDc(e),e.p.forEach(Nn6),e.p=null}function xDc(e){e===fti&&(fti=e.l)}function ajg(e){return fti={p:[],l:fti,h:e,m:!0,_:0}}function Nn6(e){var t=e[OEe];t.i===0||t.i===1?t.j():t.O=!0}function DDc(e,t){t._=t.p.length;var r=t.p[0],n=e!==void 0&&e!==r;return t.h.g||Y1r("ES5").S(t,e,n),n?(r[OEe].P&&(x3o(t),w$(4)),Rjn(e)&&(e=T3o(t,e),t.l||q3o(t,e)),t.u&&Y1r("Patches").M(r[OEe].t,e,t.u,t.s)):e=T3o(t,r,[]),x3o(t),t.u&&t.v(t.u,t.s),e!==pjg?e:void 0}function T3o(e,t,r){if(IDc(t))return t;var n=t[OEe];if(!n)return rUi(t,function(a,u){return ojg(e,n,t,a,u,r)},!0),t;if(n.A!==e)return t;if(!n.P)return q3o(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var i=n.i===4||n.i===5?n.o=zDc(n.k):n.o;rUi(n.i===3?new Set(i):i,function(a,u){return ojg(e,n,i,a,u,r)}),q3o(e,i,!1),r&&e.u&&Y1r("Patches").R(n,r,e.u,e.s)}return n.o}function ojg(e,t,r,n,i,a){if(process.env.NODE_ENV!=="production"&&i===r&&w$(5),lti(i)){var u=T3o(e,i,a&&t&&t.i!==3&&!MDc(t.D,n)?a.concat(n):void 0);if(djg(r,n,u),!lti(u))return;e.m=!1}if(Rjn(i)&&!IDc(i)){if(!e.h.F&&e._<1)return;T3o(e,i),t&&t.A.l||q3o(e,i)}}function q3o(e,t,r){r===void 0&&(r=!1),e.h.F&&e.m&&BDc(t,r)}function SDc(e,t){var r=e[OEe];return(r?Ijn(r):e)[t]}function ujg(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function TDc(e){e.P||(e.P=!0,e.l&&TDc(e.l))}function EDc(e){e.o||(e.o=zDc(e.t))}function qDc(e,t,r){var n=ADc(t)?Y1r("MapSet").N(t,r):NDc(t)?Y1r("MapSet").T(t,r):e.g?function(i,a){var u=Array.isArray(i),f={i:u?1:0,A:a?a.A:ijg(),P:!1,I:!1,D:{},l:a,t:i,k:null,o:null,j:null,C:!1},d=f,c=CDc;u&&(d=[f],c=tUi);var o=Proxy.revocable(d,c),l=o.revoke,g=o.proxy;return f.k=g,f.j=l,g}(t,r):Y1r("ES5").J(t,r);return(r?r.A:ijg()).p.push(n),n}function zn6(e){return lti(e)||w$(22,e),function t(r){if(!Rjn(r))return r;var n,i=r[OEe],a=dti(r);if(i){if(!i.P&&(i.i<4||!Y1r("ES5").K(i)))return i.t;i.I=!0,n=sjg(r,a),i.I=!1}else n=sjg(r,a);return rUi(n,function(u,f){i&&qn6(i.t,u)===f||djg(n,u,t(f))}),a===3?new Set(n):n}(e)}function sjg(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return zDc(e)}var cjg,fti,RDc=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",Bn6=typeof Map<"u",In6=typeof Set<"u",ljg=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",pjg=RDc?Symbol.for("immer-nothing"):((cjg={})["immer-nothing"]=!0,cjg),fjg=RDc?Symbol.for("immer-draftable"):"__$immer_draftable",OEe=RDc?Symbol.for("immer-state"):"__$immer_state";var Rn6={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(e){return"Cannot apply patch, path doesn't resolve: "+e},16:'Sets cannot have "replace" patches.',17:function(e){return"Unsupported patch operation: "+e},18:function(e){return"The plugin for '"+e+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+e+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(e){return"produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+e+"'"},22:function(e){return"'current' expects a draft, got: "+e},23:function(e){return"'original' expects a draft, got: "+e},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Fn6=""+Object.prototype.constructor,FDc=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,Ln6=Object.getOwnPropertyDescriptors||function(e){var t={};return FDc(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)}),t},Un6={},CDc={get:function(e,t){if(t===OEe)return e;var r=Ijn(e);if(!MDc(r,t))return function(i,a,u){var f,d=ujg(a,u);return d?"value"in d?d.value:(f=d.get)===null||f===void 0?void 0:f.call(i.k):void 0}(e,r,t);var n=r[t];return e.I||!Rjn(n)?n:n===SDc(e.t,t)?(EDc(e),e.o[t]=qDc(e.A.h,n,e)):n},has:function(e,t){return t in Ijn(e)},ownKeys:function(e){return Reflect.ownKeys(Ijn(e))},set:function(e,t,r){var n=ujg(Ijn(e),t);if(n!=null&&n.set)return n.set.call(e.k,r),!0;if(!e.P){var i=SDc(Ijn(e),t),a=i==null?void 0:i[OEe];if(a&&a.t===r)return e.o[t]=r,e.D[t]=!1,!0;if(Cn6(r,i)&&(r!==void 0||MDc(e.t,t)))return!0;EDc(e),TDc(e)}return e.o[t]===r&&typeof r!="number"&&(r!==void 0||t in e.o)||(e.o[t]=r,e.D[t]=!0,!0)},deleteProperty:function(e,t){return SDc(e.t,t)!==void 0||t in e.t?(e.D[t]=!1,EDc(e),TDc(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=Ijn(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.i!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty:function(){w$(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){w$(12)}},tUi={};rUi(CDc,function(e,t){tUi[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),tUi.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&w$(13),tUi.set.call(this,e,t,void 0)},tUi.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&w$(14),CDc.set.call(this,e[0],t,r,e[0])};var Vn6=function(){function e(r){var n=this;this.g=ljg,this.F=!0,this.produce=function(i,a,u){if(typeof i=="function"&&typeof a!="function"){var f=a;a=i;var d=n;return function(S){var x=this;S===void 0&&(S=f);for(var A=arguments.length,z=Array(A>1?A-1:0),N=1;N<A;N++)z[N-1]=arguments[N];return d.produce(S,function(C){var U;return(U=a).call.apply(U,[x,C].concat(z))})}}var c;if(typeof a!="function"&&w$(6),u!==void 0&&typeof u!="function"&&w$(7),Rjn(i)){var o=ajg(n),l=qDc(n,i,void 0),g=!0;try{c=a(l),g=!1}finally{g?x3o(o):xDc(o)}return typeof Promise<"u"&&c instanceof Promise?c.then(function(S){return wDc(o,u),DDc(S,o)},function(S){throw x3o(o),S}):(wDc(o,u),DDc(c,o))}if(!i||typeof i!="object"){if((c=a(i))===void 0&&(c=i),c===pjg&&(c=void 0),n.F&&BDc(c,!0),u){var O=[],j=[];Y1r("Patches").M(i,c,O,j),u(O,j)}return c}w$(21,i)},this.produceWithPatches=function(i,a){if(typeof i=="function")return function(c){for(var o=arguments.length,l=Array(o>1?o-1:0),g=1;g<o;g++)l[g-1]=arguments[g];return n.produceWithPatches(c,function(O){return i.apply(void 0,[O].concat(l))})};var u,f,d=n.produce(i,a,function(c,o){u=c,f=o});return typeof Promise<"u"&&d instanceof Promise?d.then(function(c){return[c,u,f]}):[d,u,f]},typeof(r==null?void 0:r.useProxies)=="boolean"&&this.setUseProxies(r.useProxies),typeof(r==null?void 0:r.autoFreeze)=="boolean"&&this.setAutoFreeze(r.autoFreeze)}var t=e.prototype;return t.createDraft=function(r){Rjn(r)||w$(8),lti(r)&&(r=zn6(r));var n=ajg(this),i=qDc(this,r,void 0);return i[OEe].C=!0,xDc(n),i},t.finishDraft=function(r,n){var i=r&&r[OEe];process.env.NODE_ENV!=="production"&&(i&&i.C||w$(9),i.I&&w$(10));var a=i.A;return wDc(a,n),DDc(void 0,a)},t.setAutoFreeze=function(r){this.F=r},t.setUseProxies=function(r){r&&!ljg&&w$(20),this.g=r},t.applyPatches=function(r,n){var i;for(i=n.length-1;i>=0;i--){var a=n[i];if(a.path.length===0&&a.op==="replace"){r=a.value;break}}i>-1&&(n=n.slice(i+1));var u=Y1r("Patches").$;return lti(r)?u(r,n):this.produce(r,function(f){return u(f,n)})},e}(),PEe=new Vn6,Wn6=PEe.produce,FMB=PEe.produceWithPatches.bind(PEe),LMB=PEe.setAutoFreeze.bind(PEe),UMB=PEe.setUseProxies.bind(PEe),VMB=PEe.applyPatches.bind(PEe),WMB=PEe.createDraft.bind(PEe),HMB=PEe.finishDraft.bind(PEe),_jg=Wn6;async function hjg({cliEnvironment:e,version:t}){try{return await o_i(e.packageName,{version:t}),!0}catch{return!1}}var nUi="FERN_CWD";async function iUi({version:e,cliContext:t,env:r}){t.suppressUpgradeMessage();let n=["--quiet","--yes",`${t.environment.packageName}@${e}`,...process.argv.slice(2)];t.logger.debug([`Re-running CLI at version ${e}.`,`${cl.dim(`+ npx ${n.map(f=>`"${f}"`).join(" ")}`)}`].join(`
|
|
2280
|
-
`));let{failed:i,stdout:a,stderr:u}=await iwe(t.logger,"npx",["--quiet",...n],{stdio:"inherit",reject:!1,env:{...r,[nUi]:process.env[nUi]??process.cwd()}});if(a.includes("code EEXIST")||u.includes("code EEXIST"))return await iUi({version:e,cliContext:t});i&&t.failWithoutThrowing()}var yjg="FERN_PRE_UPGRADE_VERSION";async function bjg({cliContext:e,includePreReleases:t,targetVersion:r}){r!=null&&(await hjg({cliEnvironment:e.environment,version:r})||e.failAndThrow(`Failed to upgrade to ${r} because it does not exist. See https://www.npmjs.com/package/${e.environment.packageName}?activeTab=versions.`),Pne(r,e.environment.packageVersion)||e.failAndThrow(`Cannot upgrade because target version (${r}) is behind existing version ${e.environment.packageVersion}`));let n=r!=null?{latestVersion:r,isUpgradeAvailable:!0}:(await e.isUpgradeAvailable({includePreReleases:t})).cliUpgradeInfo;if(n&&!n.isUpgradeAvailable){let i=process.env[yjg];if(i==null){e.logger.info("No upgrade available.");return}await e.runTask(async a=>{await jDc({fromVersion:i,toVersion:n.latestVersion,context:a})}),await e.exitIfFailed()}else if(n!=null){let i=await wBt();if(i==null)return e.failAndThrow(`Directory "${Yqt}" not found.`);let a=await e.runTask(f=>e5t.loadProjectConfig({directory:i,context:f})),u=_jg(a.rawConfig,f=>{f.version=n.latestVersion});await(0,vjg.writeFile)(a._absolutePath,JSON.stringify(u,void 0,2)),e.logger.info(`Upgrading from ${cl.dim(e.environment.packageVersion)} \u2192 ${cl.green(n.latestVersion)}`),await iwe(e.logger,"npm",["install","-g",`${e.environment.packageName}@${n.latestVersion}`]),await iUi({version:n.latestVersion,cliContext:e,env:{[yjg]:e.environment.packageVersion}})}}async function gjg({project:e,cliContext:t,logWarnings:r}){let n=e.docsWorkspaces;n!=null&&await t.runTaskForWorkspace(n,async i=>{await EMa({workspace:n,context:i,logWarnings:r,loadAPIWorkspace:e.loadAPIWorkspace})}),await Promise.all(e.apiWorkspaces.map(async i=>{await t.runTaskForWorkspace(i,async a=>{let u=await i.toFernWorkspace({context:a});await UFt({workspace:u,context:a,logWarnings:r})})}))}var X1r=require("fs/promises");var LDc=yu(require("path"),1);async function mjg({project:e,cliContext:t,sdkLanguage:r}){await Promise.all(e.apiWorkspaces.map(async n=>{await t.runTaskForWorkspace(n,async i=>{n instanceof WQ?await $n6({workspace:n,context:i,sdkLanguage:r}):n instanceof y5r&&await Hn6({workspace:n,context:i})})}))}async function Hn6({workspace:e,context:t}){for(let[r,n]of Object.entries(e.definition.importedDefinitions)){let i=pf(e.absoluteFilepath,zs.of(p9),zs.of(r),zs.of(`.${p9}`));await Ojg({definition:n.definition,absolutePathToOutputDirectory:i}),t.logger.info(cl.green(`Wrote imported definition at ${LDc.default.relative(process.cwd(),i)}`))}}async function $n6({workspace:e,context:t,sdkLanguage:r}){let n=await e.toFernWorkspace({context:t}),i=pf(e.absoluteFilepath,zs.of(`.${p9}`));await Ojg({definition:n.definition,absolutePathToOutputDirectory:i}),t.logger.info(cl.green(`Wrote definition to ${LDc.default.relative(process.cwd(),i)}`))}async function Ojg({definition:e,absolutePathToOutputDirectory:t}){await Vh(t)&&await(0,X1r.rmdir)(t,{recursive:!0}),await(0,X1r.mkdir)(t,{recursive:!0}),await(0,X1r.writeFile)(pf(t,zs.of(nB)),av.dump(e.rootApiFile.contents));for(let[r,n]of Object.entries(e.packageMarkers)){let i=pf(t,zs.of(r));await(0,X1r.mkdir)(Hg(i),{recursive:!0}),await(0,X1r.writeFile)(i,av.dump(n.contents))}for(let[r,n]of Object.entries(e.namedDefinitionFiles)){let i=pf(t,zs.of(r));await(0,X1r.mkdir)(Hg(i),{recursive:!0}),await(0,X1r.writeFile)(i,av.dump(n.contents))}}function Pjg(e){try{return new URL(e),!0}catch{return!1}}Jn6();async function Jn6(){let e=new Wha(process.stdout),t=async()=>{await e.exit()};process.on("SIGINT",async()=>{e.suppressUpgradeMessage(),await t()});try{let r=process.env[nUi];r!=null&&process.chdir(r);let n=await Kn6(e);e.environment.packageVersion===n?await Gn6(e):await iUi({version:n,cliContext:e})}catch(r){await e.instrumentPostHogEvent({command:process.argv.join(" "),properties:{failed:!0,error:r}}),r instanceof Gte?e.failWithoutThrowing():r instanceof Zqt?e.logger.error(`Failed. ${r.log}`):e.failWithoutThrowing("Failed.",r)}await t()}async function Gn6(e){let t=Aof(Suu(process.argv)).scriptName(e.environment.cliName).version(!1).fail((r,n,i)=>{n==null&&(i.showHelp(),e.logger.error(r))}).strict().exitProcess(!1).command("$0",!1,r=>r.option("version",{describe:"Print current version",alias:"v"}).version(!1),r=>{r.version!=null?e.logger.info(e.environment.packageVersion):(t.showHelp(),e.failAndThrow())}).option("log-level",{default:hM.Info,choices:_4r}).demandCommand().recommendCommands();Yn6(t,e),Xn6(t,e),Qn6(t,e),Zn6(t,e),kn6(t,e),ti6(t,e),ei6(t,e),ii6(t,e),ri6(t,e),ni6(t,e),ui6(t,e),si6(t,e),di6(t,e),pi6(t,e),li6(t,e),fi6(t,e),ci6(t,e),oi6(t,e),ai6({cli:t,cliContext:e,onRun:()=>{e.suppressUpgradeMessage()}}),YAf(t,e),XAf(t,e),t.middleware(async r=>{e.setLogLevel(r["log-level"]),e.logDebugInfo()}),await t.parse()}async function Kn6(e){if(process.env.FERN_NO_VERSION_REDIRECTION==="true")return e.environment.packageVersion;let t=await wBt();if(t!=null){let r=await e.runTask(n=>e5t.loadProjectConfig({directory:t,context:n}));return r.version==="*"?e.environment.packageVersion:r.version}return J6n({cliEnvironment:e.environment})}function Yn6(e,t){e.command("init","Initialize a Fern API",r=>r.option("api",{boolean:!0,description:"Initialize an api."}).option("docs",{boolean:!0,description:"Initialize a docs website."}).option("organization",{alias:"org",type:"string",description:"Organization name"}).option("openapi",{type:"string",description:"Filepath or url to an existing OpenAPI spec"}),async r=>{if(r.api!=null&&r.docs!=null)return t.failWithoutThrowing("Cannot specify both --api and --docs. Please choose one.");if(r.docs!=null)await t.runTask(async n=>{await Duu({organization:r.organization,versionOfCli:await J6n({cliEnvironment:t.environment}),taskContext:n})});else{let n;if(r.openapi!=null){if(Pjg(r.openapi)){let a=await Rof({url:r.openapi,logger:t.logger});a.status==="failure"&&t.failAndThrow(a.errorMessage);let u=a.filePath;n=I_.of(u)}else n=I_.of(j2(e4r(),r.openapi));await Vh(n)||t.failAndThrow(`${n} does not exist`)}await t.runTask(async i=>{await wuu({organization:r.organization,versionOfCli:await J6n({cliEnvironment:t.environment}),context:i,openApiPath:n})})}})}function Xn6(e,t){e.command("token","Generate a Fern Token",r=>r.option("organization",{alias:"org",type:"string",description:"The organization to create a token for. Defaults to the one in `fern.config.json`"}),async r=>{await t.runTask(async n=>{await Cbg({orgId:r.organization??(await q7(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0})).config.organization,taskContext:n})})})}function Qn6(e,t){e.command("add <generator>",`Add a code generator to ${i5}`,r=>r.positional("generator",{type:"string",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("group",{string:!0,description:"Add the generator to the specified group"}),async r=>{await ZAf({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),generatorName:r.generator,groupName:r.group,cliContext:t})})}function Zn6(e,t){e.command(["generate"],"Generate all generators in the specified group",r=>r.option("api",{string:!0,description:"If multiple APIs, specify the name with --api <name>. Otherwise, just --api."}).option("docs",{string:!0,description:"If multiple docs sites, specify the name with --docs <name>. Otherwise just --docs."}).option("instance",{string:!0,description:"The url for the instance of docs (e.g. --instance acme.docs.buildwithfern.com)"}).option("preview",{boolean:!0,default:!1,description:"Whether to generate a preview link for the docs"}).option("group",{type:"string",description:"The group to generate"}).option("mode",{choices:Object.values(vbg),description:"Defaults to the mode specified in generators.yml"}).option("version",{type:"string",description:"The version for the generated packages"}).option("printZipUrl",{boolean:!0,hidden:!0,default:!1}).option("local",{boolean:!0,default:!1,description:"Run the generator(s) locally, using Docker"}).option("keepDocker",{boolean:!0,default:!1,description:"Prevent auto-deletion of the Docker containers."}),async r=>r.api!=null&&r.docs!=null?t.failWithoutThrowing("Cannot specify both --api and --docs. Please choose one."):r.local&&r.preview?t.failWithoutThrowing("The --local flag is incompatible with --preview."):r.api!=null?await xwc({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local,preview:r.preview,mode:r.mode}):r.docs!=null?(r.group!=null&&t.logger.warn("--group is ignored when generating docs"),r.version!=null&&t.logger.warn("--version is ignored when generating docs"),await bbg({project:await q7(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0},!0),cliContext:t,instance:r.instance,preview:r.preview})):await xwc({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local,preview:r.preview,mode:r.mode}))}function kn6(e,t){e.command("ir <path-to-output>","Generate IR (Intermediate Representation)",r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("version",{string:!0,description:"The version of IR to produce"}).option("language",{choices:Object.values(pg.GenerationLanguage),description:"Generate IR for a particular language"}).option("audience",{type:"array",string:!0,default:new Array,description:"Filter the IR for certain audiences"}),async r=>{await Wog({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:j2(e4r(),r.pathToOutput),cliContext:t,generationLanguage:r.language,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"},version:r.version,keywords:void 0,smartCasing:!1,readme:void 0})})}function ei6(e,t){e.command("openapi-ir <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("language",{choices:Object.values(pg.GenerationLanguage),description:"Generate IR for a particular language"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await Jog({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:j2(e4r(),r.pathToOutput),cliContext:t,sdkLanguage:r.language})})}function ti6(e,t){e.command("fdr <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write FDR API definition",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("audience",{type:"array",string:!0,default:new Array,description:"Filter the FDR API definition for certain audiences"}),async r=>{await _ed({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:j2(e4r(),r.pathToOutput),cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}})})}function ri6(e,t){e.command(["register"],!1,r=>r.option("version",{type:"string",description:"The version for the registered api"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let n=await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),i=await t.runTask(a=>s2e(a));await Mbg({project:n,cliContext:t,token:i,version:r.version})})}function ni6(e,t){e.command(["register-v2"],!1,r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let n=await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),i=await t.runTask(a=>s2e(a));await xbg({project:n,cliContext:t,token:i})})}function ii6(e,t){e.command("check","Validates your Fern Definition. Logs errors.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("warnings",{boolean:!0,description:"Log warnings in addition to errors.",default:!1}),async r=>{await gjg({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,logWarnings:r.warnings})})}function ai6({cli:e,cliContext:t,onRun:r}){e.command("upgrade",`Upgrades version in ${M8t}. Also upgrades generators in ${i5} to their minimum-compatible versions.`,n=>n.option("rc",{boolean:!0,hidden:!0,default:!1}).option("version",{string:!0,description:"The version to upgrade to. Defaults to the latest release."}),async n=>{await bjg({cliContext:t,includePreReleases:n.rc,targetVersion:n.version}),r()})}function oi6(e,t){e.command("api update",`Pulls the latest OpenAPI spec from the specified origin in ${i5} and updates the local spec.`,r=>r.option("api",{string:!0,description:"The API to update the spec for. If not specified, all APIs with a declared origin will be updated."}),async r=>{await t.instrumentPostHogEvent({command:"fern api update"}),await Bbg({cliContext:t,project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0})})})}function ui6(e,t){e.command("login","Log in to Fern via GitHub",r=>r.option("device-code",{boolean:!0,default:!1,description:"Use device code authorization"}),async r=>{await t.runTask(async n=>{await t.instrumentPostHogEvent({command:"fern login"}),await ypi(n,{useDeviceCodeFlow:r.deviceCode})})})}function si6(e,t){e.command("format","Formats your Fern Definition",r=>r.option("ci",{boolean:!0,default:!1,description:"Fail with non-zero exit status if files are not formatted correctly."}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await t.instrumentPostHogEvent({command:"fern format"}),await fed({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,shouldFix:!r.ci})})}function ci6(e,t){e.command("test","Runs tests specified in --command, this spins up a mock server in the background that is terminated upon completion of the tests.",r=>r.option("api",{string:!0,description:"The API to mock."}).option("command",{string:!0,description:"The command to run to test your SDK."}).option("language",{choices:Object.values(pg.GenerationLanguage),description:"Run the tests configured to a specific language"}),async r=>{await t.instrumentPostHogEvent({command:"fern test"}),await Tbg({cliContext:t,project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,nameOverride:".mock",sdkLanguage:r.language}),testCommand:r.command,generationLanguage:r.language})})}function li6(e,t){e.command("mock","Starts a mock server for an API.",r=>r.option("port",{number:!0,description:"The port the server binds to."}).option("api",{string:!0,description:"The API to mock."}),async r=>{await t.instrumentPostHogEvent({command:"fern mock"}),await Obg({cliContext:t,project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),port:r.port})})}function fi6(e,t){e.command("write-overrides","Generate a basic openapi overrides file.",r=>[r.option("api",{string:!0,description:"Only run the command on the provided API"}),r.option("exclude-models",{boolean:!0,description:"When generating the initial overrides, also stub the models (in addition to the endpoints)",default:!1})],async r=>{await t.instrumentPostHogEvent({command:"fern generate-overrides"}),await Kog({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),includeModels:!r.excludeModels,cliContext:t})})}function di6(e,t){e.command("write-definition","Write underlying Fern Definition for OpenAPI specs and API Dependencies.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("language",{choices:Object.values(pg.GenerationLanguage),description:"Write the definition for a particular SDK language"}),async r=>{await t.instrumentPostHogEvent({command:"fern write-definition"}),await mjg({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0,sdkLanguage:r.language}),cliContext:t,sdkLanguage:r.language})})}function pi6(e,t){e.command("docs dev","Run a local development server to preview your docs",r=>r.option("port",{number:!0,description:"Run the development server on the following port"}).option("bundle-path",{string:!0,hidden:!0,description:"Path of the local docs bundle to use"}),async r=>{let n;r.port!=null?n=r.port:n=await xpi({port:[3e3,3001,3002,3003,3004,3005,3006,3007,3008,3009,3010]});let i=r.bundlePath;await led({loadProject:()=>q7(t,{defaultToAllApiWorkspaces:!0,commandLineApiWorkspace:void 0}),cliContext:t,port:n,bundlePath:i})})}
|
|
2280
|
+
`));let{failed:i,stdout:a,stderr:u}=await iwe(t.logger,"npx",["--quiet",...n],{stdio:"inherit",reject:!1,env:{...r,[nUi]:process.env[nUi]??process.cwd()}});if((a==null?void 0:a.includes("code EEXIST"))||(u==null?void 0:u.includes("code EEXIST")))return await iUi({version:e,cliContext:t});i&&t.failWithoutThrowing()}var yjg="FERN_PRE_UPGRADE_VERSION";async function bjg({cliContext:e,includePreReleases:t,targetVersion:r}){r!=null&&(await hjg({cliEnvironment:e.environment,version:r})||e.failAndThrow(`Failed to upgrade to ${r} because it does not exist. See https://www.npmjs.com/package/${e.environment.packageName}?activeTab=versions.`),Pne(r,e.environment.packageVersion)||e.failAndThrow(`Cannot upgrade because target version (${r}) is behind existing version ${e.environment.packageVersion}`));let n=r!=null?{latestVersion:r,isUpgradeAvailable:!0}:(await e.isUpgradeAvailable({includePreReleases:t})).cliUpgradeInfo;if(n&&!n.isUpgradeAvailable){let i=process.env[yjg];if(i==null){e.logger.info("No upgrade available.");return}await e.runTask(async a=>{await jDc({fromVersion:i,toVersion:n.latestVersion,context:a})}),await e.exitIfFailed()}else if(n!=null){let i=await wBt();if(i==null)return e.failAndThrow(`Directory "${Yqt}" not found.`);let a=await e.runTask(f=>e5t.loadProjectConfig({directory:i,context:f})),u=_jg(a.rawConfig,f=>{f.version=n.latestVersion});await(0,vjg.writeFile)(a._absolutePath,JSON.stringify(u,void 0,2)),e.logger.info(`Upgrading from ${cl.dim(e.environment.packageVersion)} \u2192 ${cl.green(n.latestVersion)}`),await iwe(e.logger,"npm",["install","-g",`${e.environment.packageName}@${n.latestVersion}`]),await iUi({version:n.latestVersion,cliContext:e,env:{[yjg]:e.environment.packageVersion}})}}async function gjg({project:e,cliContext:t,logWarnings:r}){let n=e.docsWorkspaces;n!=null&&await t.runTaskForWorkspace(n,async i=>{await EMa({workspace:n,context:i,logWarnings:r,loadAPIWorkspace:e.loadAPIWorkspace})}),await Promise.all(e.apiWorkspaces.map(async i=>{await t.runTaskForWorkspace(i,async a=>{let u=await i.toFernWorkspace({context:a});await UFt({workspace:u,context:a,logWarnings:r})})}))}var X1r=require("fs/promises");var LDc=yu(require("path"),1);async function mjg({project:e,cliContext:t,sdkLanguage:r}){await Promise.all(e.apiWorkspaces.map(async n=>{await t.runTaskForWorkspace(n,async i=>{n instanceof WQ?await $n6({workspace:n,context:i,sdkLanguage:r}):n instanceof y5r&&await Hn6({workspace:n,context:i})})}))}async function Hn6({workspace:e,context:t}){for(let[r,n]of Object.entries(e.definition.importedDefinitions)){let i=pf(e.absoluteFilepath,zs.of(p9),zs.of(r),zs.of(`.${p9}`));await Ojg({definition:n.definition,absolutePathToOutputDirectory:i}),t.logger.info(cl.green(`Wrote imported definition at ${LDc.default.relative(process.cwd(),i)}`))}}async function $n6({workspace:e,context:t,sdkLanguage:r}){let n=await e.toFernWorkspace({context:t}),i=pf(e.absoluteFilepath,zs.of(`.${p9}`));await Ojg({definition:n.definition,absolutePathToOutputDirectory:i}),t.logger.info(cl.green(`Wrote definition to ${LDc.default.relative(process.cwd(),i)}`))}async function Ojg({definition:e,absolutePathToOutputDirectory:t}){await Vh(t)&&await(0,X1r.rmdir)(t,{recursive:!0}),await(0,X1r.mkdir)(t,{recursive:!0}),await(0,X1r.writeFile)(pf(t,zs.of(nB)),av.dump(e.rootApiFile.contents));for(let[r,n]of Object.entries(e.packageMarkers)){let i=pf(t,zs.of(r));await(0,X1r.mkdir)(Hg(i),{recursive:!0}),await(0,X1r.writeFile)(i,av.dump(n.contents))}for(let[r,n]of Object.entries(e.namedDefinitionFiles)){let i=pf(t,zs.of(r));await(0,X1r.mkdir)(Hg(i),{recursive:!0}),await(0,X1r.writeFile)(i,av.dump(n.contents))}}function Pjg(e){try{return new URL(e),!0}catch{return!1}}Jn6();async function Jn6(){let e=new Wha(process.stdout),t=async()=>{await e.exit()};process.on("SIGINT",async()=>{e.suppressUpgradeMessage(),await t()});try{let r=process.env[nUi];r!=null&&process.chdir(r);let n=await Kn6(e);e.environment.packageVersion===n?await Gn6(e):await iUi({version:n,cliContext:e})}catch(r){await e.instrumentPostHogEvent({command:process.argv.join(" "),properties:{failed:!0,error:r}}),r instanceof Gte?e.failWithoutThrowing():r instanceof Zqt?e.logger.error(`Failed. ${r.log}`):e.failWithoutThrowing("Failed.",r)}await t()}async function Gn6(e){let t=Aof(Suu(process.argv)).scriptName(e.environment.cliName).version(!1).fail((r,n,i)=>{n==null&&(i.showHelp(),e.logger.error(r))}).strict().exitProcess(!1).command("$0",!1,r=>r.option("version",{describe:"Print current version",alias:"v"}).version(!1),r=>{r.version!=null?e.logger.info(e.environment.packageVersion):(t.showHelp(),e.failAndThrow())}).option("log-level",{default:hM.Info,choices:_4r}).demandCommand().recommendCommands();Yn6(t,e),Xn6(t,e),Qn6(t,e),Zn6(t,e),kn6(t,e),ti6(t,e),ei6(t,e),ii6(t,e),ri6(t,e),ni6(t,e),ui6(t,e),si6(t,e),di6(t,e),pi6(t,e),li6(t,e),fi6(t,e),ci6(t,e),oi6(t,e),ai6({cli:t,cliContext:e,onRun:()=>{e.suppressUpgradeMessage()}}),YAf(t,e),XAf(t,e),t.middleware(async r=>{e.setLogLevel(r["log-level"]),e.logDebugInfo()}),await t.parse()}async function Kn6(e){if(process.env.FERN_NO_VERSION_REDIRECTION==="true")return e.environment.packageVersion;let t=await wBt();if(t!=null){let r=await e.runTask(n=>e5t.loadProjectConfig({directory:t,context:n}));return r.version==="*"?e.environment.packageVersion:r.version}return J6n({cliEnvironment:e.environment})}function Yn6(e,t){e.command("init","Initialize a Fern API",r=>r.option("api",{boolean:!0,description:"Initialize an api."}).option("docs",{boolean:!0,description:"Initialize a docs website."}).option("organization",{alias:"org",type:"string",description:"Organization name"}).option("openapi",{type:"string",description:"Filepath or url to an existing OpenAPI spec"}),async r=>{if(r.api!=null&&r.docs!=null)return t.failWithoutThrowing("Cannot specify both --api and --docs. Please choose one.");if(r.docs!=null)await t.runTask(async n=>{await Duu({organization:r.organization,versionOfCli:await J6n({cliEnvironment:t.environment}),taskContext:n})});else{let n;if(r.openapi!=null){if(Pjg(r.openapi)){let a=await Rof({url:r.openapi,logger:t.logger});a.status==="failure"&&t.failAndThrow(a.errorMessage);let u=a.filePath;n=I_.of(u)}else n=I_.of(j2(e4r(),r.openapi));await Vh(n)||t.failAndThrow(`${n} does not exist`)}await t.runTask(async i=>{await wuu({organization:r.organization,versionOfCli:await J6n({cliEnvironment:t.environment}),context:i,openApiPath:n})})}})}function Xn6(e,t){e.command("token","Generate a Fern Token",r=>r.option("organization",{alias:"org",type:"string",description:"The organization to create a token for. Defaults to the one in `fern.config.json`"}),async r=>{await t.runTask(async n=>{await Cbg({orgId:r.organization??(await q7(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0})).config.organization,taskContext:n})})})}function Qn6(e,t){e.command("add <generator>",`Add a code generator to ${i5}`,r=>r.positional("generator",{type:"string",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("group",{string:!0,description:"Add the generator to the specified group"}),async r=>{await ZAf({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),generatorName:r.generator,groupName:r.group,cliContext:t})})}function Zn6(e,t){e.command(["generate"],"Generate all generators in the specified group",r=>r.option("api",{string:!0,description:"If multiple APIs, specify the name with --api <name>. Otherwise, just --api."}).option("docs",{string:!0,description:"If multiple docs sites, specify the name with --docs <name>. Otherwise just --docs."}).option("instance",{string:!0,description:"The url for the instance of docs (e.g. --instance acme.docs.buildwithfern.com)"}).option("preview",{boolean:!0,default:!1,description:"Whether to generate a preview link for the docs"}).option("group",{type:"string",description:"The group to generate"}).option("mode",{choices:Object.values(vbg),description:"Defaults to the mode specified in generators.yml"}).option("version",{type:"string",description:"The version for the generated packages"}).option("printZipUrl",{boolean:!0,hidden:!0,default:!1}).option("local",{boolean:!0,default:!1,description:"Run the generator(s) locally, using Docker"}).option("keepDocker",{boolean:!0,default:!1,description:"Prevent auto-deletion of the Docker containers."}),async r=>r.api!=null&&r.docs!=null?t.failWithoutThrowing("Cannot specify both --api and --docs. Please choose one."):r.local&&r.preview?t.failWithoutThrowing("The --local flag is incompatible with --preview."):r.api!=null?await xwc({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local,preview:r.preview,mode:r.mode}):r.docs!=null?(r.group!=null&&t.logger.warn("--group is ignored when generating docs"),r.version!=null&&t.logger.warn("--version is ignored when generating docs"),await bbg({project:await q7(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0},!0),cliContext:t,instance:r.instance,preview:r.preview})):await xwc({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local,preview:r.preview,mode:r.mode}))}function kn6(e,t){e.command("ir <path-to-output>","Generate IR (Intermediate Representation)",r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("version",{string:!0,description:"The version of IR to produce"}).option("language",{choices:Object.values(pg.GenerationLanguage),description:"Generate IR for a particular language"}).option("audience",{type:"array",string:!0,default:new Array,description:"Filter the IR for certain audiences"}),async r=>{await Wog({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:j2(e4r(),r.pathToOutput),cliContext:t,generationLanguage:r.language,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"},version:r.version,keywords:void 0,smartCasing:!1,readme:void 0})})}function ei6(e,t){e.command("openapi-ir <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("language",{choices:Object.values(pg.GenerationLanguage),description:"Generate IR for a particular language"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await Jog({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:j2(e4r(),r.pathToOutput),cliContext:t,sdkLanguage:r.language})})}function ti6(e,t){e.command("fdr <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write FDR API definition",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("audience",{type:"array",string:!0,default:new Array,description:"Filter the FDR API definition for certain audiences"}),async r=>{await _ed({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:j2(e4r(),r.pathToOutput),cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}})})}function ri6(e,t){e.command(["register"],!1,r=>r.option("version",{type:"string",description:"The version for the registered api"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let n=await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),i=await t.runTask(a=>s2e(a));await Mbg({project:n,cliContext:t,token:i,version:r.version})})}function ni6(e,t){e.command(["register-v2"],!1,r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let n=await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),i=await t.runTask(a=>s2e(a));await xbg({project:n,cliContext:t,token:i})})}function ii6(e,t){e.command("check","Validates your Fern Definition. Logs errors.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("warnings",{boolean:!0,description:"Log warnings in addition to errors.",default:!1}),async r=>{await gjg({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,logWarnings:r.warnings})})}function ai6({cli:e,cliContext:t,onRun:r}){e.command("upgrade",`Upgrades version in ${M8t}. Also upgrades generators in ${i5} to their minimum-compatible versions.`,n=>n.option("rc",{boolean:!0,hidden:!0,default:!1}).option("version",{string:!0,description:"The version to upgrade to. Defaults to the latest release."}),async n=>{await bjg({cliContext:t,includePreReleases:n.rc,targetVersion:n.version}),r()})}function oi6(e,t){e.command("api update",`Pulls the latest OpenAPI spec from the specified origin in ${i5} and updates the local spec.`,r=>r.option("api",{string:!0,description:"The API to update the spec for. If not specified, all APIs with a declared origin will be updated."}),async r=>{await t.instrumentPostHogEvent({command:"fern api update"}),await Bbg({cliContext:t,project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0})})})}function ui6(e,t){e.command("login","Log in to Fern via GitHub",r=>r.option("device-code",{boolean:!0,default:!1,description:"Use device code authorization"}),async r=>{await t.runTask(async n=>{await t.instrumentPostHogEvent({command:"fern login"}),await ypi(n,{useDeviceCodeFlow:r.deviceCode})})})}function si6(e,t){e.command("format","Formats your Fern Definition",r=>r.option("ci",{boolean:!0,default:!1,description:"Fail with non-zero exit status if files are not formatted correctly."}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await t.instrumentPostHogEvent({command:"fern format"}),await fed({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,shouldFix:!r.ci})})}function ci6(e,t){e.command("test","Runs tests specified in --command, this spins up a mock server in the background that is terminated upon completion of the tests.",r=>r.option("api",{string:!0,description:"The API to mock."}).option("command",{string:!0,description:"The command to run to test your SDK."}).option("language",{choices:Object.values(pg.GenerationLanguage),description:"Run the tests configured to a specific language"}),async r=>{await t.instrumentPostHogEvent({command:"fern test"}),await Tbg({cliContext:t,project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,nameOverride:".mock",sdkLanguage:r.language}),testCommand:r.command,generationLanguage:r.language})})}function li6(e,t){e.command("mock","Starts a mock server for an API.",r=>r.option("port",{number:!0,description:"The port the server binds to."}).option("api",{string:!0,description:"The API to mock."}),async r=>{await t.instrumentPostHogEvent({command:"fern mock"}),await Obg({cliContext:t,project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),port:r.port})})}function fi6(e,t){e.command("write-overrides","Generate a basic openapi overrides file.",r=>[r.option("api",{string:!0,description:"Only run the command on the provided API"}),r.option("exclude-models",{boolean:!0,description:"When generating the initial overrides, also stub the models (in addition to the endpoints)",default:!1})],async r=>{await t.instrumentPostHogEvent({command:"fern generate-overrides"}),await Kog({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),includeModels:!r.excludeModels,cliContext:t})})}function di6(e,t){e.command("write-definition","Write underlying Fern Definition for OpenAPI specs and API Dependencies.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("language",{choices:Object.values(pg.GenerationLanguage),description:"Write the definition for a particular SDK language"}),async r=>{await t.instrumentPostHogEvent({command:"fern write-definition"}),await mjg({project:await q7(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0,sdkLanguage:r.language}),cliContext:t,sdkLanguage:r.language})})}function pi6(e,t){e.command("docs dev","Run a local development server to preview your docs",r=>r.option("port",{number:!0,description:"Run the development server on the following port"}).option("bundle-path",{string:!0,hidden:!0,description:"Path of the local docs bundle to use"}),async r=>{let n;r.port!=null?n=r.port:n=await xpi({port:[3e3,3001,3002,3003,3004,3005,3006,3007,3008,3009,3010]});let i=r.bundlePath;await led({loadProject:()=>q7(t,{defaultToAllApiWorkspaces:!0,commandLineApiWorkspace:void 0}),cliContext:t,port:n,bundlePath:i})})}
|
|
2281
2281
|
/*
|
|
2282
2282
|
object-assign
|
|
2283
2283
|
(c) Sindre Sorhus
|