fern-api 0.63.10 → 0.63.12
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/cli.cjs +4 -4
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1704,7 +1704,7 @@ ${c.indent}`:""}${RBd(o)}:${l.indent?" ":""}`;return u=!1,s=!0,l.objectItem=void
|
|
|
1704
1704
|
`}),r.replaceAll(/\n$/g,"")}function t5D(e){return e?Fh.green(R6.radioOn):R6.radioOff}var M4o=ci(nMe(),1);function X9p(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var cAa=class extends X2{_run(t){this.done=t;let r=LW(this.rl),i=r.line.pipe((0,M4o.map)(this.filterInput.bind(this))),n=this.handleSubmitEvents(i);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),r.keypress.pipe((0,M4o.takeUntil)(n.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),i="";r+=this.status==="answered"?this.getMaskedValue(this.answer):this.getMaskedValue(this.rl.line||""),t&&(i=`
|
|
1705
1705
|
`+Fh.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?Fh.cyan(X9p(t,this.opt.mask)):Fh.italic.dim("[hidden]"):this.opt.mask?X9p(t,this.opt.mask):Fh.italic.dim("[input is hidden] ")}getSpinningValue(t){return this.getMaskedValue(t)}filterInput(t){return t||(this.opt.default==null?"":this.opt.default)}onEnd(t){this.status="answered",this.answer=t.value,this.render(),this.screen.done(),this.done(t.value)}onError(t){this.render(t.isValid)}onKeypress(){this.opt.default&&=void 0,this.render()}};var mUp=ci(Hec(),1),PUp=ci(nMe(),1);var gAa=class extends X2{_run(t){this.done=t,this.editorResult=new PUp.Subject;let r=LW(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let i=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,n=this.handleSubmitEvents(this.editorResult);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,i?this.render():this.startExternalEditor(),this}render(t){let r="",i=this.getQuestion();i+=this.status==="answered"?Fh.dim("Received"):Fh.dim("Press <enter> to launch your preferred editor."),t&&(r=Fh.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),(0,mUp.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 nVp=ci(kUp(),1);var rVp=ci(require("readline"),1),iVp=ci(tVp(),1),aGi=class{constructor(t){this.rl||=rVp.default.createInterface(v9D(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 v9D(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let n=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw n.isTtyError=!0,n}let r=new iVp.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var PAa=class extends aGi{constructor(t={}){super(t),this.log=(0,nVp.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return tAa(this.rl,this.bottomBar.split(`
|
|
1706
1706
|
`).length),this}updateBottomBar(t){return tAa(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+`
|
|
1707
|
-
`}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&&w4o(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var _Vp=ci(uVp(),1),hVp=ci(ZZs(),1),yVp=ci(dVp(),1),Uq=ci(nMe(),1),vVp=ci(lMa(),1);var Z4o=ci(nMe(),1),pVp=ci(lMa(),1),k4o=function(e,t,r){return typeof e[t]!="function"?(0,Z4o.of)(e):(0,Z4o.from)((0,pVp.default)(e[t])(r).then(i=>(e[t]=i,e)))};var jAa={isPlainObject:_Vp.default,set:yVp.default,get:hVp.default},X3n=class extends aGi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=jAa.isPlainObject(r)?{...r}:{},jAa.isPlainObject(t)&&(t=Object.values(t).every(n=>jAa.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,Uq.from)(t):t;return this.process=i.pipe((0,Uq.concatMap)(this.processQuestion.bind(this)),(0,Uq.publish)()),this.process.connect(),this.process.pipe((0,Uq.reduce)((n,a)=>(jAa.set(n,a.name,a.answer),n),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,Uq.defer)(()=>(0,Uq.of)(t).pipe((0,Uq.concatMap)(this.setDefaultType.bind(this)),(0,Uq.concatMap)(this.filterIfRunnable.bind(this)),(0,Uq.concatMap)(()=>k4o(t,"message",this.answers)),(0,Uq.concatMap)(()=>k4o(t,"default",this.answers)),(0,Uq.concatMap)(()=>k4o(t,"choices",this.answers)),(0,Uq.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,Uq.defer)(()=>(0,Uq.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,Uq.defer)(()=>(0,Uq.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&jAa.get(this.answers,t.name)!==void 0)return(0,Uq.empty)();if(t.when===!1)return(0,Uq.empty)();if(typeof t.when!="function")return(0,Uq.of)(t);let{answers:r}=this;return(0,Uq.defer)(()=>(0,Uq.from)((0,vVp.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,Uq.filter)(i=>i!=null)))}};function bVp(e){let t=function(r,i){let n;try{n=new X3n(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",iAa),this.registerPrompt("input",Y$i),this.registerPrompt("number",nAa),this.registerPrompt("confirm",aAa),this.registerPrompt("rawlist",oAa),this.registerPrompt("expand",uAa),this.registerPrompt("checkbox",sAa),this.registerPrompt("password",cAa),this.registerPrompt("editor",gAa)},t.restoreDefaultPrompts(),t}var ttc=bVp();function z9D(e,t){ttc.registerPrompt(e,t)}function x9D(){ttc.restoreDefaultPrompts()}var R9D={prompt:ttc,ui:{BottomBar:PAa,Prompt:X3n},createPromptModule:bVp,registerPrompt:z9D,restoreDefaultPrompts:x9D,Separator:Aae},e2o=R9D;var MWp=ci(gVp()),lVD="4.2.1",AWt;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay"})(AWt||(AWt={}));function fVD(e,t){if(!e)throw new Error(t)}function dVD(e){return e?.replace(/\/+$/,"")}async function pVD(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function _VD(){return new Date().getTime()}function OWp(){return new Date().toISOString()}function AWp(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var IAa=String.fromCharCode,mWp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h2o={};function hVD(e,t){if(!h2o[e]){h2o[e]={};for(let r=0;r<e.length;r++)h2o[e][e.charAt(r)]=r}return h2o[e][t]}var zAa={compressToBase64:function(e){if(e==null)return"";let t=zAa._compress(e,6,function(r){return mWp.charAt(r)});switch(t.length%4){default:case 0:return t;case 1:return t+"===";case 2:return t+"==";case 3:return t+"="}},decompressFromBase64:function(e){return e==null?"":e==""?null:zAa._decompress(e.length,32,function(t){return hVD(mWp,e.charAt(t))})},compress:function(e){return zAa._compress(e,16,function(t){return IAa(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,d="",s="",o="",c=2,b=3,g=2,O=0,m=0,P;for(P=0;P<e.length;P+=1)if(d=e.charAt(P),Object.prototype.hasOwnProperty.call(i,d)||(i[d]=b++,n[d]=!0),s=o+d,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:zAa._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,d=3,s="",o,c,b,g,O,m,P;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=IAa(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=IAa(b);break;case 2:return""}for(i[3]=P,c=P,n.push(P);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,d),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(P=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=IAa(b),P=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=IAa(b),P=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,d),d++),i[P])s=i[P];else if(P===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,d),d++)}}},Ftc=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}};var y2o="0123456789abcdef",v2o=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=y2o.charAt(this.bytes[r]>>>4),t+=y2o.charAt(this.bytes[r]&15),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=y2o.charAt(this.bytes[r]>>>4),t+=y2o.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},Ltc=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??yVD()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return v2o.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let t=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return t[6]=64|t[6]>>>4,t[8]=128|t[8]>>>2,v2o.ofInner(t)}},yVD=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),PWp,jWp=()=>vVD().toString(),vVD=()=>(PWp||(PWp=new Ltc)).generate(),b2o=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},xAa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function wWp(e){return typeof e=="object"&&(e instanceof b2o||e instanceof xAa)}var Utc=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new Ftc,this._isInitialized=!1,fVD(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=dVD(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.defaultOptIn=r?.defaultOptIn??!0,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:wWp},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(AWt.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(AWt.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(AWt.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=jWp();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let l=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",l,n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.fetchWithRetry(u,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(d=>d.json()).catch(d=>{this._events.emit("error",d)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagsStateless(r,i,n,a,u);if(!l)return;let d=l[t];return d===void 0&&(d=!1),d}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u);if(!l)return;let d=l[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let l=await this.getDecide(t,r,i,n,u),d=l?.featureFlags,s=l?.featureFlagPayloads,o=s;return s&&(o=Object.fromEntries(Object.entries(s).map(([c,b])=>[c,this._parsePayload(b)]))),{flags:d,payloads:o}}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:OWp(),uuid:i?.uuid?i.uuid:jWp()};(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId);let u=this.getPersistedProperty(AWt.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:n}),this.setPersistedProperty(AWt.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=AWp(()=>this.flushBackground(),this.flushInterval))})}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(()=>{})}async flush(){return this.flushPromise||(this.flushPromise=this._flush().finally(()=>{this.flushPromise=null}),this.addPendingPromise(this.flushPromise)),this.flushPromise}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(AWt.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty(AWt.Queue)||[];this.setPersistedProperty(AWt.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:OWp()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${_VD()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,d=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(zAa.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(l,d)}catch(s){throw s instanceof xAa||n(),this._events.emit("error",s),s}return n(),this._events.emit("flush",i),i}async fetchWithRetry(t,r,i,n){var a;return(a=AbortSignal).timeout??(a.timeout=function(l){let d=new AbortController;return setTimeout(()=>d.abort(),l),d.signal}),await pVD(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(d){throw new xAa(d)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new b2o(u);return u},{...this._retryOptions,...i})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(AWt.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!wWp(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},Vtc=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},Wtc=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!Wtc){let e=gWp();Wtc=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var qWp=Wtc,bVD=1152921504606847e3,gVD=["is_not"],g2o=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},Z2=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},Htc=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...l}){this.debugMode=!1,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=l.fetch||qWp,this.onError=l.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,l;if(!this.loadedSuccessfullyOnce)return u;for(let d of this.featureFlags)if(t===d.key){l=d;break}if(l!==void 0)try{u=this.computeFlagLocally(l,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(d){d instanceof Z2?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${d}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return this.featureFlags.map(async d=>{try{let s=this.computeFlagLocally(d,t,r,i,n);a[d.key]=s;let o=await this.computeFeatureFlagPayloadLocally(d.key,s);o&&(u[d.key]=o)}catch(s){s instanceof Z2||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${s}`)),l=!0}}),{response:a,payloads:u,fallbackToDecide:l}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new Z2("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let d=this.groupTypeMapping[String(l)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new Z2("Flag has unknown group type index");if(!(d in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[d];return this.matchFeatureFlagProperties(t,i[d],s)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,d=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of d)try{if(this.isConditionMatch(t,r,s,i)){let o=s.variant,c=n.multivariate?.variants||[];o&&c.some(b=>b.key===o)?l=o:l=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof Z2)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new Z2("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=l=>{this.logMsgIfDebug(()=>console.warn(l))};if((i.properties||[]).length>0){for(let l of i.properties){let d=l.type,s=!1;if(d==="cohort"?s=CWp(l,n,this.cohorts,this.debugMode):s=TWp(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&SWp(t.key,r)>a/100)}getMatchingVariant(t,r){let i=SWp(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(l=>{n=i+l.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:l.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new g2o("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0}catch(t){t instanceof g2o&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=AWp(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function SWp(e,t,r=""){let i=(0,MWp.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/bVD}function TWp(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new Z2("Operator is_not_set is not supported")}else throw new Z2(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!gVD.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function d(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return DWp(String(n))&&String(u).match(String(n))!==null;case"not_regex":return DWp(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?d(u,String(n),a):d(u,s,a):d(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=OVD(String(n));if(s==null&&(s=EWp(n)),s==null)throw new Z2(`Invalid date: ${n}`);let o=EWp(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new Z2(`Unknown operator: ${a}`)}}function CWp(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new Z2("can't match cohort without a given cohort property value");let a=r[n];return BWp(a,t,r,i)}function BWp(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let d=BWp(l,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof Z2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new Z2("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let d;l.type==="cohort"?d=CWp(l,t,r,i):d=TWp(l,t);let s=l.negation||!1;if(n==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof Z2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new Z2("can't match cohort without a given cohort property value");return n==="AND"}}function DWp(e){try{return new RegExp(e),!0}catch{return!1}}function EWp(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new Z2(`${e} is in an invalid date format`)}else throw new Z2(`The date provided ${e} must be a string, number, or date object`)}function OVD(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var mVD=30*1e3,PVD=50*1e3,n7n=class extends Utc{constructor(t,r={}){super(t,r),this._memoryStorage=new Vtc,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new Htc({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:mVD,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||PVD}getPersistedProperty(t){return this._memoryStorage.getProperty(t)}setPersistedProperty(t,r){return this._memoryStorage.setProperty(t,r)}fetch(t,r){return this.options.fetch?this.options.fetch(t,r):qWp(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return lVD}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture({distinctId:t,event:r,properties:i,groups:n,sendFeatureFlags:a,timestamp:u,disableGeoip:l,uuid:d}){let s=b=>{super.captureStateless(t,r,b,{timestamp:u,disableGeoip:l,uuid:d})},o=(b,g,O)=>super.getFeatureFlagsStateless(b,g,void 0,void 0,O),c=Promise.resolve().then(async()=>{if(a)return await o(t,n,l);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let b={};for(let[g,O]of Object.entries(n||{}))b[g]=String(O);return await this.getAllFlags(t,{groups:b,disableGeoip:l,onlyEvaluateLocally:!0})}return{}}).then(b=>{let g={};if(b)for(let[m,P]of Object.entries(b))g[`$feature/${m}`]=P;let O=Object.keys(b||{}).filter(m=>b?.[m]!==!1);return O.length>0&&(g.$active_feature_flags=O),g}).catch(()=>({})).then(b=>{s({...b,...i,$groups:n})});this.addPendingPromise(c)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties:d,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,d,s);d=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,d,s),b=c!==void 0;!b&&!u&&(c=await super.getFeatureFlagStateless(t,r,n,d,s,a));let g=`${t}_${c}`;return l&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(g))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(g):this.distinctIdHasSentFlagCalls[r]=[g],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:c,locally_evaluated:b,[`$feature/${t}`]:c},groups:n,disableGeoip:a})),c}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:l,sendFeatureFlagEvents:d,personProperties:s,groupProperties:o}=n||{},c=this.addLocalPersonAndGroupProperties(r,a,s,o);s=c.allPersonProperties,o=c.allGroupProperties;let b;return i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i)),l==null&&(l=!1),d==null&&(d=!0),l==null&&(l=!1),!(b!==void 0)&&!l&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:l}=r||{},d=this.addLocalPersonAndGroupProperties(t,i,u,l);u=d.allPersonProperties,l=d.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}},$tc=class e{constructor(t,r,i,n){this.posthog=t,this.posthogHost=r,this.organization=i,this.prefix=n,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(i=>{if(i.exception?.values===void 0||i.exception.values.length===0)return i;i.tags||(i.tags={});let n=r(),a=i.tags[e.POSTHOG_ID_TAG];if(a===void 0)return i;i.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:i.exception.values[0]?.value,$exception_type:i.exception.values[0]?.type,$exception_personURL:i.tags["PostHog Person URL"],$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:i.exception.values[0]?.value,$sentry_exception_type:i.exception.values[0]?.type,$sentry_tags:i.tags},l=n.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&l!==void 0&&i.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${l}&query=${i.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),i})}};$tc.POSTHOG_ID_TAG="posthog_distinct_id";var O2o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new n7n(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.63.10",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var RAa=class{async sendEvent(){}async identify(){}async flush(){}};var a7n=require("fs/promises"),RWp=require("os"),NWp=require("path");var IWp=ci(require("crypto")),P2o=new Uint8Array(256),m2o=P2o.length;function Gtc(){return m2o>P2o.length-16&&(IWp.default.randomFillSync(P2o),m2o=0),P2o.slice(m2o,m2o+=16)}var WW=[];for(let e=0;e<256;++e)WW.push((e+256).toString(16).slice(1));function zWp(e,t=0){return WW[e[t+0]]+WW[e[t+1]]+WW[e[t+2]]+WW[e[t+3]]+"-"+WW[e[t+4]]+WW[e[t+5]]+"-"+WW[e[t+6]]+WW[e[t+7]]+"-"+WW[e[t+8]]+WW[e[t+9]]+"-"+WW[e[t+10]]+WW[e[t+11]]+WW[e[t+12]]+WW[e[t+13]]+WW[e[t+14]]+WW[e[t+15]]}var xWp=ci(require("crypto")),Qtc={randomUUID:xWp.default.randomUUID};function jVD(e,t,r){if(Qtc.randomUUID&&!t&&!e)return Qtc.randomUUID();e=e||{};let i=e.random||(e.rng||Gtc)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return zWp(i)}var Iae=jVD;var wVD="id",SVD=".fern",NAa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new n7n(r),this.userId=t==null?void 0:tJs(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.63.10",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Vu($l.of((0,RWp.homedir)()),Qa.of(SVD),Qa.of(wVD));await Cf(t)||(await(0,a7n.mkdir)((0,NWp.dirname)(t),{recursive:!0}),await(0,a7n.writeFile)(t,Iae())),this.persistedDistinctId=(await(0,a7n.readFile)(t)).toString()}return this.persistedDistinctId}};var Jtc;async function o7n(){return Jtc==null&&(Jtc=await DVD()),Jtc}async function DVD(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new RAa;let r=await wRo();return r!=null?new NAa({token:r,posthogApiKey:e}):await QNn()!=null?new O2o({posthogApiKey:e}):new NAa({token:void 0,posthogApiKey:e})}catch{return new RAa}}function FAa(e,t){return function(){return e.apply(t,arguments)}}var{toString:EVD}=Object.prototype,{getPrototypeOf:Ytc}=Object,w2o=(e=>t=>{let r=EVD.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),qWt=e=>(e=e.toLowerCase(),t=>w2o(t)===e),S2o=e=>t=>typeof t===e,{isArray:u7n}=Array,LAa=S2o("undefined");function MVD(e){return e!==null&&!LAa(e)&&e.constructor!==null&&!LAa(e.constructor)&&oMe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var LWp=qWt("ArrayBuffer");function AVD(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&LWp(e.buffer),t}var qVD=S2o("string"),oMe=S2o("function"),UWp=S2o("number"),D2o=e=>e!==null&&typeof e=="object",TVD=e=>e===!0||e===!1,j2o=e=>{if(w2o(e)!=="object")return!1;let t=Ytc(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},CVD=qWt("Date"),BVD=qWt("File"),IVD=qWt("Blob"),zVD=qWt("FileList"),xVD=e=>D2o(e)&&oMe(e.pipe),RVD=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||oMe(e.append)&&((t=w2o(e))==="formdata"||t==="object"&&oMe(e.toString)&&e.toString()==="[object FormData]"))},NVD=qWt("URLSearchParams"),[FVD,LVD,UVD,VVD]=["ReadableStream","Request","Response","Headers"].map(qWt),WVD=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function UAa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),u7n(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,l;for(i=0;i<u;i++)l=a[i],t.call(null,e[l],l,e)}}function VWp(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var lGi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,WWp=e=>!LAa(e)&&e!==lGi;function Ktc(){let{caseless:e}=WWp(this)&&this||{},t={},r=(i,n)=>{let a=e&&VWp(t,n)||n;j2o(t[a])&&j2o(i)?t[a]=Ktc(t[a],i):j2o(i)?t[a]=Ktc({},i):u7n(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&UAa(arguments[i],r);return t}var HVD=(e,t,r,{allOwnKeys:i}={})=>(UAa(t,(n,a)=>{r&&oMe(n)?e[a]=FAa(n,r):e[a]=n},{allOwnKeys:i}),e),$VD=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),GVD=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},QVD=(e,t,r,i)=>{let n,a,u,l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!l[u]&&(t[u]=e[u],l[u]=!0);e=r!==!1&&Ytc(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},JVD=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},KVD=e=>{if(!e)return null;if(u7n(e))return e;let t=e.length;if(!UWp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},YVD=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ytc(Uint8Array)),XVD=(e,t)=>{let i=(e&&e[Symbol.iterator]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},ZVD=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},kVD=qWt("HTMLFormElement"),eWD=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),FWp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),tWD=qWt("RegExp"),HWp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};UAa(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},rWD=e=>{HWp(e,(t,r)=>{if(oMe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(oMe(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},iWD=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return u7n(e)?i(e):i(String(e).split(t)),r},nWD=()=>{},aWD=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function oWD(e){return!!(e&&oMe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var uWD=e=>{let t=new Array(10),r=(i,n)=>{if(D2o(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=u7n(i)?[]:{};return UAa(i,(u,l)=>{let d=r(u,n+1);!LAa(d)&&(a[l]=d)}),t[n]=void 0,a}}return i};return r(e,0)},sWD=qWt("AsyncFunction"),cWD=e=>e&&(D2o(e)||oMe(e))&&oMe(e.then)&&oMe(e.catch),$Wp=((e,t)=>e?setImmediate:t?((r,i)=>(lGi.addEventListener("message",({source:n,data:a})=>{n===lGi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),lGi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",oMe(lGi.postMessage)),lWD=typeof queueMicrotask<"u"?queueMicrotask.bind(lGi):typeof process<"u"&&process.nextTick||$Wp,_s={isArray:u7n,isArrayBuffer:LWp,isBuffer:MVD,isFormData:RVD,isArrayBufferView:AVD,isString:qVD,isNumber:UWp,isBoolean:TVD,isObject:D2o,isPlainObject:j2o,isReadableStream:FVD,isRequest:LVD,isResponse:UVD,isHeaders:VVD,isUndefined:LAa,isDate:CVD,isFile:BVD,isBlob:IVD,isRegExp:tWD,isFunction:oMe,isStream:xVD,isURLSearchParams:NVD,isTypedArray:YVD,isFileList:zVD,forEach:UAa,merge:Ktc,extend:HVD,trim:WVD,stripBOM:$VD,inherits:GVD,toFlatObject:QVD,kindOf:w2o,kindOfTest:qWt,endsWith:JVD,toArray:KVD,forEachEntry:XVD,matchAll:ZVD,isHTMLForm:kVD,hasOwnProperty:FWp,hasOwnProp:FWp,reduceDescriptors:HWp,freezeMethods:rWD,toObjectSet:iWD,toCamelCase:eWD,noop:nWD,toFiniteNumber:aWD,findKey:VWp,global:lGi,isContextDefined:WWp,isSpecCompliantForm:oWD,toJSONObject:uWD,isAsyncFn:sWD,isThenable:cWD,setImmediate:$Wp,asap:lWD};function s7n(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}_s.inherits(s7n,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:_s.toJSONObject(this.config),code:this.code,status:this.status}}});var GWp=s7n.prototype,QWp={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{QWp[e]={value:e}});Object.defineProperties(s7n,QWp);Object.defineProperty(GWp,"isAxiosError",{value:!0});s7n.from=(e,t,r,i,n,a)=>{let u=Object.create(GWp);return _s.toFlatObject(e,u,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),s7n.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var xp=s7n;var JWp=ci(uwa(),1),E2o=JWp.default;function Xtc(e){return _s.isPlainObject(e)||_s.isArray(e)}function YWp(e){return _s.endsWith(e,"[]")?e.slice(0,-2):e}function KWp(e,t,r){return e?e.concat(t).map(function(n,a){return n=YWp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function fWD(e){return _s.isArray(e)&&!e.some(Xtc)}var dWD=_s.toFlatObject(_s,{},null,function(t){return/^is[A-Z]/.test(t)});function pWD(e,t,r){if(!_s.isObject(e))throw new TypeError("target must be an object");t=t||new(E2o||FormData),r=_s.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,P){return!_s.isUndefined(P[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&_s.isSpecCompliantForm(t);if(!_s.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(_s.isDate(O))return O.toISOString();if(!d&&_s.isBlob(O))throw new xp("Blob is not supported. Use a Buffer instead.");return _s.isArrayBuffer(O)||_s.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,P){let E=O;if(O&&!P&&typeof O=="object"){if(_s.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(_s.isArray(O)&&fWD(O)||(_s.isFileList(O)||_s.endsWith(m,"[]"))&&(E=_s.toArray(O)))return m=YWp(m),E.forEach(function(M,D){!(_s.isUndefined(M)||M===null)&&t.append(u===!0?KWp([m],D,a):u===null?m:m+"[]",s(M))}),!1}return Xtc(O)?!0:(t.append(KWp(P,m,a),s(O)),!1)}let c=[],b=Object.assign(dWD,{defaultVisitor:o,convertValue:s,isVisitable:Xtc});function g(O,m){if(!_s.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),_s.forEach(O,function(E,q){(!(_s.isUndefined(E)||E===null)&&n.call(t,E,_s.isString(q)?q.trim():q,m,b))===!0&&g(E,m?m.concat(q):[q])}),c.pop()}}if(!_s.isObject(e))throw new TypeError("data must be an object");return g(e),t}var YDi=pWD;function XWp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function ZWp(e,t){this._pairs=[],e&&YDi(e,this,t)}var kWp=ZWp.prototype;kWp.append=function(t,r){this._pairs.push([t,r])};kWp.toString=function(t){let r=t?function(i){return t.call(this,i,XWp)}:XWp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var eHp=ZWp;function _WD(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function fGi(e,t,r){if(!t)return e;let i=r&&r.encode||_WD;_s.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=_s.isURLSearchParams(t)?t.toString():new eHp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var Ztc=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){_s.forEach(this.handlers,function(i){i!==null&&t(i)})}},ktc=Ztc;var c7n={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var nHp=ci(require("crypto"),1);var tHp=ci(require("url"),1),rHp=tHp.default.URLSearchParams;var erc="abcdefghijklmnopqrstuvwxyz",iHp="0123456789",aHp={DIGIT:iHp,ALPHA:erc,ALPHA_DIGIT:erc+erc.toUpperCase()+iHp},hWD=(e=16,t=aHp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);nHp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},oHp={isNode:!0,classes:{URLSearchParams:rHp,FormData:E2o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:aHp,generateString:hWD,protocols:["http","https","file","data"]};var irc={};jo(irc,{hasBrowserEnv:()=>rrc,hasStandardBrowserEnv:()=>yWD,hasStandardBrowserWebWorkerEnv:()=>vWD,navigator:()=>trc,origin:()=>bWD});var rrc=typeof window<"u"&&typeof document<"u",trc=typeof navigator=="object"&&navigator||void 0,yWD=rrc&&(!trc||["ReactNative","NativeScript","NS"].indexOf(trc.product)<0),vWD=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",bWD=rrc&&window.location.href||"http://localhost";var sA={...irc,...oHp};function nrc(e,t){return YDi(e,new sA.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return sA.isNode&&_s.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function gWD(e){return _s.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function OWD(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function mWD(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),d=a>=r.length;return u=!u&&_s.isArray(n)?n.length:u,d?(_s.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!_s.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&_s.isArray(n[u])&&(n[u]=OWD(n[u])),!l)}if(_s.isFormData(e)&&_s.isFunction(e.entries)){let r={};return _s.forEachEntry(e,(i,n)=>{t(gWD(i),n,r,0)}),r}return null}var M2o=mWD;function PWD(e,t,r){if(_s.isString(e))try{return(t||JSON.parse)(e),_s.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var arc={transitional:c7n,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=_s.isObject(t);if(a&&_s.isHTMLForm(t)&&(t=new FormData(t)),_s.isFormData(t))return n?JSON.stringify(M2o(t)):t;if(_s.isArrayBuffer(t)||_s.isBuffer(t)||_s.isStream(t)||_s.isFile(t)||_s.isBlob(t)||_s.isReadableStream(t))return t;if(_s.isArrayBufferView(t))return t.buffer;if(_s.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return nrc(t,this.formSerializer).toString();if((l=_s.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return YDi(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),PWD(t)):t}],transformResponse:[function(t){let r=this.transitional||arc.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(_s.isResponse(t)||_s.isReadableStream(t))return t;if(t&&_s.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?xp.from(l,xp.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:sA.classes.FormData,Blob:sA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_s.forEach(["delete","get","head","post","put","patch"],e=>{arc.headers[e]={}});var l7n=arc;var jWD=_s.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),uHp=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1707
|
+
`}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&&w4o(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var _Vp=ci(uVp(),1),hVp=ci(ZZs(),1),yVp=ci(dVp(),1),Uq=ci(nMe(),1),vVp=ci(lMa(),1);var Z4o=ci(nMe(),1),pVp=ci(lMa(),1),k4o=function(e,t,r){return typeof e[t]!="function"?(0,Z4o.of)(e):(0,Z4o.from)((0,pVp.default)(e[t])(r).then(i=>(e[t]=i,e)))};var jAa={isPlainObject:_Vp.default,set:yVp.default,get:hVp.default},X3n=class extends aGi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=jAa.isPlainObject(r)?{...r}:{},jAa.isPlainObject(t)&&(t=Object.values(t).every(n=>jAa.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,Uq.from)(t):t;return this.process=i.pipe((0,Uq.concatMap)(this.processQuestion.bind(this)),(0,Uq.publish)()),this.process.connect(),this.process.pipe((0,Uq.reduce)((n,a)=>(jAa.set(n,a.name,a.answer),n),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,Uq.defer)(()=>(0,Uq.of)(t).pipe((0,Uq.concatMap)(this.setDefaultType.bind(this)),(0,Uq.concatMap)(this.filterIfRunnable.bind(this)),(0,Uq.concatMap)(()=>k4o(t,"message",this.answers)),(0,Uq.concatMap)(()=>k4o(t,"default",this.answers)),(0,Uq.concatMap)(()=>k4o(t,"choices",this.answers)),(0,Uq.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,Uq.defer)(()=>(0,Uq.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,Uq.defer)(()=>(0,Uq.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&jAa.get(this.answers,t.name)!==void 0)return(0,Uq.empty)();if(t.when===!1)return(0,Uq.empty)();if(typeof t.when!="function")return(0,Uq.of)(t);let{answers:r}=this;return(0,Uq.defer)(()=>(0,Uq.from)((0,vVp.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,Uq.filter)(i=>i!=null)))}};function bVp(e){let t=function(r,i){let n;try{n=new X3n(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",iAa),this.registerPrompt("input",Y$i),this.registerPrompt("number",nAa),this.registerPrompt("confirm",aAa),this.registerPrompt("rawlist",oAa),this.registerPrompt("expand",uAa),this.registerPrompt("checkbox",sAa),this.registerPrompt("password",cAa),this.registerPrompt("editor",gAa)},t.restoreDefaultPrompts(),t}var ttc=bVp();function z9D(e,t){ttc.registerPrompt(e,t)}function x9D(){ttc.restoreDefaultPrompts()}var R9D={prompt:ttc,ui:{BottomBar:PAa,Prompt:X3n},createPromptModule:bVp,registerPrompt:z9D,restoreDefaultPrompts:x9D,Separator:Aae},e2o=R9D;var MWp=ci(gVp()),lVD="4.2.1",AWt;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay"})(AWt||(AWt={}));function fVD(e,t){if(!e)throw new Error(t)}function dVD(e){return e?.replace(/\/+$/,"")}async function pVD(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function _VD(){return new Date().getTime()}function OWp(){return new Date().toISOString()}function AWp(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var IAa=String.fromCharCode,mWp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h2o={};function hVD(e,t){if(!h2o[e]){h2o[e]={};for(let r=0;r<e.length;r++)h2o[e][e.charAt(r)]=r}return h2o[e][t]}var zAa={compressToBase64:function(e){if(e==null)return"";let t=zAa._compress(e,6,function(r){return mWp.charAt(r)});switch(t.length%4){default:case 0:return t;case 1:return t+"===";case 2:return t+"==";case 3:return t+"="}},decompressFromBase64:function(e){return e==null?"":e==""?null:zAa._decompress(e.length,32,function(t){return hVD(mWp,e.charAt(t))})},compress:function(e){return zAa._compress(e,16,function(t){return IAa(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,d="",s="",o="",c=2,b=3,g=2,O=0,m=0,P;for(P=0;P<e.length;P+=1)if(d=e.charAt(P),Object.prototype.hasOwnProperty.call(i,d)||(i[d]=b++,n[d]=!0),s=o+d,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:zAa._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,d=3,s="",o,c,b,g,O,m,P;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=IAa(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=IAa(b);break;case 2:return""}for(i[3]=P,c=P,n.push(P);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,d),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(P=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=IAa(b),P=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=IAa(b),P=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,d),d++),i[P])s=i[P];else if(P===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,d),d++)}}},Ftc=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}};var y2o="0123456789abcdef",v2o=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=y2o.charAt(this.bytes[r]>>>4),t+=y2o.charAt(this.bytes[r]&15),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=y2o.charAt(this.bytes[r]>>>4),t+=y2o.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},Ltc=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??yVD()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return v2o.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let t=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return t[6]=64|t[6]>>>4,t[8]=128|t[8]>>>2,v2o.ofInner(t)}},yVD=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),PWp,jWp=()=>vVD().toString(),vVD=()=>(PWp||(PWp=new Ltc)).generate(),b2o=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},xAa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function wWp(e){return typeof e=="object"&&(e instanceof b2o||e instanceof xAa)}var Utc=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new Ftc,this._isInitialized=!1,fVD(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=dVD(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.defaultOptIn=r?.defaultOptIn??!0,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:wWp},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(AWt.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(AWt.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(AWt.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=jWp();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let l=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",l,n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.fetchWithRetry(u,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(d=>d.json()).catch(d=>{this._events.emit("error",d)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagsStateless(r,i,n,a,u);if(!l)return;let d=l[t];return d===void 0&&(d=!1),d}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u);if(!l)return;let d=l[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let l=await this.getDecide(t,r,i,n,u),d=l?.featureFlags,s=l?.featureFlagPayloads,o=s;return s&&(o=Object.fromEntries(Object.entries(s).map(([c,b])=>[c,this._parsePayload(b)]))),{flags:d,payloads:o}}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:OWp(),uuid:i?.uuid?i.uuid:jWp()};(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId);let u=this.getPersistedProperty(AWt.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:n}),this.setPersistedProperty(AWt.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=AWp(()=>this.flushBackground(),this.flushInterval))})}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(()=>{})}async flush(){return this.flushPromise||(this.flushPromise=this._flush().finally(()=>{this.flushPromise=null}),this.addPendingPromise(this.flushPromise)),this.flushPromise}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(AWt.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty(AWt.Queue)||[];this.setPersistedProperty(AWt.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:OWp()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${_VD()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,d=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(zAa.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(l,d)}catch(s){throw s instanceof xAa||n(),this._events.emit("error",s),s}return n(),this._events.emit("flush",i),i}async fetchWithRetry(t,r,i,n){var a;return(a=AbortSignal).timeout??(a.timeout=function(l){let d=new AbortController;return setTimeout(()=>d.abort(),l),d.signal}),await pVD(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(d){throw new xAa(d)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new b2o(u);return u},{...this._retryOptions,...i})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(AWt.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!wWp(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},Vtc=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},Wtc=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!Wtc){let e=gWp();Wtc=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var qWp=Wtc,bVD=1152921504606847e3,gVD=["is_not"],g2o=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},Z2=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},Htc=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...l}){this.debugMode=!1,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=l.fetch||qWp,this.onError=l.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,l;if(!this.loadedSuccessfullyOnce)return u;for(let d of this.featureFlags)if(t===d.key){l=d;break}if(l!==void 0)try{u=this.computeFlagLocally(l,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(d){d instanceof Z2?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${d}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return this.featureFlags.map(async d=>{try{let s=this.computeFlagLocally(d,t,r,i,n);a[d.key]=s;let o=await this.computeFeatureFlagPayloadLocally(d.key,s);o&&(u[d.key]=o)}catch(s){s instanceof Z2||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${s}`)),l=!0}}),{response:a,payloads:u,fallbackToDecide:l}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new Z2("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let d=this.groupTypeMapping[String(l)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new Z2("Flag has unknown group type index");if(!(d in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[d];return this.matchFeatureFlagProperties(t,i[d],s)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,d=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of d)try{if(this.isConditionMatch(t,r,s,i)){let o=s.variant,c=n.multivariate?.variants||[];o&&c.some(b=>b.key===o)?l=o:l=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof Z2)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new Z2("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=l=>{this.logMsgIfDebug(()=>console.warn(l))};if((i.properties||[]).length>0){for(let l of i.properties){let d=l.type,s=!1;if(d==="cohort"?s=CWp(l,n,this.cohorts,this.debugMode):s=TWp(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&SWp(t.key,r)>a/100)}getMatchingVariant(t,r){let i=SWp(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(l=>{n=i+l.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:l.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new g2o("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0}catch(t){t instanceof g2o&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=AWp(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function SWp(e,t,r=""){let i=(0,MWp.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/bVD}function TWp(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new Z2("Operator is_not_set is not supported")}else throw new Z2(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!gVD.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function d(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return DWp(String(n))&&String(u).match(String(n))!==null;case"not_regex":return DWp(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?d(u,String(n),a):d(u,s,a):d(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=OVD(String(n));if(s==null&&(s=EWp(n)),s==null)throw new Z2(`Invalid date: ${n}`);let o=EWp(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new Z2(`Unknown operator: ${a}`)}}function CWp(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new Z2("can't match cohort without a given cohort property value");let a=r[n];return BWp(a,t,r,i)}function BWp(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let d=BWp(l,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof Z2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new Z2("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let d;l.type==="cohort"?d=CWp(l,t,r,i):d=TWp(l,t);let s=l.negation||!1;if(n==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof Z2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new Z2("can't match cohort without a given cohort property value");return n==="AND"}}function DWp(e){try{return new RegExp(e),!0}catch{return!1}}function EWp(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new Z2(`${e} is in an invalid date format`)}else throw new Z2(`The date provided ${e} must be a string, number, or date object`)}function OVD(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var mVD=30*1e3,PVD=50*1e3,n7n=class extends Utc{constructor(t,r={}){super(t,r),this._memoryStorage=new Vtc,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new Htc({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:mVD,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||PVD}getPersistedProperty(t){return this._memoryStorage.getProperty(t)}setPersistedProperty(t,r){return this._memoryStorage.setProperty(t,r)}fetch(t,r){return this.options.fetch?this.options.fetch(t,r):qWp(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return lVD}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture({distinctId:t,event:r,properties:i,groups:n,sendFeatureFlags:a,timestamp:u,disableGeoip:l,uuid:d}){let s=b=>{super.captureStateless(t,r,b,{timestamp:u,disableGeoip:l,uuid:d})},o=(b,g,O)=>super.getFeatureFlagsStateless(b,g,void 0,void 0,O),c=Promise.resolve().then(async()=>{if(a)return await o(t,n,l);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let b={};for(let[g,O]of Object.entries(n||{}))b[g]=String(O);return await this.getAllFlags(t,{groups:b,disableGeoip:l,onlyEvaluateLocally:!0})}return{}}).then(b=>{let g={};if(b)for(let[m,P]of Object.entries(b))g[`$feature/${m}`]=P;let O=Object.keys(b||{}).filter(m=>b?.[m]!==!1);return O.length>0&&(g.$active_feature_flags=O),g}).catch(()=>({})).then(b=>{s({...b,...i,$groups:n})});this.addPendingPromise(c)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties:d,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,d,s);d=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,d,s),b=c!==void 0;!b&&!u&&(c=await super.getFeatureFlagStateless(t,r,n,d,s,a));let g=`${t}_${c}`;return l&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(g))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(g):this.distinctIdHasSentFlagCalls[r]=[g],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:c,locally_evaluated:b,[`$feature/${t}`]:c},groups:n,disableGeoip:a})),c}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:l,sendFeatureFlagEvents:d,personProperties:s,groupProperties:o}=n||{},c=this.addLocalPersonAndGroupProperties(r,a,s,o);s=c.allPersonProperties,o=c.allGroupProperties;let b;return i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i)),l==null&&(l=!1),d==null&&(d=!0),l==null&&(l=!1),!(b!==void 0)&&!l&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:l}=r||{},d=this.addLocalPersonAndGroupProperties(t,i,u,l);u=d.allPersonProperties,l=d.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}},$tc=class e{constructor(t,r,i,n){this.posthog=t,this.posthogHost=r,this.organization=i,this.prefix=n,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(i=>{if(i.exception?.values===void 0||i.exception.values.length===0)return i;i.tags||(i.tags={});let n=r(),a=i.tags[e.POSTHOG_ID_TAG];if(a===void 0)return i;i.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:i.exception.values[0]?.value,$exception_type:i.exception.values[0]?.type,$exception_personURL:i.tags["PostHog Person URL"],$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:i.exception.values[0]?.value,$sentry_exception_type:i.exception.values[0]?.type,$sentry_tags:i.tags},l=n.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&l!==void 0&&i.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${l}&query=${i.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),i})}};$tc.POSTHOG_ID_TAG="posthog_distinct_id";var O2o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new n7n(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.63.12",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var RAa=class{async sendEvent(){}async identify(){}async flush(){}};var a7n=require("fs/promises"),RWp=require("os"),NWp=require("path");var IWp=ci(require("crypto")),P2o=new Uint8Array(256),m2o=P2o.length;function Gtc(){return m2o>P2o.length-16&&(IWp.default.randomFillSync(P2o),m2o=0),P2o.slice(m2o,m2o+=16)}var WW=[];for(let e=0;e<256;++e)WW.push((e+256).toString(16).slice(1));function zWp(e,t=0){return WW[e[t+0]]+WW[e[t+1]]+WW[e[t+2]]+WW[e[t+3]]+"-"+WW[e[t+4]]+WW[e[t+5]]+"-"+WW[e[t+6]]+WW[e[t+7]]+"-"+WW[e[t+8]]+WW[e[t+9]]+"-"+WW[e[t+10]]+WW[e[t+11]]+WW[e[t+12]]+WW[e[t+13]]+WW[e[t+14]]+WW[e[t+15]]}var xWp=ci(require("crypto")),Qtc={randomUUID:xWp.default.randomUUID};function jVD(e,t,r){if(Qtc.randomUUID&&!t&&!e)return Qtc.randomUUID();e=e||{};let i=e.random||(e.rng||Gtc)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return zWp(i)}var Iae=jVD;var wVD="id",SVD=".fern",NAa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new n7n(r),this.userId=t==null?void 0:tJs(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.63.12",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Vu($l.of((0,RWp.homedir)()),Qa.of(SVD),Qa.of(wVD));await Cf(t)||(await(0,a7n.mkdir)((0,NWp.dirname)(t),{recursive:!0}),await(0,a7n.writeFile)(t,Iae())),this.persistedDistinctId=(await(0,a7n.readFile)(t)).toString()}return this.persistedDistinctId}};var Jtc;async function o7n(){return Jtc==null&&(Jtc=await DVD()),Jtc}async function DVD(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new RAa;let r=await wRo();return r!=null?new NAa({token:r,posthogApiKey:e}):await QNn()!=null?new O2o({posthogApiKey:e}):new NAa({token:void 0,posthogApiKey:e})}catch{return new RAa}}function FAa(e,t){return function(){return e.apply(t,arguments)}}var{toString:EVD}=Object.prototype,{getPrototypeOf:Ytc}=Object,w2o=(e=>t=>{let r=EVD.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),qWt=e=>(e=e.toLowerCase(),t=>w2o(t)===e),S2o=e=>t=>typeof t===e,{isArray:u7n}=Array,LAa=S2o("undefined");function MVD(e){return e!==null&&!LAa(e)&&e.constructor!==null&&!LAa(e.constructor)&&oMe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var LWp=qWt("ArrayBuffer");function AVD(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&LWp(e.buffer),t}var qVD=S2o("string"),oMe=S2o("function"),UWp=S2o("number"),D2o=e=>e!==null&&typeof e=="object",TVD=e=>e===!0||e===!1,j2o=e=>{if(w2o(e)!=="object")return!1;let t=Ytc(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},CVD=qWt("Date"),BVD=qWt("File"),IVD=qWt("Blob"),zVD=qWt("FileList"),xVD=e=>D2o(e)&&oMe(e.pipe),RVD=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||oMe(e.append)&&((t=w2o(e))==="formdata"||t==="object"&&oMe(e.toString)&&e.toString()==="[object FormData]"))},NVD=qWt("URLSearchParams"),[FVD,LVD,UVD,VVD]=["ReadableStream","Request","Response","Headers"].map(qWt),WVD=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function UAa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),u7n(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,l;for(i=0;i<u;i++)l=a[i],t.call(null,e[l],l,e)}}function VWp(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var lGi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,WWp=e=>!LAa(e)&&e!==lGi;function Ktc(){let{caseless:e}=WWp(this)&&this||{},t={},r=(i,n)=>{let a=e&&VWp(t,n)||n;j2o(t[a])&&j2o(i)?t[a]=Ktc(t[a],i):j2o(i)?t[a]=Ktc({},i):u7n(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&UAa(arguments[i],r);return t}var HVD=(e,t,r,{allOwnKeys:i}={})=>(UAa(t,(n,a)=>{r&&oMe(n)?e[a]=FAa(n,r):e[a]=n},{allOwnKeys:i}),e),$VD=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),GVD=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},QVD=(e,t,r,i)=>{let n,a,u,l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!l[u]&&(t[u]=e[u],l[u]=!0);e=r!==!1&&Ytc(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},JVD=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},KVD=e=>{if(!e)return null;if(u7n(e))return e;let t=e.length;if(!UWp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},YVD=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ytc(Uint8Array)),XVD=(e,t)=>{let i=(e&&e[Symbol.iterator]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},ZVD=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},kVD=qWt("HTMLFormElement"),eWD=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),FWp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),tWD=qWt("RegExp"),HWp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};UAa(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},rWD=e=>{HWp(e,(t,r)=>{if(oMe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(oMe(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},iWD=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return u7n(e)?i(e):i(String(e).split(t)),r},nWD=()=>{},aWD=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function oWD(e){return!!(e&&oMe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var uWD=e=>{let t=new Array(10),r=(i,n)=>{if(D2o(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=u7n(i)?[]:{};return UAa(i,(u,l)=>{let d=r(u,n+1);!LAa(d)&&(a[l]=d)}),t[n]=void 0,a}}return i};return r(e,0)},sWD=qWt("AsyncFunction"),cWD=e=>e&&(D2o(e)||oMe(e))&&oMe(e.then)&&oMe(e.catch),$Wp=((e,t)=>e?setImmediate:t?((r,i)=>(lGi.addEventListener("message",({source:n,data:a})=>{n===lGi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),lGi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",oMe(lGi.postMessage)),lWD=typeof queueMicrotask<"u"?queueMicrotask.bind(lGi):typeof process<"u"&&process.nextTick||$Wp,_s={isArray:u7n,isArrayBuffer:LWp,isBuffer:MVD,isFormData:RVD,isArrayBufferView:AVD,isString:qVD,isNumber:UWp,isBoolean:TVD,isObject:D2o,isPlainObject:j2o,isReadableStream:FVD,isRequest:LVD,isResponse:UVD,isHeaders:VVD,isUndefined:LAa,isDate:CVD,isFile:BVD,isBlob:IVD,isRegExp:tWD,isFunction:oMe,isStream:xVD,isURLSearchParams:NVD,isTypedArray:YVD,isFileList:zVD,forEach:UAa,merge:Ktc,extend:HVD,trim:WVD,stripBOM:$VD,inherits:GVD,toFlatObject:QVD,kindOf:w2o,kindOfTest:qWt,endsWith:JVD,toArray:KVD,forEachEntry:XVD,matchAll:ZVD,isHTMLForm:kVD,hasOwnProperty:FWp,hasOwnProp:FWp,reduceDescriptors:HWp,freezeMethods:rWD,toObjectSet:iWD,toCamelCase:eWD,noop:nWD,toFiniteNumber:aWD,findKey:VWp,global:lGi,isContextDefined:WWp,isSpecCompliantForm:oWD,toJSONObject:uWD,isAsyncFn:sWD,isThenable:cWD,setImmediate:$Wp,asap:lWD};function s7n(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}_s.inherits(s7n,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:_s.toJSONObject(this.config),code:this.code,status:this.status}}});var GWp=s7n.prototype,QWp={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{QWp[e]={value:e}});Object.defineProperties(s7n,QWp);Object.defineProperty(GWp,"isAxiosError",{value:!0});s7n.from=(e,t,r,i,n,a)=>{let u=Object.create(GWp);return _s.toFlatObject(e,u,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),s7n.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var xp=s7n;var JWp=ci(uwa(),1),E2o=JWp.default;function Xtc(e){return _s.isPlainObject(e)||_s.isArray(e)}function YWp(e){return _s.endsWith(e,"[]")?e.slice(0,-2):e}function KWp(e,t,r){return e?e.concat(t).map(function(n,a){return n=YWp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function fWD(e){return _s.isArray(e)&&!e.some(Xtc)}var dWD=_s.toFlatObject(_s,{},null,function(t){return/^is[A-Z]/.test(t)});function pWD(e,t,r){if(!_s.isObject(e))throw new TypeError("target must be an object");t=t||new(E2o||FormData),r=_s.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,P){return!_s.isUndefined(P[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&_s.isSpecCompliantForm(t);if(!_s.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(_s.isDate(O))return O.toISOString();if(!d&&_s.isBlob(O))throw new xp("Blob is not supported. Use a Buffer instead.");return _s.isArrayBuffer(O)||_s.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,P){let E=O;if(O&&!P&&typeof O=="object"){if(_s.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(_s.isArray(O)&&fWD(O)||(_s.isFileList(O)||_s.endsWith(m,"[]"))&&(E=_s.toArray(O)))return m=YWp(m),E.forEach(function(M,D){!(_s.isUndefined(M)||M===null)&&t.append(u===!0?KWp([m],D,a):u===null?m:m+"[]",s(M))}),!1}return Xtc(O)?!0:(t.append(KWp(P,m,a),s(O)),!1)}let c=[],b=Object.assign(dWD,{defaultVisitor:o,convertValue:s,isVisitable:Xtc});function g(O,m){if(!_s.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),_s.forEach(O,function(E,q){(!(_s.isUndefined(E)||E===null)&&n.call(t,E,_s.isString(q)?q.trim():q,m,b))===!0&&g(E,m?m.concat(q):[q])}),c.pop()}}if(!_s.isObject(e))throw new TypeError("data must be an object");return g(e),t}var YDi=pWD;function XWp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function ZWp(e,t){this._pairs=[],e&&YDi(e,this,t)}var kWp=ZWp.prototype;kWp.append=function(t,r){this._pairs.push([t,r])};kWp.toString=function(t){let r=t?function(i){return t.call(this,i,XWp)}:XWp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var eHp=ZWp;function _WD(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function fGi(e,t,r){if(!t)return e;let i=r&&r.encode||_WD;_s.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=_s.isURLSearchParams(t)?t.toString():new eHp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var Ztc=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){_s.forEach(this.handlers,function(i){i!==null&&t(i)})}},ktc=Ztc;var c7n={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var nHp=ci(require("crypto"),1);var tHp=ci(require("url"),1),rHp=tHp.default.URLSearchParams;var erc="abcdefghijklmnopqrstuvwxyz",iHp="0123456789",aHp={DIGIT:iHp,ALPHA:erc,ALPHA_DIGIT:erc+erc.toUpperCase()+iHp},hWD=(e=16,t=aHp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);nHp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},oHp={isNode:!0,classes:{URLSearchParams:rHp,FormData:E2o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:aHp,generateString:hWD,protocols:["http","https","file","data"]};var irc={};jo(irc,{hasBrowserEnv:()=>rrc,hasStandardBrowserEnv:()=>yWD,hasStandardBrowserWebWorkerEnv:()=>vWD,navigator:()=>trc,origin:()=>bWD});var rrc=typeof window<"u"&&typeof document<"u",trc=typeof navigator=="object"&&navigator||void 0,yWD=rrc&&(!trc||["ReactNative","NativeScript","NS"].indexOf(trc.product)<0),vWD=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",bWD=rrc&&window.location.href||"http://localhost";var sA={...irc,...oHp};function nrc(e,t){return YDi(e,new sA.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return sA.isNode&&_s.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function gWD(e){return _s.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function OWD(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function mWD(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),d=a>=r.length;return u=!u&&_s.isArray(n)?n.length:u,d?(_s.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!_s.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&_s.isArray(n[u])&&(n[u]=OWD(n[u])),!l)}if(_s.isFormData(e)&&_s.isFunction(e.entries)){let r={};return _s.forEachEntry(e,(i,n)=>{t(gWD(i),n,r,0)}),r}return null}var M2o=mWD;function PWD(e,t,r){if(_s.isString(e))try{return(t||JSON.parse)(e),_s.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var arc={transitional:c7n,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=_s.isObject(t);if(a&&_s.isHTMLForm(t)&&(t=new FormData(t)),_s.isFormData(t))return n?JSON.stringify(M2o(t)):t;if(_s.isArrayBuffer(t)||_s.isBuffer(t)||_s.isStream(t)||_s.isFile(t)||_s.isBlob(t)||_s.isReadableStream(t))return t;if(_s.isArrayBufferView(t))return t.buffer;if(_s.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return nrc(t,this.formSerializer).toString();if((l=_s.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return YDi(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),PWD(t)):t}],transformResponse:[function(t){let r=this.transitional||arc.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(_s.isResponse(t)||_s.isReadableStream(t))return t;if(t&&_s.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?xp.from(l,xp.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:sA.classes.FormData,Blob:sA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_s.forEach(["delete","get","head","post","put","patch"],e=>{arc.headers[e]={}});var l7n=arc;var jWD=_s.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),uHp=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1708
1708
|
`).forEach(function(u){n=u.indexOf(":"),r=u.substring(0,n).trim().toLowerCase(),i=u.substring(n+1).trim(),!(!r||t[r]&&jWD[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var sHp=Symbol("internals");function VAa(e){return e&&String(e).trim().toLowerCase()}function A2o(e){return e===!1||e==null?e:_s.isArray(e)?e.map(A2o):String(e)}function wWD(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,i;for(;i=r.exec(e);)t[i[1]]=i[2];return t}var SWD=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function orc(e,t,r,i,n){if(_s.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!_s.isString(t)){if(_s.isString(i))return t.indexOf(i)!==-1;if(_s.isRegExp(i))return i.test(t)}}function DWD(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function EWD(e,t){let r=_s.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,u){return this[i].call(this,t,n,a,u)},configurable:!0})})}var f7n=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(l,d,s){let o=VAa(d);if(!o)throw new Error("header name must be a non-empty string");let c=_s.findKey(n,o);(!c||n[c]===void 0||s===!0||s===void 0&&n[c]!==!1)&&(n[c||d]=A2o(l))}let u=(l,d)=>_s.forEach(l,(s,o)=>a(s,o,d));if(_s.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(_s.isString(t)&&(t=t.trim())&&!SWD(t))u(uHp(t),r);else if(_s.isHeaders(t))for(let[l,d]of t.entries())a(d,l,i);else t!=null&&a(r,t,i);return this}get(t,r){if(t=VAa(t),t){let i=_s.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return wWD(n);if(_s.isFunction(r))return r.call(this,n,i);if(_s.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=VAa(t),t){let i=_s.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||orc(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(u){if(u=VAa(u),u){let l=_s.findKey(i,u);l&&(!r||orc(i,i[l],l,r))&&(delete i[l],n=!0)}}return _s.isArray(t)?t.forEach(a):a(t),n}clear(t){let r=Object.keys(this),i=r.length,n=!1;for(;i--;){let a=r[i];(!t||orc(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return _s.forEach(this,(n,a)=>{let u=_s.findKey(i,a);if(u){r[u]=A2o(n),delete r[a];return}let l=t?DWD(a):String(a).trim();l!==a&&delete r[a],r[l]=A2o(n),i[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return _s.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&_s.isArray(i)?i.join(", "):i)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
1709
1709
|
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let i=new this(t);return r.forEach(n=>i.set(n)),i}static accessor(t){let i=(this[sHp]=this[sHp]={accessors:{}}).accessors,n=this.prototype;function a(u){let l=VAa(u);i[l]||(EWD(n,u),i[l]=!0)}return _s.isArray(t)?t.forEach(a):a(t),this}};f7n.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);_s.reduceDescriptors(f7n.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});_s.freezeMethods(f7n);var hR=f7n;function WAa(e,t){let r=this||l7n,i=t||r,n=hR.from(i.headers),a=i.data;return _s.forEach(e,function(l){a=l.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function HAa(e){return!!(e&&e.__CANCEL__)}function cHp(e,t,r){xp.call(this,e??"canceled",xp.ERR_CANCELED,t,r),this.name="CanceledError"}_s.inherits(cHp,xp,{__CANCEL__:!0});var uMe=cHp;function Prr(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new xp("Request failed with status code "+r.status,[xp.ERR_BAD_REQUEST,xp.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function urc(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function src(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function dGi(e,t,r){let i=!urc(t);return e&&i||r==!1?src(e,t):t}var SHp=ci(SAa(),1),DHp=ci(require("http"),1),EHp=ci(require("https"),1),MHp=ci(require("util"),1),AHp=ci(htc(),1),tdi=ci(require("zlib"),1);var pGi="1.8.2";function $Aa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var MWD=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function crc(e,t,r){let i=r&&r.Blob||sA.classes.Blob,n=$Aa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=MWD.exec(e);if(!a)throw new xp("Invalid URL",xp.ERR_INVALID_URL);let u=a[1],l=a[2],d=a[3],s=Buffer.from(decodeURIComponent(d),l?"base64":"utf8");if(t){if(!i)throw new xp("Blob is not supported",xp.ERR_NOT_SUPPORT);return new i([s],{type:u})}return s}throw new xp("Unsupported protocol "+n,xp.ERR_NOT_SUPPORT)}var _Gi=ci(require("stream"),1);var lHp=ci(require("stream"),1);var lrc=Symbol("internals"),frc=class extends lHp.default.Transform{constructor(t){t=_s.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!_s.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[lrc]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",i=>{i==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[lrc];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[lrc],a=n.maxRate,u=this.readableHighWaterMark,l=n.timeWindow,d=1e3/l,s=a/d,o=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,c=(g,O)=>{let m=Buffer.byteLength(g);n.bytesSeen+=m,n.bytes+=m,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(g)?process.nextTick(O):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(O)}},b=(g,O)=>{let m=Buffer.byteLength(g),P=null,E=u,q,M=0;if(a){let D=Date.now();(!n.ts||(M=D-n.ts)>=l)&&(n.ts=D,q=s-n.bytes,n.bytes=q<0?-q:0,M=0),q=s-n.bytes}if(a){if(q<=0)return setTimeout(()=>{O(null,g)},l-M);q<E&&(E=q)}E&&m>E&&m-E>o&&(P=g.subarray(E),g=g.subarray(0,E)),c(g,P?()=>{process.nextTick(O,null,P)}:O)};b(t,function g(O,m){if(O)return i(O);m?b(m,g):i(null)})}},drc=frc;var qHp=require("events");var dHp=ci(require("util"),1),pHp=require("stream");var{asyncIterator:fHp}=Symbol,AWD=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[fHp]?yield*e[fHp]():yield e},q2o=AWD;var qWD=sA.ALPHABET.ALPHA_DIGIT+"-_",GAa=typeof TextEncoder=="function"?new TextEncoder:new dHp.default.TextEncoder,XDi=`\r
|
|
1710
1710
|
`,TWD=GAa.encode(XDi),CWD=2,prc=class{constructor(t,r){let{escapeName:i}=this.constructor,n=_s.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${XDi}`;n?r=GAa.encode(String(r).replace(/\r?\n|\r\n?/g,XDi)):a+=`Content-Type: ${r.type||"application/octet-stream"}${XDi}`,this.headers=GAa.encode(a+XDi),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+CWD,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;_s.isTypedArray(t)?yield t:yield*q2o(t),yield TWD}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},BWD=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+sA.generateString(n,qWD)}=r||{};if(!_s.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let u=GAa.encode("--"+a+XDi),l=GAa.encode("--"+a+"--"+XDi+XDi),d=l.byteLength,s=Array.from(e.entries()).map(([c,b])=>{let g=new prc(c,b);return d+=g.size,g});d+=u.byteLength*s.length,d=_s.toFiniteNumber(d);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(o["Content-Length"]=d),t&&t(o),pHp.Readable.from(async function*(){for(let c of s)yield u,yield*c.encode();yield l}())},_Hp=BWD;var hHp=ci(require("stream"),1),_rc=class extends hHp.default.Transform{__transform(t,r,i){this.push(t),i()}_transform(t,r,i){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let n=Buffer.alloc(2);n[0]=120,n[1]=156,this.push(n,r)}this.__transform(t,r,i)}},yHp=_rc;var IWD=(e,t)=>_s.isAsyncFn(e)?function(...r){let i=r.pop();e.apply(this,r).then(n=>{try{t?i(null,...t(n)):i(null,n)}catch(a){i(a)}},i)}:e,vHp=IWD;function zWD(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,u;return t=t!==void 0?t:1e3,function(d){let s=Date.now(),o=i[a];u||(u=s),r[n]=d,i[n]=s;let c=a,b=0;for(;c!==n;)b+=r[c++],c=c%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-u<t)return;let g=o&&s-o;return g?Math.round(b*1e3/g):void 0}}var bHp=zWD;function xWD(e,t){let r=0,i=1e3/t,n,a,u=(s,o=Date.now())=>{r=o,n=null,a&&(clearTimeout(a),a=null),e.apply(null,s)};return[(...s)=>{let o=Date.now(),c=o-r;c>=i?u(s,o):(n=s,a||(a=setTimeout(()=>{a=null,u(n)},i-c)))},()=>n&&u(n)]}var gHp=xWD;var edi=(e,t,r=3)=>{let i=0,n=bHp(50,250);return gHp(a=>{let u=a.loaded,l=a.lengthComputable?a.total:void 0,d=u-i,s=n(d),o=u<=l;i=u;let c={loaded:u,total:l,progress:l?u/l:void 0,bytes:d,rate:s||void 0,estimated:s&&l&&o?(l-u)/s:void 0,event:a,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(c)},r)},d7n=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},p7n=e=>(...t)=>_s.asap(()=>e(...t));var OHp={flush:tdi.default.constants.Z_SYNC_FLUSH,finishFlush:tdi.default.constants.Z_SYNC_FLUSH},RWD={flush:tdi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:tdi.default.constants.BROTLI_OPERATION_FLUSH},mHp=_s.isFunction(tdi.default.createBrotliDecompress),{http:NWD,https:FWD}=AHp.default,LWD=/https:?/,PHp=sA.protocols.map(e=>e+":"),jHp=(e,[t,r])=>(e.on("end",r).on("error",r),t);function UWD(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function THp(e,t,r){let i=t;if(!i&&i!==!1){let n=SHp.default.getProxyForUrl(r);n&&(i=new URL(n))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let a=Buffer.from(i.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let n=i.hostname||i.host;e.hostname=n,e.host=n,e.port=i.port,e.path=r,i.protocol&&(e.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}e.beforeRedirects.proxy=function(a){THp(a,t,a.href)}}var VWD=typeof process<"u"&&_s.kindOf(process)==="process",WWD=e=>new Promise((t,r)=>{let i,n,a=(d,s)=>{n||(n=!0,i&&i(d,s))},u=d=>{a(d),t(d)},l=d=>{a(d,!0),r(d)};e(u,l,d=>i=d).catch(l)}),HWD=({address:e,family:t})=>{if(!_s.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},wHp=(e,t)=>HWD(_s.isObject(e)?e:{address:e,family:t}),CHp=VWD&&function(t){return WWD(async function(i,n,a){let{data:u,lookup:l,family:d}=t,{responseType:s,responseEncoding:o}=t,c=t.method.toUpperCase(),b,g=!1,O;if(l){let Se=vHp(l,Qe=>_s.isArray(Qe)?Qe:[Qe]);l=(Qe,Dt,Ee)=>{Se(Qe,Dt,(Te,zt,Pe)=>{if(Te)return Ee(Te);let at=_s.isArray(zt)?zt.map(it=>wHp(it)):[wHp(zt,Pe)];Dt.all?Ee(Te,at):Ee(Te,at[0].address,at[0].family)})}}let m=new qHp.EventEmitter,P=()=>{t.cancelToken&&t.cancelToken.unsubscribe(E),t.signal&&t.signal.removeEventListener("abort",E),m.removeAllListeners()};a((Se,Qe)=>{b=!0,Qe&&(g=!0,P())});function E(Se){m.emit("abort",!Se||Se.type?new uMe(null,t,O):Se)}m.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(E),t.signal&&(t.signal.aborted?E():t.signal.addEventListener("abort",E)));let q=dGi(t.baseURL,t.url,t.allowAbsoluteUrls),M=new URL(q,sA.hasBrowserEnv?sA.origin:void 0),D=M.protocol||PHp[0];if(D==="data:"){let Se;if(c!=="GET")return Prr(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{Se=crc(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(Qe){throw xp.from(Qe,xp.ERR_BAD_REQUEST,t)}return s==="text"?(Se=Se.toString(o),(!o||o==="utf8")&&(Se=_s.stripBOM(Se))):s==="stream"&&(Se=_Gi.default.Readable.from(Se)),Prr(i,n,{data:Se,status:200,statusText:"OK",headers:new hR,config:t})}if(PHp.indexOf(D)===-1)return n(new xp("Unsupported protocol "+D,xp.ERR_BAD_REQUEST,t));let C=hR.from(t.headers).normalize();C.set("User-Agent","axios/"+pGi,!1);let{onUploadProgress:x,onDownloadProgress:$}=t,I=t.maxRate,L,V;if(_s.isSpecCompliantForm(u)){let Se=C.getContentType(/boundary=([-_\w\d]{10,70})/i);u=_Hp(u,Qe=>{C.set(Qe)},{tag:`axios-${pGi}-boundary`,boundary:Se&&Se[1]||void 0})}else if(_s.isFormData(u)&&_s.isFunction(u.getHeaders)){if(C.set(u.getHeaders()),!C.hasContentLength())try{let Se=await MHp.default.promisify(u.getLength).call(u);Number.isFinite(Se)&&Se>=0&&C.setContentLength(Se)}catch{}}else if(_s.isBlob(u)||_s.isFile(u))u.size&&C.setContentType(u.type||"application/octet-stream"),C.setContentLength(u.size||0),u=_Gi.default.Readable.from(q2o(u));else if(u&&!_s.isStream(u)){if(!Buffer.isBuffer(u))if(_s.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(_s.isString(u))u=Buffer.from(u,"utf-8");else return n(new xp("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",xp.ERR_BAD_REQUEST,t));if(C.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return n(new xp("Request body larger than maxBodyLength limit",xp.ERR_BAD_REQUEST,t))}let X=_s.toFiniteNumber(C.getContentLength());_s.isArray(I)?(L=I[0],V=I[1]):L=V=I,u&&(x||L)&&(_s.isStream(u)||(u=_Gi.default.Readable.from(u,{objectMode:!1})),u=_Gi.default.pipeline([u,new drc({maxRate:_s.toFiniteNumber(L)})],_s.noop),x&&u.on("progress",jHp(u,d7n(X,edi(p7n(x),!1,3)))));let K;if(t.auth){let Se=t.auth.username||"",Qe=t.auth.password||"";K=Se+":"+Qe}if(!K&&M.username){let Se=M.username,Qe=M.password;K=Se+":"+Qe}K&&C.delete("authorization");let Z;try{Z=fGi(M.pathname+M.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Se){let Qe=new Error(Se.message);return Qe.config=t,Qe.url=t.url,Qe.exists=!0,n(Qe)}C.set("Accept-Encoding","gzip, compress, deflate"+(mHp?", br":""),!1);let fe={path:Z,method:c,headers:C.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:K,protocol:D,family:d,beforeRedirect:UWD,beforeRedirects:{}};!_s.isUndefined(l)&&(fe.lookup=l),t.socketPath?fe.socketPath=t.socketPath:(fe.hostname=M.hostname.startsWith("[")?M.hostname.slice(1,-1):M.hostname,fe.port=M.port,THp(fe,t.proxy,D+"//"+M.hostname+(M.port?":"+M.port:"")+fe.path));let me,_e=LWD.test(fe.protocol);if(fe.agent=_e?t.httpsAgent:t.httpAgent,t.transport?me=t.transport:t.maxRedirects===0?me=_e?EHp.default:DHp.default:(t.maxRedirects&&(fe.maxRedirects=t.maxRedirects),t.beforeRedirect&&(fe.beforeRedirects.config=t.beforeRedirect),me=_e?FWD:NWD),t.maxBodyLength>-1?fe.maxBodyLength=t.maxBodyLength:fe.maxBodyLength=1/0,t.insecureHTTPParser&&(fe.insecureHTTPParser=t.insecureHTTPParser),O=me.request(fe,function(Qe){if(O.destroyed)return;let Dt=[Qe],Ee=+Qe.headers["content-length"];if($||V){let it=new drc({maxRate:_s.toFiniteNumber(V)});$&&it.on("progress",jHp(it,d7n(Ee,edi(p7n($),!0,3)))),Dt.push(it)}let Te=Qe,zt=Qe.req||O;if(t.decompress!==!1&&Qe.headers["content-encoding"])switch((c==="HEAD"||Qe.statusCode===204)&&delete Qe.headers["content-encoding"],(Qe.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":Dt.push(tdi.default.createUnzip(OHp)),delete Qe.headers["content-encoding"];break;case"deflate":Dt.push(new yHp),Dt.push(tdi.default.createUnzip(OHp)),delete Qe.headers["content-encoding"];break;case"br":mHp&&(Dt.push(tdi.default.createBrotliDecompress(RWD)),delete Qe.headers["content-encoding"])}Te=Dt.length>1?_Gi.default.pipeline(Dt,_s.noop):Dt[0];let Pe=_Gi.default.finished(Te,()=>{Pe(),P()}),at={status:Qe.statusCode,statusText:Qe.statusMessage,headers:new hR(Qe.headers),config:t,request:zt};if(s==="stream")at.data=Te,Prr(i,n,at);else{let it=[],be=0;Te.on("data",function(bt){it.push(bt),be+=bt.length,t.maxContentLength>-1&&be>t.maxContentLength&&(g=!0,Te.destroy(),n(new xp("maxContentLength size of "+t.maxContentLength+" exceeded",xp.ERR_BAD_RESPONSE,t,zt)))}),Te.on("aborted",function(){if(g)return;let bt=new xp("stream has been aborted",xp.ERR_BAD_RESPONSE,t,zt);Te.destroy(bt),n(bt)}),Te.on("error",function(bt){O.destroyed||n(xp.from(bt,null,t,zt))}),Te.on("end",function(){try{let bt=it.length===1?it[0]:Buffer.concat(it);s!=="arraybuffer"&&(bt=bt.toString(o),(!o||o==="utf8")&&(bt=_s.stripBOM(bt))),at.data=bt}catch(bt){return n(xp.from(bt,null,t,at.request,at))}Prr(i,n,at)})}m.once("abort",it=>{Te.destroyed||(Te.emit("error",it),Te.destroy())})}),m.once("abort",Se=>{n(Se),O.destroy(Se)}),O.on("error",function(Qe){n(xp.from(Qe,null,t,O))}),O.on("socket",function(Qe){Qe.setKeepAlive(!0,1e3*60)}),t.timeout){let Se=parseInt(t.timeout,10);if(Number.isNaN(Se)){n(new xp("error trying to parse `config.timeout` to int",xp.ERR_BAD_OPTION_VALUE,t,O));return}O.setTimeout(Se,function(){if(b)return;let Dt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",Ee=t.transitional||c7n;t.timeoutErrorMessage&&(Dt=t.timeoutErrorMessage),n(new xp(Dt,Ee.clarifyTimeoutError?xp.ETIMEDOUT:xp.ECONNABORTED,t,O)),E()})}if(_s.isStream(u)){let Se=!1,Qe=!1;u.on("end",()=>{Se=!0}),u.once("error",Dt=>{Qe=!0,O.destroy(Dt)}),u.on("close",()=>{!Se&&!Qe&&E(new uMe("Request stream has been aborted",t,O))}),u.pipe(O)}else O.end(u)})};var BHp=sA.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,sA.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(sA.origin),sA.navigator&&/(msie|trident)/i.test(sA.navigator.userAgent)):()=>!0;var IHp=sA.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let u=[e+"="+encodeURIComponent(t)];_s.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),_s.isString(i)&&u.push("path="+i),_s.isString(n)&&u.push("domain="+n),a===!0&&u.push("secure"),document.cookie=u.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var zHp=e=>e instanceof hR?{...e}:e;function TWt(e,t){t=t||{};let r={};function i(s,o,c,b){return _s.isPlainObject(s)&&_s.isPlainObject(o)?_s.merge.call({caseless:b},s,o):_s.isPlainObject(o)?_s.merge({},o):_s.isArray(o)?o.slice():o}function n(s,o,c,b){if(_s.isUndefined(o)){if(!_s.isUndefined(s))return i(void 0,s,c,b)}else return i(s,o,c,b)}function a(s,o){if(!_s.isUndefined(o))return i(void 0,o)}function u(s,o){if(_s.isUndefined(o)){if(!_s.isUndefined(s))return i(void 0,s)}else return i(void 0,o)}function l(s,o,c){if(c in t)return i(s,o);if(c in e)return i(void 0,s)}let d={url:a,method:a,data:a,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:l,headers:(s,o,c)=>n(zHp(s),zHp(o),c,!0)};return _s.forEach(Object.keys(Object.assign({},e,t)),function(o){let c=d[o]||n,b=c(e[o],t[o],o);_s.isUndefined(b)&&c!==l||(r[o]=b)}),r}var T2o=e=>{let t=TWt({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:u,auth:l}=t;t.headers=u=hR.from(u),t.url=fGi(dGi(t.baseURL,t.url),e.params,e.paramsSerializer),l&&u.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let d;if(_s.isFormData(r)){if(sA.hasStandardBrowserEnv||sA.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((d=u.getContentType())!==!1){let[s,...o]=d?d.split(";").map(c=>c.trim()).filter(Boolean):[];u.setContentType([s||"multipart/form-data",...o].join("; "))}}if(sA.hasStandardBrowserEnv&&(i&&_s.isFunction(i)&&(i=i(t)),i||i!==!1&&BHp(t.url))){let s=n&&a&&IHp.read(a);s&&u.set(n,s)}return t};var $WD=typeof XMLHttpRequest<"u",xHp=$WD&&function(e){return new Promise(function(r,i){let n=T2o(e),a=n.data,u=hR.from(n.headers).normalize(),{responseType:l,onUploadProgress:d,onDownloadProgress:s}=n,o,c,b,g,O;function m(){g&&g(),O&&O(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let P=new XMLHttpRequest;P.open(n.method.toUpperCase(),n.url,!0),P.timeout=n.timeout;function E(){if(!P)return;let M=hR.from("getAllResponseHeaders"in P&&P.getAllResponseHeaders()),C={data:!l||l==="text"||l==="json"?P.responseText:P.response,status:P.status,statusText:P.statusText,headers:M,config:e,request:P};Prr(function($){r($),m()},function($){i($),m()},C),P=null}"onloadend"in P?P.onloadend=E:P.onreadystatechange=function(){!P||P.readyState!==4||P.status===0&&!(P.responseURL&&P.responseURL.indexOf("file:")===0)||setTimeout(E)},P.onabort=function(){P&&(i(new xp("Request aborted",xp.ECONNABORTED,e,P)),P=null)},P.onerror=function(){i(new xp("Network Error",xp.ERR_NETWORK,e,P)),P=null},P.ontimeout=function(){let D=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",C=n.transitional||c7n;n.timeoutErrorMessage&&(D=n.timeoutErrorMessage),i(new xp(D,C.clarifyTimeoutError?xp.ETIMEDOUT:xp.ECONNABORTED,e,P)),P=null},a===void 0&&u.setContentType(null),"setRequestHeader"in P&&_s.forEach(u.toJSON(),function(D,C){P.setRequestHeader(C,D)}),_s.isUndefined(n.withCredentials)||(P.withCredentials=!!n.withCredentials),l&&l!=="json"&&(P.responseType=n.responseType),s&&([b,O]=edi(s,!0),P.addEventListener("progress",b)),d&&P.upload&&([c,g]=edi(d),P.upload.addEventListener("progress",c),P.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(o=M=>{P&&(i(!M||M.type?new uMe(null,e,P):M),P.abort(),P=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));let q=$Aa(n.url);if(q&&sA.protocols.indexOf(q)===-1){i(new xp("Unsupported protocol "+q+":",xp.ERR_BAD_REQUEST,e));return}P.send(a||null)})};var GWD=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let i=new AbortController,n,a=function(s){if(!n){n=!0,l();let o=s instanceof Error?s:this.reason;i.abort(o instanceof xp?o:new uMe(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new xp(`timeout ${t} of ms exceeded`,xp.ETIMEDOUT))},t),l=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:d}=i;return d.unsubscribe=()=>_s.asap(l),d}},RHp=GWD;var QWD=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let i=0,n;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},JWD=async function*(e,t){for await(let r of KWD(e))yield*QWD(r,t)},KWD=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:i}=await t.read();if(r)break;yield i}}finally{await t.cancel()}},hrc=(e,t,r,i)=>{let n=JWD(e,t),a=0,u,l=d=>{u||(u=!0,i&&i(d))};return new ReadableStream({async pull(d){try{let{done:s,value:o}=await n.next();if(s){l(),d.close();return}let c=o.byteLength;if(r){let b=a+=c;r(b)}d.enqueue(new Uint8Array(o))}catch(s){throw l(s),s}},cancel(d){return l(d),n.return()}},{highWaterMark:2})};var B2o=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",FHp=B2o&&typeof ReadableStream=="function",YWD=B2o&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),LHp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},XWD=FHp&&LHp(()=>{let e=!1,t=new Request(sA.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),NHp=64*1024,yrc=FHp&&LHp(()=>_s.isReadableStream(new Response("").body)),C2o={stream:yrc&&(e=>e.body)};B2o&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!C2o[t]&&(C2o[t]=_s.isFunction(e[t])?r=>r[t]():(r,i)=>{throw new xp(`Response type '${t}' is not supported`,xp.ERR_NOT_SUPPORT,i)})})})(new Response);var ZWD=async e=>{if(e==null)return 0;if(_s.isBlob(e))return e.size;if(_s.isSpecCompliantForm(e))return(await new Request(sA.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(_s.isArrayBufferView(e)||_s.isArrayBuffer(e))return e.byteLength;if(_s.isURLSearchParams(e)&&(e=e+""),_s.isString(e))return(await YWD(e)).byteLength},kWD=async(e,t)=>{let r=_s.toFiniteNumber(e.getContentLength());return r??ZWD(t)},UHp=B2o&&(async e=>{let{url:t,method:r,data:i,signal:n,cancelToken:a,timeout:u,onDownloadProgress:l,onUploadProgress:d,responseType:s,headers:o,withCredentials:c="same-origin",fetchOptions:b}=T2o(e);s=s?(s+"").toLowerCase():"text";let g=RHp([n,a&&a.toAbortSignal()],u),O,m=g&&g.unsubscribe&&(()=>{g.unsubscribe()}),P;try{if(d&&XWD&&r!=="get"&&r!=="head"&&(P=await kWD(o,i))!==0){let C=new Request(t,{method:"POST",body:i,duplex:"half"}),x;if(_s.isFormData(i)&&(x=C.headers.get("content-type"))&&o.setContentType(x),C.body){let[$,I]=d7n(P,edi(p7n(d)));i=hrc(C.body,NHp,$,I)}}_s.isString(c)||(c=c?"include":"omit");let E="credentials"in Request.prototype;O=new Request(t,{...b,signal:g,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:i,duplex:"half",credentials:E?c:void 0});let q=await fetch(O),M=yrc&&(s==="stream"||s==="response");if(yrc&&(l||M&&m)){let C={};["status","statusText","headers"].forEach(L=>{C[L]=q[L]});let x=_s.toFiniteNumber(q.headers.get("content-length")),[$,I]=l&&d7n(x,edi(p7n(l),!0))||[];q=new Response(hrc(q.body,NHp,$,()=>{I&&I(),m&&m()}),C)}s=s||"text";let D=await C2o[_s.findKey(C2o,s)||"text"](q,e);return!M&&m&&m(),await new Promise((C,x)=>{Prr(C,x,{data:D,headers:hR.from(q.headers),status:q.status,statusText:q.statusText,config:e,request:O})})}catch(E){throw m&&m(),E&&E.name==="TypeError"&&/fetch/i.test(E.message)?Object.assign(new xp("Network Error",xp.ERR_NETWORK,e,O),{cause:E.cause||E}):xp.from(E,E&&E.code,e,O)}});var vrc={http:CHp,xhr:xHp,fetch:UHp};_s.forEach(vrc,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var VHp=e=>`- ${e}`,eHD=e=>_s.isFunction(e)||e===null||e===!1,I2o={getAdapter:e=>{e=_s.isArray(e)?e:[e];let{length:t}=e,r,i,n={};for(let a=0;a<t;a++){r=e[a];let u;if(i=r,!eHD(r)&&(i=vrc[(u=String(r)).toLowerCase()],i===void 0))throw new xp(`Unknown adapter '${u}'`);if(i)break;n[u||"#"+a]=i}if(!i){let a=Object.entries(n).map(([l,d])=>`adapter ${l} `+(d===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
|
|
@@ -1943,11 +1943,11 @@ ${M}${q}${D}${Rd_.default.cursorHide}`});var jIa=ci(C1i(),1);function opc(e,t){i
|
|
|
1943
1943
|
Run ${Gs.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1944
1944
|
Run ${Gs.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),h7n(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function vpc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!up_(e))return;let n=t??"",a=e.filter(l=>l.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((l,d)=>l.generatorName.localeCompare(d.generatorName)||l.currentVersion.localeCompare(d.currentVersion));for(let l of u)n+=`
|
|
1945
1945
|
${await WgE(l.generatorName)} (${l.apiName!=null?"API: "+l.apiName+", ":""}Group: ${l.generatorGroup}) `+Gs.dim(l.currentVersion)+Gs.reset(" \u2192 ")+Gs.green(l.latestVersion);return n+=`
|
|
1946
|
-
`,i?h7n(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function WgE(e){let r=await new op_.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 HgE({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await cp_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=T1i(o.name,c),g=await Akt({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:c});g!=null&&(l.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),l}let u={type:"multiApi",versions:{}};return await cp_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,d,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][d]==null&&(u.versions[l][d]={});let c=T1i(s.name,o),b=await Akt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function cp_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let l=await kVt({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let d of l.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function lp_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let d=$ae(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function zHo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await HgE({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[d,s]of Object.entries(l.versions))u.push(...lp_(s,d,t.logger));else u.push(...lp_(l.versions,void 0,t.logger))}return u}var TIa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),l=u?`status code ${u}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var J2n=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var K2n=e=>e!==null&&typeof e=="object";var CIa=(...e)=>{for(let t of e)if((!K2n(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Opc({},...e)},bpc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function xHo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Opc(e[r]??[],t[r]??[])}var gpc=(e={},t={})=>({beforeRequest:xHo(e,t,"beforeRequest"),beforeRetry:xHo(e,t,"beforeRetry"),afterResponse:xHo(e,t,"afterResponse"),beforeError:xHo(e,t,"beforeError")}),Opc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(K2n(n)){for(let[a,u]of Object.entries(n))K2n(u)&&a in t&&(u=Opc(t[a],u)),t={...t,[a]:u};K2n(n.hooks)&&(i=gpc(i,n.hooks),t.hooks=i),K2n(n.headers)&&(r=bpc(r,n.headers),t.headers=r)}return t};var fp_=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),dp_=typeof globalThis.AbortController=="function",pp_=typeof globalThis.ReadableStream=="function",_p_=typeof globalThis.FormData=="function",RHo=["get","post","put","patch","head","delete"],$gE=()=>{};$gE();var hp_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},NHo=2147483647,FHo=Symbol("stop"),yp_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},vp_={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var gp_=e=>RHo.includes(e)?e.toUpperCase():e,GgE=["get","put","head","delete","options","trace"],QgE=[408,413,429,500,502,503,504],JgE=[413,429,503],bp_={limit:2,methods:GgE,statusCodes:QgE,afterStatusCodes:JgE,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Op_=(e={})=>{if(typeof e=="number")return{...bp_,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{...bp_,...e}};async function mpc(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new J2n(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function Ppc(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var mp_=(e,t)=>{let r={};for(let i in t)!(i in vp_)&&!(i in yp_)&&!(i in e)&&(r[i]=t[i]);return r};var BIa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>NHo)throw new RangeError(`The \`timeout\` option cannot be greater than ${NHo}`);await Promise.resolve();let l=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let d=new TIa(l,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!pp_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return i._stream(l.clone(),i._options.onDownloadProgress)}return l},u=i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n();for(let[l,d]of Object.entries(hp_))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let o=(await u).clone();if(l==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:bpc(this._input.headers,r.headers),hooks:gpc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:gp_(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:Op_(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(dp_){this.abortController=new globalThis.AbortController;let i=this._options.signal??this._input.signal;i?.addEventListener("abort",()=>{this.abortController.abort(i.reason)}),this._options.signal=this.abortController.signal}if(fp_&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(_p_&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof J2n)throw t;if(t instanceof TIa){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),NHo);if(this._retryCount<1)throw r;await Ppc(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===FHo)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=mp_(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):mpc(r,t,this.abortController,this._options)}_stream(t,r){let i=Number(t.headers.get("content-length"))||0,n=0;return t.status===204?(r&&r({percent:1,totalBytes:i,transferredBytes:n},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:i},new Uint8Array);async function l(){let{done:d,value:s}=await u.read();if(d){a.close();return}if(r){n+=s.byteLength;let o=i===0?0:n/i;r({percent:o,transferredBytes:n,totalBytes:i},s)}a.enqueue(s),await l()}await l()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var jpc=e=>{let t=(r,i)=>BIa.create(r,CIa(e,i));for(let r of RHo)t[r]=(i,n)=>BIa.create(i,CIa(e,n,{method:r}));return t.create=r=>jpc(CIa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),jpc(CIa(e,r))),t.stop=FHo,t},KgE=jpc(),Pp_=KgE;var $p_=ci(Hp_(),1);function Mpc(e){let t=(0,$p_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var F__=ci(N__(),1),L__=ci(C1i(),1),Vpc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Wpc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function Hpc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Mpc(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,F__.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,l&&(d.authorization=`${l.type} ${l.token}`);let s;try{s=await Pp_(u,{headers:d,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new Vpc(e):c}if(t.allVersions)return s;let o=new Wpc(e,r);if(s["dist-tags"][r]){let{time:c}=s;s=s.versions[s["dist-tags"][r]],s.time=c}else if(r){let c=!!s.versions[r];if(i&&!c)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!c){let g=Object.keys(s.versions);if(r=L__.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function FIa(e,t){let{version:r}=await Hpc(e.toLowerCase(),t);return r}async function mMi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:FIa(e.packageName,{version:t?"prerelease":"latest"})}var U__=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],XHo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Pb.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new IHo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),u=this.getCliName();(n==null||a==null||u==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:u}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.63.10"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Gs.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new w9}failWithoutThrowing(t,r){this.didSucceed=!1,qHo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await o7n()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await sp_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1946
|
+
`,i?h7n(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function WgE(e){let r=await new op_.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 HgE({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await cp_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=T1i(o.name,c),g=await Akt({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:c});g!=null&&(l.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),l}let u={type:"multiApi",versions:{}};return await cp_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,d,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][d]==null&&(u.versions[l][d]={});let c=T1i(s.name,o),b=await Akt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function cp_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let l=await kVt({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let d of l.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function lp_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let d=$ae(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function zHo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await HgE({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[d,s]of Object.entries(l.versions))u.push(...lp_(s,d,t.logger));else u.push(...lp_(l.versions,void 0,t.logger))}return u}var TIa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),l=u?`status code ${u}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var J2n=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var K2n=e=>e!==null&&typeof e=="object";var CIa=(...e)=>{for(let t of e)if((!K2n(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Opc({},...e)},bpc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function xHo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Opc(e[r]??[],t[r]??[])}var gpc=(e={},t={})=>({beforeRequest:xHo(e,t,"beforeRequest"),beforeRetry:xHo(e,t,"beforeRetry"),afterResponse:xHo(e,t,"afterResponse"),beforeError:xHo(e,t,"beforeError")}),Opc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(K2n(n)){for(let[a,u]of Object.entries(n))K2n(u)&&a in t&&(u=Opc(t[a],u)),t={...t,[a]:u};K2n(n.hooks)&&(i=gpc(i,n.hooks),t.hooks=i),K2n(n.headers)&&(r=bpc(r,n.headers),t.headers=r)}return t};var fp_=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),dp_=typeof globalThis.AbortController=="function",pp_=typeof globalThis.ReadableStream=="function",_p_=typeof globalThis.FormData=="function",RHo=["get","post","put","patch","head","delete"],$gE=()=>{};$gE();var hp_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},NHo=2147483647,FHo=Symbol("stop"),yp_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},vp_={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var gp_=e=>RHo.includes(e)?e.toUpperCase():e,GgE=["get","put","head","delete","options","trace"],QgE=[408,413,429,500,502,503,504],JgE=[413,429,503],bp_={limit:2,methods:GgE,statusCodes:QgE,afterStatusCodes:JgE,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Op_=(e={})=>{if(typeof e=="number")return{...bp_,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{...bp_,...e}};async function mpc(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new J2n(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function Ppc(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var mp_=(e,t)=>{let r={};for(let i in t)!(i in vp_)&&!(i in yp_)&&!(i in e)&&(r[i]=t[i]);return r};var BIa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>NHo)throw new RangeError(`The \`timeout\` option cannot be greater than ${NHo}`);await Promise.resolve();let l=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let d=new TIa(l,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!pp_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return i._stream(l.clone(),i._options.onDownloadProgress)}return l},u=i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n();for(let[l,d]of Object.entries(hp_))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let o=(await u).clone();if(l==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:bpc(this._input.headers,r.headers),hooks:gpc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:gp_(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:Op_(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(dp_){this.abortController=new globalThis.AbortController;let i=this._options.signal??this._input.signal;i?.addEventListener("abort",()=>{this.abortController.abort(i.reason)}),this._options.signal=this.abortController.signal}if(fp_&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(_p_&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof J2n)throw t;if(t instanceof TIa){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),NHo);if(this._retryCount<1)throw r;await Ppc(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===FHo)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=mp_(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):mpc(r,t,this.abortController,this._options)}_stream(t,r){let i=Number(t.headers.get("content-length"))||0,n=0;return t.status===204?(r&&r({percent:1,totalBytes:i,transferredBytes:n},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:i},new Uint8Array);async function l(){let{done:d,value:s}=await u.read();if(d){a.close();return}if(r){n+=s.byteLength;let o=i===0?0:n/i;r({percent:o,transferredBytes:n,totalBytes:i},s)}a.enqueue(s),await l()}await l()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var jpc=e=>{let t=(r,i)=>BIa.create(r,CIa(e,i));for(let r of RHo)t[r]=(i,n)=>BIa.create(i,CIa(e,n,{method:r}));return t.create=r=>jpc(CIa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),jpc(CIa(e,r))),t.stop=FHo,t},KgE=jpc(),Pp_=KgE;var $p_=ci(Hp_(),1);function Mpc(e){let t=(0,$p_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var F__=ci(N__(),1),L__=ci(C1i(),1),Vpc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Wpc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function Hpc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Mpc(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,F__.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,l&&(d.authorization=`${l.type} ${l.token}`);let s;try{s=await Pp_(u,{headers:d,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new Vpc(e):c}if(t.allVersions)return s;let o=new Wpc(e,r);if(s["dist-tags"][r]){let{time:c}=s;s=s.versions[s["dist-tags"][r]],s.time=c}else if(r){let c=!!s.versions[r];if(i&&!c)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!c){let g=Object.keys(s.versions);if(r=L__.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function FIa(e,t){let{version:r}=await Hpc(e.toLowerCase(),t);return r}async function mMi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:FIa(e.packageName,{version:t?"prerelease":"latest"})}var U__=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],XHo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Pb.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new IHo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),u=this.getCliName();(n==null||a==null||u==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:u}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.63.12"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Gs.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new w9}failWithoutThrowing(t,r){this.didSucceed=!1,qHo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await o7n()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await sp_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1947
1947
|
`)||(r+=`
|
|
1948
1948
|
`),this.stderr.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram({code:t}={}){process.exit(t??(this.didSucceed?0:1))}longestWorkspaceName;registerWorkspaces(t){let r=b3s(t.map(i=>i.type==="docs"?"docs":i.workspaceName??"api"),i=>i.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new wIa(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let i=this.addTaskWithInit(t).start(),n;try{n=await r(i)}catch(a){throw a.message.includes("globalThis")?(i.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),i.failWithoutThrowing()):i.failWithoutThrowing(void 0,a),new w9}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await o7n()).sendEvent(t)}logger=GXt((t,...r)=>this.log(t,...r));stderr=GXt((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=V__(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?V__(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=U__[this.numTasks++%U__.length],u=Gs.hex(a)(n);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===AB.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}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let i=t.filter(n=>Jwi.indexOf(n.level)>=Jwi.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===Pb.Debug,stderr:r})}_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 mMi({cliEnvironment:this.environment,includePreReleases:t}),i=$ae(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await zHo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await epc({message:t,default:r})}async getInput(t){return await tpc({message:t.message,default:t.default})}};function V__(e){return`[${e}]:`}var MI_=require("fs/promises");function vFe({breadcrumbs:e=[],title:t,subtitle:r}){let i=[];return e.length>0&&i.push(Gs.blue(e.join(" -> "))),i.push(t),r!=null&&i.push(Gs.dim(r)),i.join(`
|
|
1949
1949
|
`)}var bM_=require("fs/promises");var sHt=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};var DMe=class extends sHt{definition;sources;type="fern";constructor({definition:t,sources:r,...i}){super(i),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var LIa=class{context;constructor(t){this.context=t}};var ZHo=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[u,l]of Object.entries(i.files)){let d=n!=null?yy.of(`${n}${bVt}${u}`):yy.of(u);t[d]=l}let a=Object.keys(i.directories).sort();for(let u of a){let l=n!=null?`${n}${bVt}${u}`:u,d=i.directories[u];r(d,l)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(bVt))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[yy.of(t[0])]??={};let[r,...i]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(i)}};var vJi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new ZHo,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":i,"display-name":n,docs:a}){let u=this.getOrCreateFile(t);u.service==null&&(u.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(u.service.auth=r),i!=null&&(u.service["base-path"]=i),n!=null&&(u.service["display-name"]=n),a!=null&&(u.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return $kt(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let i of Object.values(this.rootApiFile["auth-schemes"]))W__(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(W__(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??T_((zxe(r)+"/"+uWi(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===yy.of(i3))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=zjo(zxe(yzn.of(`/${t}`)),yzn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=zjo(zxe(yzn.of(`/${t}`)),yzn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===yy.of(i3))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(l=>OEe(l,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=WN(n,r.path))}addChannelExample(t,{example:r}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.examples==null&&(i.channel.examples=[]),i.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:i}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.messages[r]=i}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([n,a])=>[n,{...a,path:WN(r,a.path)}]))});for(let n of Object.values(t))n.service!=null&&(n.service={...n.service,endpoints:Object.fromEntries(Object.entries(n.service.endpoints).map(([a,u])=>[a,{...u,path:WN(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===zS?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 W__(e){return e?.header!=null}var Gae={openapi:e=>({...e,type:"openapi",_visit:function(t){return Gae._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return Gae._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 r8n={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return r8n._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var nL={basic:e=>({...e,type:"basic",_visit:function(t){return nL._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return nL._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return nL._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return nL._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return nL._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 vO={primitive:e=>({value:e,type:"primitive",_visit:function(t){return vO._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return vO._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return vO._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return vO._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return vO._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return vO._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return vO._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return vO._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 w_={int:e=>({value:e,type:"int",_visit:function(t){return w_._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return w_._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return w_._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return w_._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return w_._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return w_._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return w_._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return w_._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return w_._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return w_._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return w_._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 i8n={boolean:e=>({value:e,type:"boolean",_visit:function(t){return i8n._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return i8n._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 PMi={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return PMi._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return PMi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undiscriminated":return t.undiscriminated(e.value);default:return t._other(e)}}};var eH={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case eH.GenerallyAvailable:return t.generallyAvailable();case eH.Beta:return t.beta();case eH.Deprecated:return t.deprecated();default:return t._other()}}};var bFe={cursor:e=>({...e,type:"cursor",_visit:function(t){return bFe._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return bFe._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return bFe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var Hdi={language:e=>({...e,type:"language",_visit:function(t){return Hdi._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return Hdi._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 tH={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 tH.Curl:return t.curl();case tH.Python:return t.python();case tH.Javascript:return t.javascript();case tH.Typescript:return t.typescript();case tH.Go:return t.go();case tH.Ruby:return t.ruby();case tH.Csharp:return t.csharp();case tH.Java:return t.java();case tH.Js:return t.js();case tH.Node:return t.node();case tH.Ts:return t.ts();case tH.Nodets:return t.nodets();case tH.Golang:return t.golang();case tH.Dotnet:return t.dotnet();case tH.Jvm:return t.jvm();default:return t._other()}}};var cHt={unknown:e=>({value:e,type:"unknown",_visit:function(t){return cHt._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return cHt._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 lHt={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return lHt._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return lHt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var rH={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case rH.Get:return t.get();case rH.Post:return t.post();case rH.Put:return t.put();case rH.Patch:return t.patch();case rH.Delete:return t.delete();case rH.Head:return t.head();case rH.Options:return t.options();case rH.Trace:return t.trace();default:return t._other()}}};var jMi={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return jMi._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return jMi._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return jMi._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 $di={file:e=>({...e,type:"file",_visit:function(t){return $di._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return $di._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 lJ={file:e=>({...e,type:"file",_visit:function(t){return lJ._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return lJ._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return lJ._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return lJ._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return lJ._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return lJ._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return lJ._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"bytes":return t.bytes(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 Fy={primitive:e=>({...e,type:"primitive",_visit:function(t){return Fy._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Fy._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Fy._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Fy._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Fy._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Fy._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Fy._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Fy._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Fy._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Fy._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Fy._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 Xj={int:e=>({...e,type:"int",_visit:function(t){return Xj._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Xj._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Xj._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Xj._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Xj._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Xj._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Xj._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Xj._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Xj._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Xj._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Xj._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 vz={boolean:e=>({value:e,type:"boolean",_visit:function(t){return vz._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return vz._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 Gdi={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return Gdi._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return Gdi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var EMe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return EMe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return EMe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return EMe._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 vC={file:e=>({...e,type:"file",_visit:function(t){return vC._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return vC._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return vC._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return vC._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return vC._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return vC._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return vC._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"bytes":return t.bytes(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 zl={primitive:e=>({...e,type:"primitive",_visit:function(t){return zl._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return zl._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return zl._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return zl._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return zl._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return zl._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return zl._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return zl._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return zl._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return zl._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return zl._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 ik={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return ik._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return ik._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var up={int:e=>({...e,type:"int",_visit:function(t){return up._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return up._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return up._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return up._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return up._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return up._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return up._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return up._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return up._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return up._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return up._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 Ev={};jo(Ev,{AllOfPropertyConflict:()=>D8n,ArraySchema:()=>_Go,ArraySchemaWithExample:()=>VGo,Availability:()=>s$o,Base64WithExample:()=>RGo,BasicSecurityScheme:()=>f$o,BearerSecurityScheme:()=>d$o,BooleanSchema:()=>sGo,BooleanWithExample:()=>NGo,BytesResponse:()=>v8n,CasingOverrides:()=>h$o,CommonProperty:()=>PGo,CommonPropertyWithExample:()=>XGo,CursorPagination:()=>$$o,CustomCodeSample:()=>W$o,CustomCodeSampleLanguage:()=>L$o,CustomCodeSampleSdk:()=>V$o,CustomPagination:()=>Q$o,DateWithExample:()=>xGo,DatetimeWithExample:()=>zGo,DiscriminatedOneOfSchema:()=>OGo,DiscriminatedOneOfSchemaWithExample:()=>KGo,DoubleSchema:()=>oGo,DoubleWithExample:()=>BGo,Encoding:()=>u$o,Endpoint:()=>J$o,EndpointExample:()=>m8n,EndpointResponseExample:()=>F$o,EndpointSdkName:()=>cir,EndpointWithExample:()=>gh_,EnumSchema:()=>u8n,EnumSchemaWithExample:()=>LGo,EnumValue:()=>DMi,ErrorExample:()=>I$o,FernExample:()=>x$o,FileResponse:()=>h8n,FileSchema:()=>E$o,FloatWithExample:()=>CGo,FullEndpointExample:()=>H$o,FullExample:()=>Hq,FullObjectExample:()=>P$o,FullOneOfExample:()=>w$o,GlobalHeader:()=>lGo,Header:()=>MMi,HeaderExample:()=>O8n,HeaderSecurityScheme:()=>p$o,HeaderWithExample:()=>TMi,HttpEndpointServer:()=>b8n,HttpError:()=>z$o,HttpErrorWithExample:()=>EGo,HttpMethod:()=>l8n,IdempotencyHeader:()=>fGo,Int64WithExample:()=>AGo,IntSchema:()=>nGo,IntWithExample:()=>MGo,JsonRequest:()=>T$o,JsonRequestWithExample:()=>wGo,JsonResponse:()=>y8n,JsonResponseWithExample:()=>A8n,KeyValuePair:()=>j$o,LiteralExample:()=>m$o,LiteralSchema:()=>S8n,LiteralSchemaValue:()=>dGo,LongSchema:()=>aGo,MapSchema:()=>hGo,MapSchemaWithExample:()=>WGo,MultipartRequest:()=>_8n,MultipartRequestProperty:()=>q$o,MultipartRequestPropertyEncoding:()=>A$o,MultipartSchema:()=>M$o,NamedFullExample:()=>fir,Namespace:()=>y$o,NamespaceId:()=>O$o,NullableSchema:()=>vGo,NullableSchemaWithExample:()=>$Go,OauthSecurityScheme:()=>b$o,ObjectProperty:()=>gGo,ObjectPropertyConflictInfo:()=>E8n,ObjectPropertyWithExample:()=>JGo,ObjectSchema:()=>pGo,ObjectSchemaWithExample:()=>GGo,OctetStreamRequest:()=>p8n,OffsetPagination:()=>G$o,OneOfSchema:()=>bGo,OneOfSchemaWithExample:()=>QGo,OpenApiIntermediateRepresentation:()=>vh_,OpenApiSource:()=>i$o,OptionalSchema:()=>yGo,OptionalSchemaWithExample:()=>HGo,Pagination:()=>P8n,PathParameter:()=>f8n,PathParameterExample:()=>R$o,PathParameterWithExample:()=>jGo,PrimitiveExample:()=>c8n,PrimitiveSchema:()=>qMi,PrimitiveSchemaValue:()=>cGo,PrimitiveSchemaValueWithExample:()=>FGo,PrimitiveSchemaWithExample:()=>q8n,PropertyKey:()=>s8n,ProtobufEncoding:()=>o$o,ProtobufSource:()=>n$o,QueryParameter:()=>d8n,QueryParameterExample:()=>g8n,QueryParameterWithExample:()=>M8n,QuerySecurityScheme:()=>_$o,ReferencedSchema:()=>lir,Request:()=>C$o,RequestWithExample:()=>SGo,Response:()=>B$o,ResponseWithExample:()=>DGo,Schema:()=>Om,SchemaId:()=>nk,SchemaWithExample:()=>pA,Schemas:()=>iGo,SdkGroup:()=>v$o,SdkGroupInfo:()=>S$o,SdkGroupName:()=>EMi,SecurityScheme:()=>g$o,SecuritySchemeId:()=>l$o,Server:()=>HIa,Source:()=>a$o,StatusCode:()=>sir,StreamingResponseExample:()=>N$o,StringSchema:()=>uGo,StringSchemaWithExample:()=>IGo,SupportedSdkLanguage:()=>U$o,Tag:()=>c$o,TagId:()=>ak,Tags:()=>D$o,TextResponse:()=>AMi,Uint64WithExample:()=>TGo,UintWithExample:()=>qGo,UnDiscriminatedOneOfSchema:()=>mGo,UnDiscriminatedOneOfSchemaWithExample:()=>YGo,UnknownSchemaWithExample:()=>UGo,Webhook:()=>K$o,WebhookExampleCall:()=>w8n,WebhookHttpMethod:()=>j8n,WebhookWithExample:()=>Oh_,WebsocketChannel:()=>rGo,WebsocketHandshake:()=>Y$o,WebsocketHandshakeWithExample:()=>bh_,WebsocketMessageExample:()=>eGo,WebsocketMessageOrigin:()=>X$o,WebsocketMessageSchema:()=>Z$o,WebsocketServer:()=>k$o,WebsocketSessionExample:()=>tGo,WithAvailability:()=>Ah,WithDescription:()=>bf,WithEncoding:()=>Qae,WithInline:()=>GE,WithName:()=>C0,WithNamespace:()=>e0,WithSdkGroupName:()=>om,WithSource:()=>Jh,WithStatusCode:()=>gFe,WithTitle:()=>am,commons:()=>Kpc,example:()=>Ypc,finalIr:()=>Xpc,parseIr:()=>Zpc});var Kpc={};jo(Kpc,{BasicSecurityScheme:()=>f$o,BearerSecurityScheme:()=>d$o,Encoding:()=>u$o,HeaderSecurityScheme:()=>p$o,Namespace:()=>y$o,NamespaceId:()=>O$o,OauthSecurityScheme:()=>b$o,OpenApiSource:()=>i$o,ProtobufEncoding:()=>o$o,ProtobufSource:()=>n$o,QuerySecurityScheme:()=>_$o,SchemaId:()=>nk,SdkGroup:()=>v$o,SdkGroupName:()=>EMi,SecurityScheme:()=>g$o,SecuritySchemeId:()=>l$o,Server:()=>HIa,Source:()=>a$o,StatusCode:()=>sir,Tag:()=>c$o,TagId:()=>ak,WithAvailability:()=>Ah,WithDescription:()=>bf,WithEncoding:()=>Qae,WithInline:()=>GE,WithName:()=>C0,WithNamespace:()=>e0,WithSdkGroupName:()=>om,WithSource:()=>Jh,WithStatusCode:()=>gFe,WithTitle:()=>am});var At={};jo(At,{JsonError:()=>n8n,ParseError:()=>a8n,any:()=>nh_,bigint:()=>$__,boolean:()=>ah_,booleanLiteral:()=>ih_,date:()=>G__,discriminant:()=>_h_,enum_:()=>e$o,getObjectLikeUtils:()=>fHt,getObjectUtils:()=>bJi,getSchemaUtils:()=>Wq,isProperty:()=>SMi,lazy:()=>Q__,lazyObject:()=>eh_,list:()=>r$o,number:()=>oh_,object:()=>t$o,objectWithoutOptionalProperties:()=>k__,optional:()=>$pc,property:()=>K__,record:()=>lh_,set:()=>fh_,string:()=>uh_,stringLiteral:()=>rh_,transform:()=>Gpc,undiscriminatedUnion:()=>ph_,union:()=>yh_,unknown:()=>sh_,withParsedProperties:()=>Jpc});var Ej={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function dA(e,t){return`Expected ${t}. Received ${emE(e)}.`}function emE(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function aL(e){return{...e,json:H__(e.json),parse:H__(e.parse)}}function H__(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1950
|
-
`)),{ok:!0,value:t}):i}}function kHo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var n8n=class e extends Error{errors;constructor(t){super(t.map(kHo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var a8n=class e extends Error{errors;constructor(t){super(t.map(kHo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Wq(e){return{optional:()=>$pc(e),transform:t=>Gpc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new a8n(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new n8n(i.errors)}}}function $pc(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>Ej.OPTIONAL};return{...t,...Wq(t)}}function Gpc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...Wq(r)}}function $__(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:dA(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:dA(t,"bigint")}]},getType:()=>Ej.BIGINT};return{...aL(e),...Wq(e)}}var tmE=/^([+-]?\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 G__(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:dA(t,"string")}]}:tmE.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:dA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:dA(t,"Date object")}]},getType:()=>Ej.DATE};return{...aL(e),...Wq(e)}}function fJ(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...aL(r),...Wq(r)}}}function e$o(e){let t=new Set(e);return fJ(Ej.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:dA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:dA(i,"enum")}]}:{ok:!0,value:i})()}function Q__(e){let t=Qpc(e);return{...t,...Wq(t)}}function Qpc(e){return{parse:(t,r)=>o8n(e).parse(t,r),json:(t,r)=>o8n(e).json(t,r),getType:()=>o8n(e).getType()}}function o8n(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function UIa(e){return Object.entries(e)}function VIa(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function wMi(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 WIa(e){return Object.keys(e)}function J__(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function fHt(e){return{withParsedProperties:t=>Jpc(e,t)}}function Jpc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((l,[d,s])=>({...l,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!wMi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:dA(i,"object")}]};let a=new Set(Object.keys(t)),u=VIa(i,Object.keys(i).filter(l=>!a.has(l)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...Wq(r),...fHt(r)}}function K__(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function SMi(e){return e.isProperty}function t$o(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>SMi(i)?i.rawKey:r),_getParsedProperties:()=>WIa(e),parse:(r,i)=>{let n={},a=[];for(let[u,l]of UIa(e)){let d=SMi(l)?l.rawKey:u,s=SMi(l)?l.valueSchema:l,o={rawKey:d,parsedKey:u,valueSchema:s};n[d]=o,Z__(s)&&a.push(d)}return Y__({value:r,requiredKeys:a,getProperty:u=>{let l=n[u];if(l!=null)return{transformedKey:l.parsedKey,transform:d=>l.valueSchema.parse(d,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of UIa(e)){let l=SMi(u)?u.valueSchema:u;Z__(l)&&n.push(a)}return Y__({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return SMi(u)?{transformedKey:u.rawKey,transform:l=>u.valueSchema.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:l=>u.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>Ej.OBJECT};return{...aL(t),...Wq(t),...fHt(t),...bJi(t)}}function Y__({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!wMi(e))return{ok:!1,errors:[{path:a,message:dA(e,"object")}]};let u=new Set(t),l=[],d={};for(let[s,o]of Object.entries(e)){let c=r(s);if(c!=null){u.delete(s);let b=c.transform(o);b.ok?d[c.transformedKey]=b.value:(d[s]=o,l.push(...b.errors))}else switch(i){case"fail":l.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=o;break}}return l.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),l.length===0||n?{ok:!0,value:d}:{ok:!1,errors:l}}function bJi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>X__({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>X__({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>Ej.OBJECT};return{...r,...Wq(r),...fHt(r),...bJi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>Ej.OBJECT};return{...t,...Wq(t),...fHt(t),...bJi(t)}}}}function X__({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=J__(WIa(t),s=>n.has(s)),l=r(VIa(t,u)),d=i(VIa(t,a));return l.ok&&d.ok?{ok:!0,value:{...l.value,...d.value}}:{ok:!1,errors:[...l.ok?[]:l.errors,...d.ok?[]:d.errors]}}function Z__(e){return!rmE(e)}function rmE(e){switch(e.getType()){case Ej.ANY:case Ej.UNKNOWN:case Ej.OPTIONAL:return!0;default:return!1}}function k__(e){return t$o(e)}function eh_(e){let t={...Qpc(e),_getRawProperties:()=>o8n(e)._getRawProperties(),_getParsedProperties:()=>o8n(e)._getParsedProperties()};return{...t,...Wq(t),...fHt(t),...bJi(t)}}function r$o(e){let t={parse:(r,i)=>th_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>th_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>Ej.LIST};return{...aL(t),...Wq(t)}}function th_(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:dA(e,"list"),path:[]}]}}function rh_(e){return fJ(Ej.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:dA(r,`"${e}"`)}]})()}function ih_(e){return fJ(Ej.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:dA(r,`${e.toString()}`)}]})()}var nh_=fJ(Ej.ANY,e=>({ok:!0,value:e}));var ah_=fJ(Ej.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:dA(e,"boolean")}]});var oh_=fJ(Ej.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:dA(e,"number")}]});var uh_=fJ(Ej.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:dA(e,"string")}]});var sh_=fJ(Ej.UNKNOWN,e=>({ok:!0,value:e}));function lh_(e,t){let r={parse:(i,n)=>ch_({value:i,isKeyNumeric:e.getType()===Ej.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>ch_({value:i,isKeyNumeric:e.getType()===Ej.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>Ej.RECORD};return{...aL(r),...Wq(r)}}function ch_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return wMi(e)?UIa(e).reduce((a,[u,l])=>{if(l==null)return a;let d=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),c=i(l,s);if(d.ok&&o.ok&&c.ok)return{ok:!0,value:{...d.value,[o.value]:c.value}};let b=[];return d.ok||b.push(...d.errors),o.ok||b.push(...o.errors),c.ok||b.push(...c.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:dA(e,"object")}]}}function fh_(e){let t=r$o(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:dA(i,"Set")}]},getType:()=>Ej.SET};return{...aL(r),...Wq(r)}}function ph_(e){let t={parse:(r,i)=>dh_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>dh_((n,a)=>n.json(r,a),e,i),getType:()=>Ej.UNDISCRIMINATED_UNION};return{...aL(t),...Wq(t)}}function dh_(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let l of u.errors)i.push({path:l.path,message:`[Variant ${n}] ${l.message}`})}return{ok:!1,errors:i}}function _h_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function yh_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=e$o(WIa(t)),a={parse:(u,l)=>hh_({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:d=>n.parse(d,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),json:(u,l)=>hh_({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:d=>n.json(d,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),getType:()=>Ej.UNION};return{...aL(a),...Wq(a),...fHt(a)}}function hh_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:l=[]}){if(!wMi(e))return{ok:!1,errors:[{path:l,message:dA(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:l,message:`Missing discriminant ("${t}")`}]};let o=i(d);if(!o.ok)return{ok:!1,errors:o.errors};let c=n(o.value);if(c==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...l,t],message:"Unexpected discriminant value"}]};let b=u(s,c);return b.ok?{ok:!0,value:{[r]:d,...b.value}}:b}var am=At.objectWithoutOptionalProperties({title:At.string().optional()});var i$o=At.objectWithoutOptionalProperties({file:At.string()});var n$o=At.objectWithoutOptionalProperties({file:At.string()});var a$o=At.union("type",{openapi:i$o,protobuf:n$o}).transform({transform:e=>{switch(e.type){case"openapi":return Gae.openapi(e);case"protobuf":return Gae.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Jh=At.objectWithoutOptionalProperties({source:a$o.optional()});var o$o=At.objectWithoutOptionalProperties({typeName:At.string()});var u$o=At.union("type",{protobuf:o$o}).transform({transform:e=>{switch(e.type){case"protobuf":return r8n.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Qae=At.objectWithoutOptionalProperties({encoding:u$o.optional()});var bf=At.objectWithoutOptionalProperties({description:At.string().optional()});var s$o=At.enum_(["GenerallyAvailable","Beta","Deprecated"]);var Ah=At.objectWithoutOptionalProperties({availability:s$o.optional()});var sir=At.number();var gFe=At.objectWithoutOptionalProperties({statusCode:sir.optional()});var C0=At.objectWithoutOptionalProperties({nameOverride:At.string().optional(),generatedName:At.string()});var GE=At.objectWithoutOptionalProperties({inline:At.boolean().optional()});var nk=At.string();var ak=At.string();var c$o=At.objectWithoutOptionalProperties({id:ak}).extend(bf);var l$o=At.string();var f$o=At.objectWithoutOptionalProperties({usernameVariableName:At.string().optional(),usernameEnvVar:At.string().optional(),passwordVariableName:At.string().optional(),passwordEnvVar:At.string().optional()});var d$o=At.objectWithoutOptionalProperties({tokenVariableName:At.string().optional(),tokenEnvVar:At.string().optional()});var p$o=At.objectWithoutOptionalProperties({headerName:At.string(),prefix:At.string().optional(),headerVariableName:At.string().optional(),headerEnvVar:At.string().optional()});var _$o=At.objectWithoutOptionalProperties({queryParameterName:At.string()});var h$o=At.objectWithoutOptionalProperties({snake:At.string().optional(),camel:At.string().optional(),screamingSnake:At.string().optional(),pascal:At.string().optional()});var DMi=At.objectWithoutOptionalProperties({nameOverride:At.string().optional(),generatedName:At.string(),value:At.string(),casing:h$o.optional()}).extend(bf).extend(Ah);var y$o=At.objectWithoutOptionalProperties({type:At.stringLiteral("namespace"),name:At.string()});var v$o=At.undiscriminatedUnion([At.string(),y$o]);var EMi=At.list(v$o);var om=At.objectWithoutOptionalProperties({groupName:EMi.optional()});var e0=At.objectWithoutOptionalProperties({namespace:At.string().optional()});var u8n=At.objectWithoutOptionalProperties({default:DMi.optional(),values:At.list(DMi)}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Jh).extend(am).extend(GE);var b$o=At.objectWithoutOptionalProperties({scopesEnum:u8n.optional()});var g$o=At.union("type",{basic:f$o,bearer:d$o,header:p$o,query:_$o,oauth:b$o}).transform({transform:e=>{switch(e.type){case"basic":return nL.basic(e);case"bearer":return nL.bearer(e);case"header":return nL.header(e);case"query":return nL.query(e);case"oauth":return nL.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var HIa=At.objectWithoutOptionalProperties({name:At.string().optional(),url:At.string(),audiences:At.list(At.string()).optional()}).extend(bf);var O$o=At.string();var Ypc={};jo(Ypc,{FullExample:()=>Hq,FullObjectExample:()=>P$o,FullOneOfExample:()=>w$o,KeyValuePair:()=>j$o,LiteralExample:()=>m$o,PrimitiveExample:()=>c8n,PropertyKey:()=>s8n});var s8n=At.string();var c8n=At.union("type",{int:At.object({value:At.number()}),int64:At.object({value:At.number()}),uint:At.object({value:At.number()}),uint64:At.object({value:At.number()}),float:At.object({value:At.number()}),double:At.object({value:At.number()}),string:At.object({value:At.string()}),datetime:At.object({value:At.string()}),date:At.object({value:At.string()}),base64:At.object({value:At.string()}),boolean:At.object({value:At.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return w_.int(e.value);case"int64":return w_.int64(e.value);case"uint":return w_.uint(e.value);case"uint64":return w_.uint64(e.value);case"float":return w_.float(e.value);case"double":return w_.double(e.value);case"string":return w_.string(e.value);case"datetime":return w_.datetime(e.value);case"date":return w_.date(e.value);case"base64":return w_.base64(e.value);case"boolean":return w_.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var m$o=At.union("type",{boolean:At.object({value:At.boolean()}),string:At.object({value:At.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return i8n.boolean(e.value);case"string":return i8n.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Hq=At.union("type",{primitive:At.object({value:c8n}),object:At.lazyObject(()=>P$o),array:At.object({value:At.list(At.lazy(()=>Hq))}),map:At.object({value:At.list(At.lazyObject(()=>j$o))}),enum:At.object({value:At.string()}),literal:At.object({value:m$o}),oneOf:At.object({value:At.lazy(()=>w$o)}),unknown:At.object({value:At.lazy(()=>Hq)})}).transform({transform:e=>{switch(e.type){case"primitive":return vO.primitive(e.value);case"object":return vO.object(e);case"array":return vO.array(e.value);case"map":return vO.map(e.value);case"enum":return vO.enum(e.value);case"literal":return vO.literal(e.value);case"oneOf":return vO.oneOf(e.value);case"unknown":return vO.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var P$o=At.objectWithoutOptionalProperties({properties:At.record(s8n,At.lazy(()=>Hq))});var j$o=At.objectWithoutOptionalProperties({key:c8n,value:At.lazy(()=>Hq)});var w$o=At.union("type",{discriminated:At.object({value:At.record(s8n,At.lazy(()=>Hq))}),undiscriminated:At.object({value:At.lazy(()=>Hq)})}).transform({transform:e=>{switch(e.type){case"discriminated":return PMi.discriminated(e.value);case"undiscriminated":return PMi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Xpc={};jo(Xpc,{AllOfPropertyConflict:()=>D8n,ArraySchema:()=>_Go,Availability:()=>s$o,BooleanSchema:()=>sGo,BytesResponse:()=>v8n,CasingOverrides:()=>h$o,CommonProperty:()=>PGo,CursorPagination:()=>$$o,CustomCodeSample:()=>W$o,CustomCodeSampleLanguage:()=>L$o,CustomCodeSampleSdk:()=>V$o,CustomPagination:()=>Q$o,DiscriminatedOneOfSchema:()=>OGo,DoubleSchema:()=>oGo,Endpoint:()=>J$o,EndpointExample:()=>m8n,EndpointResponseExample:()=>F$o,EndpointSdkName:()=>cir,EnumSchema:()=>u8n,EnumValue:()=>DMi,ErrorExample:()=>I$o,FernExample:()=>x$o,FileResponse:()=>h8n,FileSchema:()=>E$o,FullEndpointExample:()=>H$o,GlobalHeader:()=>lGo,Header:()=>MMi,HeaderExample:()=>O8n,HttpEndpointServer:()=>b8n,HttpError:()=>z$o,HttpMethod:()=>l8n,IdempotencyHeader:()=>fGo,IntSchema:()=>nGo,JsonRequest:()=>T$o,JsonResponse:()=>y8n,LiteralSchema:()=>S8n,LiteralSchemaValue:()=>dGo,LongSchema:()=>aGo,MapSchema:()=>hGo,MultipartRequest:()=>_8n,MultipartRequestProperty:()=>q$o,MultipartRequestPropertyEncoding:()=>A$o,MultipartSchema:()=>M$o,NullableSchema:()=>vGo,ObjectProperty:()=>gGo,ObjectPropertyConflictInfo:()=>E8n,ObjectSchema:()=>pGo,OctetStreamRequest:()=>p8n,OffsetPagination:()=>G$o,OneOfSchema:()=>bGo,OpenApiIntermediateRepresentation:()=>vh_,OptionalSchema:()=>yGo,Pagination:()=>P8n,PathParameter:()=>f8n,PathParameterExample:()=>R$o,PrimitiveSchema:()=>qMi,PrimitiveSchemaValue:()=>cGo,QueryParameter:()=>d8n,QueryParameterExample:()=>g8n,ReferencedSchema:()=>lir,Request:()=>C$o,Response:()=>B$o,Schema:()=>Om,Schemas:()=>iGo,SdkGroupInfo:()=>S$o,StreamingResponseExample:()=>N$o,StringSchema:()=>uGo,SupportedSdkLanguage:()=>U$o,Tags:()=>D$o,TextResponse:()=>AMi,UnDiscriminatedOneOfSchema:()=>mGo,Webhook:()=>K$o,WebhookExampleCall:()=>w8n,WebhookHttpMethod:()=>j8n,WebsocketChannel:()=>rGo,WebsocketHandshake:()=>Y$o,WebsocketMessageExample:()=>eGo,WebsocketMessageOrigin:()=>X$o,WebsocketMessageSchema:()=>Z$o,WebsocketServer:()=>k$o,WebsocketSessionExample:()=>tGo});var S$o=At.objectWithoutOptionalProperties({summary:At.string().optional(),description:At.string().optional()});var D$o=At.objectWithoutOptionalProperties({tagsById:At.record(ak,c$o),orderedTagIds:At.list(ak).optional()});var l8n=At.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var f8n=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>Om),variableReference:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(bf).extend(Ah).extend(Jh);var d8n=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>Om),parameterNameOverride:At.string().optional()}).extend(bf).extend(Ah).extend(Jh);var MMi=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>Om),env:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(bf).extend(Ah).extend(Jh);var cir=At.objectWithoutOptionalProperties({groupName:EMi,methodName:At.string()});var p8n=At.objectWithoutOptionalProperties({}).extend(bf).extend(Jh);var E$o=At.objectWithoutOptionalProperties({isOptional:At.boolean(),isArray:At.boolean()}).extend(bf);var M$o=At.union("type",{file:E$o,json:At.object({value:At.lazy(()=>Om)})}).transform({transform:e=>{switch(e.type){case"file":return $di.file(e);case"json":return $di.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var A$o=At.enum_(["json","form"]);var q$o=At.objectWithoutOptionalProperties({key:At.string(),schema:M$o,contentType:At.string().optional(),exploded:At.boolean().optional(),encoding:A$o.optional()}).extend(bf);var _8n=At.objectWithoutOptionalProperties({name:At.string().optional(),properties:At.list(q$o)}).extend(bf).extend(Jh);var T$o=At.objectWithoutOptionalProperties({schema:At.lazy(()=>Om),contentType:At.string().optional(),additionalProperties:At.boolean()}).extend(bf).extend(Jh);var C$o=At.union("type",{octetStream:p8n,multipart:_8n,json:T$o}).transform({transform:e=>{switch(e.type){case"octetStream":return jMi.octetStream(e);case"multipart":return jMi.multipart(e);case"json":return jMi.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var h8n=At.objectWithoutOptionalProperties({}).extend(bf).extend(Jh).extend(gFe);var y8n=At.objectWithoutOptionalProperties({schema:At.lazy(()=>Om),responseProperty:At.string().optional()}).extend(bf).extend(Jh).extend(gFe);var AMi=At.objectWithoutOptionalProperties({}).extend(bf).extend(Jh).extend(gFe);var v8n=At.objectWithoutOptionalProperties({}).extend(bf).extend(Jh).extend(gFe);var B$o=At.union("type",{file:h8n,json:y8n,text:AMi,bytes:v8n,streamingSse:y8n,streamingText:AMi,streamingJson:y8n}).transform({transform:e=>{switch(e.type){case"file":return lJ.file(e);case"json":return lJ.json(e);case"text":return lJ.text(e);case"bytes":return lJ.bytes(e);case"streamingSse":return lJ.streamingSse(e);case"streamingText":return lJ.streamingText(e);case"streamingJson":return lJ.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var I$o=At.objectWithoutOptionalProperties({name:At.string().optional(),description:At.string().optional(),example:At.lazy(()=>Hq)});var z$o=At.objectWithoutOptionalProperties({schema:At.lazy(()=>Om).optional(),examples:At.list(I$o).optional()}).extend(bf).extend(C0).extend(Jh);var b8n=At.objectWithoutOptionalProperties({name:At.string().optional(),url:At.string().optional(),audiences:At.list(At.string()).optional()});var x$o=At.unknown();var R$o=At.objectWithoutOptionalProperties({name:At.string(),parameterNameOverride:At.string().optional(),value:At.lazy(()=>Hq)});var g8n=At.objectWithoutOptionalProperties({name:At.string(),value:At.lazy(()=>Hq)});var O8n=At.objectWithoutOptionalProperties({name:At.string(),value:At.lazy(()=>Hq)});var N$o=At.objectWithoutOptionalProperties({sse:At.boolean(),events:At.list(At.lazy(()=>Hq))});var F$o=At.union("type",{withStreaming:N$o,withoutStreaming:At.object({value:At.lazy(()=>Hq)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return lHt.withStreaming(e);case"withoutStreaming":return lHt.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var L$o=At.objectWithoutOptionalProperties({name:At.string().optional(),language:At.string(),code:At.string(),install:At.string().optional()}).extend(bf);var U$o=At.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var V$o=At.objectWithoutOptionalProperties({name:At.string().optional(),sdk:U$o,code:At.string()}).extend(bf);var W$o=At.union("type",{language:L$o,sdk:V$o}).transform({transform:e=>{switch(e.type){case"language":return Hdi.language(e);case"sdk":return Hdi.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var H$o=At.objectWithoutOptionalProperties({name:At.string().optional(),pathParameters:At.list(R$o).optional(),queryParameters:At.list(g8n).optional(),headers:At.list(O8n).optional(),request:At.lazy(()=>Hq).optional(),response:F$o.optional(),codeSamples:At.list(W$o)}).extend(bf);var m8n=At.union("type",{unknown:At.object({value:x$o}),full:H$o}).transform({transform:e=>{switch(e.type){case"unknown":return cHt.unknown(e.value);case"full":return cHt.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var $$o=At.objectWithoutOptionalProperties({cursor:At.string(),nextCursor:At.property("next_cursor",At.string()),results:At.string()});var G$o=At.objectWithoutOptionalProperties({offset:At.string(),results:At.string(),step:At.string().optional(),hasNextPage:At.string().optional()});var Q$o=At.objectWithoutOptionalProperties({results:At.string()});var P8n=At.union("type",{cursor:$$o,offset:G$o,custom:Q$o}).transform({transform:e=>{switch(e.type){case"cursor":return bFe.cursor(e);case"offset":return bFe.offset(e);case"custom":return bFe.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var J$o=At.objectWithoutOptionalProperties({authed:At.boolean(),internal:At.boolean().optional(),idempotent:At.boolean().optional(),method:l8n,audiences:At.list(At.string()),path:At.string(),summary:At.string().optional(),operationId:At.string().optional(),tags:At.list(ak),pathParameters:At.list(f8n),queryParameters:At.list(d8n),headers:At.list(MMi),sdkName:cir.optional(),generatedRequestName:At.string(),requestNameOverride:At.string().optional(),request:C$o.optional(),response:B$o.optional(),errors:At.record(sir,z$o),servers:At.list(b8n),examples:At.list(m8n),pagination:P8n.optional()}).extend(bf).extend(Ah).extend(Jh).extend(e0);var j8n=At.enum_(["GET","POST"]);var w8n=At.objectWithoutOptionalProperties({name:At.string().optional(),payload:At.lazy(()=>Hq)}).extend(bf);var K$o=At.objectWithoutOptionalProperties({audiences:At.list(At.string()),sdkName:cir.optional(),method:j8n,summary:At.string().optional(),operationId:At.string(),tags:At.list(ak),headers:At.list(MMi),generatedPayloadName:At.string(),payload:At.lazy(()=>Om),examples:At.list(w8n)}).extend(bf).extend(Jh).extend(e0);var Y$o=At.objectWithoutOptionalProperties({queryParameters:At.list(d8n),headers:At.list(MMi),pathParameters:At.list(f8n)});var X$o=At.enum_(["client","server"]);var Z$o=At.objectWithoutOptionalProperties({name:At.string(),origin:X$o,body:At.lazy(()=>Om)});var k$o=At.objectWithoutOptionalProperties({name:At.string(),url:At.string()});var eGo=At.objectWithoutOptionalProperties({messageType:At.string(),payload:At.lazy(()=>Hq)}).extend(bf);var tGo=At.objectWithoutOptionalProperties({name:At.string().optional(),queryParameters:At.list(g8n).optional(),headers:At.list(O8n).optional(),messages:At.list(eGo)}).extend(bf);var rGo=At.objectWithoutOptionalProperties({audiences:At.list(At.string()),path:At.string(),groupName:EMi,summary:At.string().optional(),handshake:Y$o,messages:At.list(Z$o),servers:At.list(k$o),examples:At.list(tGo)}).extend(bf).extend(Jh);var iGo=At.objectWithoutOptionalProperties({rootSchemas:At.record(nk,At.lazy(()=>Om)),namespacedSchemas:At.record(O$o,At.record(nk,At.lazy(()=>Om)))});var nGo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional()});var aGo=At.objectWithoutOptionalProperties({default:At.number().optional()});var oGo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional()});var uGo=At.objectWithoutOptionalProperties({default:At.string().optional(),pattern:At.string().optional(),format:At.string().optional(),minLength:At.number().optional(),maxLength:At.number().optional()});var sGo=At.objectWithoutOptionalProperties({default:At.boolean().optional()});var cGo=At.union("type",{int:nGo,int64:aGo,uint:At.object({}),uint64:At.object({}),float:At.object({}),double:oGo,string:uGo,datetime:At.object({}),date:At.object({}),base64:At.object({}),boolean:sGo}).transform({transform:e=>{switch(e.type){case"int":return Xj.int(e);case"int64":return Xj.int64(e);case"uint":return Xj.uint();case"uint64":return Xj.uint64();case"float":return Xj.float();case"double":return Xj.double(e);case"string":return Xj.string(e);case"datetime":return Xj.datetime();case"date":return Xj.date();case"base64":return Xj.base64();case"boolean":return Xj.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var qMi=At.objectWithoutOptionalProperties({schema:cGo}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am);var lGo=At.objectWithoutOptionalProperties({header:At.string(),name:At.string().optional(),optional:At.boolean().optional(),env:At.string().optional(),schema:At.lazy(()=>Om).optional()});var fGo=At.objectWithoutOptionalProperties({header:At.string(),name:At.string().optional(),env:At.string().optional(),schema:At.lazy(()=>Om).optional()});var vh_=At.objectWithoutOptionalProperties({apiVersion:At.unknown().optional(),title:At.string().optional(),description:At.string().optional(),basePath:At.string().optional(),servers:At.list(HIa),websocketServers:At.list(HIa),groups:At.record(At.string(),S$o),tags:D$o,hasEndpointsMarkedInternal:At.boolean(),endpoints:At.list(J$o),webhooks:At.list(K$o),channels:At.record(At.string(),rGo),groupedSchemas:iGo,variables:At.record(At.string(),qMi),nonRequestReferencedSchemas:At.set(nk),securitySchemes:At.record(l$o,g$o),globalHeaders:At.list(lGo).optional(),idempotencyHeaders:At.list(fGo).optional()});var lir=At.objectWithoutOptionalProperties({schema:nk}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Jh).extend(am);var dGo=At.union("type",{boolean:At.object({value:At.boolean()}),string:At.object({value:At.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return vz.boolean(e.value);case"string":return vz.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var S8n=At.objectWithoutOptionalProperties({value:dGo}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am);var Om=At.union("type",{primitive:qMi,object:At.lazyObject(()=>pGo),array:At.lazyObject(()=>_Go),map:At.lazyObject(()=>hGo),optional:At.lazyObject(()=>yGo),enum:u8n,reference:lir,literal:S8n,oneOf:At.object({value:At.lazy(()=>bGo)}),nullable:At.lazyObject(()=>vGo),unknown:C0}).transform({transform:e=>{switch(e.type){case"primitive":return Fy.primitive(e);case"object":return Fy.object(e);case"array":return Fy.array(e);case"map":return Fy.map(e);case"optional":return Fy.optional(e);case"enum":return Fy.enum(e);case"reference":return Fy.reference(e);case"literal":return Fy.literal(e);case"oneOf":return Fy.oneOf(e.value);case"nullable":return Fy.nullable(e);case"unknown":return Fy.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var D8n=At.objectWithoutOptionalProperties({propertyKey:At.string(),allOfSchemaIds:At.list(nk),conflictingTypeSignatures:At.boolean()});var pGo=At.objectWithoutOptionalProperties({allOf:At.list(lir),properties:At.list(At.lazyObject(()=>gGo)),allOfPropertyConflicts:At.list(D8n),additionalProperties:At.boolean()}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Jh).extend(am).extend(GE);var E8n=At.objectWithoutOptionalProperties({differentSchema:At.boolean()});var gGo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>Om),readonly:At.boolean().optional(),writeonly:At.boolean().optional(),conflict:At.record(nk,E8n),generatedName:At.string(),nameOverride:At.string().optional(),audiences:At.list(At.string())}).extend(Ah);var _Go=At.objectWithoutOptionalProperties({value:At.lazy(()=>Om)}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am).extend(GE);var hGo=At.objectWithoutOptionalProperties({key:qMi,value:At.lazy(()=>Om)}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Qae).extend(am).extend(GE);var yGo=At.objectWithoutOptionalProperties({value:At.lazy(()=>Om)}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am).extend(GE);var vGo=At.objectWithoutOptionalProperties({value:At.lazy(()=>Om)}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am).extend(GE);var bGo=At.union("type",{discriminated:At.lazyObject(()=>OGo),undiscriminated:At.lazyObject(()=>mGo)}).transform({transform:e=>{switch(e.type){case"discriminated":return Gdi.discriminated(e);case"undiscriminated":return Gdi.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var OGo=At.objectWithoutOptionalProperties({discriminantProperty:At.string(),commonProperties:At.list(At.lazyObject(()=>PGo)),schemas:At.record(At.string(),At.lazy(()=>Om))}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Qae).extend(Jh).extend(am).extend(GE);var PGo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>Om)});var mGo=At.objectWithoutOptionalProperties({schemas:At.list(At.lazy(()=>Om))}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Qae).extend(Jh).extend(am).extend(GE);var Zpc={};jo(Zpc,{ArraySchemaWithExample:()=>VGo,Base64WithExample:()=>RGo,BooleanWithExample:()=>NGo,CommonPropertyWithExample:()=>XGo,DateWithExample:()=>xGo,DatetimeWithExample:()=>zGo,DiscriminatedOneOfSchemaWithExample:()=>KGo,DoubleWithExample:()=>BGo,EndpointWithExample:()=>gh_,EnumSchemaWithExample:()=>LGo,FloatWithExample:()=>CGo,HeaderWithExample:()=>TMi,HttpErrorWithExample:()=>EGo,Int64WithExample:()=>AGo,IntWithExample:()=>MGo,JsonRequestWithExample:()=>wGo,JsonResponseWithExample:()=>A8n,MapSchemaWithExample:()=>WGo,NamedFullExample:()=>fir,NullableSchemaWithExample:()=>$Go,ObjectPropertyWithExample:()=>JGo,ObjectSchemaWithExample:()=>GGo,OneOfSchemaWithExample:()=>QGo,OptionalSchemaWithExample:()=>HGo,PathParameterWithExample:()=>jGo,PrimitiveSchemaValueWithExample:()=>FGo,PrimitiveSchemaWithExample:()=>q8n,QueryParameterWithExample:()=>M8n,RequestWithExample:()=>SGo,ResponseWithExample:()=>DGo,SchemaWithExample:()=>pA,StringSchemaWithExample:()=>IGo,Uint64WithExample:()=>TGo,UintWithExample:()=>qGo,UnDiscriminatedOneOfSchemaWithExample:()=>YGo,UnknownSchemaWithExample:()=>UGo,WebhookWithExample:()=>Oh_,WebsocketHandshakeWithExample:()=>bh_});var fir=At.objectWithoutOptionalProperties({name:At.string().optional(),value:At.unknown()}).extend(bf);var M8n=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>pA),parameterNameOverride:At.string().optional()}).extend(bf).extend(Ah).extend(Jh);var TMi=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>pA),env:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(bf).extend(Ah).extend(Jh);var bh_=At.objectWithoutOptionalProperties({queryParameters:At.list(M8n),headers:At.list(TMi)});var jGo=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>pA),variableReference:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(bf).extend(Ah).extend(Jh);var wGo=At.objectWithoutOptionalProperties({schema:At.lazy(()=>pA),contentType:At.string().optional(),fullExamples:At.list(fir).optional(),additionalProperties:At.boolean()}).extend(bf).extend(Jh);var SGo=At.union("type",{octetStream:p8n,multipart:_8n,json:wGo}).transform({transform:e=>{switch(e.type){case"octetStream":return EMe.octetStream(e);case"multipart":return EMe.multipart(e);case"json":return EMe.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var A8n=At.objectWithoutOptionalProperties({schema:At.lazy(()=>pA),responseProperty:At.string().optional(),fullExamples:At.list(fir).optional()}).extend(bf).extend(Jh).extend(gFe);var DGo=At.union("type",{file:h8n,json:A8n,text:AMi,bytes:v8n,streamingSse:A8n,streamingText:AMi,streamingJson:A8n}).transform({transform:e=>{switch(e.type){case"file":return vC.file(e);case"json":return vC.json(e);case"text":return vC.text(e);case"bytes":return vC.bytes(e);case"streamingSse":return vC.streamingSse(e);case"streamingText":return vC.streamingText(e);case"streamingJson":return vC.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var EGo=At.objectWithoutOptionalProperties({statusCode:sir,schema:At.lazy(()=>pA),fullExamples:At.list(fir).optional()}).extend(bf).extend(C0).extend(Jh);var gh_=At.objectWithoutOptionalProperties({authed:At.boolean(),internal:At.boolean().optional(),idempotent:At.boolean().optional(),method:l8n,audiences:At.list(At.string()),path:At.string(),summary:At.string().optional(),operationId:At.string().optional(),tags:At.list(ak),pathParameters:At.list(jGo),queryParameters:At.list(M8n),headers:At.list(TMi),sdkName:cir.optional(),generatedRequestName:At.string(),requestNameOverride:At.string().optional(),request:SGo.optional(),response:DGo.optional(),errors:At.record(sir,EGo),servers:At.list(b8n),examples:At.list(m8n),pagination:P8n.optional()}).extend(bf).extend(Ah).extend(Jh).extend(e0);var Oh_=At.objectWithoutOptionalProperties({audiences:At.list(At.string()),sdkName:cir.optional(),method:j8n,summary:At.string().optional(),operationId:At.string(),tags:At.list(ak),headers:At.list(TMi),generatedPayloadName:At.string(),payload:At.lazy(()=>pA),examples:At.list(w8n)}).extend(bf).extend(Jh).extend(e0);var MGo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional(),example:At.number().optional()});var AGo=At.objectWithoutOptionalProperties({default:At.number().optional(),example:At.number().optional()});var qGo=At.objectWithoutOptionalProperties({default:At.number().optional(),example:At.number().optional()});var TGo=At.objectWithoutOptionalProperties({default:At.number().optional(),example:At.number().optional()});var CGo=At.objectWithoutOptionalProperties({example:At.number().optional()});var BGo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional(),example:At.number().optional()});var IGo=At.objectWithoutOptionalProperties({default:At.string().optional(),pattern:At.string().optional(),format:At.string().optional(),minLength:At.number().optional(),maxLength:At.number().optional(),example:At.string().optional()});var zGo=At.objectWithoutOptionalProperties({example:At.string().optional()});var xGo=At.objectWithoutOptionalProperties({example:At.string().optional()});var RGo=At.objectWithoutOptionalProperties({example:At.string().optional()});var NGo=At.objectWithoutOptionalProperties({default:At.boolean().optional(),example:At.boolean().optional()});var FGo=At.union("type",{int:MGo,int64:AGo,uint:qGo,uint64:TGo,float:CGo,double:BGo,string:IGo,datetime:zGo,date:xGo,base64:RGo,boolean:NGo}).transform({transform:e=>{switch(e.type){case"int":return up.int(e);case"int64":return up.int64(e);case"uint":return up.uint(e);case"uint64":return up.uint64(e);case"float":return up.float(e);case"double":return up.double(e);case"string":return up.string(e);case"datetime":return up.datetime(e);case"date":return up.date(e);case"base64":return up.base64(e);case"boolean":return up.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var q8n=At.objectWithoutOptionalProperties({schema:FGo}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am);var LGo=At.objectWithoutOptionalProperties({default:DMi.optional(),values:At.list(DMi),example:At.string().optional()}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Jh).extend(am).extend(GE);var UGo=At.objectWithoutOptionalProperties({example:At.unknown()}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am);var pA=At.union("type",{primitive:q8n,object:At.lazyObject(()=>GGo),array:At.lazyObject(()=>VGo),map:At.lazyObject(()=>WGo),optional:At.lazyObject(()=>HGo),enum:LGo,reference:lir,literal:S8n,oneOf:At.object({value:At.lazy(()=>QGo)}),nullable:At.lazyObject(()=>$Go),unknown:UGo}).transform({transform:e=>{switch(e.type){case"primitive":return zl.primitive(e);case"object":return zl.object(e);case"array":return zl.array(e);case"map":return zl.map(e);case"optional":return zl.optional(e);case"enum":return zl.enum(e);case"reference":return zl.reference(e);case"literal":return zl.literal(e);case"oneOf":return zl.oneOf(e.value);case"nullable":return zl.nullable(e);case"unknown":return zl.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var VGo=At.objectWithoutOptionalProperties({value:At.lazy(()=>pA),example:At.list(At.unknown()).optional()}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am).extend(GE);var WGo=At.objectWithoutOptionalProperties({key:q8n,value:At.lazy(()=>pA),example:At.unknown().optional()}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Qae).extend(am).extend(GE);var HGo=At.objectWithoutOptionalProperties({value:At.lazy(()=>pA)}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am).extend(GE);var $Go=At.objectWithoutOptionalProperties({value:At.lazy(()=>pA)}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am).extend(GE);var GGo=At.objectWithoutOptionalProperties({allOf:At.list(lir),properties:At.list(At.lazyObject(()=>JGo)),allOfPropertyConflicts:At.list(D8n),fullExamples:At.list(fir).optional(),additionalProperties:At.boolean()}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Jh).extend(am).extend(GE);var JGo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>pA),readonly:At.boolean().optional(),writeonly:At.boolean().optional(),audiences:At.list(At.string()),conflict:At.record(nk,E8n),nameOverride:At.string().optional(),generatedName:At.string()}).extend(Ah);var QGo=At.union("type",{discriminated:At.lazyObject(()=>KGo),undiscriminated:At.lazyObject(()=>YGo)}).transform({transform:e=>{switch(e.type){case"discriminated":return ik.discriminated(e);case"undiscriminated":return ik.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var KGo=At.objectWithoutOptionalProperties({discriminantProperty:At.string(),commonProperties:At.list(At.lazyObject(()=>XGo)),schemas:At.record(At.string(),At.lazy(()=>pA))}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Qae).extend(Jh).extend(am).extend(GE);var XGo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>pA)});var YGo=At.objectWithoutOptionalProperties({schemas:At.list(At.lazy(()=>pA))}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Qae).extend(Jh).extend(am).extend(GE);var mh_=/^(\d+)/,T8n=/^[a-zA-Z][a-zA-Z0-9_]*$/,Ph_={"<":"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 CMi(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let u=Math.floor(e/10),l=e%10;return l===0?i[u]:`${i[u]}_${t[l]}`}if(e<1e3){let u=Math.floor(e/100),l=e%100;return l===0?`${t[u]}_hundred`:`${t[u]}_hundred_${CMi(l)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${CMi(a)}`}function $Ia(e){let t=e.match(mh_);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=CMi(n);return i.length>0?`${a}_${i}`:a}}}function C8n(e){let t=$Ia(e),r=Ph_[e];return t!=null?iz(T_(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":iz(T_(e)))}function Jae(e,t){return e.type==="primitive"&&t.type==="primitive"?jh_(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?imE(e.values,t.values):e.type==="array"&&t.type==="array"?Jae(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"?Jae(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?nmE(e.value,t.value):e.type==="object"&&t.type==="object"?amE(e,t):e.type==="map"&&t.type==="map"?jh_(e.key.schema,t.key.schema)&&Jae(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function jh_(e,t){return e.type===t.type}function imE(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return OEe(r,i)}function nmE(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,i])=>{let n=t.schemas[r];return n==null?!1:Jae(i,n)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,i)=>{let n=t.schemas[i];return n==null?!1:Jae(r,n)}):!1}function amE(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(i=>[i.key,i.schema]));return Object.entries(t.properties).every(([i,n])=>{let a=r[i];return a==null?!1:Jae(a,n.schema)})}var n8;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(n8||(n8={}));var ZGo=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;respectNullableSchemas;onlyIncludeReferencedSchemas;inlinePathParameters;useBytesForBinaryResponse;respectForwardCompatibleEnums;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:u}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=u,this.globalHeaderOverrides=a,this.detectGlobalHeaders=i?.detectGlobalHeaders??!0,this.objectQueryParameters=i?.objectQueryParameters??!1,this.respectReadonlySchemas=i?.respectReadonlySchemas??!1,this.respectNullableSchemas=i?.respectNullableSchemas??!1,this.onlyIncludeReferencedSchemas=i?.onlyIncludeReferencedSchemas??!1,this.inlinePathParameters=i?.inlinePathParameters??!1,this.useBytesForBinaryResponse=i?.useBytesForBinaryResponse??!1,this.respectForwardCompatibleEnums=i?.respectForwardCompatibleEnums??!1,this.referencedSchemaIds=i?.onlyIncludeReferencedSchemas?new Set:void 0,this.enableUniqueErrorsPerEndpoint=i?.enableUniqueErrorsPerEndpoint??!1,this.builder=new vJi(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let l={};if(!this.enableUniqueErrorsPerEndpoint)for(let d of r.endpoints)for(let[s,o]of Object.entries(d.errors)){let c=parseInt(s),b=l[c];b==null&&o.schema!=null?l[c]=o.schema:b!=null&&o.schema!=null&&Jae(b,o.schema)||this.unknownSchema.add(c)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.onlyIncludeReferencedSchemas&&this.isInAnyState(n8.Channel,n8.Endpoint,n8.Webhook)}markSchemaAsReferenced(t,r){switch(t.type){case"primitive":return;case"object":this.markObjectSchemaAsReferenced(t,r);return;case"array":this.markSchemaAsReferenced(t.value,r);return;case"map":this.markSchemaAsReferenced(t.value,r);return;case"optional":this.markSchemaAsReferenced(t.value,r);return;case"reference":this.markSchemaIdAsReferenced(t.schema,r);return;case"oneOf":this.markOneofSchemaAsReferenced(t.value,r);return;case"nullable":this.markSchemaAsReferenced(t.value,r);return;case"enum":return;case"literal":return;case"unknown":return;default:mo(t)}}markObjectSchemaAsReferenced(t,r){for(let i of t.allOf)this.markSchemaIdAsReferenced(i.schema,r);for(let i of t.properties)this.markSchemaAsReferenced(i.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let i of Object.values(t.schemas))this.markSchemaAsReferenced(i,r);return;case"undiscriminated":for(let i of t.schemas)this.markSchemaAsReferenced(i,r);return;default:mo(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let i=this.getSchema(t,r);i!=null&&this.markSchemaAsReferenced(i,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function Ox(e){switch(e){case eH.Deprecated:return"deprecated";case eH.Beta:return"pre-release";case eH.GenerallyAvailable:return"generally-available";default:return}}function omE(e){let t=e.find(i=>typeof i=="object"&&i.type==="namespace"),r=e.filter(i=>typeof i=="string"||i.type!=="namespace");return t?[t,...r]:r}function wh_(e){let t=e?omE(e):void 0;if(t==null||t.length===0)return UVi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(T_(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(T_(n.name)):r.push(n.name,UVi);break}default:mo(n.type)}else mo(n);return r.join("/")}function BMi(e){return yy.of(`${wh_(e)}.yml`)}function kpc({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?UVi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,wh_(r))}function Sh_({sdkName:e,namespaceOverride:t}){return yy.of(`${kpc({sdkName:e,namespaceOverride:t})}.yml`)}function Dh_({location:e,namespaceOverride:t}){return t!=null?WN(yy.of(t),e):e}function kGo(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:mo(e.type)}}function B8n(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:mo(e)}}function _A(e){return typeof e=="string"?e:e.type}function I8n(e){if(typeof e!="string")return e.docs}function GIa(e){if(typeof e!="string")return e.default}function e_c(e){if(typeof e!="string")return e.validation}var umE=-2147483648,smE=2147483647,cmE=-17976931348623157e292,lmE=17976931348623157e292;function Eg({schema:e,fileContainingReference:t,declarationFile:r=t,context:i,namespace:n,declarationDepth:a}){switch(i.shouldMarkSchemaAsReferenced()&&i.markSchemaAsReferenced(e,n),e.type){case"primitive":return eQo(e);case"array":return i_c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return n_c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return r_c({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return o_c();case"optional":return tQo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return a_c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return gmE({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,u_c(e);case"object":return OmE({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return mmE({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:mo(e)}}function eQo(e){switch(e.schema.type){case"string":return pmE({description:e.description,schema:e.schema});case"int":return _mE({description:e.description,schema:e.schema});case"float":return hmE({description:e.description,schema:e.schema});case"double":return ymE({description:e.description,schema:e.schema});case"boolean":return fmE({description:e.description,schema:e.schema});case"int64":return dmE({description:e.description,schema:e.schema})}let t=e.schema._visit({int:()=>"integer",int64:()=>"long",uint:()=>"uint",uint64:()=>"uint64",float:()=>"double",double:()=>"double",string:()=>"string",datetime:()=>"datetime",date:()=>"date",base64:()=>"base64",boolean:()=>"boolean",_other:()=>"unknown"});return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:Ox(e.availability)}:{}}}function fmE({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function dmE({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function pmE({description:e,schema:t}){let r="string",i=vmE(t);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function _mE({description:e,schema:t}){let r="integer",i=Mh_(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function hmE({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function ymE({description:e,schema:t}){let r="double",i=Mh_(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function vmE(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=bmE(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function bmE(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 Mh_(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=t_c(r,t),i=t_c(i,t),n=t_c(n,t),!(r==null&&i==null&&a==null&&u==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:u,multipleOf:n}}function t_c(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[umE,smE]:[cmE,lmE];return e<r||e>i?void 0:e}function r_c({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=PmE(n)??e.schema,u=B8n(n),l=jmE(n),d=rQo({context:r,fileContainingReference:t,declarationFile:BMi(u),type:a}),s=n.type==="nullable"?`optional<${d}>`:d;return e.description==null&&l==null?s:{type:n.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:Ox(e.availability)}:{}}}function i_c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=Eg({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=`list<${_A(u)}>`;return e.description==null&&e.title==null?l:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:Ox(e.availability)}:{},type:l}}function n_c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=eQo(e.key),l=Eg({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),d=e.encoding!=null?kGo(e.encoding):void 0,s=`map<${_A(u)}, ${_A(l)}>`;if(e.description==null&&d==null&&e.title==null)return s;let o={type:s};return e.description!=null&&(o.docs=e.description),e.encoding!=null&&(o.encoding=d),e.availability!=null&&(o.availability=Ox(e.availability)),o}function a_c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.respectNullableSchemas)return tQo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let u=Eg({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=_A(u),d=I8n(u),s=GIa(u),o=e_c(u),c=l.startsWith("nullable<")?l:`nullable<${l}>`;if(e.availability==null&&e.description==null&&d==null&&s==null&&o==null&&e.title==null)return Eh_({typeReference:c,itemType:l});let b={type:c};return(e.description!=null||d!=null)&&(b.docs=e.description??d),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=Ox(e.availability)),Eh_({typeReference:b,itemType:l})}function tQo({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=Eg({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=_A(u),d=I8n(u),s=GIa(u),o=e_c(u),c=l.startsWith("optional<")?l:`optional<${l}>`;if(e.availability==null&&e.description==null&&d==null&&s==null&&o==null&&e.title==null)return c;let b={type:c};return(e.description!=null||d!=null)&&(b.docs=e.description??d),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=Ox(e.availability)),b}function o_c(){return"unknown"}function u_c(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:mo(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:Ox(e.availability)}:{}}}function gmE({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=QIa(e,n),u=e.nameOverride??e.generatedName;i.builder.addType(r,{name:u,schema:a.schema});let l=rQo({type:u,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return l;let d={type:l};return e.description!=null&&(d.docs=e.description),e.default!=null&&(d.default=e.default.value),e.availability!=null&&(d.availability=Ox(e.availability)),d}function OmE({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=s_c({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=e.nameOverride??e.generatedName;i.builder.addType(r,{name:l,schema:u.schema});let d=rQo({type:l,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:Ox(e.availability)}:{}}}function mmE({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=c_c({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=e.nameOverride??e.generatedName;i.builder.addType(r,{name:l,schema:u.schema});let d=rQo({type:l,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{...e.title!=null?{"display-name":e.title}:{},type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:Ox(e.availability)}:{}}}function rQo({type:e,fileContainingReference:t,declarationFile:r,context:i}){if(r===t)return e;let n=i.builder.addImport({file:t,fileToImport:r});return n!=null?`${n}.${e}`:e}function PmE(e){return Fy._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 jmE(e){return Fy._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 Eh_({typeReference:e,itemType:t}){return t.startsWith("optional<")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}function Qdi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:mo(e)}}function qh_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=DmE(e);break;case"array":a=wmE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=SmE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=EmE({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=AmE(e.nameOverride,e.generatedName);break;case"optional":a=Th_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=MmE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=QIa(e,n);break;case"literal":a=qmE(e,e.nameOverride,e.generatedName);break;case"object":a=s_c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=c_c({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:mo(e)}return a}function s_c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(n8.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),u=!1,l={},d=new Set;for(let g of e.properties){if(g.readonly&&(u=!0),a&&g.readonly)continue;if(Object.keys(g.conflict).length>0){if(Object.entries(g.conflict).every(([D,C])=>!C.differentSchema))continue;Object.entries(g.conflict).forEach(([D])=>{l_c({property:g.key,schemaId:D,context:t,namespace:i}).forEach(x=>{d.add(x)})})}let O=Eg({schema:g.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),m=g.audiences,P=g.nameOverride,E=Ox(g.availability),q=ImE(g);l[g.key]=BmE({typeReference:O,audiences:m,name:P,availability:E,propertyAccess:q})}let s=new Set;for(let g of e.allOfPropertyConflicts)g.allOfSchemaIds.forEach(O=>d.add(O)),g.conflictingTypeSignatures&&s.add(g.propertyKey);let o=[];for(let g of e.allOf){let O=Ch_({schema:g.schema,context:t,namespace:i});if(O==null||d.has(g.schema)||d.has(O))continue;let m=Eg({schema:Fy.reference(g),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(_A(m))}for(let g of d){let O=f_c(t,g,i);for(let m of O.properties)l[m.key]==null&&(s.has(m.key)&&(l[m.key]="unknown"),l[m.key]=Eg({schema:m.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let m of O.allOf){if(d.has(m.schema))continue;let P=Eg({schema:Fy.reference(m),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(_A(P))}}let c={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(l).map(([g,O])=>CmE(g)?[g,typeof O=="string"?{type:O,name:`_${g}`}:{...O,name:`_${g}`}]:[g,O]))};o.length>0&&(c.extends=o),e.additionalProperties&&(c["extra-properties"]=!0),e.availability!=null&&(c.availability=Ox(e.availability)),e.source!=null&&(c.source=Qdi(e.source)),c.inline=d_c(e,n);let b=e.nameOverride??e.generatedName;return{name:u&&t.respectReadonlySchemas&&!a?`${b}Read`:b,schema:c}}function l_c({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return l_c({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:u}=f_c(r,t,i),l=a.some(s=>s.key===e),d=[...u.flatMap(s=>l_c({property:e,context:r,schemaId:s.schema,namespace:i}))];if(l||d.length>0)return[t,...d]}return[]}function f_c(e,t,r){let i=e.getSchema(t,r);if(i==null)return{properties:[],allOf:[]};if(i.type==="object")return{properties:i.properties,allOf:i.allOf};if(i.type==="reference")return f_c(e,i.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${i.type}`)}function wmE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:i_c({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function SmE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:n_c({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function DmE(e){let t=eQo(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...i}=t;return{name:e.nameOverride??e.generatedName,schema:{...i}}}function Ah_(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function QIa(e,t){let r={enum:e.values.map(a=>{let u=a.nameOverride??a.generatedName,l=a.value;if(u===l&&a.description==null&&(a.casing==null||Ah_(a.casing)))return u;let d={value:a.value};if(u!==l&&(d.name=u),a.description!=null&&(d.docs=a.description),a.casing!=null&&!Ah_(a.casing)){let s={},o=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,o=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,o=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,o=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,o=!0),o&&(d.casing=s)}return d})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=d_c(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?Qdi(e.source):void 0};for(let a of r.enum){let u=typeof a=="string"?a:a.name??a.value;i.has(u.toLowerCase())||(n.enum.push(a),i.add(u.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function EmE({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:r_c({schema:e,context:t,fileContainingReference:r,namespace:i})}}function MmE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:a_c({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:Th_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function Th_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:tQo({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function AmE(e,t){return{name:e??t,schema:o_c()}}function qmE(e,t,r){return{name:t??r,schema:u_c(e)}}function c_c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?kGo(e.encoding):void 0;if(e.type==="discriminated"){let l={};for(let s of e.commonProperties)l[s.key]=Eg({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let d={};for(let[s,o]of Object.entries(e.schemas))d[s]=Eg({schema:o,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":l,docs:e.description??void 0,availability:e.availability!=null?Ox(e.availability):void 0,union:d,encoding:a,source:e.source!=null?Qdi(e.source):void 0}}}let u=[];for(let l of e.schemas)u.push(Eg({schema:l,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:u,encoding:a,source:e.source!=null?Qdi(e.source):void 0,inline:d_c(e,n)}}}var TmE=/^[0-9]/;function CmE(e){return TmE.test(e)}function Ch_({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?Ch_({context:t,schema:i.schema,namespace:r}):e}function BmE({typeReference:e,audiences:t,name:r,availability:i,propertyAccess:n}){return t.length===0&&r==null&&i==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{},...n!=null?{access:n}:{}}}function d_c(e,t){return e.inline===!0||t>0?!0:void 0}function ImE(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return JN.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return JN.ObjectPropertyAccess.WriteOnly}}function Bh_(e){let t=e.replace(/^x-|^X-/,"");return T_(t)}var Ih_="BasicAuthScheme",iQo="BearerAuthScheme";function zh_(e){if(e.authOverrides!=null){for(let[r,i]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:i});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,i]of Object.entries(e.ir.securitySchemes))if(i.type==="basic"){let n={scheme:"basic"};i.usernameVariableName!=null&&(n.username===void 0?n.username={name:i.usernameVariableName}:n.username.name=i.usernameVariableName),i.usernameEnvVar!=null&&(n.username===void 0?n.username={env:i.usernameEnvVar}:n.username.env=i.usernameEnvVar),i.passwordVariableName!=null&&(n.password===void 0?n.password={name:i.passwordVariableName}:n.password.name=i.passwordVariableName),i.passwordEnvVar!=null&&(n.password===void 0?n.password={env:i.passwordEnvVar}:n.password.env=i.passwordEnvVar),e.builder.addAuthScheme({name:Ih_,schema:n}),t||(e.builder.setAuth(Ih_),t=!0)}else if(i.type==="bearer"){let n={scheme:"bearer"};i.tokenVariableName!=null&&(n.token===void 0?n.token={name:i.tokenVariableName}:n.token.name=i.tokenVariableName),i.tokenEnvVar!=null&&(n.token===void 0?n.token={env:i.tokenEnvVar}:n.token.env=i.tokenEnvVar),e.builder.addAuthScheme({name:iQo,schema:n}),t||(e.builder.setAuth(iQo),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??Bh_(i.headerName),env:i.headerEnvVar}});else{let n={header:i.headerName,name:i.headerVariableName??"apiKey",type:"string"};i.headerEnvVar!=null&&(n.env=i.headerEnvVar),i.prefix!=null&&(n.prefix=i.prefix),e.builder.addAuthScheme({name:r,schema:n}),e.builder.setAuth(r),t=!0}else if(i.type==="oauth"){let n={scheme:"bearer"};e.builder.addAuthScheme({name:iQo,schema:n}),t||(e.builder.setAuth(iQo),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(yy.of("__package__.yml"),{name:"OauthScope",schema:QIa(i.scopesEnum,0).schema})}}function dir({header:e,context:t,fileContainingReference:r,namespace:i}){let n=Eg({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=_A(n),u=e.name.replace(/^x-|^X-/,""),l=e.parameterNameOverride!=null?e.parameterNameOverride:T_(u);if(e.description==null&&e.name===l&&e.env==null&&e.availability==null)return a;let d={type:a};return l!==e.name&&(d.name=l),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=Ox(e.availability)),d}function nQo({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=Eg({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return _A(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:_A(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=Ox(e.availability)),a}function oQo({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=p_c({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=_A(n.value),u=GIa(n.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let l={type:a};return u!=null&&(l.default=u),n.allowMultiple&&(l["allow-multiple"]=!0),e.description!=null&&(l.docs=e.description),e.parameterNameOverride!=null&&(l.name=e.parameterNameOverride),e.availability!=null&&(l.availability=Ox(e.availability)),zmE(n.value)&&n.value.validation!==void 0&&(l.validation=n.value.validation),l.default==null&&l["allow-multiple"]==null&&l.docs==null&&l.name==null&&l.availability==null&&l.validation==null?a:l}function p_c({schema:e,context:t,fileContainingReference:r,namespace:i}){if(e.type==="reference"){let n=t.getSchema(e.schema,i);if(n==null)return;if(n.type==="array")return{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:yy.of(zS),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[],u=!1;for(let[l,d]of Object.entries(n.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(u=!0),d.type==="literal"&&d.value.type==="string"&&(T8n.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:C8n(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),u&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[l,d]=n.value.schemas;if(l!=null&&d!=null&&aQo({array:l,primitive:d}))return{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(l!=null&&d!=null&&aQo({array:l,primitive:d}))return{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:l,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[l,d]of Object.entries(n.value.schemas))return p_c({schema:d,context:t,fileContainingReference:r,namespace:i})}else if(t.objectQueryParameters)return{value:Eg({schema:e,context:t,fileContainingReference:r,declarationFile:yy.of(zS),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let n=t.getSchema(e.value.schema,i);if(n==null)return;if(n.type==="array")return{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:yy.of(zS),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.objectQueryParameters)return{value:Eg({schema:e,context:t,fileContainingReference:r,declarationFile:yy.of(zS),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let n=[],a=!1;for(let[u,l]of Object.entries(e.value.value.schemas))l.type==="primitive"&&l.schema.type==="string"&&(a=!0),l.type==="literal"&&l.value.type==="string"&&(T8n.test(l.value.value)?n.push(l.value.value):n.push({value:l.value.value,name:C8n(l.value.value)}));if(n.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:n}}),a&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[u,l]=e.value.value.schemas;if(u!=null&&l!=null&&aQo({array:u,primitive:l}))return{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:l,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(u!=null&&l!=null&&aQo({array:l,primitive:u}))return{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[u,l]of Object.entries(e.value.value.schemas))return p_c({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:l,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.objectQueryParameters?{value:Eg({schema:e,context:t,fileContainingReference:r,declarationFile:yy.of(zS),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:Eg({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:Eg({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function aQo({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function zmE(e){return e.type!=null}function xh_({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"]=xmE(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=RmE({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=IMi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function xmE(e){let t={};return e.forEach(r=>{let i=IMi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function RmE({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=IMi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function IMi(e){switch(e.type){case"primitive":return Rh_(e.value);case"object":return Nh_(e.properties);case"array":return NmE(e.value);case"map":return FmE(e.value);case"oneOf":return LmE(e.value);case"enum":return e.value;case"literal":return UmE(e.value);case"unknown":return IMi(e.value);default:mo(e)}}function Rh_(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:mo(e)}}function Nh_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,IMi(r)]))}function NmE(e){return e.map(t=>IMi(t))}function FmE(e){return Object.fromEntries(e.map(t=>[Rh_(t.key),IMi(t.value)]))}function LmE(e){return e.type==="discriminated"?Nh_(e.value):IMi(e.value)}function UmE(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:mo(e)}}function Jdi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function uQo(e,t){return t??(e?.groupName!=null?Jdi(e.groupName):void 0)}function Fh_({channel:e,context:t,declarationFile:r}){let i={path:e.path,url:e.servers[0]?.name,auth:!1};e.audiences!=null&&e.audiences.length>0&&(i.audiences=e.audiences),e.summary!=null&&(i["display-name"]=e.summary),e.description!=null&&(i.docs=e.description);let n=Jdi(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=nQo({pathParameter:d,context:t,fileContainingReference:r,namespace:n});Object.keys(a).length>0&&(i["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let s=oQo({queryParameter:d,context:t,fileContainingReference:r,namespace:n});s!=null&&(u[d.name]=s)}Object.keys(u).length>0&&(i["query-parameters"]=u);let l={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let s=dir({header:d,context:t,fileContainingReference:r,namespace:n});l[d.name]=s}Object.keys(l).length>0&&(i.headers=l),t.builder.addChannel(r,{channel:i});for(let d of e.messages)t.builder.addChannelMessage(r,{messageId:d.name,message:{origin:d.origin,body:Eg({schema:d.body,context:t,fileContainingReference:r,namespace:n,declarationDepth:0})}});for(let d of e.examples){let s=xh_({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:s})}}var Kdi="Base",VmE="Default";function zMi(e){return Object.entries(e).reduce((t,[r,i])=>(GRn(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function Lh_(e){if(e.environmentOverrides!=null){for(let[g,O]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:g,schema:O});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[];for(let g of e.ir.servers){let O=g.audiences?{url:g.url,audiences:g.audiences}:g.url;if(g.name==null){r.push(O);continue}t[g.name]=O}let i={},n=[];for(let g of e.ir.endpoints)for(let O of g.servers){if(O.url==null)continue;let m=O.audiences?{url:O.url,audiences:O.audiences}:O.url;if(O.name==null){n.push(m);continue}i[O.name]=m}let a={},u=[];for(let g of e.ir.websocketServers){let O=g.audiences?{url:g.url,audiences:g.audiences}:g.url;if(g.name==null){u.push(O);continue}a[g.name]=O}let l=Object.keys(t).length,d=l>0,s=Object.keys(i).length>0,o=Object.keys(a).length>0;if(!d&&!s&&o&&e.ir.servers.length===0){for(let[g,O]of Object.entries(a))e.builder.addEnvironment({name:g,schema:O});e.builder.setDefaultEnvironment(Object.keys(a)[0]),e.builder.setDefaultUrl(Kdi);return}if(n.length>0&&e.logger.error(`Skipping endpoint level servers ${n.map(g=>typeof g=="string"?g:g.url).join(", ")} because x-fern-server-name was not provided.`),!d){let g=e.ir.servers[0]?.url,O=e.ir.servers[0]?.audiences;if(g!=null){let m=O?{url:g,audiences:O}:g;t[VmE]=m}}let c=Object.values(t).map(g=>typeof g=="string"?g:g.url),b=r.filter(g=>{let O=typeof g=="string"?g:g.url;return!c.includes(O)});if(b.length>0&&e.logger.error(`Skipping top level servers ${b.map(g=>typeof g=="string"?g:g.url).join(", ")} because x-fern-server-name was not provided.`),s)if(l===1){let g=Object.keys(t)[0],O=Object.values(t)[0],m=typeof O=="string"?O:O.url;e.builder.addEnvironment({name:g,schema:{urls:{[Kdi]:m,...zMi(i),...zMi(a)}}}),e.builder.setDefaultEnvironment(g),e.builder.setDefaultUrl(Kdi)}else{let g=!0;for(let[O,m]of Object.entries(t))g?(e.builder.addEnvironment({name:O,schema:{urls:{[Kdi]:typeof m=="string"?m:m.url,...zMi(i),...zMi(a)}}}),e.builder.setDefaultEnvironment(O),g=!1):e.builder.addEnvironment({name:O,schema:{urls:{[Kdi]:typeof m=="string"?m:m.url,...zMi(i),...zMi(a)}}});e.builder.setDefaultUrl(Kdi)}else{let g=!0;for(let[O,m]of Object.entries(t))g?(o?e.builder.addEnvironment({name:O,schema:{urls:{[Kdi]:typeof m=="string"?m:m.url,...zMi(a)}}}):e.builder.addEnvironment({name:O,schema:m}),e.builder.setDefaultEnvironment(O),g=!1):o?e.builder.addEnvironment({name:O,schema:{urls:{[Kdi]:typeof m=="string"?m:m.url,...zMi(a)}}}):e.builder.addEnvironment({name:O,schema:m});o&&e.builder.setDefaultUrl(Kdi)}}function sQo(e){return _A(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var __c=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},WmE=.75,HmE=new Set("authorization");function Uh_(e){if(e.globalHeaderOverrides!=null){for(let[r,i]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:i});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,i]of Object.entries(t)){let n="optional<string>";if(i.name==null&&i.env==null&&typeof i.schema=="string")n=i.schema;else if(i!=null){let a=i.schema?B8n(i.schema):void 0,u=a!=null?Jdi(a):void 0,l=yy.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?_A(Eg({schema:i.schema,context:e,fileContainingReference:u?WN(yy.of(T_(u)),l):l,namespace:u,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(HmE.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let l=t[a.name],d=dir({header:{...a,schema:l?.schema??a.schema,name:l?.name??a.name},fileContainingReference:yy.of(i3),context:e,namespace:void 0});u=new __c(d),r[a.name]=u}u.increment()}let i=e.ir.endpoints.length*WmE;for(let[n,a]of Object.entries(r)){let u=t[n],l=a.count===e.ir.endpoints.length,d=a.count>=i;u==null&&(l?e.builder.addGlobalHeader({name:n,schema:a.schema}):d&&e.builder.addGlobalHeader({name:n,schema:sQo(a.schema)}))}}}function Vh_(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?B8n(t.schema):void 0,i=r!=null?Jdi(r):void 0,n=dir({header:{...t,schema:t.schema??Fy.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:Xj.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:yy.of(i3),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:sQo(n)})}}function dJ(e){switch(e.type){case"primitive":return Hh_(e.value);case"object":return $h_(e.properties);case"array":return Gh_(e.value);case"map":return GmE(e.value);case"oneOf":return QmE(e.value);case"enum":return e.value;case"literal":return JmE(e.value);case"unknown":return dJ(e.value);default:mo(e)}}function Wh_(e){switch(e.type){case"withStreaming":return e.sse?{stream:$mE(e.events)}:{stream:Gh_(e.events)};case"withoutStreaming":return{body:dJ(e.value)};default:mo(e)}}function Hh_(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:mo(e)}}function $h_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,dJ(r)]))}function $mE(e){return e.map(t=>({event:"",data:dJ(t)}))}function Gh_(e){return e.map(t=>dJ(t))}function GmE(e){return Object.fromEntries(e.map(t=>[Hh_(t.key),dJ(t.value)]))}function QmE(e){return e.type==="discriminated"?$h_(e.value):dJ(e.value)}function JmE(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:mo(e)}}function Qh_({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"]=KmE(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=YmE(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=XmE({context:t,namedFullExamples:e.headers})),e.request!=null&&(r.request=dJ(e.request)),e.response!=null&&(r.response=Wh_(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(i=>i.type==="language"?{name:i.name??void 0,docs:i.description??void 0,language:i.language,code:i.code,install:i.install??void 0}:{name:i.name??void 0,docs:i.description??void 0,sdk:i.sdk,code:i.code}).filter(V0)),r)}function KmE(e){let t={};return e.forEach(r=>{let i=dJ(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function YmE(e){let t={};return e.forEach(r=>{let i=dJ(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function XmE({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=dJ(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function Jh_(e){return rH._visit(e,{get:()=>JN.HttpMethodSchema.Get,post:()=>JN.HttpMethodSchema.Post,put:()=>JN.HttpMethodSchema.Put,patch:()=>JN.HttpMethodSchema.Patch,delete:()=>JN.HttpMethodSchema.Delete,head:()=>JN.HttpMethodSchema.Head,options:()=>{throw new Error("OPTIONS is unsupported")},trace:()=>{throw new Error("TRACE is unsupported")},_other:()=>{throw new Error("Unknown http method is unsupported")}})}function Kh_(e){return e==="POST"||e==="PUT"||e==="PATCH"}function Yh_({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,u=e.path,l=uQo(e.sdkName,e.namespace),d={};for(let P of e.pathParameters)P.parameterNameOverride&&(u=u.replace(P.name,P.parameterNameOverride)),d[P.parameterNameOverride??P.name]=nQo({pathParameter:P,context:r,fileContainingReference:t,namespace:l}),a.add(P.name);let s={};for(let P of e.queryParameters){let E=oQo({queryParameter:P,context:r,fileContainingReference:t,namespace:l});E!=null&&(s[P.name]=E,a.add(P.name))}let o;if(e.pagination!=null)switch(e.pagination.type){case"cursor":o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":o={type:"custom",results:e.pagination.results};break;default:mo(e.pagination)}let c={path:u,method:Jh_(e.method),auth:e.authed,docs:e.description??void 0,pagination:o,source:e.source!=null?Qdi(e.source):void 0};!ePE({context:r,request:e.request})&&Object.keys(d).length>0&&(c["path-parameters"]=d),e.summary!=null&&(c["display-name"]=e.summary);let b={},g=r.builder.getGlobalHeaderNames(),O=r.builder.getAuthHeaderName();O!=null&&g.add(O);let m=e.headers.filter(P=>!g.has(P.name));for(let P of m){let E=dir({header:P,context:r,fileContainingReference:t,namespace:l});b[P.name]=E,a.add(typeof E=="string"?P.name:E.name??P.name)}if(e.request!=null){r.setInState(n8.Request);let P=kmE({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.inlinePathParameters&&Object.keys(d).length>0?d:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(i),headers:Object.keys(b).length>0?b:void 0,usedNames:a,namespace:l});c.request=P.value,n=[...n,...P.schemaIdsToExclude??[]],r.unsetInState(n8.Request)}else{let P=r.inlinePathParameters&&Object.keys(d).length>0,E=Object.keys(s).length>0,q=Object.keys(b).length>0,M={};(P||E||q)&&(M.name=e.requestNameOverride??e.generatedRequestName),P&&(M["path-parameters"]=d),E&&(M["query-parameters"]=s),q&&(M.headers=b),Object.keys(M).length>0&&(c.request=M)}if(e.response!=null&&e.response._visit({json:P=>{let E=Eg({schema:P.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c.response={docs:P.description??void 0,type:_A(E)},P.statusCode!=null&&(c.response["status-code"]=P.statusCode),P.responseProperty!=null&&(c.response.property=P.responseProperty)},streamingJson:P=>{let E=Eg({schema:P.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c["response-stream"]={docs:P.description??void 0,type:_A(E),format:"json"}},streamingSse:P=>{let E=Eg({schema:P.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c["response-stream"]={docs:P.description??void 0,type:_A(E),format:"sse"}},file:P=>{c.response={docs:P.description??void 0,type:"file","status-code":P.statusCode}},bytes:P=>{c.response={docs:P.description??void 0,type:"bytes","status-code":P.statusCode}},streamingText:P=>{c["response-stream"]={docs:P.description??void 0,type:"text"}},text:P=>{c.response={docs:P.description??void 0,type:"text","status-code":P.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let P=r.getDefaultServerName(),E=e.servers[0];E==null?P!=null&&(c.url=P):c.url=E.name??void 0}return e.idempotent&&(c.idempotent=!0),e.availability!=null&&(c.availability=Ox(e.availability)),Object.entries(e.errors).forEach(([P,E])=>{let q=E.generatedName,M=yy.of(zS);r.builder.enableUniqueErrorsPerEndpoint&&(q=`${e.generatedRequestName}${E.generatedName}`,E.schema!=null&&(E.schema.type!=="reference"&&E.schema.type!=="oneOf"?E.schema.generatedName=`${e.generatedRequestName}${E.schema.generatedName}`:E.schema.type==="oneOf"&&(E.schema.value.generatedName=`${e.generatedRequestName}${E.schema.value.generatedName}`)));let D={"status-code":parseInt(P)},C=Dh_({location:Xh_,namespaceOverride:l});if(E.schema!=null){let I=Eg({schema:E.schema,context:r,fileContainingReference:C,declarationFile:C,namespace:l,declarationDepth:0});D.type=_A(I),D.docs=E.description}r.builder.addError(C,{name:q,schema:r.isErrorUnknownSchema(parseInt(P))?{...D,type:"unknown"}:D}),c.errors==null&&(c.errors=[]);let x=r.builder.addImport({file:t,fileToImport:C});c.errors.push(x!=null?`${x}.${q}`:q),D.type!=null&&E.examples?.forEach(I=>{let L={value:dJ(I.example),name:I.name,docs:I.description};r.builder.addErrorExample(C,{name:q,example:L})})}),e.examples.length>0&&(c.examples=ZmE({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?c.audiences=[h_c,...e.audiences]:e.audiences.length>0&&(c.audiences=e.audiences),{value:c,schemaIdsToExclude:n}}function ZmE({endpointExamples:e,context:t}){return e.map(r=>{try{return Qh_({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function kmE({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:u,queryParameters:l,nonRequestReferencedSchemas:d,headers:s,usedNames:o,namespace:c}){if(i.type==="json"){let b=i.schema.type==="reference"?i.schema.schema:void 0,g=i.schema.type==="reference"?r.getSchema(i.schema.schema,c):i.schema;if(g?.type!=="object"||b!=null&&d.includes(b)){let q=Eg({schema:i.schema,fileContainingReference:t,context:r,namespace:c,declarationDepth:0}),M={schemaIdsToExclude:[],value:{body:q}},D=Object.keys(u??{}).length>0,C=Object.keys(l??{}).length>0,x=Object.keys(s??{}).length>0;return D&&(M.value["path-parameters"]=u),C&&(M.value["query-parameters"]=l),x&&(M.value.headers=s),(D||C||x)&&(M.value.name=n??a),i.contentType!=null&&(M.value["content-type"]=i.contentType),i.description!=null&&(M.value.docs=i.description),M}let O=Object.fromEntries(g.properties.filter(q=>q.readonly==null?!0:!(Kh_(e.method)&&q.readonly)).map(q=>{let M=Eg({schema:q.schema,fileContainingReference:t,context:r,namespace:c,declarationDepth:1}),D=q.nameOverride??q.key,C=Ox(q.availability);if(!o.has(D)&&q.audiences.length<=0)return o.add(D),q.nameOverride!=null?[q.key,{type:_A(M),docs:I8n(M),name:q.nameOverride,availability:C}]:[q.key,C?{...typeof M=="string"?{type:M}:M,availability:C}:M];let x={type:_A(M),docs:I8n(M)};return o.has(D)&&(x.name=q.generatedName),q.audiences.length>0&&(x.audiences=q.audiences),C!=null&&(x.availability=C),o.add(D),[q.key,x]})),m=g.allOf.map(q=>{let M=Eg({schema:Fy.reference(q),fileContainingReference:t,context:r,namespace:c,declarationDepth:0});return _A(M)}).filter(q=>q!=="unknown"),P={properties:O};m.length>0&&(P.extends=m),i.additionalProperties&&(P["extra-properties"]=!0);let E={name:n??g.nameOverride??g.generatedName,"path-parameters":u,"query-parameters":l,headers:s,body:P};return i.contentType!=null&&(E["content-type"]=i.contentType),i.description!=null&&(E.docs=i.description),{schemaIdsToExclude:b!=null?[b]:[],value:E}}else{if(i.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":mM.APPLICATION_OCTET_STREAM,...i.description?{docs:i.description}:{}}};if(i.type==="multipart"){let b=Object.fromEntries(i.properties.map(g=>{if(g.schema.type==="file"){let O=g.schema.isArray?"list<file>":"file";if(O=g.schema.isOptional?`optional<${O}>`:O,g.description!=null||g.contentType!=null){let m={type:O};if(g.description!=null&&(m.docs=g.description),g.contentType!=null){let P=g.contentType.split(",")[0];m["content-type"]=P}return[g.key,m]}return[g.key,O]}else{let O=Eg({schema:g.schema.value,fileContainingReference:t,context:r,namespace:c,declarationDepth:1});if(g.contentType!=null||g.exploded||g.encoding==="form"){let m=typeof O=="string"?{type:O}:O;g.contentType!=null&&(m["content-type"]=g.contentType),g.encoding==="form"?m.style="form":g.exploded&&(m.style="exploded"),O=m}return[g.key,O]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":u,"query-parameters":l,headers:s,body:{properties:b},"content-type":mM.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else mo(i)}}function ePE({context:e,request:t}){if(!e.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;default:mo(t)}}function tPE({location:e,namespaceOverride:t}){return t!=null?{...e,file:WN(yy.of(t),e.file)}:e}function rPE(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:yy.of(`${T_(r)}.yml`),endpointId:e.summary!=null?T_(e.summary):T_(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:yy.of(zS),endpointId:T_(e.summary)}:{file:yy.of(zS),endpointId:T_(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:yy.of(zS),endpointId:i};let n=JIa(r),a=JIa(i);if(OEe(n,a))return{file:yy.of("__package__.yml"),endpointId:r};let u=aPE({operationId:i,tag:r,path:e.path,method:e.method});if(u!=null)return u;let l=[];for(let d=0;d<n.length;++d){let s=n[d];if(s!=null&&s===a[d])l.push(s);else{let o=T_(r);return{file:yy.of(`${o}.yml`),endpointId:i,tag:r}}}if(l.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:yy.of(T_(l.join("_"))+".yml"),endpointId:T_(a.slice(l.length).join("_")),tag:r}}function KIa(e){let t=e.tags[0];if(e.sdkName!=null){let r=kpc({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:yy.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return tPE({namespaceOverride:e.namespace,location:rPE(e)})}function JIa(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=Sxe(t),t}var iPE=new RegExp("[^a-zA-Z0-9{}]+"),nPE=new RegExp("[{}]","g");function aPE({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(iPE).join("_").replaceAll(nPE,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:yy.of(T_(t)+".yml"),endpointId:T_(e.slice(0,-1*a.length)),tag:t}}function Zh_(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:u,file:l,tag:d}=KIa(a),s=l.split(".")[0];s!=null&&t.add(s);let o;if(a.sdkName!=null){let g=e.ir.groups;for(let O of a.sdkName.groupName){let m=typeof O=="string"?O:O.name,P=g[m];if(P==null)break;if(P.summary!=null||P.description!=null){o=g[m];break}}}let c=d==null?void 0:i.tagsById[d];e.setInState(n8.Endpoint),e.setEndpointMethod(a.method);let b=Yh_({context:e,endpoint:a,declarationFile:l});e.unsetEndpointMethod(),e.unsetInState(n8.Endpoint),n=[...n,...b.schemaIdsToExclude],e.builder.addEndpoint(l,{name:u,schema:b.value,source:a.source!=null?Qdi(a.source):void 0}),(c?.id!=null||c?.description!=null)&&e.builder.setServiceInfo(l,{"display-name":o?.summary??c?.id,docs:o?.description??c?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function kh_(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?Jdi(r.groupName):void 0,n=Eg({schema:Fy.primitive(r),context:e,fileContainingReference:yy.of(zS),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:_A(n),docs:r.description??void 0}})}}function ey_(e){for(let t of e.ir.webhooks){let r=sPE({webhook:t,context:e});if(r==null)continue;let i=uQo(t.sdkName,t.namespace),n={};for(let u of t.headers)n[u.name]=dir({header:u,context:e,fileContainingReference:r.file,namespace:i});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:n,payload:Eg({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:dJ(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function oPE({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:WN(yy.of(t),e.file)}:e}function uPE({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:yy.of(zS),endpointId:i};let n=JIa(r),a=JIa(i);if(OEe(n,a))return{file:yy.of("__package__.yml"),endpointId:r};let u=[];for(let l=0;l<n.length;++l){let d=n[l];if(d!=null&&d===a[l])u.push(d);else{let s=T_(r);return{file:yy.of(`${s}.yml`),endpointId:i,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:yy.of(T_(u.join("_"))+".yml"),endpointId:T_(a.slice(u.length).join("_")),tag:r}}function sPE({webhook:e,context:t}){return e.sdkName!=null?{file:Sh_({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:oPE({namespaceOverride:e.namespace,location:uPE({webhook:e,context:t})})}var cPE=yy.of(zS);function ry_(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return ty_({namespace:e.namespace,groupName:e.groupName});case"oneOf":return ty_({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return cPE;default:mo(e)}}function ty_({namespace:e,groupName:t}){return e!=null&&t!=null?BMi([{type:"namespace",name:e},...t]):e!=null?BMi([{type:"namespace",name:e}]):BMi(t)}var h_c="external",Xh_=yy.of(zS);function iy_({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let u=ry_(a),l=qh_({schema:a,context:i,declarationFile:u,namespace:r,declarationDepth:0});if(_Si(l.schema)){let d=_A(l.schema);if(d===(l.name??n)||d===`optional<${l.name??n}>`)continue}i.builder.addType(u,{name:l.name??n,schema:l.schema})}}function ny_(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),Lh_(e),Uh_(e),Vh_(e),zh_(e),kh_(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(h_c);let t=Zh_(e),r=t.sdkGroups;e.setInState(n8.Webhook),ey_(e),e.unsetInState(n8.Webhook),e.setInState(n8.Channel);for(let n of Object.values(e.ir.channels)){let a=BMi(n.groupName);Fh_({channel:n,context:e,declarationFile:a})}e.unsetInState(n8.Channel);let i=lPE({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});iy_({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))iy_({schemas:a,schemaIdsToExclude:i,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}function lPE({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}function y_c(e){let t=new ZGo(e);return ny_(t)}var Ydi={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!1,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1};function v_c({options:e,overrides:t}){return{enableUniqueErrorsPerEndpoint:t?.enableUniqueErrorsPerEndpoint??e?.enableUniqueErrorsPerEndpoint??Ydi.enableUniqueErrorsPerEndpoint,detectGlobalHeaders:t?.detectGlobalHeaders??e?.detectGlobalHeaders??Ydi.detectGlobalHeaders,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??Ydi.objectQueryParameters,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??Ydi.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??Ydi.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??Ydi.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??Ydi.inlinePathParameters,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??Ydi.useBytesForBinaryResponse,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??Ydi.respectForwardCompatibleEnums}}var cQo=class{args;constructor(t){this.args=t}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=y_c({taskContext:t,ir:r,options:v_c({overrides:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.args.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.args.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.args.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.args.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.args.objectQueryParameters,useBytesForBinaryResponse:i?.useBytesForBinaryResponse??this.args.useBytesForBinaryResponse,respectForwardCompatibleEnums:i?.respectForwardCompatibleEnums??this.args.respectForwardCompatibleEnums}}),authOverrides:i?.auth!=null?{auth:i.auth}:this.args.generatorsConfiguration?.api?.auth!=null?{...this.args.generatorsConfiguration.api}:void 0,environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:n??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:qd.dump(a.rootApiFile)},namedDefinitionFiles:{...dd(a.definitionFiles,u=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:qd.dump(u),contents:u})),[yy.of(zS)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:qd.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var YIa=class extends sHt{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;converter;constructor(t){super(t),this.inlinePathParameters=t.inlinePathParameters,this.objectQueryParameters=t.objectQueryParameters,this.onlyIncludeReferencedSchemas=t.onlyIncludeReferencedSchemas,this.respectReadonlySchemas=t.respectReadonlySchemas,this.respectNullableSchemas=t.respectNullableSchemas,this.exampleGeneration=t.exampleGeneration,this.useBytesForBinaryResponse=t.useBytesForBinaryResponse,this.respectForwardCompatibleEnums=t.respectForwardCompatibleEnums,this.converter=new cQo(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:i},n){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:i},n);return this.converter.convert({context:t,ir:a,settings:n,absoluteFilePath:r})}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new DMe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion})}};function z8n(e){if(e.settings==null&&e.raw?.api?.auth==null)return;let t={detectGlobalHeaders:!0};return e.settings?.unions==="v1"&&(t.discriminatedUnionV2=!0),e.raw?.api?.auth!=null&&(t.auth=e.raw?.api?.auth),t}var a1_=ci(lYo(),1);var cH={BEARER_FORMAT:"x-bearer-format",ENUM_VAR_NAMES:"x-enum-varnames",INTERNAL:"x-internal",EXAMPLES:"x-examples",TAGS:"x-tags",REDOCLY_CODE_SAMPLES_KEBAB:"x-code-samples",REDOCLY_CODE_SAMPLES_CAMEL:"x-codeSamples"};var D5n={of(e){return e}};var qj_={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},u0c={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:qj_,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},id={SOURCE:D5n.of("source"),SDK_NAMESPACE:D5n.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:D5n.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:D5n.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:D5n.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport"};var a4={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!0,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,preserveSchemaIds:!1,objectQueryParameters:!1,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!1,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!0};function s0c({options:e,overrides:t}){return{disableExamples:t?.disableExamples??a4.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.discriminatedUnionV2??a4.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.useTitlesAsName??a4.useTitlesAsName,audiences:t?.audiences??e?.audiences??a4.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??a4.optionalAdditionalProperties,coerceEnumsToLiterals:t?.coerceEnumsToLiterals??e?.coerceEnumsToLiterals??a4.coerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??a4.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??a4.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??a4.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??a4.inlinePathParameters,preserveSchemaIds:t?.preserveSchemaIds??a4.preserveSchemaIds,shouldUseUndiscriminatedUnionsWithLiterals:t?.shouldUseUndiscriminatedUnionsWithLiterals??e?.shouldUseUndiscriminatedUnionsWithLiterals??a4.shouldUseUndiscriminatedUnionsWithLiterals,shouldUseIdiomaticRequestNames:t?.shouldUseIdiomaticRequestNames??e?.shouldUseIdiomaticRequestNames??a4.shouldUseIdiomaticRequestNames,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??a4.objectQueryParameters,filter:t?.filter??e?.filter??a4.filter,asyncApiNaming:t?.asyncApiNaming??e?.asyncApiNaming??a4.asyncApiNaming,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??a4.useBytesForBinaryResponse,exampleGeneration:t?.exampleGeneration??e?.exampleGeneration??void 0,defaultFormParameterEncoding:t?.defaultFormParameterEncoding??e?.defaultFormParameterEncoding??void 0,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??a4.respectForwardCompatibleEnums,additionalPropertiesDefaultsTo:t?.additionalPropertiesDefaultsTo??e?.additionalPropertiesDefaultsTo??a4.additionalPropertiesDefaultsTo,typeDatesAsStrings:t?.typeDatesAsStrings??e?.typeDatesAsStrings??a4.typeDatesAsStrings}}var Tj_={naming:"v1"};function hf(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function Yza(e,t,r,i,n=[]){try{let a=hf(e,t);if(a!=null)return r.parse(a)}catch{let u=Sxe(n).join(" -> ");i.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}function JJi(e){let t=hf(e,"examples");return t!=null&&Array.isArray(t)?t:[]}function Cj_({schema:e,logger:t}){return hf(e,id.ENCODING)??void 0}function Bj_(e){return hf(e,id.FERN_ENUM)}function Ij_({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let u=hf(i,id.SDK_NAMESPACE),l=hf(i,id.SDK_GROUP_NAME),d=hf(i,id.TYPE_DEFINITION);if(d!=null)return Xza({fernType:d,nameOverride:e,generatedName:t,title:r,description:n,availability:a,namespace:u,groupName:typeof l=="string"?[l]:l})}function Xza({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l}){return G2({type:e,_default:void 0,validation:void 0,visitor:{primitive:d=>{switch(d.v1){case"BASE_64":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.base64({example:void 0})});case"BOOLEAN":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.boolean({default:void 0,example:void 0})});case"DATE":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.date({example:void 0})});case"DATE_TIME":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.datetime({example:void 0})});case"FLOAT":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.float({example:void 0})});case"DOUBLE":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.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 zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.uint({default:void 0,example:void 0})});case"INTEGER":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.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 zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.uint64({default:void 0,example:void 0})});case"LONG":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:mo(d.v1)}},unknown:()=>zl.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,namespace:u,groupName:l}),map:({keyType:d,valueType:s})=>d?.type==="primitive"&&s!=null?zl.map({nameOverride:t,generatedName:r,title:i,key:d,value:s,description:n,availability:a,namespace:u,groupName:l,encoding:void 0,example:void 0,inline:void 0}):void 0,list:d=>d!=null?zl.array({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:l,example:void 0,inline:void 0}):void 0,optional:d=>d!=null?zl.optional({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:l,inline:void 0}):void 0,nullable:d=>d!=null?zl.nullable({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:l,inline:void 0}):void 0,set:d=>d!=null?zl.array({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:l,example:void 0,inline:void 0}):void 0,literal:d=>zl.literal({nameOverride:t,generatedName:r,title:i,value:d._visit({string:s=>vz.string(s),boolean:s=>vz.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,namespace:u,groupName:l}),named:()=>{}}})}function zj_(e){let t=hf(e,id.SOURCE);if(t!=null)return t.endsWith(".proto")?Gae.protobuf({file:t}):Gae.openapi({file:t})}function KJi(e){if(e!=null&&typeof e=="boolean")return e}function sp(e){return e.$ref!=null}function xj_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:u,wrapAsNullable:l,context:d,namespace:s,groupName:o,example:c,encoding:b,source:g}){return n===void 0&&(n=d.options.additionalPropertiesDefaultsTo),typeof n=="boolean"||E5n(n,d.options)?fYo({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:up.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:zl.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:void 0,groupName:void 0}),namespace:s,groupName:o,example:c,encoding:b}):fYo({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:up.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:Rj_(t0(n,d.options.optionalAdditionalProperties?l:!1,d,[...i,"Value"],g,s,void 0,void 0,void 0)),namespace:s,groupName:o,example:c,encoding:b})}function Rj_(e){switch(e.type){case"array":case"enum":case"map":case"object":e.inline=!0;break;case"literal":case"primitive":case"reference":case"unknown":break;case"nullable":case"optional":e.inline=!0,e.value=Rj_(e.value);break;case"oneOf":e.value.inline=!0;break;default:mo(e)}return e}function fYo({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsNullable:a,description:u,availability:l,namespace:d,groupName:s,example:o,encoding:c}){return a?zl.nullable({nameOverride:e,generatedName:t,title:r,value:zl.map({nameOverride:e,generatedName:t,title:r,description:u,availability:i.availability,key:i,value:n,namespace:d,groupName:s,encoding:c,example:o,inline:void 0}),description:u,availability:l,namespace:d,groupName:s,inline:void 0}):zl.map({nameOverride:e,generatedName:t,title:r,description:u,availability:l,key:i,value:n,namespace:d,groupName:s,encoding:c,example:o,inline:void 0})}function E5n(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:!sp(e)&&Object.keys(e).length===0}function Nj_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:u,wrapAsNullable:l,context:d,namespace:s,groupName:o,example:c,source:b}){let g=n==null?zl.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:s,groupName:o}):t0(n,!1,d,[...i,"Item"],b,s);return s4E({nameOverride:e,generatedName:t,title:r,namespace:s,groupName:o,itemSchema:g,wrapAsNullable:l,description:a,availability:u,example:c})}function s4E({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsNullable:n,description:a,availability:u,namespace:l,groupName:d,example:s}){return n?zl.nullable({nameOverride:e,generatedName:t,title:r,value:zl.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,namespace:l,groupName:d,example:s,inline:void 0}),description:a,availability:u,namespace:l,groupName:d,inline:void 0}):zl.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,namespace:l,groupName:d,example:s,inline:void 0})}function vJ(e){switch(hf(e,id.AVAILABILITY)){case"deprecated":return eH.Deprecated;case"beta":return eH.Beta;case"generally-available":return eH.GenerallyAvailable;default:break}if(!sp(e)&&e.deprecated)return eH.Deprecated}function c0c({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:l,wrapAsNullable:d,discriminator:s,context:o,namespace:c,groupName:b,encoding:g,source:O}){let m=s.propertyName,P=Object.fromEntries(Object.entries(s.mapping??{}).map(([q,M])=>{let D=upi({$ref:M},!1,o,[M],g,O,c);return o.markReferencedByDiscriminatedUnion({$ref:M},m,1),[q,D]})),E=Object.entries(n).filter(([q])=>q!==m).map(([q,M])=>{let D=l!=null&&l.includes(q),C=t0(M,!D,o,[...i,q],O,c);return{key:q,schema:C}});return Fj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:E,description:a,availability:u,discriminant:m,subtypes:P,namespace:c,groupName:b,source:O})}function l0c({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:l,wrapAsNullable:d,discriminant:s,variants:o,context:c,namespace:b,groupName:g,encoding:O,source:m}){let P=Object.fromEntries(Object.entries(o).map(([q,M])=>{if(sp(M)){let D=upi(M,!1,c,[M.$ref],O,m,b);return c.markReferencedByDiscriminatedUnion(M,s,1),[q,D]}else{let D=M5n(M,!1,c,[...i,q],O,m,b,new Set([s]));return[q,D]}})),E=Object.entries(n).filter(([q])=>q!==s).map(([q,M])=>{let D=l!=null&&l.includes(q),C=t0(M,!D,c,[...i,q],m,b);return{key:q,schema:C}});return Fj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:E,description:a,availability:u,discriminant:s,subtypes:P,namespace:b,groupName:g,source:m})}function Fj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,availability:u,discriminant:l,subtypes:d,namespace:s,groupName:o,source:c}){return i?zl.nullable({nameOverride:e,generatedName:t,title:r,value:zl.oneOf(ik.discriminated({description:a,availability:u,discriminantProperty:l,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:n,namespace:s,groupName:o,encoding:void 0,source:c,inline:void 0})),namespace:s,groupName:o,description:a,availability:u,inline:void 0}):zl.oneOf(ik.discriminated({description:a,availability:u,discriminantProperty:l,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:n,namespace:s,groupName:o,encoding:void 0,source:c,inline:void 0}))}function Lj_(e){if(e.proto!=null)return r8n.protobuf({typeName:e.proto.type})}function oAi({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:u,description:l,availability:d,wrapAsNullable:s,namespace:o,groupName:c,context:b,source:g,inline:O}){let m=l4E(n??[]),P=new Set(a),E=Array.from(P).map((M,D)=>{let C=i?.[M],x=m[D],$=T8n.test(M),I=C?.name??x,L=$?M:C8n(M);return I!=null&&!T8n.test(I)&&(b?.logger.warn(`Enum name override ${I} is not a valid name. Falling back on ${L}.`),I=void 0),{nameOverride:I,generatedName:L,value:M,description:C?.description,availability:d,casing:{snake:C?.casing?.snake??void 0,pascal:C?.casing?.pascal??void 0,screamingSnake:C?.casing?.screamingSnake??void 0,camel:C?.casing?.camel??void 0}}}),q=u!=null?E.find(M=>M.value===u):void 0;return c4E({wrapAsNullable:s,nameOverride:e,generatedName:t,title:r,values:E,_default:q,description:l,availability:d,namespace:o,groupName:c,source:g,inline:O})}function c4E({wrapAsNullable:e,nameOverride:t,generatedName:r,title:i,values:n,_default:a,description:u,availability:l,namespace:d,groupName:s,source:o,inline:c}){return e?zl.nullable({nameOverride:t,generatedName:r,title:i,value:zl.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,default:a,availability:l,example:void 0,namespace:d,groupName:s,source:o,inline:c}),description:u,availability:l,namespace:d,groupName:s,inline:c}):zl.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,availability:l,default:a,example:void 0,namespace:d,groupName:s,source:o,inline:c})}function l4E(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(i=>i[r]===t[r]);)r++;return e.map(i=>i.substring(r))}function Uj_({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,description:o,availability:c,wrapAsNullable:b,example:g,namespace:O,groupName:m}){return i==="int64"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="uint32"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="uint64"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):u8({nameOverride:e,generatedName:t,title:r,primitive:up.int({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m})}function Vj_(e){return typeof e=="string"?vz.string(e):typeof e=="boolean"?vz.boolean(e):vz.string(`${e}`)}function Wj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,value:n,description:a,availability:u,namespace:l,groupName:d}){return i?zl.nullable({nameOverride:e,generatedName:t,title:r,value:zl.literal({nameOverride:e,generatedName:t,title:r,value:Vj_(n),description:a,availability:u,namespace:l,groupName:d}),description:a,availability:u,namespace:l,groupName:d,inline:void 0}):zl.literal({nameOverride:e,generatedName:t,title:r,value:Vj_(n),description:a,availability:u,namespace:l,groupName:d})}function f0c({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,description:o,availability:c,wrapAsNullable:b,example:g,namespace:O,groupName:m}){return i==null||i==="double"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.double({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="float"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.float({example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="int32"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.int({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="int64"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="uint32"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="uint64"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="time-delta"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.float({example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):u8({nameOverride:e,generatedName:t,title:r,primitive:up.float({example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m})}var f4E={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},d4E={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}}},p4E={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}}},_4E={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},h4E={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},y4E={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},v4E={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},b4E={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function dYo(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[f4E,d4E,p4E,_4E,h4E,y4E,v4E,b4E],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:l}=a.applyStrategy(t);t=u,r=[...r,...l]}}while(t.join("")!==n.join(""));return r}function s8(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:iz(T_(n))).join("");return/^\d/.test(i)?$Ia(i)??i:i}function d0c(e){let t=e.join("_");return T_(t)}function qM(e){switch(e.type){case"object":return Fy.object({allOf:e.allOf,properties:e.properties.map(t=>O4E(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:e.inline});case"array":return Fy.array({description:e.description,availability:e.availability,value:qM(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return Fy.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,source:e.source,inline:e.inline});case"literal":return Fy.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"nullable":return Fy.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:qM(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return Fy.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:qM(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return Fy.primitive({description:e.description,availability:e.availability,schema:Hj_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return Fy.map({description:e.description,availability:e.availability,key:Fy.primitive({description:e.key.description,availability:e.key.availability,schema:Hj_(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:qM(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return Fy.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return Fy.oneOf(g4E(e.value));case"unknown":return Fy.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:mo(e)}}function g4E(e){switch(e.type){case"discriminated":return Gdi.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:qM(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,qM(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return Gdi.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>qM(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:mo(e)}}function Hj_(e){switch(e.type){case"string":return Xj.string(e);case"base64":return Xj.base64();case"boolean":return Xj.boolean(e);case"date":return Xj.date();case"datetime":return Xj.datetime();case"double":return Xj.double(e);case"float":return Xj.float();case"int":return Xj.int(e);case"int64":return Xj.int64(e);case"uint":return Xj.uint();case"uint64":return Xj.uint64();default:mo(e)}}function O4E(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:qM(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function pYo(e,t){return Jae(qM(e),qM(t))}function $j_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:u,wrapAsNullable:l,allOf:d,context:s,propertiesToExclude:o,namespace:c,groupName:b,fullExamples:g,additionalProperties:O,availability:m,source:P}){let E=[...u??[]],q={...n},M=[],D=[];for(let I of d)if(sp(I)){let L=s.resolveSchemaReference(I);if(L.discriminator!=null&&L.discriminator.mapping!=null)continue;if(L.oneOf!=null){for(let X of L.oneOf){let K=sp(X)?s.resolveSchemaReference(X):X,Z=t0(K,!1,s.DUMMY,i,P,c);Z.type==="object"&&M.push(...Z.properties.map(fe=>fe.schema.type!=="optional"&&fe.schema.type!=="nullable"?{...fe,schema:zl.optional({nameOverride:void 0,generatedName:"",title:void 0,value:fe.schema,description:void 0,availability:fe.availability,namespace:void 0,groupName:void 0,inline:void 0})}:fe))}continue}let V=uAi(I);if(V==null)continue;D.push({schemaId:V,convertedSchema:p0c(I,[V],P,s.options.preserveSchemaIds),properties:Gj_({schema:I,context:s,breadcrumbs:i,source:P,namespace:c})}),s.markSchemaAsReferencedByNonRequest(V)}else{let L=t0(I,!1,s,i,P,c);L.type==="object"&&M.push(...L.properties)}let C={};for(let I of D)for(let[L,V]of Object.entries(I.properties)){let X=C[L];X!=null?(X.schemaIds.push(I.schemaId),X.schemas.some(Z=>pYo(Z,V))||X.schemas.push(V)):C[L]={schemaIds:[I.schemaId],schemas:[V]}}let x=[];for(let[I,L]of Object.entries(C))L.schemaIds.length>1&&x.push({propertyKey:I,allOfSchemaIds:L.schemaIds,conflictingTypeSignatures:L.schemas.length>1});let $=Object.entries(q).map(([I,L])=>{let V=E.includes(I),X=hf(L,id.AUDIENCES)??[],K=vJ(L),Z=sp(L)?!1:L.readOnly,fe=sp(L)?!1:L.writeOnly,me=hf(L,id.FERN_PROPERTY_NAME),_e=[...i,I],Se=d0c(_e),Qe=V?t0(L,!1,s,_e,P,c):zl.optional({nameOverride:e,generatedName:Se,title:r,description:void 0,availability:K,value:t0(L,!1,s,_e,P,c),namespace:c,groupName:b,inline:void 0}),Dt={};for(let Ee of D){let Te=Ee.properties[I];Te!=null&&!pYo(Qe,Te)?Dt[Ee.schemaId]={differentSchema:!0}:Te!=null&&(Dt[Ee.schemaId]={differentSchema:!1})}return{key:I,schema:Qe,nameOverride:me,audiences:X,conflict:Dt,generatedName:d0c([...i,I]),availability:K,readonly:Z,writeonly:fe}});return $.push(...M.map(I=>{let L=I.conflict;for(let V of D){let X=V.properties[I.key];X!=null&&!pYo(I.schema,X)?L[V.schemaId]={differentSchema:!0}:X!=null&&(L[V.schemaId]={differentSchema:!1})}return{...I,conflict:L}})),m4E({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,properties:$.filter(I=>!o.has(I.key)),description:a,allOf:D.map(I=>I.convertedSchema),allOfPropertyConflicts:x,namespace:c,groupName:b,fullExamples:g,additionalProperties:O,availability:m,source:P,context:s})}function m4E({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,allOf:u,allOfPropertyConflicts:l,namespace:d,groupName:s,fullExamples:o,additionalProperties:c,availability:b,source:g,context:O}){return i?zl.nullable({nameOverride:e,generatedName:t,title:r,value:zl.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:l,namespace:d,groupName:s,fullExamples:o,additionalProperties:E5n(c,O.options),availability:void 0,source:g,inline:void 0}),description:a,availability:b,namespace:d,groupName:s,inline:void 0}):zl.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:l,namespace:d,groupName:s,fullExamples:o,additionalProperties:E5n(c,O.options),availability:b,source:g,inline:void 0})}function Gj_({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[u,l]=sp(e)?[t.resolveSchemaReference(e),dYo(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...Gj_({schema:d,context:t,breadcrumbs:l,source:i,namespace:n})};for(let[d,s]of Object.entries(u.properties??{})){let o=t0(s,!1,t,[...l,d],i,n);a[d]=o}return a}function A5n({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsNullable:u,context:l,subtypes:d,namespace:s,groupName:o,encoding:c,source:b,subtypePrefixOverrides:g}){let O=w4E({schemas:d}),m=d.flatMap((E,q)=>{if(!sp(E)&&E.enum!=null&&l.options.coerceEnumsToLiterals&&E.type==="string")return E.enum.map(D=>zl.literal({nameOverride:void 0,generatedName:s8([t,D],l.options.preserveSchemaIds),title:void 0,value:vz.string(String(D)),namespace:s,groupName:void 0,description:void 0,availability:D.availability}));let M=O[q];if(g!=null){let D=g[q];D!=null&&"name"in D&&(M=D.name)}return[t0(E,!1,l,[...i,M??`${q}`],b,s)]}),P=P4E(m);return j4E({uniqueSubtypes:P,nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:n,availability:a,namespace:s,groupName:o,context:l,encoding:c,source:b})}function P4E(e){let t=[];for(let r=0;r<e.length;++r){let i=e[r],n=!1;for(let a=r+1;a<e.length;++a){let u=e[a];if(i!=null&&u!=null&&Jae(i,u)){n=!0;break}}i!=null&&!n&&t.push(i)}return t}function j4E({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,namespace:l,groupName:d,context:s,encoding:o,source:c}){if(Object.entries(e).every(([g,O])=>O.type==="literal")){let g={},O=[];return Object.entries(e).forEach(([m,P])=>{P.type==="literal"&&P.value.type==="string"&&(O.push(P.value.value),P.description!=null&&(g[P.value.value]={description:P.description}))}),oAi({nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,fernEnum:g,enumVarNames:void 0,enumValues:O,_default:void 0,namespace:l,groupName:d,context:s,source:c,inline:void 0})}return e.length===1&&e[0]!=null?e[0]:Qj_({nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,subtypes:e,namespace:l,groupName:d,encoding:o,source:c})}function _0c({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsNullable:a,context:u,namespace:l,groupName:d,discriminator:s,encoding:o,source:c}){let b=Object.entries(s.mapping??{}).map(([m,P],E)=>{let q={$ref:P},M=upi(q,!1,u,[P],o,c,l);return u.markSchemaWithDiscriminantValue(q,s.propertyName,m),M.type==="object"&&(M.properties={[s.propertyName]:zl.literal({nameOverride:void 0,generatedName:s8([t,m],u.options.preserveSchemaIds),title:void 0,value:vz.string(m),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...M.properties.filter(D=>D.key!==s.propertyName)}),M}),g=[];for(let m=0;m<b.length;++m){let P=b[m],E=!1;for(let q=m+1;q<b.length;++q){let M=b[q];if(P!=null&&M!=null&&Jae(P,M)){E=!0;break}}P!=null&&!E&&g.push(P)}if(Object.entries(g).every(([m,P])=>P.type==="literal")){let m={},P=[];return Object.entries(g).forEach(([E,q])=>{q.type==="literal"&&q.value.type==="string"&&(P.push(q.value.value),q.description!=null&&(m[q.value.value]={description:q.description}))}),oAi({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,fernEnum:m,enumVarNames:void 0,enumValues:P,_default:void 0,namespace:l,groupName:d,context:u,source:c,inline:void 0})}return g.length===1&&g[0]!=null?g[0]:Qj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,subtypes:g,namespace:l,groupName:d,encoding:o,source:c})}function w4E({schemas:e}){let t={},r=0;for(let a of e){if(!sp(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),l={},d=u;for(let[s,o]of Object.entries(t)){let c=eOo(o,u);d=eOo(d,o),l[s]=c}l[r]=d,t=l}}r++}let i=[],n=0;for(let a of e){let u=t[n];if(u!=null&&u.length>0){let l=u.sort();if(l[0]!=null){i.push(l[0]),++n;continue}}sp(a)?i.push(CMi(n)??`${n}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?i.push(""):i.push(CMi(n)??`${n}`),++n}return i}function Qj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,description:n,availability:a,subtypes:u,namespace:l,groupName:d,encoding:s,source:o}){return i?zl.nullable({nameOverride:e,generatedName:t,title:r,value:zl.oneOf(ik.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,namespace:l,groupName:d,encoding:s,source:o,inline:void 0})),description:n,availability:a,namespace:l,groupName:d,inline:void 0}):zl.oneOf(ik.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,namespace:l,groupName:d,encoding:s,source:o,inline:void 0}))}function q5n(e){if(e.default!=null&&typeof e.default=="string")return e.default}function _Yo({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=JJi(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function Jj_({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=JJi(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function Pir({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=JJi(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function Kj_({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=JJi(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var YJi="#/components/schemas/";function t0(e,t,r,i,n,a,u=!1,l=new Set,d){let s=zj_(e)??n,o=C4E({schema:e,logger:r.logger});if(sp(e)){let c=uAi(e);return c!=null?(u?r.markSchemaAsReferencedByRequest(c):r.markSchemaAsReferencedByNonRequest(c),upi(e,t,r,i,o,s,a)):M5n(r.resolveSchemaReference(e),t,r,dYo(e.$ref),o,s,a,l,u,d)}return M5n(e,t,r,i,o,s,a,l,u,d)}function upi(e,t,r,i,n,a,u){let l=e.$ref.includes("properties")?M5n(r.resolveSchemaReference(e),t,r,i,n,a,u,new Set):zl.reference(p0c(e,i,a,r.options.preserveSchemaIds));return t?zl.nullable({title:void 0,nameOverride:void 0,generatedName:s8(i,r.options.preserveSchemaIds),value:l,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0}):l}function S4E(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function M5n(e,t,r,i,n,a,u,l=new Set,d=!1,s){typeof e=="string"&&(e={type:e});let o=hf(e,id.TYPE_NAME)??(r.options.useTitlesAsName?S4E(e.title):void 0),c=hf(e,id.SDK_GROUP_NAME)??hf(e,cH.TAGS)?.[0],b=(typeof c=="string"?[c]:c)??[];b=r.resolveGroupName(b);let g=s8(i,r.options.preserveSchemaIds),O=e.title,m=e.description,P=vJ(e),E=[];e.example!=null&&E.push({name:void 0,value:e.example,description:void 0});let q=hf(e,cH.EXAMPLES);q!=null&&Object.keys(q).length>0&&E.push(...Object.entries(q).map(([C,x])=>({name:x?.summary??C,value:x.value,description:x.description})));let M=JJi(e);M!=null&&Object.keys(M).length>0&&E.push(...M.map(C=>({name:void 0,value:C,description:void 0})));let D=Ij_({schema:e,description:m,title:O,nameOverride:o,generatedName:g,availability:P});if(D!=null)return D;if(Array.isArray(e.type)){let C=e.type.indexOf("null"),x=C!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&x)e.type.splice(C,1),e.type=e.type[0],e.nullable=!0;else if(x&&(e.type.splice(C,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let $=new Set([...e.oneOf,...e.type]);e.oneOf=[...$]}}if(!t&&e.nullable===!0)return M5n(e,!0,r,i,n,a,u,l,d,s);if(e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(!vYo(e.enum))return u8({nameOverride:o,generatedName:g,title:O,primitive:up.string({default:q5n(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:Pir({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b,wrapAsNullable:t,description:m,availability:P});let C=Bj_(e);return e.enum.length===1&&e.enum[0]!=null&&C==null?Wj_({nameOverride:o,generatedName:g,title:O,wrapAsNullable:t,value:e.enum[0],description:m,availability:P,namespace:u,groupName:b}):oAi({nameOverride:o,generatedName:g,title:O,fernEnum:C,enumVarNames:hf(e,[cH.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:m,availability:P,wrapAsNullable:t,namespace:u,groupName:b,context:r,source:a,inline:void 0})}if(vYo(e.type)&&e.type.length>1){let C=e.type.includes("null"),x=e.type.filter($=>$!=="null").map($=>({type:$,nullable:C}));return A5n({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t,context:r,subtypes:x,namespace:u,groupName:b,encoding:n,source:a})}if(e.type==="boolean"){let C=hf(e,id.BOOLEAN_LITERAL);return C!=null?Yj_({nameOverride:o,generatedName:g,title:O,literal:vz.boolean(C),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b}):u8({nameOverride:o,generatedName:g,title:O,primitive:up.boolean({default:D4E(e.default),example:Jj_({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b})}if(e.type==="number")return f0c({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:KJi(e.exclusiveMinimum),exclusiveMaximum:KJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:_Yo({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="integer")return Uj_({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:KJi(e.exclusiveMinimum),exclusiveMaximum:KJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:_Yo({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="float")return f0c({nameOverride:o,generatedName:g,title:O,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:KJi(e.exclusiveMinimum),exclusiveMaximum:KJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:_Yo({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="string"){if(e.format==="date-time")return u8({nameOverride:o,generatedName:g,title:O,primitive:up.datetime({example:Pir({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b});if(e.format==="date"&&r.options.typeDatesAsStrings===!1)return u8({nameOverride:o,generatedName:g,title:O,primitive:up.date({example:Pir({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b});if(e.format==="json-string")return zl.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:P,namespace:u,groupName:b,example:void 0});let C=kj_(e,"const");return C!=null?Yj_({nameOverride:o,generatedName:g,title:O,literal:vz.string(C),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b}):u8({nameOverride:o,generatedName:g,title:O,primitive:up.string({default:q5n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:Pir({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b,wrapAsNullable:t,description:m,availability:P})}if(e.type==="array")return Nj_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,item:e.items,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,example:Kj_({schema:e,logger:r.logger,fallback:s}),source:a});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&hYo(e))return xj_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,additionalProperties:e.additionalProperties,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,example:e.example,source:a});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?_0c({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,discriminator:e.discriminator,encoding:n,source:a}):c0c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,source:a});if(e.oneOf!=null&&e.oneOf.length>0){let C=hf(e,id.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||C?_0c({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,discriminator:e.discriminator,encoding:n,source:a}):c0c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,source:a});if(e.oneOf.length===1&&e.oneOf[0]!=null){let x=t0(e.oneOf[0],t,r,i,a,u,d);return T5n(x,m,u,b)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let L=e.oneOf[0],V=e.oneOf[1];if(!sp(L)&&L.type==="null")return t0(V,!0,r,i,a,u);if(!sp(V)&&V.type==="null")return t0(L,!0,r,i,a,u)}let x=A4E({schemas:e.oneOf});if(x!=null)return oAi({nameOverride:o,generatedName:g,title:O,fernEnum:void 0,enumVarNames:void 0,enumValues:x,_default:e.default,description:m,availability:P,wrapAsNullable:t,namespace:u,groupName:b,context:r,source:a,inline:void 0});let $=Xj_({schemas:e.oneOf,context:r});if($!=null&&!r.options.discriminatedUnionV2&&!C)return l0c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:P,wrapAsNullable:t,discriminant:$.discriminant,variants:$.schemas,context:r,namespace:u,groupName:b,encoding:n,source:a});let I=e.oneOf.filter(L=>!sp(L)&&L.type==="null").length>0;return A5n({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t||I,context:r,subtypes:e.oneOf.filter(L=>sp(L)||L.type!=="null"),encoding:n,namespace:u,groupName:b,source:a})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let $=t0(e.anyOf[0],t,r,i,a,u,d);return T5n($,m,u,b)}if(e.anyOf.length===2){let[$,I]=e.anyOf;if($!=null&&I!=null){if(!sp($)&&$.type==="null"){let L=t0(I,!0,r,i,a,u);return T5n(L,m,u,b)}else if(!sp(I)&&I.type==="null"){let L=t0($,!0,r,i,a,u);return T5n(L,m,u,b)}}}let C=Xj_({schemas:e.anyOf,context:r});if(C!=null&&!r.options.discriminatedUnionV2)return l0c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:P,wrapAsNullable:t,discriminant:C.discriminant,variants:C.schemas,context:r,namespace:u,groupName:b,encoding:n,source:a});let x=e.anyOf.filter($=>!sp($)&&$.type==="null").length>0;return A5n({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t||x,context:r,subtypes:e.anyOf.filter($=>sp($)||$.type!=="null"),encoding:n,namespace:u,groupName:b,source:a})}if(e.allOf!=null||e.properties!=null){let C=[];for(let $ of e.allOf??[])(sp($)||Object.keys($).length>0)&&C.push($);if((e.properties==null||hYo(e))&&C.length===1&&C[0]!=null){let $=t0(C[0],t,r,i,a,u,d);return T5n($,m,u,b)}let x=C.filter($=>{let I=yYo($);return I||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify($)}`),I});if((e.properties==null||hYo(e))&&x.length===1&&x[0]!=null){let $=t0(x[0],t,r,i,a,u,d);return T5n($,m,u,b)}return $j_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},description:m,required:e.required,wrapAsNullable:t,allOf:x,context:r,propertiesToExclude:l,namespace:u,groupName:b,fullExamples:E,additionalProperties:e.additionalProperties,availability:P,encoding:n,source:a})}if(e.type==="object"&&E4E(e)&&M4E(e)&&hYo(e))return fYo({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${g}Key`,title:void 0,description:void 0,availability:void 0,schema:up.string({default:q5n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:Pir({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b},valueSchema:zl.unknown({nameOverride:void 0,generatedName:`${g}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:b}),namespace:u,groupName:b,encoding:n,example:e.example});if(e.type==null){let C=e.example??e.default;return zl.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:P,namespace:u,groupName:b,example:C})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(i)} value=${JSON.stringify(e)}`)}function D4E(e){if(e!=null){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase();if(t==="true")return!0;if(t==="false")return!1}}}function uAi(e){if(e.$ref.startsWith(YJi))return e.$ref.replace(YJi,"")}function p0c(e,t,r,i){let n=hf(e,id.TYPE_NAME),a=s8(t,i),u=e.description,l=vJ(e),d=uAi(e);if(d==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return Fy.reference({generatedName:a,nameOverride:n,title:void 0,schema:d,description:u??void 0,availability:l,namespace:void 0,groupName:void 0,source:r})}function E4E(e){return e.oneOf==null||e.oneOf.length===0}function M4E(e){return e.allOf==null||e.allOf.length===0}function hYo(e){return e.properties==null||fZ(e.properties)===0}function vYo(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function T5n(e,t,r,i){return e.type==="reference"?zl.reference({...e,description:t,availability:e.availability,namespace:r,groupName:i}):e.type==="optional"?zl.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0}):e.type==="nullable"?zl.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0}):e}function yYo(e){return sp(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>yYo(t)):e.oneOf!=null?e.oneOf.every(t=>yYo(t)):e.anyOf!=null?e.anyOf.every(t=>yYo(t)):!1}function Yj_({literal:e,wrapAsNullable:t,namespace:r,groupName:i,description:n,availability:a,nameOverride:u,generatedName:l,title:d}){return t?zl.nullable({nameOverride:u,generatedName:l,title:d,value:zl.literal({nameOverride:u,generatedName:l,title:d,value:e,description:n,availability:a,namespace:r,groupName:i}),namespace:r,groupName:i,description:n,availability:a,inline:void 0}):zl.literal({nameOverride:u,generatedName:l,title:d,value:e,namespace:r,groupName:i,description:n,availability:a})}function u8({primitive:e,wrapAsNullable:t,namespace:r,groupName:i,description:n,availability:a,generatedName:u,nameOverride:l,title:d}){return i=typeof i=="string"?[i]:i,t?zl.nullable({nameOverride:l,generatedName:u,title:d,value:zl.primitive({nameOverride:l,generatedName:u,title:d,schema:e,description:n,availability:a,namespace:r,groupName:i}),namespace:r,groupName:i,description:n,availability:a,inline:void 0}):zl.primitive({nameOverride:l,generatedName:u,title:d,schema:e,description:n,availability:a,namespace:r,groupName:i})}function A4E({schemas:e}){let t=new Set;for(let r of e){if(sp(r))return;if(r.enum!=null&&vYo(r.enum))r.enum.forEach(i=>t.add(i));else return}return Array.from(t)}function Xj_({schemas:e,context:t}){let r={};for(let i of e){let n=Zj_({schema:i,context:t});for(let[a,u]of Object.entries(n)){let l=r[a];l!=null?l[u]=i:r[a]={[u]:i}}}for(let[i,n]of Object.entries(r))if(Object.keys(n).length===e.length)return{discriminant:i,schemas:n}}function Zj_({schema:e,context:t}){let r=sp(e)?t.resolveSchemaReference(e):e;return q4E({schema:r,context:t})}function q4E({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let i of e.anyOf){let n=Zj_({schema:i,context:t});for(let[a,u]of Object.entries(n??{}))r[a]=u}return r}for(let[i,n]of Object.entries(e.properties??{})){let a=sp(n)?t.resolveSchemaReference(n):n;a.type==="string"&&a.enum!=null&&vYo(a.enum)&&T4E(a.enum).length===1&&a.enum[0]!=null&&(r[i]=a.enum[0]);let u=kj_(a,"const");a.type==="string"&&u!=null&&(r[i]=u),i==="type"&&a.example!=null&&(r[i]=a.example)}return r}function T4E(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 kj_(e,t){let r=e[t];if(r!=null)return r}function C4E({schema:e,logger:t}){let r=Cj_({schema:e,logger:t});if(r!=null)return Lj_(r)}var C5n=class{document;taskContext;logger;DUMMY;options;namespace;static MESSAGE_REFERENCE_PREFIX="#/components/messages/";constructor({document:t,taskContext:r,options:i,namespace:n}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=i,this.namespace=n}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let i=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};i.push(n)}return i.concat(t??[])}resolveSchemaReference(t){if(!t.$ref.startsWith(YJi))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let i=t.$ref.substring(YJi.length).split("/"),n=this.document.components;if(n==null||n.schemas==null)throw new Error("Document does not have components.schemas.");let[a,u,l]=i;if(a==null||a==="")throw new Error(`${t.$ref} cannot be resolved. No schema key provided.`);let d=n.schemas[a];if(d==null)throw new Error(`Schema "${a}" is undefined in document.components.schemas.`);if(sp(d)&&(d=this.resolveSchemaReference(d)),u==="properties"&&l!=null){let s=d.properties?.[l];if(s==null)throw new Error(`Property "${l}" not found on "${a}". Full ref: ${t.$ref}`);sp(s)?d=this.resolveSchemaReference(s):d=s}return d}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,i){}markSchemaWithDiscriminantValue(t,r,i){}};var bYo=class extends C5n{getExampleMessageReference(t){return`#/components/messages/${t.messageId}`}resolveMessageReference(t){let r="#/components/messages/",i=this.document.components;if(i==null||i.messages==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve message reference: ${t.$ref} in v2 components`);let n=t.$ref.substring(r.length),a=i.messages[n];if(a==null)throw new Error(`${t.$ref} is undefined`);return a}};function B5n(e,t){let r={};if(e!=null)return{rootSchemas:r,namespacedSchemas:{[e]:t}};let i={};for(let[n,a]of Object.entries(t))switch(a.type){case"object":case"array":case"map":case"optional":case"enum":case"literal":case"reference":case"nullable":case"primitive":{if(a.namespace==null){r[n]=a;continue}let u=a.namespace;i[u]??={},i[u][n]=a;continue}case"oneOf":case"unknown":r[n]=a;continue;default:mo(a)}return{rootSchemas:r,namespacedSchemas:i}}function sAi(e){if(typeof e=="string")return vO.primitive(w_.string(e));if(typeof e=="number")return Number.isInteger(e)?vO.primitive(w_.int(e)):vO.primitive(w_.double(e));if(typeof e=="boolean")return vO.primitive(w_.boolean(e));if(Array.isArray(e)){let t=e.map(r=>sAi(r));return t.length===0?void 0:vO.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,i]of Object.entries(e)){let n=sAi(i);n!=null&&t.push({key:w_.string(r),value:n})}return vO.map(t)}}function Zza(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function ew_(e){if(e!=null&&Array.isArray(e))return e}var cAi=class{schemas;nonRequestReferencedSchemas;context;constructor(t,r,i){this.schemas=t,this.nonRequestReferencedSchemas=r,this.context=i}buildExample({schema:t,exampleId:r,example:i,options:n,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:i,options:{...n,maxCheckerDepth:n.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:i,depth:n,visitedSchemaIds:a,options:u,skipReadonly:l}){switch(i.type){case"enum":return typeof r=="string"&&tw_({schema:i,value:r})?vO.enum(r):i.values[0]!=null?vO.enum(i.values[0]?.value):void 0;case"literal":return vO.literal(i.value);case"nullable":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u)))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:l});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"optional":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u))||Object.is(r,null))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:l});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"primitive":{let d=this.buildExampleFromPrimitive({schema:i.schema,example:r,options:u});return vO.primitive(d)}case"reference":{let d=this.schemas[i.schema];if(d!=null&&!a.has(i.schema)){a.add(i.schema);let s=d?.type==="object"&&!this.nonRequestReferencedSchemas.has(i.schema),o=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:n,options:u,skipReadonly:s||this.context.options.respectReadonlySchemas?l:!1});return a.delete(i.schema),o}return}case"oneOf":switch(i.value.type){case"discriminated":{let d={},s={},o={},c=Zza(r),b=c?.[i.value.discriminantProperty],g=i.value.schemas[b],O=[],m=this.getDiscriminatedUnionVariantSchema(i.value,c);m!=null&&O.push(m),O.push(...Object.entries(i.value.schemas));for(let P of O)if(b!=null&&g!=null&&g.type==="object"){s=this.getAllProperties(g),o=this.getAllRequiredProperties(g),d[i.value.discriminantProperty]=vO.primitive(w_.string(b));break}else{let E=this.buildExampleHelper({exampleId:t,schema:P[1],example:void 0,visitedSchemaIds:a,depth:n,options:u,skipReadonly:l});if(E!=null){this.mergeExampleWith(E,d),d[i.value.discriminantProperty]=vO.primitive(w_.string(P[0]));break}}for(let P of i.value.commonProperties){s[P.key]={schema:P.schema,readonly:!1};let E=this.getResolvedSchema(P.schema);E.type!=="optional"&&E.type!=="nullable"&&(o[P.key]=P.schema)}for(let[P,E]of Object.entries(s)){let q=P in o;if(q&&c?.[P]!=null){let M=this.buildExampleHelper({schema:E.schema,exampleId:t,example:c[P],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});if(M!=null)d[P]=M;else return}else{let M=this.buildExampleHelper({exampleId:t,schema:E.schema,example:c?.[P],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});if(M!=null)d[P]=M;else if(q)return}}return vO.oneOf(PMi.discriminated(d))}case"undiscriminated":{let d=this.getUnDiscriminatedUnionVariantSchema(i.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:n,options:u,skipReadonly:l});break}}return;case"unknown":if(r!=null){let d=sAi(r);if(d!=null)return vO.unknown(d)}return u.ignoreOptionals||this.exceedsMaxDepth(n,u)?void 0:u.isParameter?vO.primitive(w_.string(u.name??"string")):vO.map([{key:w_.string("key"),value:vO.primitive(w_.string("value"))}]);case"array":{let d=ew_(r),s=[];if(d!=null&&d.length>0)for(let o of d){let c=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});c!=null&&s.push(c)}else if(i.example!=null&&i.example.length>0)for(let o of i.example){let c=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});c!=null&&s.push(c)}else{let o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});o!=null&&s.push(o)}return vO.array(s)}case"map":{let d=Zza(r??i.example);if(d!=null&&Object.entries(d).length>0){let c=[];for(let[b,g]of Object.entries(d)){let O=this.buildExampleFromPrimitive({schema:i.key.schema,example:b,options:u}),m=this.buildExampleHelper({exampleId:t,example:g,schema:i.value,visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});m!=null&&c.push({key:O,value:m})}return vO.map(c)}if(i.key.schema.type==="string"&&i.value.type==="unknown")return vO.map([{key:w_.string("key"),value:vO.unknown(vO.primitive(w_.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:i.key.schema,example:void 0,options:{...u,name:"key"}}),o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,visitedSchemaIds:a,depth:n+1,options:{...u,name:"value"},skipReadonly:l});return o!=null?vO.map([{key:s,value:o}]):vO.map([])}case"object":{let d={},s=i.fullExamples?.find(g=>g.name===t)??i.fullExamples?.find(g=>g.name==null)??i.fullExamples?.[0],o=Zza(r)??(s!=null?Zza(s.value):{})??{},c=this.getAllProperties(i),b=this.getAllRequiredProperties(i);for(let[g,O]of Object.entries(c)){if(l&&O.readonly)continue;let m=g in b,P=Object.keys(o).includes(g),E=this.buildExampleHelper({schema:O.schema,exampleId:t,example:o[g],visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:l});if(m&&E!=null)d[g]=E;else{if(m)return;(P&&E!=null||!u.ignoreOptionals&&E!=null)&&(d[g]=E)}}if(i.additionalProperties){for(let[g,O]of Object.entries(o))if(!(g in d)){let m=this.buildExampleHelper({schema:zl.unknown({example:O,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0}),exampleId:t,example:O,visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:l});m!=null&&(d[g]=m)}}return vO.object({properties:d})}default:mo(i)}}mergeExampleWith(t,r){t._visit({array:Go,enum:Go,literal:Go,map:i=>{for(let n of i){let a=n.key;a.type==="string"&&(r[a.value]=n.value)}},object:i=>{for(let[n,a]of Object.entries(i.properties))r[n]=a},oneOf:i=>{if(i.type==="discriminated")for(let[n,a]of Object.entries(i.value))r[n]=a;else this.mergeExampleWith(i.value,r)},primitive:Go,unknown:Go,_other:Go})}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let i=r?.[t.discriminantProperty];if(i==null||typeof i!="string")return Object.entries(t.schemas)[0];let n=t.schemas[i];return n==null?Object.entries(t.schemas)[0]:[i,n]}getUnDiscriminatedUnionVariantSchema(t,r){return r==null?t.schemas[0]:t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,u)=>u.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return tw_({schema:t,value:r})?5:0;case"object":{if(!Jj(r))return 0;let i=this.getAllProperties(t),n=0;for(let[a,u]of Object.entries(i))r[a]!=null?(n++,n+=this.calcExampleHeuristic(u.schema,r[a])):n--;return n}case"array":{if(!Array.isArray(r))return 0;let i=0;for(let n of r)i+=this.calcExampleHeuristic(t.value,n);return i}case"map":{if(!Jj(r))return 0;let i=0;for(let[,n]of Object.entries(r))i+=this.calcExampleHeuristic(t.value,n);return i}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let i=this.getResolvedSchema(t);return i==null?0:this.calcExampleHeuristic(i,r)}case"oneOf":return Object.values(t.value.schemas).map(n=>this.calcExampleHeuristic(n,r)).sort((n,a)=>a-n)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,i=new Set,n){if(this.exceedsMaxCheckerDepth(r,n))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,i,n);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,i,n);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let u of t.properties)if(this.hasExample(u.schema,r+1,i,n))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!i.has(t.schema)){i.add(t.schema);let u=this.hasExample(a,r,i,n);return i.delete(t.schema),u}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,i,n));default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let i of t.properties)r[i.key]={schema:i.schema,readonly:i.readonly??!1};for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let i of t.properties){let n=this.getResolvedSchema(i.schema);n.type!=="optional"&&n.type!=="nullable"&&(r[i.key]=i.schema)}for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:i}){switch(r.type){case"string":return t!=null&&typeof t=="string"?w_.string(t):r.example!=null?w_.string(r.example):w_.string(i.name??Gy.STRING);case"base64":return t!=null&&typeof t=="string"?w_.base64(t):r.example!=null?w_.base64(r.example):w_.base64(Gy.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?w_.boolean(t):r.example!=null?w_.boolean(r.example):w_.boolean(Gy.BOOLEAN);case"date":return t!=null&&typeof t=="string"?w_.date(t):r.example!=null?w_.date(r.example):w_.date(Gy.DATE);case"datetime":return t!=null&&typeof t=="string"?w_.datetime(t):r.example!=null?w_.datetime(r.example):w_.datetime(Gy.DATE_TIME);case"double":return t!=null&&typeof t=="number"?w_.double(t):r.example!=null?w_.double(r.example):w_.double(Gy.DOUBLE);case"float":return t!=null&&typeof t=="number"?w_.float(t):r.example!=null?w_.float(r.example):w_.float(Gy.FLOAT);case"int":return t!=null&&typeof t=="number"?w_.int(t):r.example!=null?w_.int(r.example):w_.int(Gy.INT);case"int64":return t!=null&&typeof t=="number"?w_.int64(t):r.example!=null?w_.int64(r.example):w_.int64(Gy.INT64);case"uint":return t!=null&&typeof t=="number"?w_.uint(t):r.example!=null?w_.uint(r.example):w_.uint(Gy.UINT);case"uint64":return t!=null&&typeof t=="number"?w_.uint64(t):r.example!=null?w_.uint64(r.example):w_.uint64(Gy.UINT64);default:mo(r)}}};function tw_({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function jir(e){switch(e.type){case"object":return zl.object({allOf:e.allOf,properties:e.properties.map(t=>I4E(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:void 0});case"array":return zl.array({description:e.description,availability:e.availability,value:jir(e.value),generatedName:e.generatedName,title:e.title,namespace:e.namespace,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0});case"enum":return zl.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,example:void 0,source:e.source,inline:void 0});case"literal":return zl.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName});case"nullable":return zl.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:jir(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"optional":return zl.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:jir(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"primitive":return zl.primitive({description:e.description,availability:e.availability,schema:rw_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return zl.map({description:e.description,availability:e.availability,key:zl.primitive({description:e.key.description,availability:e.key.availability,schema:rw_(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,namespace:e.namespace,groupName:e.groupName}),value:jir(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,example:void 0,inline:void 0});case"reference":return zl.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return zl.oneOf(B4E(e.value));case"unknown":return zl.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,namespace:void 0,groupName:void 0,description:void 0,availability:void 0});default:mo(e)}}function B4E(e){switch(e.type){case"discriminated":return ik.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:jir(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,jir(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return ik.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>jir(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:mo(e)}}function rw_(e){switch(e.type){case"string":return up.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return up.base64({example:void 0});case"boolean":return up.boolean({default:e.default,example:void 0});case"date":return up.date({example:void 0});case"datetime":return up.datetime({example:void 0});case"double":return up.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 up.float({example:void 0});case"int":return up.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 up.int64({default:e.default,example:void 0});case"uint":return up.uint({default:void 0,example:void 0});case"uint64":return up.uint64({default:void 0,example:void 0});default:mo(e)}}function I4E(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:jir(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function gYo(e){return e.type!=="optional"&&e.type!=="nullable"}function h0c(e){return e==="POST"||e==="PUT"||e==="PATCH"}function kza(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 OYo=class{schemas;context;exampleTypeFactory;logger;constructor(t,r){this.schemas=t,this.context=r,this.schemas=t,this.exampleTypeFactory=new cAi(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=x4E(t.request),i=R4E(t.response);if(r?.type==="unsupported"||i?.type==="unsupported")return[];let n=[];if(r!=null&&r.type==="present"){let c=this.isSchemaRequired(r.schema);if(r.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:h0c(t.method),schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});b!=null&&n.push([void 0,b])}else for(let{name:b,value:g}of r.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:h0c(t.method),schema:r.schema,exampleId:b,example:g,options:{isParameter:!1,ignoreOptionals:!0}});O!=null&&n.push([b,O])}if(c&&n.length===0)return this.logger.trace(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(i!=null&&i.type==="present"){let c=this.isSchemaRequired(i.schema);if(i.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:void 0,example:void 0,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});b!=null&&(t.response?.type==="json"?a.push([void 0,lHt.withoutStreaming(b)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,lHt.withStreaming({sse:t.response?.type==="streamingSse",events:[b]})]))}else for(let{name:b,value:g}of i.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:b,example:g,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});O!=null&&(t.response?.type==="json"?a.push([b,lHt.withoutStreaming(O)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,lHt.withStreaming({sse:t.response?.type==="streamingSse",events:[O]})]))}if(c&&a.length===0)return this.logger.trace(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let c of t.pathParameters){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!wir(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for path parameter ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&u.push({name:c.name,parameterNameOverride:c.parameterNameOverride,value:g})}let l=[];for(let c of t.queryParameters){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!wir(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for query parameter ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&l.push({name:c.name,value:g})}let d=[];for(let c of t.headers){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!wir(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for header ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&d.push({name:c.name,value:g})}let s=[];t.request!=null&&t.response!=null?s=z4E(n,a):t.request!=null?s=n.map(([c,b])=>({id:c,request:b,response:void 0})):t.response!=null&&(s=a.map(([c,b])=>({id:c,request:void 0,response:b})));let o=t.examples.filter(c=>kza(c)).flatMap(c=>{if(c.type==="unknown"){if(c.value!=null){let b=c.value["code-samples"];if(b!=null)return this.convertCodeSamples(b)}return}else return c.codeSamples}).filter(c=>V0(c));return s.length===0?[cHt.full({name:void 0,description:void 0,pathParameters:u,queryParameters:l,headers:d,request:void 0,response:void 0,codeSamples:o})]:s.map(({id:c,request:b,response:g})=>cHt.full({name:c,description:void 0,pathParameters:u,queryParameters:l,headers:d,request:b,response:g,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?Hdi.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):Hdi.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?tH.Csharp:r.sdk,code:r.code})).filter(V0)}isSchemaRequired(t){return gYo(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function z4E(e,t){let r=[];if(e.length<=1){let[n,a]=e[0]??[];if(t.length===0)return r.push({id:n,request:a,response:void 0}),r;for(let[u,l]of t)r.push({id:u??n,request:a,response:l});return r}if(t.length<=1){let[n,a]=t[0]??[];if(t.length===0)return r.push({id:n,request:void 0,response:a}),r;for(let[u,l]of e)r.push({id:u??n,request:l,response:a});return r}let i=new Set;for(let[n,a]of e){let u=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(n==null){if(u==null)continue;r.push({id:void 0,request:a,response:u});continue}let l=!1;for(let d=0;d<t.length;d++){let[s,o]=t[d];s==null||i.has(d)||n===s&&(r.push({id:n,request:a,response:o}),s!=null&&i.add(d),l=!0)}!l&&u!=null&&r.push({id:n,request:a,response:u})}for(let n=0;n<t.length;n++){if(i.has(n))continue;let[a,u]=t[n],l=e.find(([d])=>d==null)?.[1]??e[0]?.[1];l!=null&&r.push({id:a,request:l,response:u})}return r}function x4E(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:N4E(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function R4E(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"&&e.type!=="streamingSse"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function wir(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return wir(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undiscriminated":return wir(e.value.value);default:return!1}default:mo(e)}}function N4E(e){return zl.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:jir(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0,writeonly:void 0,inline:void 0}).filter(V0),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source,inline:void 0})}var I5n=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new cAi(t,new Set,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,handshake:i,source:n,namespace:a}){let u=[];for(let l of r){let d=[];for(let c of i.queryParameters){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:l.queryParameters?.[c.name],options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});g!=null&&!wir(g)&&(g=void 0),!(b&&g==null)&&g!=null&&d.push({name:c.name,value:g})}let s=[];for(let c of i.headers){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:l.headers?.[c.name],options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});g!=null&&!wir(g)&&(g=void 0),!(b&&g==null)&&g!=null&&s.push({name:c.name,value:g})}let o=[];for(let c of l.messages){let b=t.getExampleMessageReference(c),g=t.resolveMessageReference({$ref:b}),O=sp(g.payload)?t.resolveSchemaReference(g.payload):g.payload,m=this.exampleTypeFactory.buildExample({schema:t0(O,!1,t,[c.messageId],n,a),exampleId:void 0,example:c.value,options:{isParameter:!1,ignoreOptionals:!0}});m!=null&&o.push({messageType:c.type,payload:m,description:void 0})}u.push({name:l.summary,queryParameters:d,headers:s,description:l.description,messages:o})}return u}buildWebsocketSessionExample({handshake:t,messages:r}){let i={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},n=[];for(let u of t.queryParameters){let l=this.isSchemaRequired(u.schema),d=this.exampleTypeFactory.buildExample({schema:u.schema,exampleId:void 0,example:void 0,options:{name:u.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!wir(d)&&(d=void 0),l&&d==null)return;d!=null&&n.push({name:u.name,value:d})}let a=[];for(let u of t.headers){let l=this.isSchemaRequired(u.schema),d=this.exampleTypeFactory.buildExample({schema:u.schema,exampleId:void 0,example:void 0,options:{name:u.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!wir(d)&&(d=void 0),l&&d==null)return;d!=null&&a.push({name:u.name,value:d})}for(let u of r){let l=this.exampleTypeFactory.buildExample({schema:u.payload,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});l!=null&&i.messages.push({messageType:u.type,payload:l,description:void 0})}return i}isSchemaRequired(t){return gYo(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 bk={FERN_PARAMETER_OPTIONAL:"x-fern-optional",FERN_CHANNEL_ADDRESS:"x-fern-address",FERN_DISPLAY_NAME:"x-fern-display-name",FERN_SDK_GROUP_NAME:"x-fern-sdk-group-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path",FERN_ENUM:"x-fern-enum",IGNORE:"x-fern-ignore"};function mYo(e){return hf(e,bk.FERN_EXAMPLES)??[]}function PYo(e,t){return t.includes("://")?t:`${e}://${t}`}function jYo(e){return e.startsWith("/")?e:"/"+e}function aw_({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},u={};for(let[s,o]of Object.entries(n.components?.schemas??{})){let c=t0(o,!1,e,[s],r,e.namespace);a[s]=c}let l=new I5n(a,e),d={};for(let[s,o]of Object.entries(n.servers??{}))d[s]={name:s,url:PYo(o.protocol,o.url)};for(let[s,o]of Object.entries(n.channels??{})){let c=hf(o,bk.IGNORE);if(c!=null&&c){e.logger.debug(`Channel ${s} is marked with x-fern-ignore. Skipping.`);continue}let b=[];if(o.parameters!=null)for(let[E,q]of Object.entries(o.parameters??{}))b.push({name:E,description:q.description,parameterNameOverride:void 0,schema:q.schema!=null?t0(q.schema,!1,e,t,r,e.namespace):zl.primitive({schema:up.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,namespace:void 0,groupName:void 0,nameOverride:void 0}),variableReference:void 0,availability:vJ(q),source:r});let g=[],O=[];if(o.bindings?.ws!=null){if(o.bindings.ws.headers!=null){let E=o.bindings.ws.headers.required??[];for(let[q,M]of Object.entries(o.bindings.ws.headers.properties??{})){if(sp(M)){let D=e.resolveSchemaReference(M);g.push({name:q,schema:upi(M,!1,e,t,void 0,r,e.namespace),description:D.description,parameterNameOverride:void 0,env:void 0,availability:vJ(D),source:r});continue}g.push({name:q,schema:t0(M,!E.includes(q),e,[...t,q],r,e.namespace),description:M.description,parameterNameOverride:void 0,env:void 0,availability:vJ(M),source:r})}}if(o.bindings.ws.query!=null){let E=o.bindings.ws.query.required??[];for(let[q,M]of Object.entries(o.bindings.ws.query.properties??{})){if(sp(M)){let D=e.resolveSchemaReference(M);O.push({name:q,schema:upi(M,!1,e,t,void 0,r,e.namespace),description:D.description,parameterNameOverride:void 0,availability:vJ(D),source:r});continue}O.push({name:q,schema:t0(M,!E.includes(q),e,[...t,q],r,e.namespace),description:M.description,parameterNameOverride:void 0,availability:vJ(M),source:r})}}}let m;o.publish!=null&&("oneOf"in o.publish.message?m=iw_({generatedName:o.publish.operationId??"PublishEvent",event:o.publish,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):m=nw_({action:"Publish",channelPath:s,message:o.publish.message,context:e,source:r}));let P;if(o.subscribe!=null&&("oneOf"in o.subscribe.message?P=iw_({generatedName:o.subscribe.operationId??"SubscribeEvent",event:o.subscribe,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):P=nw_({action:"Subscribe",channelPath:s,message:o.subscribe.message,context:e,source:r})),g.length>0||O.length>0||m!=null||P!=null){let E=mYo(o),q=[];if(E.length>0)q=l.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:E,handshake:{headers:g,queryParameters:O},source:r,namespace:e.namespace});else{let x=[];m!=null&&x.push({type:"publish",payload:m}),P!=null&&x.push({type:"subscribe",payload:P});let $=l.buildWebsocketSessionExample({handshake:{headers:g,queryParameters:O},messages:x});$!=null&&q.push($)}let M=hf(o,bk.FERN_CHANNEL_ADDRESS),D=M??jYo(s),C=[];m!=null&&C.push({origin:"client",name:"publish",body:qM(m)}),P!=null&&C.push({origin:"server",name:"subscribe",body:qM(P)}),u[s]={audiences:hf(o,id.AUDIENCES)??[],handshake:{headers:g.map(x=>({...x,schema:qM(x.schema),env:x.env})),queryParameters:O.map(x=>({...x,schema:qM(x.schema)})),pathParameters:b.map(x=>({...x,parameterNameOverride:void 0,schema:qM(x.schema)}))},groupName:e.resolveGroupName([hf(o,bk.FERN_SDK_GROUP_NAME)??s]),messages:C,servers:(o.servers?.map(x=>d[x])??Object.values(d)).filter(x=>x!=null),summary:hf(o,bk.FERN_DISPLAY_NAME),path:D,description:o.description,examples:q,source:r}}}return{groupedSchemas:B5n(e.namespace,a),channels:u??void 0,servers:Object.values(d),basePath:hf(n,bk.BASE_PATH)}}function iw_({generatedName:e,event:t,context:r,breadcrumbs:i,source:n,options:a,asyncApiOptions:u}){if("oneOf"in t.message&&t.message.oneOf!=null){let l=[],d=[];for(let s of t.message.oneOf){let o,c={type:"notFound"};if(sp(s)){let b=r.resolveMessageReference(s);!sp(b.payload)&&u.naming==="v2"?(c=b.name?{type:"name",name:b.name}:c,o={...b.payload,title:b.name??b.payload.title,description:b.name??b.payload.description}):o=b.payload}else o=s;d.push(c),l.push(o)}return A5n({description:t.description??t.message.description,availability:vJ(t.message),subtypes:l,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:i,context:r,encoding:void 0,source:n,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?d:[]})}}function nw_({action:e,channelPath:t,message:r,context:i,source:n}){if(r.payload!=null){let a=r.payload;return sp(r.payload)&&(a=i.resolveSchemaReference(r.payload)),t0(a,!1,i,[t,e],n,i.namespace)}}var wYo=class extends C5n{getExampleMessageReference(t){return`#/channels/${t.channelId}/messages/${t.messageId}`}resolveMessageReference(t){let r="#/channels/",i="#/components/messages/";if(t.$ref.startsWith(r)){let l=t.$ref.split("/"),d=l[2],s=l[4];if(d==null||s==null||!this.document.channels?.[d])throw new Error(`Failed to resolve message reference ${t.$ref} in channel ${d}`);let c=this.document.channels[d].messages?.[s];if(c==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in c?this.resolveMessageReference(c):{name:s,...c}}let n=this.document.components;if(!t.$ref.startsWith(i)||!n?.messages)throw new Error(`Failed to resolve message reference: ${t.$ref} in v3 components`);let a=t.$ref.substring(i.length),u=n.messages[a];if(u==null)throw new Error(`${t.$ref} is undefined`);return{name:a,...u}}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}};var ow_="#/channels/",uw_="#/servers/",y0c="$message.";function cw_({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},u={},l={},d=[],s={};for(let[O,m]of Object.entries(n.components?.schemas??{}))a[O]=t0(m,!1,e,[O],r,e.namespace);for(let[O,m]of Object.entries(n.channels??{}))if(u[O]||(u[O]={}),m.messages){for(let[P,E]of Object.entries(m.messages))if(e.isReferenceObject(E)||e.isMessageWithPayload(E))if(l[P]||(l[P]=[]),e.isReferenceObject(E)){let q=e.resolveMessageReference(E);l[P].push({channelId:O,payload:q.payload})}else l[P].push({channelId:O,payload:E.payload})}for(let[O,m]of Object.entries(l))if(m.length===1){let P=m[0],E=P.channelId;u[E]=u[E]||{},u[E][O]=t0(P.payload,!1,e,[O],r,e.namespace)}else{d.push(O);for(let{channelId:P,payload:E}of m){let q=`${P}_${O}`;u[P]||(u[P]={}),u[P][q]=t0(E,!1,e,[q],r,e.namespace)}}let o=Object.values(u).reduce((O,m)=>({...O,...m}),{}),c=new I5n(o,e),b={};for(let[O,m]of Object.entries(n.servers??{}))b[O]={name:O,url:PYo(m.protocol,m.host)};let g={};for(let[O,m]of Object.entries(n.operations??{})){if(hf(m,bk.IGNORE))continue;let P=F4E(m);if(g[P]||(g[P]={subscribe:[],publish:[],__parsedMessages:[]}),m.action==="receive")g[P].subscribe.push(...m.messages);else if(m.action==="send")g[P].publish.push(...m.messages);else throw new Error(`Operation ${O} has an invalid action: ${m.action}`)}for(let[O,m]of Object.entries(g)){let P=[];P.push(...sw_({messages:m.subscribe,channelPath:O,origin:"server",messageSchemas:u[O]??{},duplicatedMessageIds:d,context:e})),P.push(...sw_({messages:m.publish,channelPath:O,origin:"client",messageSchemas:u[O]??{},duplicatedMessageIds:d,context:e})),g[O]!=null&&(g[O].__parsedMessages=P)}for(let[O,m]of Object.entries(n.channels??{})){if(hf(m,bk.IGNORE))continue;let P=[],E=[],q=[];if(m.parameters!=null)for(let[M,D]of Object.entries(m.parameters)){let{type:C,parameterKey:x}=L4E(D.location),$=hf(D,bk.FERN_PARAMETER_OPTIONAL),I=iz(T_(O))+iz(T_(M)),L={...D,type:"string",title:I,example:D.examples?.[0],default:D.default,enum:D.enum,required:void 0},V=t0(L,!1,e,[x],r,e.namespace);$&&(V=zl.optional({value:V,description:void 0,availability:void 0,generatedName:"",title:I,namespace:void 0,groupName:void 0,nameOverride:void 0,inline:void 0}));let X={name:x,description:D.description,parameterNameOverride:void 0,schema:V,variableReference:void 0,availability:vJ(D),source:r};C==="header"?P.push({...X,env:void 0}):C==="path"?E.push(X):C==="payload"&&q.push(X)}if(P.length>0||q.length>0||g[O]!=null&&(g[O].publish!=null||g[O].subscribe!=null)){let M=mYo(m),D=g[O]?.__parsedMessages??[],C=[];if(M.length>0)C=c.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:M,handshake:{headers:P,queryParameters:q},source:r,namespace:e.namespace});else{let x=[],{examplePublishMessage:$,exampleSubscribeMessage:I}=V4E({messages:D,messageSchemas:u[O]??{}});$!=null&&x.push($),I!=null&&x.push(I);let L=c.buildWebsocketSessionExample({handshake:{headers:P,queryParameters:q},messages:x});L!=null&&C.push(L)}s[O]={audiences:hf(m,id.AUDIENCES)??[],handshake:{headers:P.map(x=>({...x,schema:qM(x.schema),env:x.env})),queryParameters:q.map(x=>({...x,schema:qM(x.schema)})),pathParameters:E.map(x=>({...x,parameterNameOverride:void 0,schema:qM(x.schema)}))},groupName:e.resolveGroupName([hf(m,bk.FERN_SDK_GROUP_NAME)??O]),messages:D,summary:hf(m,bk.FERN_DISPLAY_NAME),servers:m.servers?.map(x=>U4E(b,x))??Object.values(b),path:m.address??jYo(O),description:m.description,examples:C,source:r}}}return{groupedSchemas:B5n(e.namespace,a),channels:s,servers:Object.values(b),basePath:hf(n,bk.BASE_PATH)}}function F4E(e){if(!e.channel.$ref.startsWith(ow_))throw new Error(`Failed to resolve channel path from operation ${e.channel.$ref}`);return e.channel.$ref.substring(ow_.length)}function L4E(e){try{let[t,r]=e.split("#/");if(t==null||r==null)throw new Error(`Invalid location format: ${e}; unable to parse message type and parameter key`);if(!t.startsWith(y0c))throw new Error(`Invalid location format: ${e}; expected ${y0c} prefix`);let i=t.substring(y0c.length);if(i!=="header"&&i!=="path"&&i!=="payload")throw new Error(`Invalid message type: ${i}. Must be one of: header, path, payload`);return{type:i,parameterKey:r}}catch{throw new Error(`Invalid location format: ${e}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`)}}function U4E(e,t){if(!t.$ref.startsWith(uw_))throw new Error(`Failed to resolve server name from server ref ${t.$ref}`);let r=t.$ref.substring(uw_.length),i=e[r];if(i==null)throw new Error(`Failed to find server with name ${r}`);return i}function sw_({messages:e,channelPath:t,origin:r,messageSchemas:i,duplicatedMessageIds:n,context:a}){let u=[];return e.forEach((l,d)=>{let o=a.resolveMessageReference(l).name;n.includes(o)&&(o=`${t}_${o}`);let c=i[o];c!=null&&u.push({origin:r,name:o??`${r}Message${d+1}`,body:qM(c)})}),u}function V4E({messages:e,messageSchemas:t}){let r=e.find(u=>u.origin==="client")?.name,i=e.find(u=>u.origin==="server")?.name,n=r!=null?t[r]:void 0,a=i!=null?t[i]:void 0;return{examplePublishMessage:n!=null&&r!=null?{type:r,payload:n}:void 0,exampleSubscribeMessage:a!=null&&i!=null?{type:i,payload:a}:void 0}}function lw_({document:e,taskContext:t,options:r,source:i,asyncApiOptions:n,namespace:a}){let u=[];if(a!=null&&u.push(a),parseFloat(e.asyncapi)<3){let l=e;l.tags?.[0]!=null?u.push(l.tags[0].name):n.naming!=="v2"&&u.push("websocket");let d=new bYo({document:l,taskContext:t,options:r,namespace:a});return aw_({context:d,breadcrumbs:u,source:i,asyncApiOptions:n,document:l})}else{let l=e,d=new wYo({document:l,taskContext:t,options:r,namespace:a});return cw_({context:d,breadcrumbs:u,source:i,asyncApiOptions:n,document:l})}}function fw_(e){let t=W4E(e),r={};return v0c({obj:t,occurrences:r,breadcrumbs:[]}),r}function v0c({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let i of e)v0c({obj:i,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let i=e.$ref;t[i]==null?t[i]=1:t[i]+=1;return}for(let i in e)v0c({obj:e[i],occurrences:t,breadcrumbs:[...r,i]})}}}function W4E(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?exa(r.get):void 0,put:r?.put!=null?exa(r.put):void 0,post:r?.post!=null?exa(r.post):void 0,patch:r?.patch!=null?exa(r.patch):void 0,delete:r?.delete!=null?exa(r.delete):void 0}]))}}function exa(e){return{...e,requestBody:e.requestBody!=null?sp(e.requestBody)?e.requestBody:H4E(e.requestBody):void 0}}function H4E(e){let t,r;for(let i in e.content){let n=mM.parse(i);n!=null&&(n.isJSON()?t=e.content[i]:n.isMultipart()&&(r=e.content[i]))}return r!=null&&t!=null?{...e,content:{[mM.MULTIPART_FORM_DATA]:r}}:e}var SYo=class{endpoints;parser=new IHi;constructor({context:t,options:r}){this.endpoints=r.filter?.endpoints?new Set(this.validateAndFilterEndpoints({context:t,endpoints:r.filter.endpoints})):void 0}skipEndpoint({method:t,path:r}){return this.endpoints!=null&&!this.endpoints.has(`${t} ${r}`)}hasEndpoints(){return this.endpoints!=null}validateAndFilterEndpoints({context:t,endpoints:r}){let i=[];for(let n of r){let a=this.parser.tryParse(n);if(a==null){t.logger.debug(`Ignoring configured filter endpoint "${n}"; expected format "POST /users/get"`);continue}i.push(`${a.method} ${a.path}`)}return i}};var dw_="#/components/parameters/",pw_="#/components/responses/",_w_="#/components/examples/",hw_="#/components/requestBodies/",z5n=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;filter;namespace;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=i,this.refOccurrences=fw_(t),this.options=n,this.source=a,this.filter=new SYo({context:r,options:n}),this.DUMMY=this.getDummy(),this.namespace=u}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};r.push(i)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return{"x-fern-type":"unknown"};if(Array.isArray(i)){let a=parseInt(n,10);if(isNaN(a)||a<0||a>=i.length)return{"x-fern-type":"unknown"};i=i[a]}else i=i[n]}return i==null?(this.logger.warn(`Encountered undefined reference: ${t.$ref}`),{"x-fern-type":"unknown"}):(sp(i)&&(i=this.resolveSchemaReference(i)),i)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(dw_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(dw_.length),i=this.document.components.parameters[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return sp(i)?this.resolveParameterReference(i):i}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(hw_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(hw_.length),i=this.document.components.requestBodies[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return sp(i)?this.resolveRequestBodyReference(i):i}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(pw_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(pw_.length),i=this.document.components.responses[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return sp(i)?this.resolveResponseReference(i):i}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(_w_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(_w_.length),i=this.document.components.examples[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return sp(i)?this.resolveExampleReference(i):i}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}};var x5n=class extends z5n{constructor({document:t,taskContext:r,options:i,source:n,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:i,source:n,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,i){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,i){}getDiscriminatedUnionMetadata(t){}};var DYo=class extends z5n{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discriminatedUnionReferences={};discriminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u})}getDummy(){return new x5n({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,i){let n=this.discriminatedUnionReferences[t.$ref];n!=null?(n.discriminants.add(r),n.numReferences+=i):this.discriminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:i}}getReferencesFromDiscriminatedUnion(t){return this.discriminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,i){let n=this.discriminatedUnionMetadata[t.$ref];n!=null?n.discriminants.set(r,i):this.discriminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,i]])}}getDiscriminatedUnionMetadata(t){return this.discriminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function yw_(e){return hf(e,id.ASYNC_CONFIG)}var vw_="$request.";function bw_(e){let t=hf(e,id.STREAMING);if(t!=null)return typeof t=="boolean"?t?{type:"stream",format:"json"}:void 0:t["stream-condition"]==null&&t.format!=null?{type:"stream",format:t.format}:{type:"streamCondition",format:t.format??"json",streamDescription:t["stream-description"],streamConditionProperty:$4E(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function $4E(e){return e.startsWith(vw_)?e.slice(vw_.length):e}function gw_(e){let t=e;if(t.cursor!=null)return bFe.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});if("offset"in e){let r=e;return bFe.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}if("type"in e&&e.type==="custom"){let r=e;return bFe.custom({results:r.results})}throw new Error("Invalid pagination extension")}function Ow_(e,t){let r=hf(t,id.PAGINATION);if(r!=null){if(typeof r=="boolean"){let i=hf(e,id.PAGINATION);if(typeof i=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return i==null?void 0:gw_(i)}return gw_(r)}}var G4E=hu.object({lang:hu.string(),label:hu.optional(hu.string()),source:hu.string()}),b0c=hu.array(G4E);var mw_={README_EXT:"x-readme"};function Q4E(e){if(!Array.isArray(e))return!1;for(let t of e)if(!Jj(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function Pw_(e){let t=hf(e,mw_.README_EXT);if(!Jj(t))return[];let r=t["code-samples"];if(!Q4E(r))return[];let i=[];for(let n of r)i.push({name:n.name,language:n.language,code:n.code,install:n.install,docs:void 0});return i}function jw_(e,t,r){let n=(hf(t,id.EXAMPLES)??[]).filter(s=>{let o=JN.serialization.ExampleEndpointCallSchema.parse(s);return o.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),o.ok}),a=Yza(t,cH.REDOCLY_CODE_SAMPLES_KEBAB,b0c,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],l=[...Yza(t,cH.REDOCLY_CODE_SAMPLES_CAMEL,b0c,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...a];l.length>0&&n.push({"code-samples":l.map(s=>({name:s.label??s.lang,language:s.lang,code:s.source,install:void 0,docs:void 0}))});let d=Pw_(t);return d.length>0&&n.push({"code-samples":d}),n.map(cHt.unknown)}function ww_(e){let t=hf(e,id.AVAILABILITY);if(t==="ga"||t==="generally-available")return eH.GenerallyAvailable;if(t==="beta"||t==="pre-release")return eH.Beta;if(t==="deprecated")return eH.Deprecated;if(e.deprecated)return eH.Deprecated}function EYo(e){return{url:J4E({url:e.url,variables:e.variables??{}}),description:e.description,name:K4E(e),audiences:hf(e,id.AUDIENCES)}}function J4E({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([i,n])=>[i,n.default]));for(let[i,n]of Object.entries(r))e=e.replace(`{${i}}`,n);return e}function K4E(e){let t=hf(e,[id.SERVER_NAME_V1,id.SERVER_NAME_V2]);if(t!=null)return t;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox"}function Sw_(e){return hf(e,id.PARAMETER_NAME)}function Dw_(e){return hf(e,id.SDK_VARIABLE)}function MYo({path:e,httpMethod:t,parameters:r,context:i,requestBreadcrumbs:n,source:a}){let u={pathParameters:[],queryParameters:[],headers:[]};for(let l of r){let d=hf(l,id.IGNORE);if(d!=null&&d){i.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let s=sp(l)?i.resolveParameterReference(l):l,o=s.required??!1,c=vJ(s),b=[...n,s.name],g=s8(b,i.options.preserveSchemaIds),O=s.schema!=null?t0(s.schema,!o,i,b,a,i.namespace,!1,new Set,Pir({schema:s,logger:i.logger})):o?zl.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:up.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:Pir({schema:s,logger:i.logger})}),description:void 0,availability:c,namespace:void 0,groupName:void 0}):zl.optional({nameOverride:void 0,generatedName:g,title:void 0,value:zl.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:up.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:Pir({schema:s,logger:i.logger})}),description:void 0,availability:void 0,namespace:void 0,groupName:void 0}),description:void 0,availability:c,namespace:void 0,groupName:void 0,inline:void 0});if(s.in==="header"&&s.schema!=null&&!sp(s.schema)&&s.schema.default!=null){let P=s.schema.default;typeof P=="string"&&P.length>0&&(O=zl.literal({nameOverride:void 0,generatedName:g,title:void 0,value:vz.string(P),description:void 0,availability:c,namespace:void 0,groupName:void 0}))}let m={name:s.name,schema:O,description:s.description,parameterNameOverride:Sw_(s),availability:c,source:a};s.in==="query"?u.queryParameters.push(m):s.in==="path"?u.pathParameters.push({...m,variableReference:Dw_(s)}):s.in==="header"?!Y4E.has(s.name.toLowerCase())&&!i.authHeaders.has(s.name)?u.headers.push({...m,env:void 0}):i.logger.debug(`Ignoring ${s.name} header, in ${t.toUpperCase()} ${e}`):i.logger.warn(`Skipping ${s.in} parameter, ${s.name}, in ${t.toUpperCase()} ${e}`)}return u}var Y4E=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function Ew_(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r,schema:n??{},examples:txa(i,t)}}}function R5n(e,t){for(let r of Object.keys(e))if(r.includes("json")||r==="*/*"){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r.includes("*")?void 0:r,schema:n??{},examples:txa(i,t)}}}function Mw_(e,t){for(let r of Object.keys(e)){let i=e[r];if(i==null)continue;return{schema:i.schema??{},examples:txa(i,t)}}}function txa(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let i=hf(e,cH.EXAMPLES);return i!=null&&Object.keys(i).length>0&&r.push(...Object.entries(i).map(([n,a])=>({name:a.summary??n,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([n,a])=>{let u=sp(a)?t.resolveExampleReference(a):a;return{name:u.summary??n,value:u.value,description:u.description}})),r}function X4E(e,t){for(let[r,i]of Object.entries(e.content))if(mM.parse(r)?.isURLEncoded())return{schema:i.schema,contentType:r,examples:txa(i,t)}}function Z4E(e){for(let[t,r]of Object.entries(e.content))if(mM.parse(t)?.isMultipart())return{schema:r.schema,encoding:r.encoding}}function k4E(e){for(let t in e.content)if(mM.parse(t)?.isOctetStream())return!0;return!1}function e2E(e,t){let r=sp(e)?g0c(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([i,n])=>!sp(n)&&n.type==="string"&&n.format==="binary")!=null}function N5n({requestBody:e,document:t,context:r,requestBreadcrumbs:i,source:n,namespace:a}){let u=sp(e)?r.resolveRequestBodyReference(e):e,l=Z4E(u),d=l?.schema,s=l?.encoding,o=X4E(u,r),c=R5n(u.content,r);if(k4E(u))return EMe.octetStream({description:u.description,source:n});if(d!=null&&c==null||d!=null&&e2E(d,t)){let b=sp(d)?g0c(d,t):{id:void 0,schema:d},g=t0(b.schema,!1,r,i,n,a),O=[];if(g.type==="object")for(let m of g.properties){let{isFile:P,isOptional:E,isArray:q,description:M}=AYo({schema:m.schema});if(P){let D=Aw_(m.key,s);O.push({key:m.key,schema:$di.file({isOptional:E,isArray:q,description:M}),description:M,contentType:D,exploded:!1,encoding:D==null?r.options.defaultFormParameterEncoding:void 0})}else{let D=Aw_(m.key,s);O.push({key:m.key,schema:$di.json(m.schema),description:void 0,contentType:D,exploded:s?.[m.key]?.explode,encoding:D==null?r.options.defaultFormParameterEncoding:void 0})}}return EMe.multipart({name:sp(d)&&r.getNumberOfOccurrencesForRef(d)===1?b.id:void 0,description:b.schema.description,properties:O,source:n})}if(c!=null){let b=t0(c.schema,!1,r,i,n,a,!0);return EMe.json({description:void 0,schema:b,contentType:c.contentType,fullExamples:c.examples,additionalProperties:!sp(c.schema)&&E5n(c.schema.additionalProperties,r.options),source:n})}if(o!=null&&o.schema!=null){let b=t0(o.schema,!1,r,i,n,a);return EMe.json({schema:b,description:u.description,contentType:o.contentType,source:n,fullExamples:o.examples,additionalProperties:!1})}}function g0c(e,t){if(!e.$ref.startsWith(YJi))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=uAi(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let i=t.components?.schemas?.[r];if(i==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return sp(i)?g0c(i,t):{id:r,schema:i}}function AYo({schema:e,isOptional:t,isArray:r,description:i}){return r2E(e)?AYo({schema:e.value,isOptional:!0,isArray:r,description:e.description}):i2E(e)?AYo({schema:e.value,isOptional:t,isArray:r,description:e.description}):n2E(e)?AYo({schema:e.value,isOptional:t,isArray:!0,description:e.description}):t2E(e)?{isFile:!0,isOptional:t??!1,isArray:r??!1,description:i??e.description}:{isFile:!1,isOptional:t??!1,isArray:r??!1,description:void 0}}function t2E(e){return e.type==="primitive"&&e.schema.type==="string"&&e.schema.format==="binary"}function r2E(e){return e.type==="optional"}function i2E(e){return e.type==="nullable"}function n2E(e){return e.type==="array"}function Aw_(e,t){return t?.[e]?.contentType}var O0c={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",498:"InvalidTokenError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},qw_=new Set(Object.values(O0c));var a2E=["200","201","202","204"];function Cw_({operationContext:e,responses:t,context:r,responseBreadcrumbs:i,responseStatusCode:n,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let l=o2E({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,s;for(let o of n!=null?[n]:a2E){let c=t[o];c!=null&&(d=!0,s==null&&(s=Tw_({operationContext:e,response:c,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace,statusCode:typeof o=="string"?parseInt(o):o})))}if(s==null&&!d&&t.default!=null&&(s=Tw_({operationContext:e,response:t.default,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace})),s!=null)switch(s.type){case"json":return{value:s,errors:l};case"streamingJson":case"streamingSse":return{value:s,errors:l};case"bytes":case"file":case"text":case"streamingText":return{value:s,errors:l};default:mo(s)}return{value:void 0,errors:l}}function Tw_({operationContext:e,streamFormat:t,response:r,context:i,responseBreadcrumbs:n,source:a,namespace:u,statusCode:l}){let d=sp(r)?i.resolveResponseReference(r):r;if(d.content!=null&&Object.entries(d.content).find(([b,g])=>{if(g.schema==null)return!1;let O=sp(g.schema)?i.resolveSchemaReference(g.schema):g.schema;return O.type==="string"&&O.format==="binary"}))return i.options.useBytesForBinaryResponse&&t==null?vC.bytes({description:d.description,source:a,statusCode:l}):vC.file({description:d.description,source:a,statusCode:l});let s=Ew_(d.content??{},i);if(s!=null&&t!=null)switch(t){case"json":return vC.streamingJson({statusCode:l,description:d.description,responseProperty:hf(e.operation,id.RESPONSE_PROPERTY),fullExamples:s.examples,schema:t0(s.schema,!1,i,n,a,u),source:a});case"sse":return vC.streamingSse({description:d.description,responseProperty:void 0,fullExamples:s.examples,schema:t0(s.schema,!1,i,n,a,u),source:a,statusCode:l})}let o=R5n(d.content??{},i);if(o!=null){if(t!=null)switch(t){case"json":return vC.streamingJson({description:d.description,responseProperty:void 0,fullExamples:o.examples,schema:t0(o.schema,!1,i,n,a,u),source:a,statusCode:l});case"sse":return vC.streamingSse({description:d.description,responseProperty:void 0,fullExamples:o.examples,schema:t0(o.schema,!1,i,n,a,u),source:a,statusCode:l})}return vC.json({description:d.description,schema:t0(o.schema,!1,i,n,a,u),responseProperty:hf(e.operation,id.RESPONSE_PROPERTY),fullExamples:o.examples,source:a,statusCode:l})}for(let[c,b]of Object.entries(d.content??{})){let g=mM.parse(c);if(g!=null){if(g.isOctetStream()||g.isPDF()||g.isAudio()||g.isImage()||g.isVideo())return vC.file({description:d.description,source:a,statusCode:l});if(g.isPlainText()){let O=b.schema;if(O==null)return vC.text({description:d.description,source:a,statusCode:l});let m=sp(O)?i.resolveSchemaReference(O):O;return m.type==="string"&&m.format==="byte"?vC.file({description:d.description,source:a,statusCode:l}):vC.text({description:d.description,source:a,statusCode:l})}}}}function o2E({responses:e,context:t,source:r,namespace:i}){let n={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let l=parseInt(a);if(l<400||l>600)continue;let d=sp(u)?t.resolveResponseReference(u):u,s=Mw_(d.content??{},t),o=O0c[l];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}n[l]={statusCode:l,nameOverride:void 0,generatedName:o,description:d.description,schema:t0(s?.schema??{},!1,t,[o,"Body"],r,i),fullExamples:s?.examples,source:r}}return n}function spi({operationContext:e,context:t,responseStatusCode:r,suffix:i,streamFormat:n,source:a}){let{document:u,operation:l,path:d,method:s,baseBreadcrumbs:o,sdkMethodName:c}=e,b=hf(l,id.IDEMPOTENT),g=hf(l,[id.REQUEST_NAME_V1,id.REQUEST_NAME_V2]),O=[...o,"Request"],m=MYo({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:O,path:d,httpMethod:s,source:a}),P=/{([^}]+)}/g,q=[...d.matchAll(P)].map(L=>L[1]).filter(L=>!m.pathParameters.some(V=>V.name===L));if(q.length>0)for(let L of q)m.pathParameters.push({name:L??"",variableReference:void 0,parameterNameOverride:void 0,availability:void 0,source:a,schema:zl.primitive({schema:up.string({default:void 0,example:void 0,format:void 0,maxLength:void 0,minLength:void 0,pattern:void 0}),description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0,availability:void 0,title:void 0}),description:void 0});let M=l.requestBody!=null?N5n({requestBody:l.requestBody,document:u,context:new x5n({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:O,source:a,namespace:t.namespace}):void 0;s2E({context:t,convertedParameters:m})&&M!=null&&M.type==="json"&&M.schema.type!=="object"&&l.requestBody!=null?M=N5n({requestBody:l.requestBody,document:u,context:t,requestBreadcrumbs:[...O,"Body"],source:a,namespace:t.namespace}):l.requestBody!=null&&(M=N5n({requestBody:l.requestBody,document:u,context:t,requestBreadcrumbs:[...O],source:a,namespace:t.namespace}));let D=[...o,"Response"],C=Cw_({operationContext:e,streamFormat:n,responses:l.responses,context:t,responseBreadcrumbs:D,responseStatusCode:r,source:a});e.method==="GET"&&(M=void 0);let x=ww_(l),$=jw_(e,l,t),I=hf(l,id.SERVER_NAME_V2);return{summary:l.summary,internal:hf(l,cH.INTERNAL),idempotent:b,audiences:hf(l,id.AUDIENCES)??[],operationId:l.operationId!=null&&i!=null?l.operationId+"_"+i:l.operationId,tags:t.resolveTagsToTagIds(l.tags),namespace:t.namespace,sdkName:c,pathParameters:m.pathParameters,queryParameters:m.queryParameters,headers:m.headers,requestNameOverride:g??void 0,generatedRequestName:s8(O,t.options.preserveSchemaIds),request:M,response:C.value,errors:C.errors,servers:I!=null?[{name:I,url:void 0,audiences:void 0}]:(l.servers??[]).map(L=>EYo(L)),description:l.description,authed:u2E(l,u),availability:x,method:s,path:d,examples:$,pagination:e.pagination,source:a}}function u2E(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function s2E({context:e,convertedParameters:t}){return e.options.inlinePathParameters&&t.pathParameters.length>0||t.queryParameters.length>0||t.headers.length>0}function Iw_({operationContext:e,context:t,asyncExtension:r,source:i}){let{operation:n,pathItemParameters:a,operationParameters:u}=e,l=r.discriminant.name,d=r.discriminant.value,s=r["response-status-code"],o=Bw_({context:t,headerToIgnore:l,parameters:a}),c=Bw_({context:t,headerToIgnore:l,parameters:u}),b=spi({operationContext:{...e,pathItemParameters:o,operationParameters:c,operation:{...n,responses:Object.fromEntries(Object.entries(n.responses).filter(([O])=>parseInt(O)!==s))}},context:t,streamFormat:void 0,source:i}),g=spi({operationContext:{...e,pathItemParameters:o,operationParameters:c,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:s,streamFormat:void 0,source:i});return g.headers.push({name:l,schema:zl.literal({nameOverride:void 0,generatedName:s8([l],t.options.preserveSchemaIds),title:void 0,description:void 0,availability:void 0,value:vz.string(d),namespace:void 0,groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:i}),{sync:b,async:g}}function Bw_({context:e,headerToIgnore:t,parameters:r}){return r.filter(i=>{let n=sp(i)?e.resolveParameterReference(i):i;return!(n.in==="header"&&n.name===t)})}var m0c="stream";function Nw_({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:spi({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let i=zw_({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(i?.schemaReference!=null){let s=uAi(i.schemaReference);s!=null&&t.excludeSchema(s)}let n=xw_({operation:e.operation,response:r.responseStream}),a=spi({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+m0c}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:i?.requestBody,responses:n},baseBreadcrumbs:[...e.baseBreadcrumbs,m0c]},context:t,streamFormat:r.format,suffix:m0c,source:t.source});a.examples=a.examples.filter(s=>Rw_(s,t)!==!1);let u=zw_({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),l=xw_({operation:e.operation,response:r.response}),d=spi({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u?.requestBody,responses:l}},context:t,source:t.source});return d.examples=d.examples.filter(s=>Rw_(s,t)!==!0),{streaming:a,nonStreaming:d}}default:mo(r)}}function zw_({context:e,operation:t,streamingExtension:r,isStreaming:i}){if(t.requestBody==null)return;let n=sp(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=R5n(n.content,e);if(a==null)return;let u=sp(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let l=u.properties?.[r.streamConditionProperty];l!=null&&sp(l)&&(l=void 0);let d={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":i,...l??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[mM.APPLICATION_JSON]:{schema:d}}},schemaReference:sp(a.schema)?a.schema:void 0}}function xw_({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[mM.APPLICATION_JSON]:{schema:t}}}}}function Rw_(e,t){return e._visit({unknown:r=>{let i=JN.serialization.ExampleEndpointCallSchema.parse(r);if(i.ok&&i.value.response!=null)return i.value.response.stream!=null},full:()=>{},_other:()=>{}})}function Fw_({context:e,operationContext:t,source:r}){let{document:i,operation:n,path:a,method:u,baseBreadcrumbs:l,sdkMethodName:d}=t,s=[...l,"Payload"],o=MYo({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:s,path:a,httpMethod:u,source:r});if(n.requestBody==null){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Missing a request body`);return}if(u!=="POST"&&u!=="GET"){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Not POST or GET`);return}let c=N5n({requestBody:n.requestBody,document:i,context:e,requestBreadcrumbs:[...l,"Payload"],source:r,namespace:e.namespace});if(c==null||c.type!=="json"){e.logger.error(`Skipping webhook ${a} because non-json request body`);return}if(n.operationId==null){e.logger.error(`Skipping webhook ${a} because no operation id present`);return}return{summary:n.summary,audiences:hf(n,id.AUDIENCES)??[],sdkName:d,namespace:e.namespace,method:u,operationId:n.operationId,tags:e.resolveTagsToTagIds(n.tags),headers:o.headers,generatedPayloadName:s8(s,e.options.preserveSchemaIds),payload:c.schema,description:n.description,examples:c2E(c.fullExamples),source:r}}function c2E(e){if(e==null)return[];let t=[];for(let r of e){let i=sAi(r.value);i!=null&&t.push({description:r.description,name:r.name,payload:i})}return t}function P0c({context:e,pathItemContext:t,operation:r,convertToWebhook:i}){let n=hf(r,id.IGNORE);if(n!=null&&n){e.logger.debug(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=l2E(r,e),u=Ow_(e.document,r),l={...t,sdkMethodName:a,baseBreadcrumbs:f2E({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path,shouldUseIdiomaticRequestNames:e.options.shouldUseIdiomaticRequestNames}),operation:r,operationParameters:r.parameters??[],pagination:u};if(i){let c=Fw_({context:e,operationContext:l,source:e.source});return c!=null?{type:"webhook",value:c}:void 0}let d=bw_(r);if(d!=null){let c=Nw_({context:e,operationContext:l,streamingExtension:d});return c!=null?{type:"streaming",streaming:c.streaming,nonStreaming:c.nonStreaming}:void 0}let s=yw_(r);if(s!=null){let c=Iw_({context:e,operationContext:l,asyncExtension:s,source:e.source});return{type:"async",async:c.async,sync:c.sync}}return{type:"http",value:spi({context:e,operationContext:l,streamFormat:void 0,source:e.source})}}function l2E(e,t){let r=hf(e,id.SDK_METHOD_NAME),i=hf(e,id.SDK_GROUP_NAME)??[];if(r!=null){let n=typeof i=="string"?[i]:i;return n=t.resolveGroupName(n),{groupName:n,methodName:r}}}function f2E({sdkMethodName:e,operation:t,httpMethod:r,path:i,shouldUseIdiomaticRequestNames:n}){let a=[];if(e!=null){if(n&&a.push(e.methodName),e.groupName.length>0){let u=e.groupName[e.groupName.length-1];u!=null&&a.push(typeof u=="string"?u:u.name)}n||a.push(e.methodName)}else t.operationId!=null?a.push(t.operationId):a.push(T_(`${r}_${i.split("/").join("_")}`));return a}function Lw_(e,t,r,i){let n=[],a=Vw_(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let l of a){if(i.filter.skipEndpoint({method:l.method,path:e})){i.logger.debug(`Skipping endpoint "${l.method} ${e}"`);continue}let d=d2E({operation:l.operation}),s=P0c({context:i,pathItemContext:{...u,method:l.method},operation:l.operation,convertToWebhook:d});s!=null&&n.push(s)}return n}function Uw_(e,t,r,i){let n=[],a=Vw_(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let l of a){if(i.filter.skipEndpoint({method:l.method,path:e})){i.logger.debug(`Skipping endpoint "${l.method} ${e}"`);continue}let d=P0c({context:i,pathItemContext:{...u,method:l.method},operation:l.operation,convertToWebhook:!0});d!=null&&n.push(d)}return n}function Vw_(e){let t=[];return e.get!=null&&t.push({method:rH.Get,operation:e.get}),e.post!=null&&t.push({method:rH.Post,operation:e.post}),e.put!=null&&t.push({method:rH.Put,operation:e.put}),e.delete!=null&&t.push({method:rH.Delete,operation:e.delete}),e.patch!=null&&t.push({method:rH.Patch,operation:e.patch}),e.head!=null&&t.push({method:rH.Head,operation:e.head}),t}function d2E({operation:e}){return hf(e,[id.WEBHOOK])??!1}function Ww_(e){let t=hf(e,id.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=hf(e,id.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function Hw_(e){return hf(e,id.FERN_BASIC_AUTH)}function j0c(e,t){if(sp(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return p2E(e,t)}function p2E(e,t){if(e.type==="apiKey"&&e.in==="header"){let r=hf(e,cH.BEARER_FORMAT),i=hf(e,id.FERN_HEADER_AUTH);return nL.header({headerName:e.name,prefix:r!=null?"Bearer":i?.prefix,headerVariableName:i?.name??hf(e,id.HEADER_VARIABLE_NAME),headerEnvVar:i?.env})}else if(e.type==="http"&&e.scheme==="bearer"){let r=hf(e,id.FERN_BEARER_TOKEN);return nL.bearer({tokenVariableName:r?.name??hf(e,id.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:r?.env})}else if(e.type==="http"&&e.scheme==="basic"){let r=Hw_(e),i=Ww_(e);return nL.basic({usernameVariableName:r?.username?.name??i.usernameVariable,usernameEnvVar:r?.username?.env,passwordVariableName:r?.password?.name??i.passwordVariable,passwordEnvVar:r?.password?.env})}else{if(e.type==="openIdConnect")return nL.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return nL.oauth({scopesEnum:_2E(e,t)})}}function _2E(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let i=oAi({nameOverride:void 0,generatedName:"OauthScope",title:void 0,enumValues:Object.keys(r),fernEnum:Object.fromEntries(Object.entries(r).map(([a,u])=>[a,{description:u}])),_default:void 0,description:void 0,availability:void 0,enumVarNames:void 0,wrapAsNullable:!1,namespace:void 0,groupName:void 0,context:void 0,source:t,inline:void 0}),n=qM(i);if(n.type==="enum")return n}}function $w_(e){return hf(e,id.BASE_PATH)}var h2E=hu.record(hu.string(),hu.object({summary:hu.string().optional(),description:hu.string().optional()}));function Gw_({document:e,context:t}){return Yza(e,id.GROUPS,h2E,t.logger)}function Qw_({context:e,document:t}){return hf(t,id.FERN_VERSION)??void 0}function Jw_(e){let t=hf(e,id.FERN_GLOBAL_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?Xza({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function Kw_(e){let t=hf(e,id.FERN_IDEMPOTENCY_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?Xza({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function Yw_(e,t){let r=hf(e,id.SDK_VARIABLES);return r==null?{}:Object.fromEntries(Object.entries(r).map(([i,n])=>{if(n.type==="string")return[i,{nameOverride:void 0,generatedName:s8([i],t),title:n.title,schema:Xj.string({default:q5n(n),pattern:n.pattern,format:n.format,minLength:n.minLength,maxLength:n.maxLength}),description:n.description,availability:void 0,namespace:void 0,groupName:void 0}];throw new Error(`Variable ${i} has unsupported schema ${JSON.stringify(n)}`)}))}var y2E="webhooks";function Xw_(e){return hf(e,y2E)??{}}function Zw_(e){return hf(e,id.RESOLUTIONS)}function kw_({openapi:e}){let t=Zw_(e);if(t==null)return e;let r={};for(let i of t){let n=`#/components/schemas/${i.name}`;for(let a of i.resolutions)e=v2E({openapi:e,schemaReference:a,schemaName:i.name}),e=e1_({openapi:e,replaceReference:a,schemaReference:n,replacedReferences:r}),r={...r,...Object.fromEntries(i.resolutions.map(u=>[n,u]))}}return e}function v2E({openapi:e,schemaReference:t,schemaName:r}){let i=t.replace("#/","").split("/").map(a=>a.replaceAll("~1","/")),n=e;for(let a of i){let u=n[a];if(u==null)return e;n=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=n,e}function e1_({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:i}){let n=Object.keys(i).filter(d=>t.startsWith(d)).sort((d,s)=>s.length-d.length)[0];if(n!=null){let d=i[n];if(d!=null){let s=r.replace(n,d);return e1_({openapi:e,replaceReference:t,schemaReference:s,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replaceAll("~1","/")),u=e;for(let d of a.slice(0,-1)){let s=u[d];if(s==null)return e;u=s}let l=a[a.length-1];return l==null||(u[l]={$ref:r}),e}function r1_({openApi:e,taskContext:t,options:r,source:i,namespace:n}){e=kw_({openapi:e});let a=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([I,L])=>j0c(L,i)==null?[]:[I,j0c(L,i)])),u=new Set(...Object.entries(a).map(([I,L])=>L.type==="basic"||L.type==="bearer"?"Authorization":L.type==="header"?L.headerName:null)),l=Yw_(e,r.preserveSchemaIds),d=Jw_(e),s=Kw_(e),o=r.audiences??[],c=[],b=[],g=new DYo({document:e,taskContext:t,authHeaders:u,options:r,source:i,namespace:n});g.filter.hasEndpoints()&&t.logger.debug("Endpoint filter applied..."),Object.entries(e.paths??{}).forEach(([I,L])=>{if(L==null)return;t.logger.debug(`Converting path ${I}`);let V=Lw_(I,L,e,g);for(let X of V){let K=t1_({operation:X});if(!(o.length>0&&!o.some(Z=>K.includes(Z))))switch(X.type){case"async":c.push(X.sync),c.push(X.async);break;case"http":c.push(X.value);break;case"streaming":c.push(X.streaming),X.nonStreaming&&c.push(X.nonStreaming);break;case"webhook":b.push(X.value);break;default:mo(X)}}}),Object.entries(Xw_(e)).forEach(([I,L])=>{if(L==null)return;t.logger.debug(`Converting path ${I}`);let V=Uw_(I,L,e,g);for(let X of V){let K=t1_({operation:X});o.length>0&&!o.some(Z=>K.includes(Z))||b.push(X.value)}});let O=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([I,L])=>{let V=hf(L,id.SDK_NAMESPACE);if(!sp(L)){let X=hf(L,id.IGNORE);if(X!=null&&X)return[];if(qw_.has(I))return[I,t0({...L,"x-fern-type-name":`${I}Body`},!1,g,[I],i,V??n)]}return[I,t0(L,!1,g,[I],i,V??n)]}).filter(I=>I.length>0)),m=b2E(O,g,i),P=g2E(m,g),E={};for(let[I,L]of Object.entries(P)){let V=qM(L);g.isSchemaExcluded(I)||(E[I]=V,t.logger.debug(`Converted schema ${I}`))}let q=new cAi(P,g.nonRequestReferencedSchemas,g),M=b.map(I=>{let V=I.examples;if(!r.disableExamples&&V.length===0){let X=q.buildExample({schema:I.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});X!=null&&(V=[{name:void 0,description:void 0,payload:X}])}return{...I,payload:qM(I.payload),examples:V}}),D=new OYo(P,g),C=c.map(I=>{let L=I.examples,V=L;if(!r.disableExamples&&(L.length===0||L.every(kza))){let Z=D.buildEndpointExample(I);Z.length>0&&(V=[...Z,...L.filter(fe=>!kza(fe))])}let X=I.request,K=I.response;return{...I,request:X?.type==="json"?{...X,schema:qM(X.schema)}:X,response:K?.type==="json"?{...K,schema:qM(K.schema)}:K,queryParameters:I.queryParameters.map(Z=>({description:Z.description,name:Z.name,schema:qM(Z.schema),parameterNameOverride:Z.parameterNameOverride,availability:Z.availability,source:Z.source})),pathParameters:I.pathParameters.map(Z=>({description:Z.description,name:Z.name,schema:qM(Z.schema),parameterNameOverride:Z.parameterNameOverride,variableReference:Z.variableReference,availability:Z.availability,source:Z.source})),headers:I.headers.map(Z=>({description:Z.description,name:Z.name,schema:qM(Z.schema),parameterNameOverride:Z.parameterNameOverride,env:Z.env,availability:Z.availability,source:Z.source})),examples:V,errors:dd(I.errors,Z=>{let fe=Z.fullExamples?.map(me=>{let _e=sAi(me.value);if(_e!=null)return{name:me.name,description:me.description,example:_e}}).filter(V0);if(fe?.length===0){let me=q.buildExample({schema:Z.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});me!=null&&fe.push({name:void 0,description:void 0,example:me})}return{generatedName:Z.generatedName,nameOverride:Z.nameOverride,schema:qM(Z.schema),description:Z.description,source:Z.source,examples:fe}})}}),x=Gw_({document:e,context:g});return{apiVersion:Qw_({context:g,document:e}),basePath:$w_(e),title:e.info.title??"",description:e.info.description,groups:Object.fromEntries(Object.entries(x??{}).map(([I,L])=>[I,{summary:L.summary??void 0,description:L.description??void 0}])),servers:(e.servers??[]).map(I=>EYo(I)),websocketServers:[],tags:{tagsById:Object.fromEntries((e.tags??[]).map(I=>[I.name,{id:I.name,description:I.description}])),orderedTagIds:e.tags?.map(I=>I.name)},endpoints:C,webhooks:M,channels:{},groupedSchemas:B5n(n,E),securitySchemes:a,hasEndpointsMarkedInternal:C.some(I=>I.internal),nonRequestReferencedSchemas:g.getReferencedSchemas(),variables:l,globalHeaders:d,idempotencyHeaders:s}}function b2E(e,t,r){let i={};for(let[n,a]of Object.entries(e)){if(a.type!=="object"){i[n]=a;continue}let u={$ref:`#/components/schemas/${n}`},l=t.getReferencesFromDiscriminatedUnion(u);if(l==null){i[n]=a;continue}let d={...a,type:"object",properties:a.properties.filter(o=>!l.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!l.discriminants.has(o.propertyKey)),source:r};i[n]=d;let s=i1_({schema:a,schemas:e});for(let o of[...new Set(s)]){let c=i[o]??e[o];c==null||c.type!=="object"||(i[o]={...c,type:"object",properties:c.properties.filter(b=>!l.discriminants.has(b.key)),allOfPropertyConflicts:c.allOfPropertyConflicts.filter(b=>!l.discriminants.has(b.propertyKey))})}}return i}function g2E(e,t){let r={};for(let[i,n]of Object.entries(e)){if(n.type!=="object"){r[i]=n;continue}let a={$ref:`#/components/schemas/${i}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[i]=n;continue}let l=[];for(let s of n.properties)if(u.discriminants.has(s.key)){let o=u.discriminants.get(s.key);o!=null&&l.push({...s,schema:zl.literal({nameOverride:void 0,generatedName:s8([n.generatedName,o],t.options.preserveSchemaIds),title:void 0,value:vz.string(o),namespace:void 0,groupName:void 0,description:void 0,availability:n.availability})})}else l.push(s);let d={...n,type:"object",properties:l};r[i]=d}return r}function i1_({schema:e,schemas:t}){let r=[];for(let i of e.allOf){r.push(i.schema);let n=t[i.schema];n!=null&&n.type==="object"&&r.push(...i1_({schema:n,schemas:t}))}return r}function t1_({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":t=e.value.audiences;break;default:mo(e)}return t}function XJi({context:e,documents:t,options:r}){let i={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],websocketServers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channels:{},groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}};for(let n of t){let a=n.source!=null?n.source:Gae.openapi({file:"<memory>"});switch(n.type){case"openapi":{let u=r1_({taskContext:e,openApi:n.value,options:s0c({options:n.settings,overrides:r}),source:a,namespace:n.namespace});i=m2E(i,u);break}case"asyncapi":{let u=lw_({document:n.value,taskContext:e,options:s0c({options:n.settings,overrides:r}),source:a,asyncApiOptions:O2E({options:n.settings}),namespace:n.namespace});u.servers!=null&&(i.websocketServers=[...i.websocketServers,...u.servers.map(l=>({...l,audiences:void 0,description:void 0}))]),u.channels!=null&&(i.channels={...i.channels,...u.channels}),u.groupedSchemas!=null&&(i.groupedSchemas=n1_(i.groupedSchemas,u.groupedSchemas)),u.basePath!=null&&(i.basePath=u.basePath);break}default:mo(n)}}return i}function O2E({options:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??Tj_.naming}}function m2E(e,t){return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],websocketServers:[...e.websocketServers,...t.websocketServers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channels:{...e.channels,...t.channels},groupedSchemas:n1_(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 n1_(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,i]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...i}:e.namespacedSchemas[r]=i;return e}var qYo={config:new a1_.Config({apis:{},styleguide:{plugins:[u0c],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0};function rxa(e){return e.swagger!=null}function w0c(e){return e.openapi!=null}function lAi(e,t={}){return{...Object.fromEntries(t3(e.namedDefinitionFiles).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...t3(e.importedDefinitions).reduce((r,[i,n])=>({...r,...Hwa(lAi(n.definition,{defaultURL:n.url}),(a,u)=>WN(i,yy.of(u)))}),{})}}function ixa(e,t={}){return{...Object.fromEntries(t3(e.packageMarkers).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...t3(e.importedDefinitions).reduce((r,[i,n])=>({...r,...Hwa(ixa(n.definition,{defaultURL:n.url}),(a,u)=>WN(i,yy.of(u)))}),{})}}function cpi(e){return{...ixa(e),...lAi(e)}}function eoe(e,t){return cpi(e.definition)[t]?.contents}function I3(e,t){for(let[r,i]of t3(cpi(e.definition)))t(r,i.contents,{isPackageMarker:uWi(r)===zS,defaultUrl:i.defaultUrl})}function ZJi(e,t){for(let[r,i]of t3(ixa(e.definition)))t(r,i.contents)}var _M_=ci(pM_(),1);async function Kxa(e){return(await(0,_M_.convertObj)(e,{})).openapi}var yM_=require("fs/promises");var hM_=require("fs/promises");async function i9n({absoluteFilePathToOverrides:e,data:t,context:r,allowNullKeys:i}){let n=null;try{let a=(await(0,hM_.readFile)(e,"utf8")).toString();try{n=JSON.parse(a)}catch{n=qd.load(a,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return w3s({data:t,overrides:n,allowNullKeys:i})}async function EOc({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,yM_.readFile)(t)).toString(),n=await qd.load(i);return r!=null?await i9n({absoluteFilePathToOverrides:r,context:e,data:n}):n}var Xxa=ci(lYo(),1);var vM_=ci(lYo(),1),MOc=ci(require("path"),1);var Yxa=class extends vM_.BaseResolver{absolutePathToOpenAPIOverrides;constructor(t){super(),this.absolutePathToOpenAPIOverrides=t}resolveExternalRef(t,r){let i=super.resolveExternalRef(t,r);return Bli($l.of(i))?i:this.absolutePathToOpenAPIOverrides!=null?MOc.default.resolve(MOc.default.dirname(this.absolutePathToOpenAPIOverrides),r):i}};async function AOc({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,parsed:r}){return(r!=null?await(0,Xxa.bundle)({...qYo,doc:{source:new Xxa.Source(e,"<openapi>"),parsed:r},externalRefResolver:new Yxa(t)}):await(0,Xxa.bundle)({...qYo,ref:e,externalRefResolver:new Yxa(t)})).bundle.parsed}var BVE=["examples","example",id.EXAMPLES,cH.REDOCLY_CODE_SAMPLES_CAMEL,cH.REDOCLY_CODE_SAMPLES_KEBAB];async function Zxa({context:e,absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r}){let i=await AOc({absolutePathToOpenAPI:t}),n;if(r!=null?n=r:typeof i=="object"&&i[id.OPENAPI_OVERIDES_FILEPATH]!=null&&(n=Vu(Xd(t),Qa.of(i[id.OPENAPI_OVERIDES_FILEPATH]))),n!=null){let a=await i9n({absoluteFilePathToOverrides:n,context:e,data:i,allowNullKeys:BVE});return await AOc({absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r,parsed:a})}return i}var wHt=class{absoluteFilePath;constructor(t){this.absoluteFilePath=t}async loadDocuments({context:t,specs:r}){let i=[];for(let n of r){let a=(await(0,bM_.readFile)(n.absoluteFilepath)).toString(),u=xq(this.absoluteFilePath,n.source.file);n.source.relativePathToDependency!=null&&(u=Vu(n.source.relativePathToDependency,u));let l=n.source.type==="protobuf"?Gae.protobuf({file:u}):Gae.openapi({file:u});if(a.includes("openapi")||a.includes("swagger")){let d=await Zxa({absolutePathToOpenAPI:n.absoluteFilepath,context:t,absolutePathToOpenAPIOverrides:n.absoluteFilepathToOverrides});if(w0c(d)){i.push({type:"openapi",value:d,source:l,namespace:n.namespace,settings:n.settings});continue}else if(rxa(d)){let s=await Kxa(d);i.push({type:"openapi",value:s,source:l,namespace:n.namespace,settings:n.settings});continue}}if(a.includes("asyncapi")){let d=await EOc({context:t,absoluteFilePath:n.absoluteFilepath,absoluteFilePathToOverrides:n.absoluteFilepathToOverrides});i.push({type:"asyncapi",value:d,source:l,namespace:n.namespace,settings:n.settings});continue}if(a.includes("openrpc")){let d=await EOc({context:t,absoluteFilePath:n.absoluteFilepath,absoluteFilePathToOverrides:n.absoluteFilepathToOverrides});i.push({type:"asyncapi",value:d,source:l,namespace:n.namespace,settings:n.settings});continue}t.failAndThrow(`${n.absoluteFilepath} is not a valid OpenAPI or AsyncAPI file`)}return i}};var JXo=require("fs/promises"),QA_=ci(fne(),1);var GA_=ci($A_(),1);function $Xo(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...u}={}){let l=n.reduce((s,o)=>({...s,[o]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[s,o]of Object.entries(l))d=d.replaceAll(s,o);return e?.debug(`+ ${d}`),(0,GA_.default)(t,r,u)}async function x3(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...u}={}){let l=$Xo(e,t,r,{doNotPipeOutput:i,secrets:n,substitutions:a,...u});i||(l.stdout?.pipe(process.stdout),l.stderr?.pipe(process.stderr));let d=await l;return d.stdout==null&&(d.stdout=""),d.stderr==null&&(d.stderr=""),d}function GXo(e,{logger:t,...r}={}){return(i,n)=>x3(t,e,i,{...r,...n})}var DHE="buf.gen.yaml",JA_="output",EHE=`${JA_}/openapi.yaml`,QXo=class{context;constructor({context:t}){this.context=t}async generate({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,relativeFilepathToProtobufRoot:i,local:n}){return n?this.generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,relativeFilepathToProtobufRoot:i}):this.generateRemote()}async generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,relativeFilepathToProtobufRoot:i}){let n=await this.setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t,relativeFilepathToProtobufRoot:i}),a=xq(t,r);return this.doGenerateLocal({cwd:n,target:a})}async setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t,relativeFilepathToProtobufRoot:r}){let i=$l.of((await QA_.default.dir()).path);return await(0,JXo.cp)(t,i,{recursive:!0}),await(0,JXo.writeFile)(Vu(i,Qa.of(DHE)),MHE({relativeFilepathToProtobufRoot:r})),i}async doGenerateLocal({cwd:t,target:r}){let i=GXo("which",{cwd:t,logger:this.context.logger});try{await i(["buf"])}catch{this.context.failAndThrow("Missing required dependency; please install 'buf' to continue (e.g. 'brew install buf').")}try{await i(["protoc-gen-openapi"])}catch{this.context.failAndThrow("Missing required dependency; please install 'protoc-gen-openapi' to continue (e.g. 'brew install go && go install github.com/fern-api/protoc-gen-openapi/cmd/protoc-gen-openapi@latest').")}let n=GXo("buf",{cwd:t,logger:this.context.logger});return await n(["config","init"]),await n(["generate",r]),Vu(t,Qa.of(EHE))}async generateRemote(){this.context.failAndThrow("Remote Protobuf generation is unimplemented.")}};function MHE({relativeFilepathToProtobufRoot:e}){return`
|
|
1950
|
+
`)),{ok:!0,value:t}):i}}function kHo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var n8n=class e extends Error{errors;constructor(t){super(t.map(kHo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var a8n=class e extends Error{errors;constructor(t){super(t.map(kHo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Wq(e){return{optional:()=>$pc(e),transform:t=>Gpc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new a8n(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new n8n(i.errors)}}}function $pc(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>Ej.OPTIONAL};return{...t,...Wq(t)}}function Gpc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...Wq(r)}}function $__(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:dA(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:dA(t,"bigint")}]},getType:()=>Ej.BIGINT};return{...aL(e),...Wq(e)}}var tmE=/^([+-]?\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 G__(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:dA(t,"string")}]}:tmE.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:dA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:dA(t,"Date object")}]},getType:()=>Ej.DATE};return{...aL(e),...Wq(e)}}function fJ(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...aL(r),...Wq(r)}}}function e$o(e){let t=new Set(e);return fJ(Ej.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:dA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:dA(i,"enum")}]}:{ok:!0,value:i})()}function Q__(e){let t=Qpc(e);return{...t,...Wq(t)}}function Qpc(e){return{parse:(t,r)=>o8n(e).parse(t,r),json:(t,r)=>o8n(e).json(t,r),getType:()=>o8n(e).getType()}}function o8n(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function UIa(e){return Object.entries(e)}function VIa(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function wMi(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 WIa(e){return Object.keys(e)}function J__(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function fHt(e){return{withParsedProperties:t=>Jpc(e,t)}}function Jpc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((l,[d,s])=>({...l,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!wMi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:dA(i,"object")}]};let a=new Set(Object.keys(t)),u=VIa(i,Object.keys(i).filter(l=>!a.has(l)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...Wq(r),...fHt(r)}}function K__(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function SMi(e){return e.isProperty}function t$o(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>SMi(i)?i.rawKey:r),_getParsedProperties:()=>WIa(e),parse:(r,i)=>{let n={},a=[];for(let[u,l]of UIa(e)){let d=SMi(l)?l.rawKey:u,s=SMi(l)?l.valueSchema:l,o={rawKey:d,parsedKey:u,valueSchema:s};n[d]=o,Z__(s)&&a.push(d)}return Y__({value:r,requiredKeys:a,getProperty:u=>{let l=n[u];if(l!=null)return{transformedKey:l.parsedKey,transform:d=>l.valueSchema.parse(d,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of UIa(e)){let l=SMi(u)?u.valueSchema:u;Z__(l)&&n.push(a)}return Y__({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return SMi(u)?{transformedKey:u.rawKey,transform:l=>u.valueSchema.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:l=>u.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>Ej.OBJECT};return{...aL(t),...Wq(t),...fHt(t),...bJi(t)}}function Y__({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!wMi(e))return{ok:!1,errors:[{path:a,message:dA(e,"object")}]};let u=new Set(t),l=[],d={};for(let[s,o]of Object.entries(e)){let c=r(s);if(c!=null){u.delete(s);let b=c.transform(o);b.ok?d[c.transformedKey]=b.value:(d[s]=o,l.push(...b.errors))}else switch(i){case"fail":l.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=o;break}}return l.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),l.length===0||n?{ok:!0,value:d}:{ok:!1,errors:l}}function bJi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>X__({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>X__({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>Ej.OBJECT};return{...r,...Wq(r),...fHt(r),...bJi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>Ej.OBJECT};return{...t,...Wq(t),...fHt(t),...bJi(t)}}}}function X__({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=J__(WIa(t),s=>n.has(s)),l=r(VIa(t,u)),d=i(VIa(t,a));return l.ok&&d.ok?{ok:!0,value:{...l.value,...d.value}}:{ok:!1,errors:[...l.ok?[]:l.errors,...d.ok?[]:d.errors]}}function Z__(e){return!rmE(e)}function rmE(e){switch(e.getType()){case Ej.ANY:case Ej.UNKNOWN:case Ej.OPTIONAL:return!0;default:return!1}}function k__(e){return t$o(e)}function eh_(e){let t={...Qpc(e),_getRawProperties:()=>o8n(e)._getRawProperties(),_getParsedProperties:()=>o8n(e)._getParsedProperties()};return{...t,...Wq(t),...fHt(t),...bJi(t)}}function r$o(e){let t={parse:(r,i)=>th_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>th_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>Ej.LIST};return{...aL(t),...Wq(t)}}function th_(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:dA(e,"list"),path:[]}]}}function rh_(e){return fJ(Ej.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:dA(r,`"${e}"`)}]})()}function ih_(e){return fJ(Ej.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:dA(r,`${e.toString()}`)}]})()}var nh_=fJ(Ej.ANY,e=>({ok:!0,value:e}));var ah_=fJ(Ej.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:dA(e,"boolean")}]});var oh_=fJ(Ej.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:dA(e,"number")}]});var uh_=fJ(Ej.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:dA(e,"string")}]});var sh_=fJ(Ej.UNKNOWN,e=>({ok:!0,value:e}));function lh_(e,t){let r={parse:(i,n)=>ch_({value:i,isKeyNumeric:e.getType()===Ej.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>ch_({value:i,isKeyNumeric:e.getType()===Ej.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>Ej.RECORD};return{...aL(r),...Wq(r)}}function ch_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return wMi(e)?UIa(e).reduce((a,[u,l])=>{if(l==null)return a;let d=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),c=i(l,s);if(d.ok&&o.ok&&c.ok)return{ok:!0,value:{...d.value,[o.value]:c.value}};let b=[];return d.ok||b.push(...d.errors),o.ok||b.push(...o.errors),c.ok||b.push(...c.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:dA(e,"object")}]}}function fh_(e){let t=r$o(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:dA(i,"Set")}]},getType:()=>Ej.SET};return{...aL(r),...Wq(r)}}function ph_(e){let t={parse:(r,i)=>dh_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>dh_((n,a)=>n.json(r,a),e,i),getType:()=>Ej.UNDISCRIMINATED_UNION};return{...aL(t),...Wq(t)}}function dh_(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let l of u.errors)i.push({path:l.path,message:`[Variant ${n}] ${l.message}`})}return{ok:!1,errors:i}}function _h_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function yh_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=e$o(WIa(t)),a={parse:(u,l)=>hh_({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:d=>n.parse(d,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),json:(u,l)=>hh_({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:d=>n.json(d,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),getType:()=>Ej.UNION};return{...aL(a),...Wq(a),...fHt(a)}}function hh_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:l=[]}){if(!wMi(e))return{ok:!1,errors:[{path:l,message:dA(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:l,message:`Missing discriminant ("${t}")`}]};let o=i(d);if(!o.ok)return{ok:!1,errors:o.errors};let c=n(o.value);if(c==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...l,t],message:"Unexpected discriminant value"}]};let b=u(s,c);return b.ok?{ok:!0,value:{[r]:d,...b.value}}:b}var am=At.objectWithoutOptionalProperties({title:At.string().optional()});var i$o=At.objectWithoutOptionalProperties({file:At.string()});var n$o=At.objectWithoutOptionalProperties({file:At.string()});var a$o=At.union("type",{openapi:i$o,protobuf:n$o}).transform({transform:e=>{switch(e.type){case"openapi":return Gae.openapi(e);case"protobuf":return Gae.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Jh=At.objectWithoutOptionalProperties({source:a$o.optional()});var o$o=At.objectWithoutOptionalProperties({typeName:At.string()});var u$o=At.union("type",{protobuf:o$o}).transform({transform:e=>{switch(e.type){case"protobuf":return r8n.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Qae=At.objectWithoutOptionalProperties({encoding:u$o.optional()});var bf=At.objectWithoutOptionalProperties({description:At.string().optional()});var s$o=At.enum_(["GenerallyAvailable","Beta","Deprecated"]);var Ah=At.objectWithoutOptionalProperties({availability:s$o.optional()});var sir=At.number();var gFe=At.objectWithoutOptionalProperties({statusCode:sir.optional()});var C0=At.objectWithoutOptionalProperties({nameOverride:At.string().optional(),generatedName:At.string()});var GE=At.objectWithoutOptionalProperties({inline:At.boolean().optional()});var nk=At.string();var ak=At.string();var c$o=At.objectWithoutOptionalProperties({id:ak}).extend(bf);var l$o=At.string();var f$o=At.objectWithoutOptionalProperties({usernameVariableName:At.string().optional(),usernameEnvVar:At.string().optional(),passwordVariableName:At.string().optional(),passwordEnvVar:At.string().optional()});var d$o=At.objectWithoutOptionalProperties({tokenVariableName:At.string().optional(),tokenEnvVar:At.string().optional()});var p$o=At.objectWithoutOptionalProperties({headerName:At.string(),prefix:At.string().optional(),headerVariableName:At.string().optional(),headerEnvVar:At.string().optional()});var _$o=At.objectWithoutOptionalProperties({queryParameterName:At.string()});var h$o=At.objectWithoutOptionalProperties({snake:At.string().optional(),camel:At.string().optional(),screamingSnake:At.string().optional(),pascal:At.string().optional()});var DMi=At.objectWithoutOptionalProperties({nameOverride:At.string().optional(),generatedName:At.string(),value:At.string(),casing:h$o.optional()}).extend(bf).extend(Ah);var y$o=At.objectWithoutOptionalProperties({type:At.stringLiteral("namespace"),name:At.string()});var v$o=At.undiscriminatedUnion([At.string(),y$o]);var EMi=At.list(v$o);var om=At.objectWithoutOptionalProperties({groupName:EMi.optional()});var e0=At.objectWithoutOptionalProperties({namespace:At.string().optional()});var u8n=At.objectWithoutOptionalProperties({default:DMi.optional(),values:At.list(DMi)}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Jh).extend(am).extend(GE);var b$o=At.objectWithoutOptionalProperties({scopesEnum:u8n.optional()});var g$o=At.union("type",{basic:f$o,bearer:d$o,header:p$o,query:_$o,oauth:b$o}).transform({transform:e=>{switch(e.type){case"basic":return nL.basic(e);case"bearer":return nL.bearer(e);case"header":return nL.header(e);case"query":return nL.query(e);case"oauth":return nL.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var HIa=At.objectWithoutOptionalProperties({name:At.string().optional(),url:At.string(),audiences:At.list(At.string()).optional()}).extend(bf);var O$o=At.string();var Ypc={};jo(Ypc,{FullExample:()=>Hq,FullObjectExample:()=>P$o,FullOneOfExample:()=>w$o,KeyValuePair:()=>j$o,LiteralExample:()=>m$o,PrimitiveExample:()=>c8n,PropertyKey:()=>s8n});var s8n=At.string();var c8n=At.union("type",{int:At.object({value:At.number()}),int64:At.object({value:At.number()}),uint:At.object({value:At.number()}),uint64:At.object({value:At.number()}),float:At.object({value:At.number()}),double:At.object({value:At.number()}),string:At.object({value:At.string()}),datetime:At.object({value:At.string()}),date:At.object({value:At.string()}),base64:At.object({value:At.string()}),boolean:At.object({value:At.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return w_.int(e.value);case"int64":return w_.int64(e.value);case"uint":return w_.uint(e.value);case"uint64":return w_.uint64(e.value);case"float":return w_.float(e.value);case"double":return w_.double(e.value);case"string":return w_.string(e.value);case"datetime":return w_.datetime(e.value);case"date":return w_.date(e.value);case"base64":return w_.base64(e.value);case"boolean":return w_.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var m$o=At.union("type",{boolean:At.object({value:At.boolean()}),string:At.object({value:At.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return i8n.boolean(e.value);case"string":return i8n.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Hq=At.union("type",{primitive:At.object({value:c8n}),object:At.lazyObject(()=>P$o),array:At.object({value:At.list(At.lazy(()=>Hq))}),map:At.object({value:At.list(At.lazyObject(()=>j$o))}),enum:At.object({value:At.string()}),literal:At.object({value:m$o}),oneOf:At.object({value:At.lazy(()=>w$o)}),unknown:At.object({value:At.lazy(()=>Hq)})}).transform({transform:e=>{switch(e.type){case"primitive":return vO.primitive(e.value);case"object":return vO.object(e);case"array":return vO.array(e.value);case"map":return vO.map(e.value);case"enum":return vO.enum(e.value);case"literal":return vO.literal(e.value);case"oneOf":return vO.oneOf(e.value);case"unknown":return vO.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var P$o=At.objectWithoutOptionalProperties({properties:At.record(s8n,At.lazy(()=>Hq))});var j$o=At.objectWithoutOptionalProperties({key:c8n,value:At.lazy(()=>Hq)});var w$o=At.union("type",{discriminated:At.object({value:At.record(s8n,At.lazy(()=>Hq))}),undiscriminated:At.object({value:At.lazy(()=>Hq)})}).transform({transform:e=>{switch(e.type){case"discriminated":return PMi.discriminated(e.value);case"undiscriminated":return PMi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Xpc={};jo(Xpc,{AllOfPropertyConflict:()=>D8n,ArraySchema:()=>_Go,Availability:()=>s$o,BooleanSchema:()=>sGo,BytesResponse:()=>v8n,CasingOverrides:()=>h$o,CommonProperty:()=>PGo,CursorPagination:()=>$$o,CustomCodeSample:()=>W$o,CustomCodeSampleLanguage:()=>L$o,CustomCodeSampleSdk:()=>V$o,CustomPagination:()=>Q$o,DiscriminatedOneOfSchema:()=>OGo,DoubleSchema:()=>oGo,Endpoint:()=>J$o,EndpointExample:()=>m8n,EndpointResponseExample:()=>F$o,EndpointSdkName:()=>cir,EnumSchema:()=>u8n,EnumValue:()=>DMi,ErrorExample:()=>I$o,FernExample:()=>x$o,FileResponse:()=>h8n,FileSchema:()=>E$o,FullEndpointExample:()=>H$o,GlobalHeader:()=>lGo,Header:()=>MMi,HeaderExample:()=>O8n,HttpEndpointServer:()=>b8n,HttpError:()=>z$o,HttpMethod:()=>l8n,IdempotencyHeader:()=>fGo,IntSchema:()=>nGo,JsonRequest:()=>T$o,JsonResponse:()=>y8n,LiteralSchema:()=>S8n,LiteralSchemaValue:()=>dGo,LongSchema:()=>aGo,MapSchema:()=>hGo,MultipartRequest:()=>_8n,MultipartRequestProperty:()=>q$o,MultipartRequestPropertyEncoding:()=>A$o,MultipartSchema:()=>M$o,NullableSchema:()=>vGo,ObjectProperty:()=>gGo,ObjectPropertyConflictInfo:()=>E8n,ObjectSchema:()=>pGo,OctetStreamRequest:()=>p8n,OffsetPagination:()=>G$o,OneOfSchema:()=>bGo,OpenApiIntermediateRepresentation:()=>vh_,OptionalSchema:()=>yGo,Pagination:()=>P8n,PathParameter:()=>f8n,PathParameterExample:()=>R$o,PrimitiveSchema:()=>qMi,PrimitiveSchemaValue:()=>cGo,QueryParameter:()=>d8n,QueryParameterExample:()=>g8n,ReferencedSchema:()=>lir,Request:()=>C$o,Response:()=>B$o,Schema:()=>Om,Schemas:()=>iGo,SdkGroupInfo:()=>S$o,StreamingResponseExample:()=>N$o,StringSchema:()=>uGo,SupportedSdkLanguage:()=>U$o,Tags:()=>D$o,TextResponse:()=>AMi,UnDiscriminatedOneOfSchema:()=>mGo,Webhook:()=>K$o,WebhookExampleCall:()=>w8n,WebhookHttpMethod:()=>j8n,WebsocketChannel:()=>rGo,WebsocketHandshake:()=>Y$o,WebsocketMessageExample:()=>eGo,WebsocketMessageOrigin:()=>X$o,WebsocketMessageSchema:()=>Z$o,WebsocketServer:()=>k$o,WebsocketSessionExample:()=>tGo});var S$o=At.objectWithoutOptionalProperties({summary:At.string().optional(),description:At.string().optional()});var D$o=At.objectWithoutOptionalProperties({tagsById:At.record(ak,c$o),orderedTagIds:At.list(ak).optional()});var l8n=At.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var f8n=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>Om),variableReference:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(bf).extend(Ah).extend(Jh);var d8n=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>Om),parameterNameOverride:At.string().optional()}).extend(bf).extend(Ah).extend(Jh);var MMi=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>Om),env:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(bf).extend(Ah).extend(Jh);var cir=At.objectWithoutOptionalProperties({groupName:EMi,methodName:At.string()});var p8n=At.objectWithoutOptionalProperties({}).extend(bf).extend(Jh);var E$o=At.objectWithoutOptionalProperties({isOptional:At.boolean(),isArray:At.boolean()}).extend(bf);var M$o=At.union("type",{file:E$o,json:At.object({value:At.lazy(()=>Om)})}).transform({transform:e=>{switch(e.type){case"file":return $di.file(e);case"json":return $di.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var A$o=At.enum_(["json","form"]);var q$o=At.objectWithoutOptionalProperties({key:At.string(),schema:M$o,contentType:At.string().optional(),exploded:At.boolean().optional(),encoding:A$o.optional()}).extend(bf);var _8n=At.objectWithoutOptionalProperties({name:At.string().optional(),properties:At.list(q$o)}).extend(bf).extend(Jh);var T$o=At.objectWithoutOptionalProperties({schema:At.lazy(()=>Om),contentType:At.string().optional(),additionalProperties:At.boolean()}).extend(bf).extend(Jh);var C$o=At.union("type",{octetStream:p8n,multipart:_8n,json:T$o}).transform({transform:e=>{switch(e.type){case"octetStream":return jMi.octetStream(e);case"multipart":return jMi.multipart(e);case"json":return jMi.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var h8n=At.objectWithoutOptionalProperties({}).extend(bf).extend(Jh).extend(gFe);var y8n=At.objectWithoutOptionalProperties({schema:At.lazy(()=>Om),responseProperty:At.string().optional()}).extend(bf).extend(Jh).extend(gFe);var AMi=At.objectWithoutOptionalProperties({}).extend(bf).extend(Jh).extend(gFe);var v8n=At.objectWithoutOptionalProperties({}).extend(bf).extend(Jh).extend(gFe);var B$o=At.union("type",{file:h8n,json:y8n,text:AMi,bytes:v8n,streamingSse:y8n,streamingText:AMi,streamingJson:y8n}).transform({transform:e=>{switch(e.type){case"file":return lJ.file(e);case"json":return lJ.json(e);case"text":return lJ.text(e);case"bytes":return lJ.bytes(e);case"streamingSse":return lJ.streamingSse(e);case"streamingText":return lJ.streamingText(e);case"streamingJson":return lJ.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var I$o=At.objectWithoutOptionalProperties({name:At.string().optional(),description:At.string().optional(),example:At.lazy(()=>Hq)});var z$o=At.objectWithoutOptionalProperties({schema:At.lazy(()=>Om).optional(),examples:At.list(I$o).optional()}).extend(bf).extend(C0).extend(Jh);var b8n=At.objectWithoutOptionalProperties({name:At.string().optional(),url:At.string().optional(),audiences:At.list(At.string()).optional()});var x$o=At.unknown();var R$o=At.objectWithoutOptionalProperties({name:At.string(),parameterNameOverride:At.string().optional(),value:At.lazy(()=>Hq)});var g8n=At.objectWithoutOptionalProperties({name:At.string(),value:At.lazy(()=>Hq)});var O8n=At.objectWithoutOptionalProperties({name:At.string(),value:At.lazy(()=>Hq)});var N$o=At.objectWithoutOptionalProperties({sse:At.boolean(),events:At.list(At.lazy(()=>Hq))});var F$o=At.union("type",{withStreaming:N$o,withoutStreaming:At.object({value:At.lazy(()=>Hq)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return lHt.withStreaming(e);case"withoutStreaming":return lHt.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var L$o=At.objectWithoutOptionalProperties({name:At.string().optional(),language:At.string(),code:At.string(),install:At.string().optional()}).extend(bf);var U$o=At.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var V$o=At.objectWithoutOptionalProperties({name:At.string().optional(),sdk:U$o,code:At.string()}).extend(bf);var W$o=At.union("type",{language:L$o,sdk:V$o}).transform({transform:e=>{switch(e.type){case"language":return Hdi.language(e);case"sdk":return Hdi.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var H$o=At.objectWithoutOptionalProperties({name:At.string().optional(),pathParameters:At.list(R$o).optional(),queryParameters:At.list(g8n).optional(),headers:At.list(O8n).optional(),request:At.lazy(()=>Hq).optional(),response:F$o.optional(),codeSamples:At.list(W$o)}).extend(bf);var m8n=At.union("type",{unknown:At.object({value:x$o}),full:H$o}).transform({transform:e=>{switch(e.type){case"unknown":return cHt.unknown(e.value);case"full":return cHt.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var $$o=At.objectWithoutOptionalProperties({cursor:At.string(),nextCursor:At.property("next_cursor",At.string()),results:At.string()});var G$o=At.objectWithoutOptionalProperties({offset:At.string(),results:At.string(),step:At.string().optional(),hasNextPage:At.string().optional()});var Q$o=At.objectWithoutOptionalProperties({results:At.string()});var P8n=At.union("type",{cursor:$$o,offset:G$o,custom:Q$o}).transform({transform:e=>{switch(e.type){case"cursor":return bFe.cursor(e);case"offset":return bFe.offset(e);case"custom":return bFe.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var J$o=At.objectWithoutOptionalProperties({authed:At.boolean(),internal:At.boolean().optional(),idempotent:At.boolean().optional(),method:l8n,audiences:At.list(At.string()),path:At.string(),summary:At.string().optional(),operationId:At.string().optional(),tags:At.list(ak),pathParameters:At.list(f8n),queryParameters:At.list(d8n),headers:At.list(MMi),sdkName:cir.optional(),generatedRequestName:At.string(),requestNameOverride:At.string().optional(),request:C$o.optional(),response:B$o.optional(),errors:At.record(sir,z$o),servers:At.list(b8n),examples:At.list(m8n),pagination:P8n.optional()}).extend(bf).extend(Ah).extend(Jh).extend(e0);var j8n=At.enum_(["GET","POST"]);var w8n=At.objectWithoutOptionalProperties({name:At.string().optional(),payload:At.lazy(()=>Hq)}).extend(bf);var K$o=At.objectWithoutOptionalProperties({audiences:At.list(At.string()),sdkName:cir.optional(),method:j8n,summary:At.string().optional(),operationId:At.string(),tags:At.list(ak),headers:At.list(MMi),generatedPayloadName:At.string(),payload:At.lazy(()=>Om),examples:At.list(w8n)}).extend(bf).extend(Jh).extend(e0);var Y$o=At.objectWithoutOptionalProperties({queryParameters:At.list(d8n),headers:At.list(MMi),pathParameters:At.list(f8n)});var X$o=At.enum_(["client","server"]);var Z$o=At.objectWithoutOptionalProperties({name:At.string(),origin:X$o,body:At.lazy(()=>Om)});var k$o=At.objectWithoutOptionalProperties({name:At.string(),url:At.string()});var eGo=At.objectWithoutOptionalProperties({messageType:At.string(),payload:At.lazy(()=>Hq)}).extend(bf);var tGo=At.objectWithoutOptionalProperties({name:At.string().optional(),queryParameters:At.list(g8n).optional(),headers:At.list(O8n).optional(),messages:At.list(eGo)}).extend(bf);var rGo=At.objectWithoutOptionalProperties({audiences:At.list(At.string()),path:At.string(),groupName:EMi,summary:At.string().optional(),handshake:Y$o,messages:At.list(Z$o),servers:At.list(k$o),examples:At.list(tGo)}).extend(bf).extend(Jh);var iGo=At.objectWithoutOptionalProperties({rootSchemas:At.record(nk,At.lazy(()=>Om)),namespacedSchemas:At.record(O$o,At.record(nk,At.lazy(()=>Om)))});var nGo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional()});var aGo=At.objectWithoutOptionalProperties({default:At.number().optional()});var oGo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional()});var uGo=At.objectWithoutOptionalProperties({default:At.string().optional(),pattern:At.string().optional(),format:At.string().optional(),minLength:At.number().optional(),maxLength:At.number().optional()});var sGo=At.objectWithoutOptionalProperties({default:At.boolean().optional()});var cGo=At.union("type",{int:nGo,int64:aGo,uint:At.object({}),uint64:At.object({}),float:At.object({}),double:oGo,string:uGo,datetime:At.object({}),date:At.object({}),base64:At.object({}),boolean:sGo}).transform({transform:e=>{switch(e.type){case"int":return Xj.int(e);case"int64":return Xj.int64(e);case"uint":return Xj.uint();case"uint64":return Xj.uint64();case"float":return Xj.float();case"double":return Xj.double(e);case"string":return Xj.string(e);case"datetime":return Xj.datetime();case"date":return Xj.date();case"base64":return Xj.base64();case"boolean":return Xj.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var qMi=At.objectWithoutOptionalProperties({schema:cGo}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am);var lGo=At.objectWithoutOptionalProperties({header:At.string(),name:At.string().optional(),optional:At.boolean().optional(),env:At.string().optional(),schema:At.lazy(()=>Om).optional()});var fGo=At.objectWithoutOptionalProperties({header:At.string(),name:At.string().optional(),env:At.string().optional(),schema:At.lazy(()=>Om).optional()});var vh_=At.objectWithoutOptionalProperties({apiVersion:At.unknown().optional(),title:At.string().optional(),description:At.string().optional(),basePath:At.string().optional(),servers:At.list(HIa),websocketServers:At.list(HIa),groups:At.record(At.string(),S$o),tags:D$o,hasEndpointsMarkedInternal:At.boolean(),endpoints:At.list(J$o),webhooks:At.list(K$o),channels:At.record(At.string(),rGo),groupedSchemas:iGo,variables:At.record(At.string(),qMi),nonRequestReferencedSchemas:At.set(nk),securitySchemes:At.record(l$o,g$o),globalHeaders:At.list(lGo).optional(),idempotencyHeaders:At.list(fGo).optional()});var lir=At.objectWithoutOptionalProperties({schema:nk}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Jh).extend(am);var dGo=At.union("type",{boolean:At.object({value:At.boolean()}),string:At.object({value:At.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return vz.boolean(e.value);case"string":return vz.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var S8n=At.objectWithoutOptionalProperties({value:dGo}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am);var Om=At.union("type",{primitive:qMi,object:At.lazyObject(()=>pGo),array:At.lazyObject(()=>_Go),map:At.lazyObject(()=>hGo),optional:At.lazyObject(()=>yGo),enum:u8n,reference:lir,literal:S8n,oneOf:At.object({value:At.lazy(()=>bGo)}),nullable:At.lazyObject(()=>vGo),unknown:C0}).transform({transform:e=>{switch(e.type){case"primitive":return Fy.primitive(e);case"object":return Fy.object(e);case"array":return Fy.array(e);case"map":return Fy.map(e);case"optional":return Fy.optional(e);case"enum":return Fy.enum(e);case"reference":return Fy.reference(e);case"literal":return Fy.literal(e);case"oneOf":return Fy.oneOf(e.value);case"nullable":return Fy.nullable(e);case"unknown":return Fy.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var D8n=At.objectWithoutOptionalProperties({propertyKey:At.string(),allOfSchemaIds:At.list(nk),conflictingTypeSignatures:At.boolean()});var pGo=At.objectWithoutOptionalProperties({allOf:At.list(lir),properties:At.list(At.lazyObject(()=>gGo)),allOfPropertyConflicts:At.list(D8n),additionalProperties:At.boolean()}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Jh).extend(am).extend(GE);var E8n=At.objectWithoutOptionalProperties({differentSchema:At.boolean()});var gGo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>Om),readonly:At.boolean().optional(),writeonly:At.boolean().optional(),conflict:At.record(nk,E8n),generatedName:At.string(),nameOverride:At.string().optional(),audiences:At.list(At.string())}).extend(Ah);var _Go=At.objectWithoutOptionalProperties({value:At.lazy(()=>Om)}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am).extend(GE);var hGo=At.objectWithoutOptionalProperties({key:qMi,value:At.lazy(()=>Om)}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Qae).extend(am).extend(GE);var yGo=At.objectWithoutOptionalProperties({value:At.lazy(()=>Om)}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am).extend(GE);var vGo=At.objectWithoutOptionalProperties({value:At.lazy(()=>Om)}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am).extend(GE);var bGo=At.union("type",{discriminated:At.lazyObject(()=>OGo),undiscriminated:At.lazyObject(()=>mGo)}).transform({transform:e=>{switch(e.type){case"discriminated":return Gdi.discriminated(e);case"undiscriminated":return Gdi.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var OGo=At.objectWithoutOptionalProperties({discriminantProperty:At.string(),commonProperties:At.list(At.lazyObject(()=>PGo)),schemas:At.record(At.string(),At.lazy(()=>Om))}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Qae).extend(Jh).extend(am).extend(GE);var PGo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>Om)});var mGo=At.objectWithoutOptionalProperties({schemas:At.list(At.lazy(()=>Om))}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Qae).extend(Jh).extend(am).extend(GE);var Zpc={};jo(Zpc,{ArraySchemaWithExample:()=>VGo,Base64WithExample:()=>RGo,BooleanWithExample:()=>NGo,CommonPropertyWithExample:()=>XGo,DateWithExample:()=>xGo,DatetimeWithExample:()=>zGo,DiscriminatedOneOfSchemaWithExample:()=>KGo,DoubleWithExample:()=>BGo,EndpointWithExample:()=>gh_,EnumSchemaWithExample:()=>LGo,FloatWithExample:()=>CGo,HeaderWithExample:()=>TMi,HttpErrorWithExample:()=>EGo,Int64WithExample:()=>AGo,IntWithExample:()=>MGo,JsonRequestWithExample:()=>wGo,JsonResponseWithExample:()=>A8n,MapSchemaWithExample:()=>WGo,NamedFullExample:()=>fir,NullableSchemaWithExample:()=>$Go,ObjectPropertyWithExample:()=>JGo,ObjectSchemaWithExample:()=>GGo,OneOfSchemaWithExample:()=>QGo,OptionalSchemaWithExample:()=>HGo,PathParameterWithExample:()=>jGo,PrimitiveSchemaValueWithExample:()=>FGo,PrimitiveSchemaWithExample:()=>q8n,QueryParameterWithExample:()=>M8n,RequestWithExample:()=>SGo,ResponseWithExample:()=>DGo,SchemaWithExample:()=>pA,StringSchemaWithExample:()=>IGo,Uint64WithExample:()=>TGo,UintWithExample:()=>qGo,UnDiscriminatedOneOfSchemaWithExample:()=>YGo,UnknownSchemaWithExample:()=>UGo,WebhookWithExample:()=>Oh_,WebsocketHandshakeWithExample:()=>bh_});var fir=At.objectWithoutOptionalProperties({name:At.string().optional(),value:At.unknown()}).extend(bf);var M8n=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>pA),parameterNameOverride:At.string().optional()}).extend(bf).extend(Ah).extend(Jh);var TMi=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>pA),env:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(bf).extend(Ah).extend(Jh);var bh_=At.objectWithoutOptionalProperties({queryParameters:At.list(M8n),headers:At.list(TMi)});var jGo=At.objectWithoutOptionalProperties({name:At.string(),schema:At.lazy(()=>pA),variableReference:At.string().optional(),parameterNameOverride:At.string().optional()}).extend(bf).extend(Ah).extend(Jh);var wGo=At.objectWithoutOptionalProperties({schema:At.lazy(()=>pA),contentType:At.string().optional(),fullExamples:At.list(fir).optional(),additionalProperties:At.boolean()}).extend(bf).extend(Jh);var SGo=At.union("type",{octetStream:p8n,multipart:_8n,json:wGo}).transform({transform:e=>{switch(e.type){case"octetStream":return EMe.octetStream(e);case"multipart":return EMe.multipart(e);case"json":return EMe.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var A8n=At.objectWithoutOptionalProperties({schema:At.lazy(()=>pA),responseProperty:At.string().optional(),fullExamples:At.list(fir).optional()}).extend(bf).extend(Jh).extend(gFe);var DGo=At.union("type",{file:h8n,json:A8n,text:AMi,bytes:v8n,streamingSse:A8n,streamingText:AMi,streamingJson:A8n}).transform({transform:e=>{switch(e.type){case"file":return vC.file(e);case"json":return vC.json(e);case"text":return vC.text(e);case"bytes":return vC.bytes(e);case"streamingSse":return vC.streamingSse(e);case"streamingText":return vC.streamingText(e);case"streamingJson":return vC.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var EGo=At.objectWithoutOptionalProperties({statusCode:sir,schema:At.lazy(()=>pA),fullExamples:At.list(fir).optional()}).extend(bf).extend(C0).extend(Jh);var gh_=At.objectWithoutOptionalProperties({authed:At.boolean(),internal:At.boolean().optional(),idempotent:At.boolean().optional(),method:l8n,audiences:At.list(At.string()),path:At.string(),summary:At.string().optional(),operationId:At.string().optional(),tags:At.list(ak),pathParameters:At.list(jGo),queryParameters:At.list(M8n),headers:At.list(TMi),sdkName:cir.optional(),generatedRequestName:At.string(),requestNameOverride:At.string().optional(),request:SGo.optional(),response:DGo.optional(),errors:At.record(sir,EGo),servers:At.list(b8n),examples:At.list(m8n),pagination:P8n.optional()}).extend(bf).extend(Ah).extend(Jh).extend(e0);var Oh_=At.objectWithoutOptionalProperties({audiences:At.list(At.string()),sdkName:cir.optional(),method:j8n,summary:At.string().optional(),operationId:At.string(),tags:At.list(ak),headers:At.list(TMi),generatedPayloadName:At.string(),payload:At.lazy(()=>pA),examples:At.list(w8n)}).extend(bf).extend(Jh).extend(e0);var MGo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional(),example:At.number().optional()});var AGo=At.objectWithoutOptionalProperties({default:At.number().optional(),example:At.number().optional()});var qGo=At.objectWithoutOptionalProperties({default:At.number().optional(),example:At.number().optional()});var TGo=At.objectWithoutOptionalProperties({default:At.number().optional(),example:At.number().optional()});var CGo=At.objectWithoutOptionalProperties({example:At.number().optional()});var BGo=At.objectWithoutOptionalProperties({default:At.number().optional(),minimum:At.number().optional(),maximum:At.number().optional(),exclusiveMinimum:At.boolean().optional(),exclusiveMaximum:At.boolean().optional(),multipleOf:At.number().optional(),example:At.number().optional()});var IGo=At.objectWithoutOptionalProperties({default:At.string().optional(),pattern:At.string().optional(),format:At.string().optional(),minLength:At.number().optional(),maxLength:At.number().optional(),example:At.string().optional()});var zGo=At.objectWithoutOptionalProperties({example:At.string().optional()});var xGo=At.objectWithoutOptionalProperties({example:At.string().optional()});var RGo=At.objectWithoutOptionalProperties({example:At.string().optional()});var NGo=At.objectWithoutOptionalProperties({default:At.boolean().optional(),example:At.boolean().optional()});var FGo=At.union("type",{int:MGo,int64:AGo,uint:qGo,uint64:TGo,float:CGo,double:BGo,string:IGo,datetime:zGo,date:xGo,base64:RGo,boolean:NGo}).transform({transform:e=>{switch(e.type){case"int":return up.int(e);case"int64":return up.int64(e);case"uint":return up.uint(e);case"uint64":return up.uint64(e);case"float":return up.float(e);case"double":return up.double(e);case"string":return up.string(e);case"datetime":return up.datetime(e);case"date":return up.date(e);case"base64":return up.base64(e);case"boolean":return up.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var q8n=At.objectWithoutOptionalProperties({schema:FGo}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am);var LGo=At.objectWithoutOptionalProperties({default:DMi.optional(),values:At.list(DMi),example:At.string().optional()}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Jh).extend(am).extend(GE);var UGo=At.objectWithoutOptionalProperties({example:At.unknown()}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am);var pA=At.union("type",{primitive:q8n,object:At.lazyObject(()=>GGo),array:At.lazyObject(()=>VGo),map:At.lazyObject(()=>WGo),optional:At.lazyObject(()=>HGo),enum:LGo,reference:lir,literal:S8n,oneOf:At.object({value:At.lazy(()=>QGo)}),nullable:At.lazyObject(()=>$Go),unknown:UGo}).transform({transform:e=>{switch(e.type){case"primitive":return zl.primitive(e);case"object":return zl.object(e);case"array":return zl.array(e);case"map":return zl.map(e);case"optional":return zl.optional(e);case"enum":return zl.enum(e);case"reference":return zl.reference(e);case"literal":return zl.literal(e);case"oneOf":return zl.oneOf(e.value);case"nullable":return zl.nullable(e);case"unknown":return zl.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var VGo=At.objectWithoutOptionalProperties({value:At.lazy(()=>pA),example:At.list(At.unknown()).optional()}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am).extend(GE);var WGo=At.objectWithoutOptionalProperties({key:q8n,value:At.lazy(()=>pA),example:At.unknown().optional()}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Qae).extend(am).extend(GE);var HGo=At.objectWithoutOptionalProperties({value:At.lazy(()=>pA)}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am).extend(GE);var $Go=At.objectWithoutOptionalProperties({value:At.lazy(()=>pA)}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(am).extend(GE);var GGo=At.objectWithoutOptionalProperties({allOf:At.list(lir),properties:At.list(At.lazyObject(()=>JGo)),allOfPropertyConflicts:At.list(D8n),fullExamples:At.list(fir).optional(),additionalProperties:At.boolean()}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Jh).extend(am).extend(GE);var JGo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>pA),readonly:At.boolean().optional(),writeonly:At.boolean().optional(),audiences:At.list(At.string()),conflict:At.record(nk,E8n),nameOverride:At.string().optional(),generatedName:At.string()}).extend(Ah);var QGo=At.union("type",{discriminated:At.lazyObject(()=>KGo),undiscriminated:At.lazyObject(()=>YGo)}).transform({transform:e=>{switch(e.type){case"discriminated":return ik.discriminated(e);case"undiscriminated":return ik.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var KGo=At.objectWithoutOptionalProperties({discriminantProperty:At.string(),commonProperties:At.list(At.lazyObject(()=>XGo)),schemas:At.record(At.string(),At.lazy(()=>pA))}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Qae).extend(Jh).extend(am).extend(GE);var XGo=At.objectWithoutOptionalProperties({key:At.string(),schema:At.lazy(()=>pA)});var YGo=At.objectWithoutOptionalProperties({schemas:At.list(At.lazy(()=>pA))}).extend(om).extend(e0).extend(C0).extend(bf).extend(Ah).extend(Qae).extend(Jh).extend(am).extend(GE);var mh_=/^(\d+)/,T8n=/^[a-zA-Z][a-zA-Z0-9_]*$/,Ph_={"<":"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 CMi(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let u=Math.floor(e/10),l=e%10;return l===0?i[u]:`${i[u]}_${t[l]}`}if(e<1e3){let u=Math.floor(e/100),l=e%100;return l===0?`${t[u]}_hundred`:`${t[u]}_hundred_${CMi(l)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${CMi(a)}`}function $Ia(e){let t=e.match(mh_);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=CMi(n);return i.length>0?`${a}_${i}`:a}}}function C8n(e){let t=$Ia(e),r=Ph_[e];return t!=null?iz(T_(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":iz(T_(e)))}function Jae(e,t){return e.type==="primitive"&&t.type==="primitive"?jh_(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?imE(e.values,t.values):e.type==="array"&&t.type==="array"?Jae(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"?Jae(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?nmE(e.value,t.value):e.type==="object"&&t.type==="object"?amE(e,t):e.type==="map"&&t.type==="map"?jh_(e.key.schema,t.key.schema)&&Jae(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function jh_(e,t){return e.type===t.type}function imE(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return OEe(r,i)}function nmE(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,i])=>{let n=t.schemas[r];return n==null?!1:Jae(i,n)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,i)=>{let n=t.schemas[i];return n==null?!1:Jae(r,n)}):!1}function amE(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(i=>[i.key,i.schema]));return Object.entries(t.properties).every(([i,n])=>{let a=r[i];return a==null?!1:Jae(a,n.schema)})}var n8;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(n8||(n8={}));var ZGo=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;respectNullableSchemas;onlyIncludeReferencedSchemas;inlinePathParameters;useBytesForBinaryResponse;respectForwardCompatibleEnums;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:u}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=u,this.globalHeaderOverrides=a,this.detectGlobalHeaders=i?.detectGlobalHeaders??!0,this.objectQueryParameters=i?.objectQueryParameters??!1,this.respectReadonlySchemas=i?.respectReadonlySchemas??!1,this.respectNullableSchemas=i?.respectNullableSchemas??!1,this.onlyIncludeReferencedSchemas=i?.onlyIncludeReferencedSchemas??!1,this.inlinePathParameters=i?.inlinePathParameters??!1,this.useBytesForBinaryResponse=i?.useBytesForBinaryResponse??!1,this.respectForwardCompatibleEnums=i?.respectForwardCompatibleEnums??!1,this.referencedSchemaIds=i?.onlyIncludeReferencedSchemas?new Set:void 0,this.enableUniqueErrorsPerEndpoint=i?.enableUniqueErrorsPerEndpoint??!1,this.builder=new vJi(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let l={};if(!this.enableUniqueErrorsPerEndpoint)for(let d of r.endpoints)for(let[s,o]of Object.entries(d.errors)){let c=parseInt(s),b=l[c];b==null&&o.schema!=null?l[c]=o.schema:b!=null&&o.schema!=null&&Jae(b,o.schema)||this.unknownSchema.add(c)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.onlyIncludeReferencedSchemas&&this.isInAnyState(n8.Channel,n8.Endpoint,n8.Webhook)}markSchemaAsReferenced(t,r){switch(t.type){case"primitive":return;case"object":this.markObjectSchemaAsReferenced(t,r);return;case"array":this.markSchemaAsReferenced(t.value,r);return;case"map":this.markSchemaAsReferenced(t.value,r);return;case"optional":this.markSchemaAsReferenced(t.value,r);return;case"reference":this.markSchemaIdAsReferenced(t.schema,r);return;case"oneOf":this.markOneofSchemaAsReferenced(t.value,r);return;case"nullable":this.markSchemaAsReferenced(t.value,r);return;case"enum":return;case"literal":return;case"unknown":return;default:mo(t)}}markObjectSchemaAsReferenced(t,r){for(let i of t.allOf)this.markSchemaIdAsReferenced(i.schema,r);for(let i of t.properties)this.markSchemaAsReferenced(i.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let i of Object.values(t.schemas))this.markSchemaAsReferenced(i,r);return;case"undiscriminated":for(let i of t.schemas)this.markSchemaAsReferenced(i,r);return;default:mo(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let i=this.getSchema(t,r);i!=null&&this.markSchemaAsReferenced(i,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function Ox(e){switch(e){case eH.Deprecated:return"deprecated";case eH.Beta:return"pre-release";case eH.GenerallyAvailable:return"generally-available";default:return}}function omE(e){let t=e.find(i=>typeof i=="object"&&i.type==="namespace"),r=e.filter(i=>typeof i=="string"||i.type!=="namespace");return t?[t,...r]:r}function wh_(e){let t=e?omE(e):void 0;if(t==null||t.length===0)return UVi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(T_(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(T_(n.name)):r.push(n.name,UVi);break}default:mo(n.type)}else mo(n);return r.join("/")}function BMi(e){return yy.of(`${wh_(e)}.yml`)}function kpc({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?UVi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,wh_(r))}function Sh_({sdkName:e,namespaceOverride:t}){return yy.of(`${kpc({sdkName:e,namespaceOverride:t})}.yml`)}function Dh_({location:e,namespaceOverride:t}){return t!=null?WN(yy.of(t),e):e}function kGo(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:mo(e.type)}}function B8n(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:mo(e)}}function _A(e){return typeof e=="string"?e:e.type}function I8n(e){if(typeof e!="string")return e.docs}function GIa(e){if(typeof e!="string")return e.default}function e_c(e){if(typeof e!="string")return e.validation}var umE=-2147483648,smE=2147483647,cmE=-17976931348623157e292,lmE=17976931348623157e292;function Eg({schema:e,fileContainingReference:t,declarationFile:r=t,context:i,namespace:n,declarationDepth:a}){switch(i.shouldMarkSchemaAsReferenced()&&i.markSchemaAsReferenced(e,n),e.type){case"primitive":return eQo(e);case"array":return i_c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return n_c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return r_c({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return o_c();case"optional":return tQo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return a_c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return gmE({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,u_c(e);case"object":return OmE({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return mmE({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:mo(e)}}function eQo(e){switch(e.schema.type){case"string":return pmE({description:e.description,schema:e.schema});case"int":return _mE({description:e.description,schema:e.schema});case"float":return hmE({description:e.description,schema:e.schema});case"double":return ymE({description:e.description,schema:e.schema});case"boolean":return fmE({description:e.description,schema:e.schema});case"int64":return dmE({description:e.description,schema:e.schema})}let t=e.schema._visit({int:()=>"integer",int64:()=>"long",uint:()=>"uint",uint64:()=>"uint64",float:()=>"double",double:()=>"double",string:()=>"string",datetime:()=>"datetime",date:()=>"date",base64:()=>"base64",boolean:()=>"boolean",_other:()=>"unknown"});return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:Ox(e.availability)}:{}}}function fmE({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function dmE({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function pmE({description:e,schema:t}){let r="string",i=vmE(t);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function _mE({description:e,schema:t}){let r="integer",i=Mh_(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function hmE({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function ymE({description:e,schema:t}){let r="double",i=Mh_(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function vmE(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=bmE(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function bmE(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 Mh_(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=t_c(r,t),i=t_c(i,t),n=t_c(n,t),!(r==null&&i==null&&a==null&&u==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:u,multipleOf:n}}function t_c(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[umE,smE]:[cmE,lmE];return e<r||e>i?void 0:e}function r_c({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=PmE(n)??e.schema,u=B8n(n),l=jmE(n),d=rQo({context:r,fileContainingReference:t,declarationFile:BMi(u),type:a}),s=n.type==="nullable"?`optional<${d}>`:d;return e.description==null&&l==null?s:{type:n.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:Ox(e.availability)}:{}}}function i_c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=Eg({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=`list<${_A(u)}>`;return e.description==null&&e.title==null?l:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:Ox(e.availability)}:{},type:l}}function n_c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=eQo(e.key),l=Eg({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),d=e.encoding!=null?kGo(e.encoding):void 0,s=`map<${_A(u)}, ${_A(l)}>`;if(e.description==null&&d==null&&e.title==null)return s;let o={type:s};return e.description!=null&&(o.docs=e.description),e.encoding!=null&&(o.encoding=d),e.availability!=null&&(o.availability=Ox(e.availability)),o}function a_c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.respectNullableSchemas)return tQo({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let u=Eg({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=_A(u),d=I8n(u),s=GIa(u),o=e_c(u),c=l.startsWith("nullable<")?l:`nullable<${l}>`;if(e.availability==null&&e.description==null&&d==null&&s==null&&o==null&&e.title==null)return Eh_({typeReference:c,itemType:l});let b={type:c};return(e.description!=null||d!=null)&&(b.docs=e.description??d),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=Ox(e.availability)),Eh_({typeReference:b,itemType:l})}function tQo({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=Eg({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=_A(u),d=I8n(u),s=GIa(u),o=e_c(u),c=l.startsWith("optional<")?l:`optional<${l}>`;if(e.availability==null&&e.description==null&&d==null&&s==null&&o==null&&e.title==null)return c;let b={type:c};return(e.description!=null||d!=null)&&(b.docs=e.description??d),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=Ox(e.availability)),b}function o_c(){return"unknown"}function u_c(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:mo(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:Ox(e.availability)}:{}}}function gmE({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=QIa(e,n),u=e.nameOverride??e.generatedName;i.builder.addType(r,{name:u,schema:a.schema});let l=rQo({type:u,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return l;let d={type:l};return e.description!=null&&(d.docs=e.description),e.default!=null&&(d.default=e.default.value),e.availability!=null&&(d.availability=Ox(e.availability)),d}function OmE({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=s_c({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=e.nameOverride??e.generatedName;i.builder.addType(r,{name:l,schema:u.schema});let d=rQo({type:l,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:Ox(e.availability)}:{}}}function mmE({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=c_c({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),l=e.nameOverride??e.generatedName;i.builder.addType(r,{name:l,schema:u.schema});let d=rQo({type:l,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{...e.title!=null?{"display-name":e.title}:{},type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:Ox(e.availability)}:{}}}function rQo({type:e,fileContainingReference:t,declarationFile:r,context:i}){if(r===t)return e;let n=i.builder.addImport({file:t,fileToImport:r});return n!=null?`${n}.${e}`:e}function PmE(e){return Fy._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 jmE(e){return Fy._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 Eh_({typeReference:e,itemType:t}){return t.startsWith("optional<")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}function Qdi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:mo(e)}}function qh_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=DmE(e);break;case"array":a=wmE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=SmE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=EmE({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=AmE(e.nameOverride,e.generatedName);break;case"optional":a=Th_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=MmE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=QIa(e,n);break;case"literal":a=qmE(e,e.nameOverride,e.generatedName);break;case"object":a=s_c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=c_c({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:mo(e)}return a}function s_c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(n8.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),u=!1,l={},d=new Set;for(let g of e.properties){if(g.readonly&&(u=!0),a&&g.readonly)continue;if(Object.keys(g.conflict).length>0){if(Object.entries(g.conflict).every(([D,C])=>!C.differentSchema))continue;Object.entries(g.conflict).forEach(([D])=>{l_c({property:g.key,schemaId:D,context:t,namespace:i}).forEach(x=>{d.add(x)})})}let O=Eg({schema:g.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),m=g.audiences,P=g.nameOverride,E=Ox(g.availability),q=ImE(g);l[g.key]=BmE({typeReference:O,audiences:m,name:P,availability:E,propertyAccess:q})}let s=new Set;for(let g of e.allOfPropertyConflicts)g.allOfSchemaIds.forEach(O=>d.add(O)),g.conflictingTypeSignatures&&s.add(g.propertyKey);let o=[];for(let g of e.allOf){let O=Ch_({schema:g.schema,context:t,namespace:i});if(O==null||d.has(g.schema)||d.has(O))continue;let m=Eg({schema:Fy.reference(g),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(_A(m))}for(let g of d){let O=f_c(t,g,i);for(let m of O.properties)l[m.key]==null&&(s.has(m.key)&&(l[m.key]="unknown"),l[m.key]=Eg({schema:m.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let m of O.allOf){if(d.has(m.schema))continue;let P=Eg({schema:Fy.reference(m),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(_A(P))}}let c={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(l).map(([g,O])=>CmE(g)?[g,typeof O=="string"?{type:O,name:`_${g}`}:{...O,name:`_${g}`}]:[g,O]))};o.length>0&&(c.extends=o),e.additionalProperties&&(c["extra-properties"]=!0),e.availability!=null&&(c.availability=Ox(e.availability)),e.source!=null&&(c.source=Qdi(e.source)),c.inline=d_c(e,n);let b=e.nameOverride??e.generatedName;return{name:u&&t.respectReadonlySchemas&&!a?`${b}Read`:b,schema:c}}function l_c({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return l_c({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:u}=f_c(r,t,i),l=a.some(s=>s.key===e),d=[...u.flatMap(s=>l_c({property:e,context:r,schemaId:s.schema,namespace:i}))];if(l||d.length>0)return[t,...d]}return[]}function f_c(e,t,r){let i=e.getSchema(t,r);if(i==null)return{properties:[],allOf:[]};if(i.type==="object")return{properties:i.properties,allOf:i.allOf};if(i.type==="reference")return f_c(e,i.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${i.type}`)}function wmE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:i_c({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function SmE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:n_c({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function DmE(e){let t=eQo(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...i}=t;return{name:e.nameOverride??e.generatedName,schema:{...i}}}function Ah_(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function QIa(e,t){let r={enum:e.values.map(a=>{let u=a.nameOverride??a.generatedName,l=a.value;if(u===l&&a.description==null&&(a.casing==null||Ah_(a.casing)))return u;let d={value:a.value};if(u!==l&&(d.name=u),a.description!=null&&(d.docs=a.description),a.casing!=null&&!Ah_(a.casing)){let s={},o=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,o=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,o=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,o=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,o=!0),o&&(d.casing=s)}return d})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=d_c(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?Qdi(e.source):void 0};for(let a of r.enum){let u=typeof a=="string"?a:a.name??a.value;i.has(u.toLowerCase())||(n.enum.push(a),i.add(u.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function EmE({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:r_c({schema:e,context:t,fileContainingReference:r,namespace:i})}}function MmE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:a_c({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:Th_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function Th_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:tQo({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function AmE(e,t){return{name:e??t,schema:o_c()}}function qmE(e,t,r){return{name:t??r,schema:u_c(e)}}function c_c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?kGo(e.encoding):void 0;if(e.type==="discriminated"){let l={};for(let s of e.commonProperties)l[s.key]=Eg({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let d={};for(let[s,o]of Object.entries(e.schemas))d[s]=Eg({schema:o,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":l,docs:e.description??void 0,availability:e.availability!=null?Ox(e.availability):void 0,union:d,encoding:a,source:e.source!=null?Qdi(e.source):void 0}}}let u=[];for(let l of e.schemas)u.push(Eg({schema:l,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:u,encoding:a,source:e.source!=null?Qdi(e.source):void 0,inline:d_c(e,n)}}}var TmE=/^[0-9]/;function CmE(e){return TmE.test(e)}function Ch_({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?Ch_({context:t,schema:i.schema,namespace:r}):e}function BmE({typeReference:e,audiences:t,name:r,availability:i,propertyAccess:n}){return t.length===0&&r==null&&i==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{},...n!=null?{access:n}:{}}}function d_c(e,t){return e.inline===!0||t>0?!0:void 0}function ImE(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return JN.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return JN.ObjectPropertyAccess.WriteOnly}}function Bh_(e){let t=e.replace(/^x-|^X-/,"");return T_(t)}var Ih_="BasicAuthScheme",iQo="BearerAuthScheme";function zh_(e){if(e.authOverrides!=null){for(let[r,i]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:i});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,i]of Object.entries(e.ir.securitySchemes))if(i.type==="basic"){let n={scheme:"basic"};i.usernameVariableName!=null&&(n.username===void 0?n.username={name:i.usernameVariableName}:n.username.name=i.usernameVariableName),i.usernameEnvVar!=null&&(n.username===void 0?n.username={env:i.usernameEnvVar}:n.username.env=i.usernameEnvVar),i.passwordVariableName!=null&&(n.password===void 0?n.password={name:i.passwordVariableName}:n.password.name=i.passwordVariableName),i.passwordEnvVar!=null&&(n.password===void 0?n.password={env:i.passwordEnvVar}:n.password.env=i.passwordEnvVar),e.builder.addAuthScheme({name:Ih_,schema:n}),t||(e.builder.setAuth(Ih_),t=!0)}else if(i.type==="bearer"){let n={scheme:"bearer"};i.tokenVariableName!=null&&(n.token===void 0?n.token={name:i.tokenVariableName}:n.token.name=i.tokenVariableName),i.tokenEnvVar!=null&&(n.token===void 0?n.token={env:i.tokenEnvVar}:n.token.env=i.tokenEnvVar),e.builder.addAuthScheme({name:iQo,schema:n}),t||(e.builder.setAuth(iQo),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??Bh_(i.headerName),env:i.headerEnvVar}});else{let n={header:i.headerName,name:i.headerVariableName??"apiKey",type:"string"};i.headerEnvVar!=null&&(n.env=i.headerEnvVar),i.prefix!=null&&(n.prefix=i.prefix),e.builder.addAuthScheme({name:r,schema:n}),e.builder.setAuth(r),t=!0}else if(i.type==="oauth"){let n={scheme:"bearer"};e.builder.addAuthScheme({name:iQo,schema:n}),t||(e.builder.setAuth(iQo),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(yy.of("__package__.yml"),{name:"OauthScope",schema:QIa(i.scopesEnum,0).schema})}}function dir({header:e,context:t,fileContainingReference:r,namespace:i}){let n=Eg({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=_A(n),u=e.name.replace(/^x-|^X-/,""),l=e.parameterNameOverride!=null?e.parameterNameOverride:T_(u);if(e.description==null&&e.name===l&&e.env==null&&e.availability==null)return a;let d={type:a};return l!==e.name&&(d.name=l),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=Ox(e.availability)),d}function nQo({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=Eg({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return _A(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:_A(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=Ox(e.availability)),a}function oQo({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=p_c({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=_A(n.value),u=GIa(n.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let l={type:a};return u!=null&&(l.default=u),n.allowMultiple&&(l["allow-multiple"]=!0),e.description!=null&&(l.docs=e.description),e.parameterNameOverride!=null&&(l.name=e.parameterNameOverride),e.availability!=null&&(l.availability=Ox(e.availability)),zmE(n.value)&&n.value.validation!==void 0&&(l.validation=n.value.validation),l.default==null&&l["allow-multiple"]==null&&l.docs==null&&l.name==null&&l.availability==null&&l.validation==null?a:l}function p_c({schema:e,context:t,fileContainingReference:r,namespace:i}){if(e.type==="reference"){let n=t.getSchema(e.schema,i);if(n==null)return;if(n.type==="array")return{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:yy.of(zS),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[],u=!1;for(let[l,d]of Object.entries(n.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(u=!0),d.type==="literal"&&d.value.type==="string"&&(T8n.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:C8n(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),u&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[l,d]=n.value.schemas;if(l!=null&&d!=null&&aQo({array:l,primitive:d}))return{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(l!=null&&d!=null&&aQo({array:l,primitive:d}))return{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:l,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[l,d]of Object.entries(n.value.schemas))return p_c({schema:d,context:t,fileContainingReference:r,namespace:i})}else if(t.objectQueryParameters)return{value:Eg({schema:e,context:t,fileContainingReference:r,declarationFile:yy.of(zS),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let n=t.getSchema(e.value.schema,i);if(n==null)return;if(n.type==="array")return{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:yy.of(zS),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.objectQueryParameters)return{value:Eg({schema:e,context:t,fileContainingReference:r,declarationFile:yy.of(zS),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let n=[],a=!1;for(let[u,l]of Object.entries(e.value.value.schemas))l.type==="primitive"&&l.schema.type==="string"&&(a=!0),l.type==="literal"&&l.value.type==="string"&&(T8n.test(l.value.value)?n.push(l.value.value):n.push({value:l.value.value,name:C8n(l.value.value)}));if(n.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:n}}),a&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[u,l]=e.value.value.schemas;if(u!=null&&l!=null&&aQo({array:u,primitive:l}))return{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:l,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(u!=null&&l!=null&&aQo({array:l,primitive:u}))return{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[u,l]of Object.entries(e.value.value.schemas))return p_c({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:l,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.objectQueryParameters?{value:Eg({schema:e,context:t,fileContainingReference:r,declarationFile:yy.of(zS),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:Eg({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:Eg({schema:Fy.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:Eg({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function aQo({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function zmE(e){return e.type!=null}function xh_({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"]=xmE(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=RmE({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=IMi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function xmE(e){let t={};return e.forEach(r=>{let i=IMi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function RmE({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=IMi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function IMi(e){switch(e.type){case"primitive":return Rh_(e.value);case"object":return Nh_(e.properties);case"array":return NmE(e.value);case"map":return FmE(e.value);case"oneOf":return LmE(e.value);case"enum":return e.value;case"literal":return UmE(e.value);case"unknown":return IMi(e.value);default:mo(e)}}function Rh_(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:mo(e)}}function Nh_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,IMi(r)]))}function NmE(e){return e.map(t=>IMi(t))}function FmE(e){return Object.fromEntries(e.map(t=>[Rh_(t.key),IMi(t.value)]))}function LmE(e){return e.type==="discriminated"?Nh_(e.value):IMi(e.value)}function UmE(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:mo(e)}}function Jdi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function uQo(e,t){return t??(e?.groupName!=null?Jdi(e.groupName):void 0)}function Fh_({channel:e,context:t,declarationFile:r}){let i={path:e.path,url:e.servers[0]?.name,auth:!1};e.audiences!=null&&e.audiences.length>0&&(i.audiences=e.audiences),e.summary!=null&&(i["display-name"]=e.summary),e.description!=null&&(i.docs=e.description);let n=Jdi(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=nQo({pathParameter:d,context:t,fileContainingReference:r,namespace:n});Object.keys(a).length>0&&(i["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let s=oQo({queryParameter:d,context:t,fileContainingReference:r,namespace:n});s!=null&&(u[d.name]=s)}Object.keys(u).length>0&&(i["query-parameters"]=u);let l={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let s=dir({header:d,context:t,fileContainingReference:r,namespace:n});l[d.name]=s}Object.keys(l).length>0&&(i.headers=l),t.builder.addChannel(r,{channel:i});for(let d of e.messages)t.builder.addChannelMessage(r,{messageId:d.name,message:{origin:d.origin,body:Eg({schema:d.body,context:t,fileContainingReference:r,namespace:n,declarationDepth:0})}});for(let d of e.examples){let s=xh_({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:s})}}var Kdi="Base",VmE="Default";function zMi(e){return Object.entries(e).reduce((t,[r,i])=>(GRn(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function Lh_(e){if(e.environmentOverrides!=null){for(let[g,O]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:g,schema:O});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[];for(let g of e.ir.servers){let O=g.audiences?{url:g.url,audiences:g.audiences}:g.url;if(g.name==null){r.push(O);continue}t[g.name]=O}let i={},n=[];for(let g of e.ir.endpoints)for(let O of g.servers){if(O.url==null)continue;let m=O.audiences?{url:O.url,audiences:O.audiences}:O.url;if(O.name==null){n.push(m);continue}i[O.name]=m}let a={},u=[];for(let g of e.ir.websocketServers){let O=g.audiences?{url:g.url,audiences:g.audiences}:g.url;if(g.name==null){u.push(O);continue}a[g.name]=O}let l=Object.keys(t).length,d=l>0,s=Object.keys(i).length>0,o=Object.keys(a).length>0;if(!d&&!s&&o&&e.ir.servers.length===0){for(let[g,O]of Object.entries(a))e.builder.addEnvironment({name:g,schema:O});e.builder.setDefaultEnvironment(Object.keys(a)[0]),e.builder.setDefaultUrl(Kdi);return}if(n.length>0&&e.logger.error(`Skipping endpoint level servers ${n.map(g=>typeof g=="string"?g:g.url).join(", ")} because x-fern-server-name was not provided.`),!d){let g=e.ir.servers[0]?.url,O=e.ir.servers[0]?.audiences;if(g!=null){let m=O?{url:g,audiences:O}:g;t[VmE]=m}}let c=Object.values(t).map(g=>typeof g=="string"?g:g.url),b=r.filter(g=>{let O=typeof g=="string"?g:g.url;return!c.includes(O)});if(b.length>0&&e.logger.error(`Skipping top level servers ${b.map(g=>typeof g=="string"?g:g.url).join(", ")} because x-fern-server-name was not provided.`),s)if(l===1){let g=Object.keys(t)[0],O=Object.values(t)[0],m=typeof O=="string"?O:O.url;e.builder.addEnvironment({name:g,schema:{urls:{[Kdi]:m,...zMi(i),...zMi(a)}}}),e.builder.setDefaultEnvironment(g),e.builder.setDefaultUrl(Kdi)}else{let g=!0;for(let[O,m]of Object.entries(t))g?(e.builder.addEnvironment({name:O,schema:{urls:{[Kdi]:typeof m=="string"?m:m.url,...zMi(i),...zMi(a)}}}),e.builder.setDefaultEnvironment(O),g=!1):e.builder.addEnvironment({name:O,schema:{urls:{[Kdi]:typeof m=="string"?m:m.url,...zMi(i),...zMi(a)}}});e.builder.setDefaultUrl(Kdi)}else{let g=!0;for(let[O,m]of Object.entries(t))g?(o?e.builder.addEnvironment({name:O,schema:{urls:{[Kdi]:typeof m=="string"?m:m.url,...zMi(a)}}}):e.builder.addEnvironment({name:O,schema:m}),e.builder.setDefaultEnvironment(O),g=!1):o?e.builder.addEnvironment({name:O,schema:{urls:{[Kdi]:typeof m=="string"?m:m.url,...zMi(a)}}}):e.builder.addEnvironment({name:O,schema:m});o&&e.builder.setDefaultUrl(Kdi)}}function sQo(e){return _A(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var __c=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},WmE=.75,HmE=new Set("authorization");function Uh_(e){if(e.globalHeaderOverrides!=null){for(let[r,i]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:i});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,i]of Object.entries(t)){let n="optional<string>";if(i.name==null&&i.env==null&&typeof i.schema=="string")n=i.schema;else if(i!=null){let a=i.schema?B8n(i.schema):void 0,u=a!=null?Jdi(a):void 0,l=yy.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?_A(Eg({schema:i.schema,context:e,fileContainingReference:u?WN(yy.of(T_(u)),l):l,namespace:u,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(HmE.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let l=t[a.name],d=dir({header:{...a,schema:l?.schema??a.schema,name:l?.name??a.name},fileContainingReference:yy.of(i3),context:e,namespace:void 0});u=new __c(d),r[a.name]=u}u.increment()}let i=e.ir.endpoints.length*WmE;for(let[n,a]of Object.entries(r)){let u=t[n],l=a.count===e.ir.endpoints.length,d=a.count>=i;u==null&&(l?e.builder.addGlobalHeader({name:n,schema:a.schema}):d&&e.builder.addGlobalHeader({name:n,schema:sQo(a.schema)}))}}}function Vh_(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?B8n(t.schema):void 0,i=r!=null?Jdi(r):void 0,n=dir({header:{...t,schema:t.schema??Fy.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:Xj.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:yy.of(i3),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:sQo(n)})}}function dJ(e){switch(e.type){case"primitive":return Hh_(e.value);case"object":return $h_(e.properties);case"array":return Gh_(e.value);case"map":return GmE(e.value);case"oneOf":return QmE(e.value);case"enum":return e.value;case"literal":return JmE(e.value);case"unknown":return dJ(e.value);default:mo(e)}}function Wh_(e){switch(e.type){case"withStreaming":return e.sse?{stream:$mE(e.events)}:{stream:Gh_(e.events)};case"withoutStreaming":return{body:dJ(e.value)};default:mo(e)}}function Hh_(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:mo(e)}}function $h_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,dJ(r)]))}function $mE(e){return e.map(t=>({event:"",data:dJ(t)}))}function Gh_(e){return e.map(t=>dJ(t))}function GmE(e){return Object.fromEntries(e.map(t=>[Hh_(t.key),dJ(t.value)]))}function QmE(e){return e.type==="discriminated"?$h_(e.value):dJ(e.value)}function JmE(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:mo(e)}}function Qh_({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"]=KmE(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=YmE(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=XmE({context:t,namedFullExamples:e.headers})),e.request!=null&&(r.request=dJ(e.request)),e.response!=null&&(r.response=Wh_(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(i=>i.type==="language"?{name:i.name??void 0,docs:i.description??void 0,language:i.language,code:i.code,install:i.install??void 0}:{name:i.name??void 0,docs:i.description??void 0,sdk:i.sdk,code:i.code}).filter(V0)),r)}function KmE(e){let t={};return e.forEach(r=>{let i=dJ(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function YmE(e){let t={};return e.forEach(r=>{let i=dJ(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function XmE({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=dJ(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function Jh_(e){return rH._visit(e,{get:()=>JN.HttpMethodSchema.Get,post:()=>JN.HttpMethodSchema.Post,put:()=>JN.HttpMethodSchema.Put,patch:()=>JN.HttpMethodSchema.Patch,delete:()=>JN.HttpMethodSchema.Delete,head:()=>JN.HttpMethodSchema.Head,options:()=>{throw new Error("OPTIONS is unsupported")},trace:()=>{throw new Error("TRACE is unsupported")},_other:()=>{throw new Error("Unknown http method is unsupported")}})}function Kh_(e){return e==="POST"||e==="PUT"||e==="PATCH"}function Yh_({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,u=e.path,l=uQo(e.sdkName,e.namespace),d={};for(let P of e.pathParameters)P.parameterNameOverride&&(u=u.replace(P.name,P.parameterNameOverride)),d[P.parameterNameOverride??P.name]=nQo({pathParameter:P,context:r,fileContainingReference:t,namespace:l}),a.add(P.name);let s={};for(let P of e.queryParameters){let E=oQo({queryParameter:P,context:r,fileContainingReference:t,namespace:l});E!=null&&(s[P.name]=E,a.add(P.name))}let o;if(e.pagination!=null)switch(e.pagination.type){case"cursor":o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":o={type:"custom",results:e.pagination.results};break;default:mo(e.pagination)}let c={path:u,method:Jh_(e.method),auth:e.authed,docs:e.description??void 0,pagination:o,source:e.source!=null?Qdi(e.source):void 0};!ePE({context:r,request:e.request})&&Object.keys(d).length>0&&(c["path-parameters"]=d),e.summary!=null&&(c["display-name"]=e.summary);let b={},g=r.builder.getGlobalHeaderNames(),O=r.builder.getAuthHeaderName();O!=null&&g.add(O);let m=e.headers.filter(P=>!g.has(P.name));for(let P of m){let E=dir({header:P,context:r,fileContainingReference:t,namespace:l});b[P.name]=E,a.add(typeof E=="string"?P.name:E.name??P.name)}if(e.request!=null){r.setInState(n8.Request);let P=kmE({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.inlinePathParameters&&Object.keys(d).length>0?d:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(i),headers:Object.keys(b).length>0?b:void 0,usedNames:a,namespace:l});c.request=P.value,n=[...n,...P.schemaIdsToExclude??[]],r.unsetInState(n8.Request)}else{let P=r.inlinePathParameters&&Object.keys(d).length>0,E=Object.keys(s).length>0,q=Object.keys(b).length>0,M={};(P||E||q)&&(M.name=e.requestNameOverride??e.generatedRequestName),P&&(M["path-parameters"]=d),E&&(M["query-parameters"]=s),q&&(M.headers=b),Object.keys(M).length>0&&(c.request=M)}if(e.response!=null&&e.response._visit({json:P=>{let E=Eg({schema:P.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c.response={docs:P.description??void 0,type:_A(E)},P.statusCode!=null&&(c.response["status-code"]=P.statusCode),P.responseProperty!=null&&(c.response.property=P.responseProperty)},streamingJson:P=>{let E=Eg({schema:P.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c["response-stream"]={docs:P.description??void 0,type:_A(E),format:"json"}},streamingSse:P=>{let E=Eg({schema:P.schema,context:r,fileContainingReference:t,namespace:l,declarationDepth:0});c["response-stream"]={docs:P.description??void 0,type:_A(E),format:"sse"}},file:P=>{c.response={docs:P.description??void 0,type:"file","status-code":P.statusCode}},bytes:P=>{c.response={docs:P.description??void 0,type:"bytes","status-code":P.statusCode}},streamingText:P=>{c["response-stream"]={docs:P.description??void 0,type:"text"}},text:P=>{c.response={docs:P.description??void 0,type:"text","status-code":P.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let P=r.getDefaultServerName(),E=e.servers[0];E==null?P!=null&&(c.url=P):c.url=E.name??void 0}return e.idempotent&&(c.idempotent=!0),e.availability!=null&&(c.availability=Ox(e.availability)),Object.entries(e.errors).forEach(([P,E])=>{let q=E.generatedName,M=yy.of(zS);r.builder.enableUniqueErrorsPerEndpoint&&(q=`${e.generatedRequestName}${E.generatedName}`,E.schema!=null&&(E.schema.type!=="reference"&&E.schema.type!=="oneOf"?E.schema.generatedName=`${e.generatedRequestName}${E.schema.generatedName}`:E.schema.type==="oneOf"&&(E.schema.value.generatedName=`${e.generatedRequestName}${E.schema.value.generatedName}`)));let D={"status-code":parseInt(P)},C=Dh_({location:Xh_,namespaceOverride:l});if(E.schema!=null){let I=Eg({schema:E.schema,context:r,fileContainingReference:C,declarationFile:C,namespace:l,declarationDepth:0});D.type=_A(I),D.docs=E.description}r.builder.addError(C,{name:q,schema:r.isErrorUnknownSchema(parseInt(P))?{...D,type:"unknown"}:D}),c.errors==null&&(c.errors=[]);let x=r.builder.addImport({file:t,fileToImport:C});c.errors.push(x!=null?`${x}.${q}`:q),D.type!=null&&E.examples?.forEach(I=>{let L={value:dJ(I.example),name:I.name,docs:I.description};r.builder.addErrorExample(C,{name:q,example:L})})}),e.examples.length>0&&(c.examples=ZmE({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?c.audiences=[h_c,...e.audiences]:e.audiences.length>0&&(c.audiences=e.audiences),{value:c,schemaIdsToExclude:n}}function ZmE({endpointExamples:e,context:t}){return e.map(r=>{try{return Qh_({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function kmE({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:u,queryParameters:l,nonRequestReferencedSchemas:d,headers:s,usedNames:o,namespace:c}){if(i.type==="json"){let b=i.schema.type==="reference"?i.schema.schema:void 0,g=i.schema.type==="reference"?r.getSchema(i.schema.schema,c):i.schema;if(g?.type!=="object"||b!=null&&d.includes(b)){let q=Eg({schema:i.schema,fileContainingReference:t,context:r,namespace:c,declarationDepth:0}),M={schemaIdsToExclude:[],value:{body:q}},D=Object.keys(u??{}).length>0,C=Object.keys(l??{}).length>0,x=Object.keys(s??{}).length>0;return D&&(M.value["path-parameters"]=u),C&&(M.value["query-parameters"]=l),x&&(M.value.headers=s),(D||C||x)&&(M.value.name=n??a),i.contentType!=null&&(M.value["content-type"]=i.contentType),i.description!=null&&(M.value.docs=i.description),M}let O=Object.fromEntries(g.properties.filter(q=>q.readonly==null?!0:!(Kh_(e.method)&&q.readonly)).map(q=>{let M=Eg({schema:q.schema,fileContainingReference:t,context:r,namespace:c,declarationDepth:1}),D=q.nameOverride??q.key,C=Ox(q.availability);if(!o.has(D)&&q.audiences.length<=0)return o.add(D),q.nameOverride!=null?[q.key,{type:_A(M),docs:I8n(M),name:q.nameOverride,availability:C}]:[q.key,C?{...typeof M=="string"?{type:M}:M,availability:C}:M];let x={type:_A(M),docs:I8n(M)};return o.has(D)&&(x.name=q.generatedName),q.audiences.length>0&&(x.audiences=q.audiences),C!=null&&(x.availability=C),o.add(D),[q.key,x]})),m=g.allOf.map(q=>{let M=Eg({schema:Fy.reference(q),fileContainingReference:t,context:r,namespace:c,declarationDepth:0});return _A(M)}).filter(q=>q!=="unknown"),P={properties:O};m.length>0&&(P.extends=m),i.additionalProperties&&(P["extra-properties"]=!0);let E={name:n??g.nameOverride??g.generatedName,"path-parameters":u,"query-parameters":l,headers:s,body:P};return i.contentType!=null&&(E["content-type"]=i.contentType),i.description!=null&&(E.docs=i.description),{schemaIdsToExclude:b!=null?[b]:[],value:E}}else{if(i.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":mM.APPLICATION_OCTET_STREAM,...i.description?{docs:i.description}:{}}};if(i.type==="multipart"){let b=Object.fromEntries(i.properties.map(g=>{if(g.schema.type==="file"){let O=g.schema.isArray?"list<file>":"file";if(O=g.schema.isOptional?`optional<${O}>`:O,g.description!=null||g.contentType!=null){let m={type:O};if(g.description!=null&&(m.docs=g.description),g.contentType!=null){let P=g.contentType.split(",")[0];m["content-type"]=P}return[g.key,m]}return[g.key,O]}else{let O=Eg({schema:g.schema.value,fileContainingReference:t,context:r,namespace:c,declarationDepth:1});if(g.contentType!=null||g.exploded||g.encoding==="form"){let m=typeof O=="string"?{type:O}:O;g.contentType!=null&&(m["content-type"]=g.contentType),g.encoding==="form"?m.style="form":g.exploded&&(m.style="exploded"),O=m}return[g.key,O]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":u,"query-parameters":l,headers:s,body:{properties:b},"content-type":mM.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else mo(i)}}function ePE({context:e,request:t}){if(!e.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;default:mo(t)}}function tPE({location:e,namespaceOverride:t}){return t!=null?{...e,file:WN(yy.of(t),e.file)}:e}function rPE(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:yy.of(`${T_(r)}.yml`),endpointId:e.summary!=null?T_(e.summary):T_(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:yy.of(zS),endpointId:T_(e.summary)}:{file:yy.of(zS),endpointId:T_(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:yy.of(zS),endpointId:i};let n=JIa(r),a=JIa(i);if(OEe(n,a))return{file:yy.of("__package__.yml"),endpointId:r};let u=aPE({operationId:i,tag:r,path:e.path,method:e.method});if(u!=null)return u;let l=[];for(let d=0;d<n.length;++d){let s=n[d];if(s!=null&&s===a[d])l.push(s);else{let o=T_(r);return{file:yy.of(`${o}.yml`),endpointId:i,tag:r}}}if(l.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:yy.of(T_(l.join("_"))+".yml"),endpointId:T_(a.slice(l.length).join("_")),tag:r}}function KIa(e){let t=e.tags[0];if(e.sdkName!=null){let r=kpc({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:yy.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return tPE({namespaceOverride:e.namespace,location:rPE(e)})}function JIa(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=Sxe(t),t}var iPE=new RegExp("[^a-zA-Z0-9{}]+"),nPE=new RegExp("[{}]","g");function aPE({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(iPE).join("_").replaceAll(nPE,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:yy.of(T_(t)+".yml"),endpointId:T_(e.slice(0,-1*a.length)),tag:t}}function Zh_(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:u,file:l,tag:d}=KIa(a),s=l.split(".")[0];s!=null&&t.add(s);let o;if(a.sdkName!=null){let g=e.ir.groups;for(let O of a.sdkName.groupName){let m=typeof O=="string"?O:O.name,P=g[m];if(P==null)break;if(P.summary!=null||P.description!=null){o=g[m];break}}}let c=d==null?void 0:i.tagsById[d];e.setInState(n8.Endpoint),e.setEndpointMethod(a.method);let b=Yh_({context:e,endpoint:a,declarationFile:l});e.unsetEndpointMethod(),e.unsetInState(n8.Endpoint),n=[...n,...b.schemaIdsToExclude],e.builder.addEndpoint(l,{name:u,schema:b.value,source:a.source!=null?Qdi(a.source):void 0}),(c?.id!=null||c?.description!=null)&&e.builder.setServiceInfo(l,{"display-name":o?.summary??c?.id,docs:o?.description??c?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function kh_(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?Jdi(r.groupName):void 0,n=Eg({schema:Fy.primitive(r),context:e,fileContainingReference:yy.of(zS),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:_A(n),docs:r.description??void 0}})}}function ey_(e){for(let t of e.ir.webhooks){let r=sPE({webhook:t,context:e});if(r==null)continue;let i=uQo(t.sdkName,t.namespace),n={};for(let u of t.headers)n[u.name]=dir({header:u,context:e,fileContainingReference:r.file,namespace:i});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:n,payload:Eg({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:dJ(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function oPE({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:WN(yy.of(t),e.file)}:e}function uPE({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:yy.of(zS),endpointId:i};let n=JIa(r),a=JIa(i);if(OEe(n,a))return{file:yy.of("__package__.yml"),endpointId:r};let u=[];for(let l=0;l<n.length;++l){let d=n[l];if(d!=null&&d===a[l])u.push(d);else{let s=T_(r);return{file:yy.of(`${s}.yml`),endpointId:i,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:yy.of(T_(u.join("_"))+".yml"),endpointId:T_(a.slice(u.length).join("_")),tag:r}}function sPE({webhook:e,context:t}){return e.sdkName!=null?{file:Sh_({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:oPE({namespaceOverride:e.namespace,location:uPE({webhook:e,context:t})})}var cPE=yy.of(zS);function ry_(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return ty_({namespace:e.namespace,groupName:e.groupName});case"oneOf":return ty_({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return cPE;default:mo(e)}}function ty_({namespace:e,groupName:t}){return e!=null&&t!=null?BMi([{type:"namespace",name:e},...t]):e!=null?BMi([{type:"namespace",name:e}]):BMi(t)}var h_c="external",Xh_=yy.of(zS);function iy_({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let u=ry_(a),l=qh_({schema:a,context:i,declarationFile:u,namespace:r,declarationDepth:0});if(_Si(l.schema)){let d=_A(l.schema);if(d===(l.name??n)||d===`optional<${l.name??n}>`)continue}i.builder.addType(u,{name:l.name??n,schema:l.schema})}}function ny_(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),Lh_(e),Uh_(e),Vh_(e),zh_(e),kh_(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(h_c);let t=Zh_(e),r=t.sdkGroups;e.setInState(n8.Webhook),ey_(e),e.unsetInState(n8.Webhook),e.setInState(n8.Channel);for(let n of Object.values(e.ir.channels)){let a=BMi(n.groupName);Fh_({channel:n,context:e,declarationFile:a})}e.unsetInState(n8.Channel);let i=lPE({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});iy_({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))iy_({schemas:a,schemaIdsToExclude:i,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}function lPE({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}function y_c(e){let t=new ZGo(e);return ny_(t)}var Ydi={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!1,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1};function v_c({options:e,overrides:t}){return{enableUniqueErrorsPerEndpoint:t?.enableUniqueErrorsPerEndpoint??e?.enableUniqueErrorsPerEndpoint??Ydi.enableUniqueErrorsPerEndpoint,detectGlobalHeaders:t?.detectGlobalHeaders??e?.detectGlobalHeaders??Ydi.detectGlobalHeaders,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??Ydi.objectQueryParameters,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??Ydi.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??Ydi.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??Ydi.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??Ydi.inlinePathParameters,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??Ydi.useBytesForBinaryResponse,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??Ydi.respectForwardCompatibleEnums}}var cQo=class{args;constructor(t){this.args=t}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=y_c({taskContext:t,ir:r,options:v_c({overrides:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.args.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.args.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.args.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.args.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.args.objectQueryParameters,useBytesForBinaryResponse:i?.useBytesForBinaryResponse??this.args.useBytesForBinaryResponse,respectForwardCompatibleEnums:i?.respectForwardCompatibleEnums??this.args.respectForwardCompatibleEnums}}),authOverrides:i?.auth!=null?{auth:i.auth}:this.args.generatorsConfiguration?.api?.auth!=null?{...this.args.generatorsConfiguration.api}:void 0,environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:n??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:qd.dump(a.rootApiFile)},namedDefinitionFiles:{...dd(a.definitionFiles,u=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:qd.dump(u),contents:u})),[yy.of(zS)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:qd.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var YIa=class extends sHt{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;converter;constructor(t){super(t),this.inlinePathParameters=t.inlinePathParameters,this.objectQueryParameters=t.objectQueryParameters,this.onlyIncludeReferencedSchemas=t.onlyIncludeReferencedSchemas,this.respectReadonlySchemas=t.respectReadonlySchemas,this.respectNullableSchemas=t.respectNullableSchemas,this.exampleGeneration=t.exampleGeneration,this.useBytesForBinaryResponse=t.useBytesForBinaryResponse,this.respectForwardCompatibleEnums=t.respectForwardCompatibleEnums,this.converter=new cQo(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:i},n){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:i},n);return this.converter.convert({context:t,ir:a,settings:n,absoluteFilePath:r})}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new DMe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion})}};function z8n(e){if(e.settings==null&&e.raw?.api?.auth==null)return;let t={detectGlobalHeaders:!0};return e.settings?.unions==="v1"&&(t.discriminatedUnionV2=!0),e.raw?.api?.auth!=null&&(t.auth=e.raw?.api?.auth),t}var a1_=ci(lYo(),1);var cH={BEARER_FORMAT:"x-bearer-format",ENUM_VAR_NAMES:"x-enum-varnames",INTERNAL:"x-internal",EXAMPLES:"x-examples",TAGS:"x-tags",REDOCLY_CODE_SAMPLES_KEBAB:"x-code-samples",REDOCLY_CODE_SAMPLES_CAMEL:"x-codeSamples"};var D5n={of(e){return e}};var qj_={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},u0c={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:qj_,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},id={SOURCE:D5n.of("source"),SDK_NAMESPACE:D5n.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:D5n.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:D5n.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:D5n.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport"};var a4={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!0,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,preserveSchemaIds:!1,objectQueryParameters:!1,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!1,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!0};function s0c({options:e,overrides:t}){return{disableExamples:t?.disableExamples??a4.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.discriminatedUnionV2??a4.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.useTitlesAsName??a4.useTitlesAsName,audiences:t?.audiences??e?.audiences??a4.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??a4.optionalAdditionalProperties,coerceEnumsToLiterals:t?.coerceEnumsToLiterals??e?.coerceEnumsToLiterals??a4.coerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??a4.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??a4.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??a4.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??a4.inlinePathParameters,preserveSchemaIds:t?.preserveSchemaIds??a4.preserveSchemaIds,shouldUseUndiscriminatedUnionsWithLiterals:t?.shouldUseUndiscriminatedUnionsWithLiterals??e?.shouldUseUndiscriminatedUnionsWithLiterals??a4.shouldUseUndiscriminatedUnionsWithLiterals,shouldUseIdiomaticRequestNames:t?.shouldUseIdiomaticRequestNames??e?.shouldUseIdiomaticRequestNames??a4.shouldUseIdiomaticRequestNames,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??a4.objectQueryParameters,filter:t?.filter??e?.filter??a4.filter,asyncApiNaming:t?.asyncApiNaming??e?.asyncApiNaming??a4.asyncApiNaming,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??a4.useBytesForBinaryResponse,exampleGeneration:t?.exampleGeneration??e?.exampleGeneration??void 0,defaultFormParameterEncoding:t?.defaultFormParameterEncoding??e?.defaultFormParameterEncoding??void 0,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??a4.respectForwardCompatibleEnums,additionalPropertiesDefaultsTo:t?.additionalPropertiesDefaultsTo??e?.additionalPropertiesDefaultsTo??a4.additionalPropertiesDefaultsTo,typeDatesAsStrings:t?.typeDatesAsStrings??e?.typeDatesAsStrings??a4.typeDatesAsStrings}}var Tj_={naming:"v1"};function hf(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function Yza(e,t,r,i,n=[]){try{let a=hf(e,t);if(a!=null)return r.parse(a)}catch{let u=Sxe(n).join(" -> ");i.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}function JJi(e){let t=hf(e,"examples");return t!=null&&Array.isArray(t)?t:[]}function Cj_({schema:e,logger:t}){return hf(e,id.ENCODING)??void 0}function Bj_(e){return hf(e,id.FERN_ENUM)}function Ij_({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let u=hf(i,id.SDK_NAMESPACE),l=hf(i,id.SDK_GROUP_NAME),d=hf(i,id.TYPE_DEFINITION);if(d!=null)return Xza({fernType:d,nameOverride:e,generatedName:t,title:r,description:n,availability:a,namespace:u,groupName:typeof l=="string"?[l]:l})}function Xza({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l}){return G2({type:e,_default:void 0,validation:void 0,visitor:{primitive:d=>{switch(d.v1){case"BASE_64":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.base64({example:void 0})});case"BOOLEAN":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.boolean({default:void 0,example:void 0})});case"DATE":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.date({example:void 0})});case"DATE_TIME":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.datetime({example:void 0})});case"FLOAT":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.float({example:void 0})});case"DOUBLE":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.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 zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.uint({default:void 0,example:void 0})});case"INTEGER":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.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 zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.uint64({default:void 0,example:void 0})});case"LONG":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return zl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:l,schema:up.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:mo(d.v1)}},unknown:()=>zl.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,namespace:u,groupName:l}),map:({keyType:d,valueType:s})=>d?.type==="primitive"&&s!=null?zl.map({nameOverride:t,generatedName:r,title:i,key:d,value:s,description:n,availability:a,namespace:u,groupName:l,encoding:void 0,example:void 0,inline:void 0}):void 0,list:d=>d!=null?zl.array({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:l,example:void 0,inline:void 0}):void 0,optional:d=>d!=null?zl.optional({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:l,inline:void 0}):void 0,nullable:d=>d!=null?zl.nullable({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:l,inline:void 0}):void 0,set:d=>d!=null?zl.array({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:l,example:void 0,inline:void 0}):void 0,literal:d=>zl.literal({nameOverride:t,generatedName:r,title:i,value:d._visit({string:s=>vz.string(s),boolean:s=>vz.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,namespace:u,groupName:l}),named:()=>{}}})}function zj_(e){let t=hf(e,id.SOURCE);if(t!=null)return t.endsWith(".proto")?Gae.protobuf({file:t}):Gae.openapi({file:t})}function KJi(e){if(e!=null&&typeof e=="boolean")return e}function sp(e){return e.$ref!=null}function xj_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:u,wrapAsNullable:l,context:d,namespace:s,groupName:o,example:c,encoding:b,source:g}){return n===void 0&&(n=d.options.additionalPropertiesDefaultsTo),typeof n=="boolean"||E5n(n,d.options)?fYo({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:up.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:zl.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:void 0,groupName:void 0}),namespace:s,groupName:o,example:c,encoding:b}):fYo({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:up.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:Rj_(t0(n,d.options.optionalAdditionalProperties?l:!1,d,[...i,"Value"],g,s,void 0,void 0,void 0)),namespace:s,groupName:o,example:c,encoding:b})}function Rj_(e){switch(e.type){case"array":case"enum":case"map":case"object":e.inline=!0;break;case"literal":case"primitive":case"reference":case"unknown":break;case"nullable":case"optional":e.inline=!0,e.value=Rj_(e.value);break;case"oneOf":e.value.inline=!0;break;default:mo(e)}return e}function fYo({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsNullable:a,description:u,availability:l,namespace:d,groupName:s,example:o,encoding:c}){return a?zl.nullable({nameOverride:e,generatedName:t,title:r,value:zl.map({nameOverride:e,generatedName:t,title:r,description:u,availability:i.availability,key:i,value:n,namespace:d,groupName:s,encoding:c,example:o,inline:void 0}),description:u,availability:l,namespace:d,groupName:s,inline:void 0}):zl.map({nameOverride:e,generatedName:t,title:r,description:u,availability:l,key:i,value:n,namespace:d,groupName:s,encoding:c,example:o,inline:void 0})}function E5n(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:!sp(e)&&Object.keys(e).length===0}function Nj_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:u,wrapAsNullable:l,context:d,namespace:s,groupName:o,example:c,source:b}){let g=n==null?zl.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:s,groupName:o}):t0(n,!1,d,[...i,"Item"],b,s);return s4E({nameOverride:e,generatedName:t,title:r,namespace:s,groupName:o,itemSchema:g,wrapAsNullable:l,description:a,availability:u,example:c})}function s4E({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsNullable:n,description:a,availability:u,namespace:l,groupName:d,example:s}){return n?zl.nullable({nameOverride:e,generatedName:t,title:r,value:zl.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,namespace:l,groupName:d,example:s,inline:void 0}),description:a,availability:u,namespace:l,groupName:d,inline:void 0}):zl.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,namespace:l,groupName:d,example:s,inline:void 0})}function vJ(e){switch(hf(e,id.AVAILABILITY)){case"deprecated":return eH.Deprecated;case"beta":return eH.Beta;case"generally-available":return eH.GenerallyAvailable;default:break}if(!sp(e)&&e.deprecated)return eH.Deprecated}function c0c({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:l,wrapAsNullable:d,discriminator:s,context:o,namespace:c,groupName:b,encoding:g,source:O}){let m=s.propertyName,P=Object.fromEntries(Object.entries(s.mapping??{}).map(([q,M])=>{let D=upi({$ref:M},!1,o,[M],g,O,c);return o.markReferencedByDiscriminatedUnion({$ref:M},m,1),[q,D]})),E=Object.entries(n).filter(([q])=>q!==m).map(([q,M])=>{let D=l!=null&&l.includes(q),C=t0(M,!D,o,[...i,q],O,c);return{key:q,schema:C}});return Fj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:E,description:a,availability:u,discriminant:m,subtypes:P,namespace:c,groupName:b,source:O})}function l0c({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:l,wrapAsNullable:d,discriminant:s,variants:o,context:c,namespace:b,groupName:g,encoding:O,source:m}){let P=Object.fromEntries(Object.entries(o).map(([q,M])=>{if(sp(M)){let D=upi(M,!1,c,[M.$ref],O,m,b);return c.markReferencedByDiscriminatedUnion(M,s,1),[q,D]}else{let D=M5n(M,!1,c,[...i,q],O,m,b,new Set([s]));return[q,D]}})),E=Object.entries(n).filter(([q])=>q!==s).map(([q,M])=>{let D=l!=null&&l.includes(q),C=t0(M,!D,c,[...i,q],m,b);return{key:q,schema:C}});return Fj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:E,description:a,availability:u,discriminant:s,subtypes:P,namespace:b,groupName:g,source:m})}function Fj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,availability:u,discriminant:l,subtypes:d,namespace:s,groupName:o,source:c}){return i?zl.nullable({nameOverride:e,generatedName:t,title:r,value:zl.oneOf(ik.discriminated({description:a,availability:u,discriminantProperty:l,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:n,namespace:s,groupName:o,encoding:void 0,source:c,inline:void 0})),namespace:s,groupName:o,description:a,availability:u,inline:void 0}):zl.oneOf(ik.discriminated({description:a,availability:u,discriminantProperty:l,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:n,namespace:s,groupName:o,encoding:void 0,source:c,inline:void 0}))}function Lj_(e){if(e.proto!=null)return r8n.protobuf({typeName:e.proto.type})}function oAi({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:u,description:l,availability:d,wrapAsNullable:s,namespace:o,groupName:c,context:b,source:g,inline:O}){let m=l4E(n??[]),P=new Set(a),E=Array.from(P).map((M,D)=>{let C=i?.[M],x=m[D],$=T8n.test(M),I=C?.name??x,L=$?M:C8n(M);return I!=null&&!T8n.test(I)&&(b?.logger.warn(`Enum name override ${I} is not a valid name. Falling back on ${L}.`),I=void 0),{nameOverride:I,generatedName:L,value:M,description:C?.description,availability:d,casing:{snake:C?.casing?.snake??void 0,pascal:C?.casing?.pascal??void 0,screamingSnake:C?.casing?.screamingSnake??void 0,camel:C?.casing?.camel??void 0}}}),q=u!=null?E.find(M=>M.value===u):void 0;return c4E({wrapAsNullable:s,nameOverride:e,generatedName:t,title:r,values:E,_default:q,description:l,availability:d,namespace:o,groupName:c,source:g,inline:O})}function c4E({wrapAsNullable:e,nameOverride:t,generatedName:r,title:i,values:n,_default:a,description:u,availability:l,namespace:d,groupName:s,source:o,inline:c}){return e?zl.nullable({nameOverride:t,generatedName:r,title:i,value:zl.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,default:a,availability:l,example:void 0,namespace:d,groupName:s,source:o,inline:c}),description:u,availability:l,namespace:d,groupName:s,inline:c}):zl.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,availability:l,default:a,example:void 0,namespace:d,groupName:s,source:o,inline:c})}function l4E(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(i=>i[r]===t[r]);)r++;return e.map(i=>i.substring(r))}function Uj_({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,description:o,availability:c,wrapAsNullable:b,example:g,namespace:O,groupName:m}){return i==="int64"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="uint32"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="uint64"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):u8({nameOverride:e,generatedName:t,title:r,primitive:up.int({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m})}function Vj_(e){return typeof e=="string"?vz.string(e):typeof e=="boolean"?vz.boolean(e):vz.string(`${e}`)}function Wj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,value:n,description:a,availability:u,namespace:l,groupName:d}){return i?zl.nullable({nameOverride:e,generatedName:t,title:r,value:zl.literal({nameOverride:e,generatedName:t,title:r,value:Vj_(n),description:a,availability:u,namespace:l,groupName:d}),description:a,availability:u,namespace:l,groupName:d,inline:void 0}):zl.literal({nameOverride:e,generatedName:t,title:r,value:Vj_(n),description:a,availability:u,namespace:l,groupName:d})}function f0c({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,description:o,availability:c,wrapAsNullable:b,example:g,namespace:O,groupName:m}){return i==null||i==="double"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.double({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="float"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.float({example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="int32"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.int({default:n,minimum:a,maximum:u,exclusiveMinimum:l,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="int64"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="uint32"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="uint64"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):i==="time-delta"?u8({nameOverride:e,generatedName:t,title:r,primitive:up.float({example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m}):u8({nameOverride:e,generatedName:t,title:r,primitive:up.float({example:g}),wrapAsNullable:b,description:o,availability:c,namespace:O,groupName:m})}var f4E={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},d4E={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}}},p4E={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}}},_4E={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},h4E={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},y4E={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},v4E={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},b4E={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function dYo(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[f4E,d4E,p4E,_4E,h4E,y4E,v4E,b4E],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:l}=a.applyStrategy(t);t=u,r=[...r,...l]}}while(t.join("")!==n.join(""));return r}function s8(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:iz(T_(n))).join("");return/^\d/.test(i)?$Ia(i)??i:i}function d0c(e){let t=e.join("_");return T_(t)}function qM(e){switch(e.type){case"object":return Fy.object({allOf:e.allOf,properties:e.properties.map(t=>O4E(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:e.inline});case"array":return Fy.array({description:e.description,availability:e.availability,value:qM(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return Fy.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,source:e.source,inline:e.inline});case"literal":return Fy.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"nullable":return Fy.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:qM(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return Fy.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:qM(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return Fy.primitive({description:e.description,availability:e.availability,schema:Hj_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return Fy.map({description:e.description,availability:e.availability,key:Fy.primitive({description:e.key.description,availability:e.key.availability,schema:Hj_(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:qM(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return Fy.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return Fy.oneOf(g4E(e.value));case"unknown":return Fy.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:mo(e)}}function g4E(e){switch(e.type){case"discriminated":return Gdi.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:qM(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,qM(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return Gdi.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>qM(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:mo(e)}}function Hj_(e){switch(e.type){case"string":return Xj.string(e);case"base64":return Xj.base64();case"boolean":return Xj.boolean(e);case"date":return Xj.date();case"datetime":return Xj.datetime();case"double":return Xj.double(e);case"float":return Xj.float();case"int":return Xj.int(e);case"int64":return Xj.int64(e);case"uint":return Xj.uint();case"uint64":return Xj.uint64();default:mo(e)}}function O4E(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:qM(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function pYo(e,t){return Jae(qM(e),qM(t))}function $j_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:u,wrapAsNullable:l,allOf:d,context:s,propertiesToExclude:o,namespace:c,groupName:b,fullExamples:g,additionalProperties:O,availability:m,source:P}){let E=[...u??[]],q={...n},M=[],D=[];for(let I of d)if(sp(I)){let L=s.resolveSchemaReference(I);if(L.discriminator!=null&&L.discriminator.mapping!=null)continue;if(L.oneOf!=null){for(let X of L.oneOf){let K=sp(X)?s.resolveSchemaReference(X):X,Z=t0(K,!1,s.DUMMY,i,P,c);Z.type==="object"&&M.push(...Z.properties.map(fe=>fe.schema.type!=="optional"&&fe.schema.type!=="nullable"?{...fe,schema:zl.optional({nameOverride:void 0,generatedName:"",title:void 0,value:fe.schema,description:void 0,availability:fe.availability,namespace:void 0,groupName:void 0,inline:void 0})}:fe))}continue}let V=uAi(I);if(V==null)continue;D.push({schemaId:V,convertedSchema:p0c(I,[V],P,s.options.preserveSchemaIds),properties:Gj_({schema:I,context:s,breadcrumbs:i,source:P,namespace:c})}),s.markSchemaAsReferencedByNonRequest(V)}else{let L=t0(I,!1,s,i,P,c);L.type==="object"&&M.push(...L.properties)}let C={};for(let I of D)for(let[L,V]of Object.entries(I.properties)){let X=C[L];X!=null?(X.schemaIds.push(I.schemaId),X.schemas.some(Z=>pYo(Z,V))||X.schemas.push(V)):C[L]={schemaIds:[I.schemaId],schemas:[V]}}let x=[];for(let[I,L]of Object.entries(C))L.schemaIds.length>1&&x.push({propertyKey:I,allOfSchemaIds:L.schemaIds,conflictingTypeSignatures:L.schemas.length>1});let $=Object.entries(q).map(([I,L])=>{let V=hf(L,id.AUDIENCES)??[],X=vJ(L),K=sp(L)?!1:L.readOnly,Z=sp(L)?!1:L.writeOnly,fe=E.includes(I)&&!K,me=hf(L,id.FERN_PROPERTY_NAME),_e=[...i,I],Se=d0c(_e),Qe=fe?t0(L,!1,s,_e,P,c):zl.optional({nameOverride:e,generatedName:Se,title:r,description:void 0,availability:X,value:t0(L,!1,s,_e,P,c),namespace:c,groupName:b,inline:void 0}),Dt={};for(let Ee of D){let Te=Ee.properties[I];Te!=null&&!pYo(Qe,Te)?Dt[Ee.schemaId]={differentSchema:!0}:Te!=null&&(Dt[Ee.schemaId]={differentSchema:!1})}return{key:I,schema:Qe,nameOverride:me,audiences:V,conflict:Dt,generatedName:d0c([...i,I]),availability:X,readonly:K,writeonly:Z}});return $.push(...M.map(I=>{let L=I.conflict;for(let V of D){let X=V.properties[I.key];X!=null&&!pYo(I.schema,X)?L[V.schemaId]={differentSchema:!0}:X!=null&&(L[V.schemaId]={differentSchema:!1})}return{...I,conflict:L}})),m4E({nameOverride:e,generatedName:t,title:r,wrapAsNullable:l,properties:$.filter(I=>!o.has(I.key)),description:a,allOf:D.map(I=>I.convertedSchema),allOfPropertyConflicts:x,namespace:c,groupName:b,fullExamples:g,additionalProperties:O,availability:m,source:P,context:s})}function m4E({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,allOf:u,allOfPropertyConflicts:l,namespace:d,groupName:s,fullExamples:o,additionalProperties:c,availability:b,source:g,context:O}){return i?zl.nullable({nameOverride:e,generatedName:t,title:r,value:zl.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:l,namespace:d,groupName:s,fullExamples:o,additionalProperties:E5n(c,O.options),availability:void 0,source:g,inline:void 0}),description:a,availability:b,namespace:d,groupName:s,inline:void 0}):zl.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:l,namespace:d,groupName:s,fullExamples:o,additionalProperties:E5n(c,O.options),availability:b,source:g,inline:void 0})}function Gj_({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[u,l]=sp(e)?[t.resolveSchemaReference(e),dYo(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...Gj_({schema:d,context:t,breadcrumbs:l,source:i,namespace:n})};for(let[d,s]of Object.entries(u.properties??{})){let o=t0(s,!1,t,[...l,d],i,n);a[d]=o}return a}function A5n({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsNullable:u,context:l,subtypes:d,namespace:s,groupName:o,encoding:c,source:b,subtypePrefixOverrides:g}){let O=w4E({schemas:d}),m=d.flatMap((E,q)=>{if(!sp(E)&&E.enum!=null&&l.options.coerceEnumsToLiterals&&E.type==="string")return E.enum.map(D=>zl.literal({nameOverride:void 0,generatedName:s8([t,D],l.options.preserveSchemaIds),title:void 0,value:vz.string(String(D)),namespace:s,groupName:void 0,description:void 0,availability:D.availability}));let M=O[q];if(g!=null){let D=g[q];D!=null&&"name"in D&&(M=D.name)}return[t0(E,!1,l,[...i,M??`${q}`],b,s)]}),P=P4E(m);return j4E({uniqueSubtypes:P,nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:n,availability:a,namespace:s,groupName:o,context:l,encoding:c,source:b})}function P4E(e){let t=[];for(let r=0;r<e.length;++r){let i=e[r],n=!1;for(let a=r+1;a<e.length;++a){let u=e[a];if(i!=null&&u!=null&&Jae(i,u)){n=!0;break}}i!=null&&!n&&t.push(i)}return t}function j4E({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,namespace:l,groupName:d,context:s,encoding:o,source:c}){if(Object.entries(e).every(([g,O])=>O.type==="literal")){let g={},O=[];return Object.entries(e).forEach(([m,P])=>{P.type==="literal"&&P.value.type==="string"&&(O.push(P.value.value),P.description!=null&&(g[P.value.value]={description:P.description}))}),oAi({nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,fernEnum:g,enumVarNames:void 0,enumValues:O,_default:void 0,namespace:l,groupName:d,context:s,source:c,inline:void 0})}return e.length===1&&e[0]!=null?e[0]:Qj_({nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,subtypes:e,namespace:l,groupName:d,encoding:o,source:c})}function _0c({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsNullable:a,context:u,namespace:l,groupName:d,discriminator:s,encoding:o,source:c}){let b=Object.entries(s.mapping??{}).map(([m,P],E)=>{let q={$ref:P},M=upi(q,!1,u,[P],o,c,l);return u.markSchemaWithDiscriminantValue(q,s.propertyName,m),M.type==="object"&&(M.properties={[s.propertyName]:zl.literal({nameOverride:void 0,generatedName:s8([t,m],u.options.preserveSchemaIds),title:void 0,value:vz.string(m),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...M.properties.filter(D=>D.key!==s.propertyName)}),M}),g=[];for(let m=0;m<b.length;++m){let P=b[m],E=!1;for(let q=m+1;q<b.length;++q){let M=b[q];if(P!=null&&M!=null&&Jae(P,M)){E=!0;break}}P!=null&&!E&&g.push(P)}if(Object.entries(g).every(([m,P])=>P.type==="literal")){let m={},P=[];return Object.entries(g).forEach(([E,q])=>{q.type==="literal"&&q.value.type==="string"&&(P.push(q.value.value),q.description!=null&&(m[q.value.value]={description:q.description}))}),oAi({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,fernEnum:m,enumVarNames:void 0,enumValues:P,_default:void 0,namespace:l,groupName:d,context:u,source:c,inline:void 0})}return g.length===1&&g[0]!=null?g[0]:Qj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,subtypes:g,namespace:l,groupName:d,encoding:o,source:c})}function w4E({schemas:e}){let t={},r=0;for(let a of e){if(!sp(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),l={},d=u;for(let[s,o]of Object.entries(t)){let c=eOo(o,u);d=eOo(d,o),l[s]=c}l[r]=d,t=l}}r++}let i=[],n=0;for(let a of e){let u=t[n];if(u!=null&&u.length>0){let l=u.sort();if(l[0]!=null){i.push(l[0]),++n;continue}}sp(a)?i.push(CMi(n)??`${n}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?i.push(""):i.push(CMi(n)??`${n}`),++n}return i}function Qj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,description:n,availability:a,subtypes:u,namespace:l,groupName:d,encoding:s,source:o}){return i?zl.nullable({nameOverride:e,generatedName:t,title:r,value:zl.oneOf(ik.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,namespace:l,groupName:d,encoding:s,source:o,inline:void 0})),description:n,availability:a,namespace:l,groupName:d,inline:void 0}):zl.oneOf(ik.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,namespace:l,groupName:d,encoding:s,source:o,inline:void 0}))}function q5n(e){if(e.default!=null&&typeof e.default=="string")return e.default}function _Yo({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=JJi(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function Jj_({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=JJi(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function Pir({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=JJi(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function Kj_({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=JJi(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var YJi="#/components/schemas/";function t0(e,t,r,i,n,a,u=!1,l=new Set,d){let s=zj_(e)??n,o=C4E({schema:e,logger:r.logger});if(sp(e)){let c=uAi(e);return c!=null?(u?r.markSchemaAsReferencedByRequest(c):r.markSchemaAsReferencedByNonRequest(c),upi(e,t,r,i,o,s,a)):M5n(r.resolveSchemaReference(e),t,r,dYo(e.$ref),o,s,a,l,u,d)}return M5n(e,t,r,i,o,s,a,l,u,d)}function upi(e,t,r,i,n,a,u){let l=e.$ref.includes("properties")?M5n(r.resolveSchemaReference(e),t,r,i,n,a,u,new Set):zl.reference(p0c(e,i,a,r.options.preserveSchemaIds));return t?zl.nullable({title:void 0,nameOverride:void 0,generatedName:s8(i,r.options.preserveSchemaIds),value:l,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0}):l}function S4E(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function M5n(e,t,r,i,n,a,u,l=new Set,d=!1,s){typeof e=="string"&&(e={type:e});let o=hf(e,id.TYPE_NAME)??(r.options.useTitlesAsName?S4E(e.title):void 0),c=hf(e,id.SDK_GROUP_NAME)??hf(e,cH.TAGS)?.[0],b=(typeof c=="string"?[c]:c)??[];b=r.resolveGroupName(b);let g=s8(i,r.options.preserveSchemaIds),O=e.title,m=e.description,P=vJ(e),E=[];e.example!=null&&E.push({name:void 0,value:e.example,description:void 0});let q=hf(e,cH.EXAMPLES);q!=null&&Object.keys(q).length>0&&E.push(...Object.entries(q).map(([C,x])=>({name:x?.summary??C,value:x.value,description:x.description})));let M=JJi(e);M!=null&&Object.keys(M).length>0&&E.push(...M.map(C=>({name:void 0,value:C,description:void 0})));let D=Ij_({schema:e,description:m,title:O,nameOverride:o,generatedName:g,availability:P});if(D!=null)return D;if(Array.isArray(e.type)){let C=e.type.indexOf("null"),x=C!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&x)e.type.splice(C,1),e.type=e.type[0],e.nullable=!0;else if(x&&(e.type.splice(C,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let $=new Set([...e.oneOf,...e.type]);e.oneOf=[...$]}}if(!t&&e.nullable===!0)return M5n(e,!0,r,i,n,a,u,l,d,s);if(e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(!vYo(e.enum))return u8({nameOverride:o,generatedName:g,title:O,primitive:up.string({default:q5n(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:Pir({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b,wrapAsNullable:t,description:m,availability:P});let C=Bj_(e);return e.enum.length===1&&e.enum[0]!=null&&C==null?Wj_({nameOverride:o,generatedName:g,title:O,wrapAsNullable:t,value:e.enum[0],description:m,availability:P,namespace:u,groupName:b}):oAi({nameOverride:o,generatedName:g,title:O,fernEnum:C,enumVarNames:hf(e,[cH.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:m,availability:P,wrapAsNullable:t,namespace:u,groupName:b,context:r,source:a,inline:void 0})}if(vYo(e.type)&&e.type.length>1){let C=e.type.includes("null"),x=e.type.filter($=>$!=="null").map($=>({type:$,nullable:C}));return A5n({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t,context:r,subtypes:x,namespace:u,groupName:b,encoding:n,source:a})}if(e.type==="boolean"){let C=hf(e,id.BOOLEAN_LITERAL);return C!=null?Yj_({nameOverride:o,generatedName:g,title:O,literal:vz.boolean(C),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b}):u8({nameOverride:o,generatedName:g,title:O,primitive:up.boolean({default:D4E(e.default),example:Jj_({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b})}if(e.type==="number")return f0c({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:KJi(e.exclusiveMinimum),exclusiveMaximum:KJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:_Yo({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="integer")return Uj_({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:KJi(e.exclusiveMinimum),exclusiveMaximum:KJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:_Yo({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="float")return f0c({nameOverride:o,generatedName:g,title:O,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:KJi(e.exclusiveMinimum),exclusiveMaximum:KJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:_Yo({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="string"){if(e.format==="date-time")return u8({nameOverride:o,generatedName:g,title:O,primitive:up.datetime({example:Pir({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b});if(e.format==="date"&&r.options.typeDatesAsStrings===!1)return u8({nameOverride:o,generatedName:g,title:O,primitive:up.date({example:Pir({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b});if(e.format==="json-string")return zl.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:P,namespace:u,groupName:b,example:void 0});let C=kj_(e,"const");return C!=null?Yj_({nameOverride:o,generatedName:g,title:O,literal:vz.string(C),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b}):u8({nameOverride:o,generatedName:g,title:O,primitive:up.string({default:q5n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:Pir({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b,wrapAsNullable:t,description:m,availability:P})}if(e.type==="array")return Nj_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,item:e.items,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,example:Kj_({schema:e,logger:r.logger,fallback:s}),source:a});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&hYo(e))return xj_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,additionalProperties:e.additionalProperties,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,example:e.example,source:a});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?_0c({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,discriminator:e.discriminator,encoding:n,source:a}):c0c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,source:a});if(e.oneOf!=null&&e.oneOf.length>0){let C=hf(e,id.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||C?_0c({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,discriminator:e.discriminator,encoding:n,source:a}):c0c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,source:a});if(e.oneOf.length===1&&e.oneOf[0]!=null){let x=t0(e.oneOf[0],t,r,i,a,u,d);return T5n(x,m,u,b)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let L=e.oneOf[0],V=e.oneOf[1];if(!sp(L)&&L.type==="null")return t0(V,!0,r,i,a,u);if(!sp(V)&&V.type==="null")return t0(L,!0,r,i,a,u)}let x=A4E({schemas:e.oneOf});if(x!=null)return oAi({nameOverride:o,generatedName:g,title:O,fernEnum:void 0,enumVarNames:void 0,enumValues:x,_default:e.default,description:m,availability:P,wrapAsNullable:t,namespace:u,groupName:b,context:r,source:a,inline:void 0});let $=Xj_({schemas:e.oneOf,context:r});if($!=null&&!r.options.discriminatedUnionV2&&!C)return l0c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:P,wrapAsNullable:t,discriminant:$.discriminant,variants:$.schemas,context:r,namespace:u,groupName:b,encoding:n,source:a});let I=e.oneOf.filter(L=>!sp(L)&&L.type==="null").length>0;return A5n({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t||I,context:r,subtypes:e.oneOf.filter(L=>sp(L)||L.type!=="null"),encoding:n,namespace:u,groupName:b,source:a})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let $=t0(e.anyOf[0],t,r,i,a,u,d);return T5n($,m,u,b)}if(e.anyOf.length===2){let[$,I]=e.anyOf;if($!=null&&I!=null){if(!sp($)&&$.type==="null"){let L=t0(I,!0,r,i,a,u);return T5n(L,m,u,b)}else if(!sp(I)&&I.type==="null"){let L=t0($,!0,r,i,a,u);return T5n(L,m,u,b)}}}let C=Xj_({schemas:e.anyOf,context:r});if(C!=null&&!r.options.discriminatedUnionV2)return l0c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:P,wrapAsNullable:t,discriminant:C.discriminant,variants:C.schemas,context:r,namespace:u,groupName:b,encoding:n,source:a});let x=e.anyOf.filter($=>!sp($)&&$.type==="null").length>0;return A5n({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t||x,context:r,subtypes:e.anyOf.filter($=>sp($)||$.type!=="null"),encoding:n,namespace:u,groupName:b,source:a})}if(e.allOf!=null||e.properties!=null){let C=[];for(let $ of e.allOf??[])(sp($)||Object.keys($).length>0)&&C.push($);if((e.properties==null||hYo(e))&&C.length===1&&C[0]!=null){let $=t0(C[0],t,r,i,a,u,d);return T5n($,m,u,b)}let x=C.filter($=>{let I=yYo($);return I||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify($)}`),I});if((e.properties==null||hYo(e))&&x.length===1&&x[0]!=null){let $=t0(x[0],t,r,i,a,u,d);return T5n($,m,u,b)}return $j_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},description:m,required:e.required,wrapAsNullable:t,allOf:x,context:r,propertiesToExclude:l,namespace:u,groupName:b,fullExamples:E,additionalProperties:e.additionalProperties,availability:P,encoding:n,source:a})}if(e.type==="object"&&E4E(e)&&M4E(e)&&hYo(e))return fYo({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${g}Key`,title:void 0,description:void 0,availability:void 0,schema:up.string({default:q5n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:Pir({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b},valueSchema:zl.unknown({nameOverride:void 0,generatedName:`${g}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:b}),namespace:u,groupName:b,encoding:n,example:e.example});if(e.type==null){let C=e.example??e.default;return zl.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:P,namespace:u,groupName:b,example:C})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(i)} value=${JSON.stringify(e)}`)}function D4E(e){if(e!=null){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase();if(t==="true")return!0;if(t==="false")return!1}}}function uAi(e){if(e.$ref.startsWith(YJi))return e.$ref.replace(YJi,"")}function p0c(e,t,r,i){let n=hf(e,id.TYPE_NAME),a=s8(t,i),u=e.description,l=vJ(e),d=uAi(e);if(d==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return Fy.reference({generatedName:a,nameOverride:n,title:void 0,schema:d,description:u??void 0,availability:l,namespace:void 0,groupName:void 0,source:r})}function E4E(e){return e.oneOf==null||e.oneOf.length===0}function M4E(e){return e.allOf==null||e.allOf.length===0}function hYo(e){return e.properties==null||fZ(e.properties)===0}function vYo(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function T5n(e,t,r,i){return e.type==="reference"?zl.reference({...e,description:t,availability:e.availability,namespace:r,groupName:i}):e.type==="optional"?zl.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0}):e.type==="nullable"?zl.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0}):e}function yYo(e){return sp(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>yYo(t)):e.oneOf!=null?e.oneOf.every(t=>yYo(t)):e.anyOf!=null?e.anyOf.every(t=>yYo(t)):!1}function Yj_({literal:e,wrapAsNullable:t,namespace:r,groupName:i,description:n,availability:a,nameOverride:u,generatedName:l,title:d}){return t?zl.nullable({nameOverride:u,generatedName:l,title:d,value:zl.literal({nameOverride:u,generatedName:l,title:d,value:e,description:n,availability:a,namespace:r,groupName:i}),namespace:r,groupName:i,description:n,availability:a,inline:void 0}):zl.literal({nameOverride:u,generatedName:l,title:d,value:e,namespace:r,groupName:i,description:n,availability:a})}function u8({primitive:e,wrapAsNullable:t,namespace:r,groupName:i,description:n,availability:a,generatedName:u,nameOverride:l,title:d}){return i=typeof i=="string"?[i]:i,t?zl.nullable({nameOverride:l,generatedName:u,title:d,value:zl.primitive({nameOverride:l,generatedName:u,title:d,schema:e,description:n,availability:a,namespace:r,groupName:i}),namespace:r,groupName:i,description:n,availability:a,inline:void 0}):zl.primitive({nameOverride:l,generatedName:u,title:d,schema:e,description:n,availability:a,namespace:r,groupName:i})}function A4E({schemas:e}){let t=new Set;for(let r of e){if(sp(r))return;if(r.enum!=null&&vYo(r.enum))r.enum.forEach(i=>t.add(i));else return}return Array.from(t)}function Xj_({schemas:e,context:t}){let r={};for(let i of e){let n=Zj_({schema:i,context:t});for(let[a,u]of Object.entries(n)){let l=r[a];l!=null?l[u]=i:r[a]={[u]:i}}}for(let[i,n]of Object.entries(r))if(Object.keys(n).length===e.length)return{discriminant:i,schemas:n}}function Zj_({schema:e,context:t}){let r=sp(e)?t.resolveSchemaReference(e):e;return q4E({schema:r,context:t})}function q4E({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let i of e.anyOf){let n=Zj_({schema:i,context:t});for(let[a,u]of Object.entries(n??{}))r[a]=u}return r}for(let[i,n]of Object.entries(e.properties??{})){let a=sp(n)?t.resolveSchemaReference(n):n;a.type==="string"&&a.enum!=null&&vYo(a.enum)&&T4E(a.enum).length===1&&a.enum[0]!=null&&(r[i]=a.enum[0]);let u=kj_(a,"const");a.type==="string"&&u!=null&&(r[i]=u),i==="type"&&a.example!=null&&(r[i]=a.example)}return r}function T4E(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 kj_(e,t){let r=e[t];if(r!=null)return r}function C4E({schema:e,logger:t}){let r=Cj_({schema:e,logger:t});if(r!=null)return Lj_(r)}var C5n=class{document;taskContext;logger;DUMMY;options;namespace;static MESSAGE_REFERENCE_PREFIX="#/components/messages/";constructor({document:t,taskContext:r,options:i,namespace:n}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=i,this.namespace=n}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let i=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};i.push(n)}return i.concat(t??[])}resolveSchemaReference(t){if(!t.$ref.startsWith(YJi))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let i=t.$ref.substring(YJi.length).split("/"),n=this.document.components;if(n==null||n.schemas==null)throw new Error("Document does not have components.schemas.");let[a,u,l]=i;if(a==null||a==="")throw new Error(`${t.$ref} cannot be resolved. No schema key provided.`);let d=n.schemas[a];if(d==null)throw new Error(`Schema "${a}" is undefined in document.components.schemas.`);if(sp(d)&&(d=this.resolveSchemaReference(d)),u==="properties"&&l!=null){let s=d.properties?.[l];if(s==null)throw new Error(`Property "${l}" not found on "${a}". Full ref: ${t.$ref}`);sp(s)?d=this.resolveSchemaReference(s):d=s}return d}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,i){}markSchemaWithDiscriminantValue(t,r,i){}};var bYo=class extends C5n{getExampleMessageReference(t){return`#/components/messages/${t.messageId}`}resolveMessageReference(t){let r="#/components/messages/",i=this.document.components;if(i==null||i.messages==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve message reference: ${t.$ref} in v2 components`);let n=t.$ref.substring(r.length),a=i.messages[n];if(a==null)throw new Error(`${t.$ref} is undefined`);return a}};function B5n(e,t){let r={};if(e!=null)return{rootSchemas:r,namespacedSchemas:{[e]:t}};let i={};for(let[n,a]of Object.entries(t))switch(a.type){case"object":case"array":case"map":case"optional":case"enum":case"literal":case"reference":case"nullable":case"primitive":{if(a.namespace==null){r[n]=a;continue}let u=a.namespace;i[u]??={},i[u][n]=a;continue}case"oneOf":case"unknown":r[n]=a;continue;default:mo(a)}return{rootSchemas:r,namespacedSchemas:i}}function sAi(e){if(typeof e=="string")return vO.primitive(w_.string(e));if(typeof e=="number")return Number.isInteger(e)?vO.primitive(w_.int(e)):vO.primitive(w_.double(e));if(typeof e=="boolean")return vO.primitive(w_.boolean(e));if(Array.isArray(e)){let t=e.map(r=>sAi(r));return t.length===0?void 0:vO.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,i]of Object.entries(e)){let n=sAi(i);n!=null&&t.push({key:w_.string(r),value:n})}return vO.map(t)}}function Zza(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function ew_(e){if(e!=null&&Array.isArray(e))return e}var cAi=class{schemas;nonRequestReferencedSchemas;context;constructor(t,r,i){this.schemas=t,this.nonRequestReferencedSchemas=r,this.context=i}buildExample({schema:t,exampleId:r,example:i,options:n,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:i,options:{...n,maxCheckerDepth:n.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:i,depth:n,visitedSchemaIds:a,options:u,skipReadonly:l}){switch(i.type){case"enum":return typeof r=="string"&&tw_({schema:i,value:r})?vO.enum(r):i.values[0]!=null?vO.enum(i.values[0]?.value):void 0;case"literal":return vO.literal(i.value);case"nullable":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u)))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:l});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"optional":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u))||Object.is(r,null))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:l});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"primitive":{let d=this.buildExampleFromPrimitive({schema:i.schema,example:r,options:u});return vO.primitive(d)}case"reference":{let d=this.schemas[i.schema];if(d!=null&&!a.has(i.schema)){a.add(i.schema);let s=d?.type==="object"&&!this.nonRequestReferencedSchemas.has(i.schema),o=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:n,options:u,skipReadonly:s||this.context.options.respectReadonlySchemas?l:!1});return a.delete(i.schema),o}return}case"oneOf":switch(i.value.type){case"discriminated":{let d={},s={},o={},c=Zza(r),b=c?.[i.value.discriminantProperty],g=i.value.schemas[b],O=[],m=this.getDiscriminatedUnionVariantSchema(i.value,c);m!=null&&O.push(m),O.push(...Object.entries(i.value.schemas));for(let P of O)if(b!=null&&g!=null&&g.type==="object"){s=this.getAllProperties(g),o=this.getAllRequiredProperties(g),d[i.value.discriminantProperty]=vO.primitive(w_.string(b));break}else{let E=this.buildExampleHelper({exampleId:t,schema:P[1],example:void 0,visitedSchemaIds:a,depth:n,options:u,skipReadonly:l});if(E!=null){this.mergeExampleWith(E,d),d[i.value.discriminantProperty]=vO.primitive(w_.string(P[0]));break}}for(let P of i.value.commonProperties){s[P.key]={schema:P.schema,readonly:!1};let E=this.getResolvedSchema(P.schema);E.type!=="optional"&&E.type!=="nullable"&&(o[P.key]=P.schema)}for(let[P,E]of Object.entries(s)){let q=P in o;if(q&&c?.[P]!=null){let M=this.buildExampleHelper({schema:E.schema,exampleId:t,example:c[P],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});if(M!=null)d[P]=M;else return}else{let M=this.buildExampleHelper({exampleId:t,schema:E.schema,example:c?.[P],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});if(M!=null)d[P]=M;else if(q)return}}return vO.oneOf(PMi.discriminated(d))}case"undiscriminated":{let d=this.getUnDiscriminatedUnionVariantSchema(i.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:n,options:u,skipReadonly:l});break}}return;case"unknown":if(r!=null){let d=sAi(r);if(d!=null)return vO.unknown(d)}return u.ignoreOptionals||this.exceedsMaxDepth(n,u)?void 0:u.isParameter?vO.primitive(w_.string(u.name??"string")):vO.map([{key:w_.string("key"),value:vO.primitive(w_.string("value"))}]);case"array":{let d=ew_(r),s=[];if(d!=null&&d.length>0)for(let o of d){let c=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});c!=null&&s.push(c)}else if(i.example!=null&&i.example.length>0)for(let o of i.example){let c=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});c!=null&&s.push(c)}else{let o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:l});o!=null&&s.push(o)}return vO.array(s)}case"map":{let d=Zza(r??i.example);if(d!=null&&Object.entries(d).length>0){let c=[];for(let[b,g]of Object.entries(d)){let O=this.buildExampleFromPrimitive({schema:i.key.schema,example:b,options:u}),m=this.buildExampleHelper({exampleId:t,example:g,schema:i.value,visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:l});m!=null&&c.push({key:O,value:m})}return vO.map(c)}if(i.key.schema.type==="string"&&i.value.type==="unknown")return vO.map([{key:w_.string("key"),value:vO.unknown(vO.primitive(w_.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:i.key.schema,example:void 0,options:{...u,name:"key"}}),o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,visitedSchemaIds:a,depth:n+1,options:{...u,name:"value"},skipReadonly:l});return o!=null?vO.map([{key:s,value:o}]):vO.map([])}case"object":{let d={},s=i.fullExamples?.find(g=>g.name===t)??i.fullExamples?.find(g=>g.name==null)??i.fullExamples?.[0],o=Zza(r)??(s!=null?Zza(s.value):{})??{},c=this.getAllProperties(i),b=this.getAllRequiredProperties(i);for(let[g,O]of Object.entries(c)){if(l&&O.readonly)continue;let m=g in b,P=Object.keys(o).includes(g),E=this.buildExampleHelper({schema:O.schema,exampleId:t,example:o[g],visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:l});if(m&&E!=null)d[g]=E;else{if(m)return;(P&&E!=null||!u.ignoreOptionals&&E!=null)&&(d[g]=E)}}if(i.additionalProperties){for(let[g,O]of Object.entries(o))if(!(g in d)){let m=this.buildExampleHelper({schema:zl.unknown({example:O,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0}),exampleId:t,example:O,visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:l});m!=null&&(d[g]=m)}}return vO.object({properties:d})}default:mo(i)}}mergeExampleWith(t,r){t._visit({array:Go,enum:Go,literal:Go,map:i=>{for(let n of i){let a=n.key;a.type==="string"&&(r[a.value]=n.value)}},object:i=>{for(let[n,a]of Object.entries(i.properties))r[n]=a},oneOf:i=>{if(i.type==="discriminated")for(let[n,a]of Object.entries(i.value))r[n]=a;else this.mergeExampleWith(i.value,r)},primitive:Go,unknown:Go,_other:Go})}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let i=r?.[t.discriminantProperty];if(i==null||typeof i!="string")return Object.entries(t.schemas)[0];let n=t.schemas[i];return n==null?Object.entries(t.schemas)[0]:[i,n]}getUnDiscriminatedUnionVariantSchema(t,r){return r==null?t.schemas[0]:t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,u)=>u.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return tw_({schema:t,value:r})?5:0;case"object":{if(!Jj(r))return 0;let i=this.getAllProperties(t),n=0;for(let[a,u]of Object.entries(i))r[a]!=null?(n++,n+=this.calcExampleHeuristic(u.schema,r[a])):n--;return n}case"array":{if(!Array.isArray(r))return 0;let i=0;for(let n of r)i+=this.calcExampleHeuristic(t.value,n);return i}case"map":{if(!Jj(r))return 0;let i=0;for(let[,n]of Object.entries(r))i+=this.calcExampleHeuristic(t.value,n);return i}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let i=this.getResolvedSchema(t);return i==null?0:this.calcExampleHeuristic(i,r)}case"oneOf":return Object.values(t.value.schemas).map(n=>this.calcExampleHeuristic(n,r)).sort((n,a)=>a-n)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,i=new Set,n){if(this.exceedsMaxCheckerDepth(r,n))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,i,n);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,i,n);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let u of t.properties)if(this.hasExample(u.schema,r+1,i,n))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!i.has(t.schema)){i.add(t.schema);let u=this.hasExample(a,r,i,n);return i.delete(t.schema),u}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,i,n));default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let i of t.properties)r[i.key]={schema:i.schema,readonly:i.readonly??!1};for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let i of t.properties){let n=this.getResolvedSchema(i.schema);n.type!=="optional"&&n.type!=="nullable"&&(r[i.key]=i.schema)}for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:i}){switch(r.type){case"string":return t!=null&&typeof t=="string"?w_.string(t):r.example!=null?w_.string(r.example):w_.string(i.name??Gy.STRING);case"base64":return t!=null&&typeof t=="string"?w_.base64(t):r.example!=null?w_.base64(r.example):w_.base64(Gy.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?w_.boolean(t):r.example!=null?w_.boolean(r.example):w_.boolean(Gy.BOOLEAN);case"date":return t!=null&&typeof t=="string"?w_.date(t):r.example!=null?w_.date(r.example):w_.date(Gy.DATE);case"datetime":return t!=null&&typeof t=="string"?w_.datetime(t):r.example!=null?w_.datetime(r.example):w_.datetime(Gy.DATE_TIME);case"double":return t!=null&&typeof t=="number"?w_.double(t):r.example!=null?w_.double(r.example):w_.double(Gy.DOUBLE);case"float":return t!=null&&typeof t=="number"?w_.float(t):r.example!=null?w_.float(r.example):w_.float(Gy.FLOAT);case"int":return t!=null&&typeof t=="number"?w_.int(t):r.example!=null?w_.int(r.example):w_.int(Gy.INT);case"int64":return t!=null&&typeof t=="number"?w_.int64(t):r.example!=null?w_.int64(r.example):w_.int64(Gy.INT64);case"uint":return t!=null&&typeof t=="number"?w_.uint(t):r.example!=null?w_.uint(r.example):w_.uint(Gy.UINT);case"uint64":return t!=null&&typeof t=="number"?w_.uint64(t):r.example!=null?w_.uint64(r.example):w_.uint64(Gy.UINT64);default:mo(r)}}};function tw_({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function jir(e){switch(e.type){case"object":return zl.object({allOf:e.allOf,properties:e.properties.map(t=>I4E(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:void 0});case"array":return zl.array({description:e.description,availability:e.availability,value:jir(e.value),generatedName:e.generatedName,title:e.title,namespace:e.namespace,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0});case"enum":return zl.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,example:void 0,source:e.source,inline:void 0});case"literal":return zl.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName});case"nullable":return zl.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:jir(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"optional":return zl.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:jir(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"primitive":return zl.primitive({description:e.description,availability:e.availability,schema:rw_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return zl.map({description:e.description,availability:e.availability,key:zl.primitive({description:e.key.description,availability:e.key.availability,schema:rw_(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,namespace:e.namespace,groupName:e.groupName}),value:jir(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,example:void 0,inline:void 0});case"reference":return zl.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return zl.oneOf(B4E(e.value));case"unknown":return zl.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,namespace:void 0,groupName:void 0,description:void 0,availability:void 0});default:mo(e)}}function B4E(e){switch(e.type){case"discriminated":return ik.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:jir(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,jir(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return ik.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>jir(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:mo(e)}}function rw_(e){switch(e.type){case"string":return up.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return up.base64({example:void 0});case"boolean":return up.boolean({default:e.default,example:void 0});case"date":return up.date({example:void 0});case"datetime":return up.datetime({example:void 0});case"double":return up.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 up.float({example:void 0});case"int":return up.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 up.int64({default:e.default,example:void 0});case"uint":return up.uint({default:void 0,example:void 0});case"uint64":return up.uint64({default:void 0,example:void 0});default:mo(e)}}function I4E(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:jir(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function gYo(e){return e.type!=="optional"&&e.type!=="nullable"}function h0c(e){return e==="POST"||e==="PUT"||e==="PATCH"}function kza(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 OYo=class{schemas;context;exampleTypeFactory;logger;constructor(t,r){this.schemas=t,this.context=r,this.schemas=t,this.exampleTypeFactory=new cAi(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=x4E(t.request),i=R4E(t.response);if(r?.type==="unsupported"||i?.type==="unsupported")return[];let n=[];if(r!=null&&r.type==="present"){let c=this.isSchemaRequired(r.schema);if(r.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:h0c(t.method),schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});b!=null&&n.push([void 0,b])}else for(let{name:b,value:g}of r.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:h0c(t.method),schema:r.schema,exampleId:b,example:g,options:{isParameter:!1,ignoreOptionals:!0}});O!=null&&n.push([b,O])}if(c&&n.length===0)return this.logger.trace(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(i!=null&&i.type==="present"){let c=this.isSchemaRequired(i.schema);if(i.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:void 0,example:void 0,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});b!=null&&(t.response?.type==="json"?a.push([void 0,lHt.withoutStreaming(b)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,lHt.withStreaming({sse:t.response?.type==="streamingSse",events:[b]})]))}else for(let{name:b,value:g}of i.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:b,example:g,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});O!=null&&(t.response?.type==="json"?a.push([b,lHt.withoutStreaming(O)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,lHt.withStreaming({sse:t.response?.type==="streamingSse",events:[O]})]))}if(c&&a.length===0)return this.logger.trace(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let c of t.pathParameters){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!wir(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for path parameter ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&u.push({name:c.name,parameterNameOverride:c.parameterNameOverride,value:g})}let l=[];for(let c of t.queryParameters){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!wir(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for query parameter ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&l.push({name:c.name,value:g})}let d=[];for(let c of t.headers){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:void 0,options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!wir(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for header ${c.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&d.push({name:c.name,value:g})}let s=[];t.request!=null&&t.response!=null?s=z4E(n,a):t.request!=null?s=n.map(([c,b])=>({id:c,request:b,response:void 0})):t.response!=null&&(s=a.map(([c,b])=>({id:c,request:void 0,response:b})));let o=t.examples.filter(c=>kza(c)).flatMap(c=>{if(c.type==="unknown"){if(c.value!=null){let b=c.value["code-samples"];if(b!=null)return this.convertCodeSamples(b)}return}else return c.codeSamples}).filter(c=>V0(c));return s.length===0?[cHt.full({name:void 0,description:void 0,pathParameters:u,queryParameters:l,headers:d,request:void 0,response:void 0,codeSamples:o})]:s.map(({id:c,request:b,response:g})=>cHt.full({name:c,description:void 0,pathParameters:u,queryParameters:l,headers:d,request:b,response:g,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?Hdi.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):Hdi.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?tH.Csharp:r.sdk,code:r.code})).filter(V0)}isSchemaRequired(t){return gYo(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function z4E(e,t){let r=[];if(e.length<=1){let[n,a]=e[0]??[];if(t.length===0)return r.push({id:n,request:a,response:void 0}),r;for(let[u,l]of t)r.push({id:u??n,request:a,response:l});return r}if(t.length<=1){let[n,a]=t[0]??[];if(t.length===0)return r.push({id:n,request:void 0,response:a}),r;for(let[u,l]of e)r.push({id:u??n,request:l,response:a});return r}let i=new Set;for(let[n,a]of e){let u=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(n==null){if(u==null)continue;r.push({id:void 0,request:a,response:u});continue}let l=!1;for(let d=0;d<t.length;d++){let[s,o]=t[d];s==null||i.has(d)||n===s&&(r.push({id:n,request:a,response:o}),s!=null&&i.add(d),l=!0)}!l&&u!=null&&r.push({id:n,request:a,response:u})}for(let n=0;n<t.length;n++){if(i.has(n))continue;let[a,u]=t[n],l=e.find(([d])=>d==null)?.[1]??e[0]?.[1];l!=null&&r.push({id:a,request:l,response:u})}return r}function x4E(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:N4E(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function R4E(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"&&e.type!=="streamingSse"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function wir(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return wir(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undiscriminated":return wir(e.value.value);default:return!1}default:mo(e)}}function N4E(e){return zl.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:jir(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0,writeonly:void 0,inline:void 0}).filter(V0),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source,inline:void 0})}var I5n=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new cAi(t,new Set,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,handshake:i,source:n,namespace:a}){let u=[];for(let l of r){let d=[];for(let c of i.queryParameters){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:l.queryParameters?.[c.name],options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});g!=null&&!wir(g)&&(g=void 0),!(b&&g==null)&&g!=null&&d.push({name:c.name,value:g})}let s=[];for(let c of i.headers){let b=this.isSchemaRequired(c.schema),g=this.exampleTypeFactory.buildExample({schema:c.schema,exampleId:void 0,example:l.headers?.[c.name],options:{name:c.name,isParameter:!0,ignoreOptionals:!0}});g!=null&&!wir(g)&&(g=void 0),!(b&&g==null)&&g!=null&&s.push({name:c.name,value:g})}let o=[];for(let c of l.messages){let b=t.getExampleMessageReference(c),g=t.resolveMessageReference({$ref:b}),O=sp(g.payload)?t.resolveSchemaReference(g.payload):g.payload,m=this.exampleTypeFactory.buildExample({schema:t0(O,!1,t,[c.messageId],n,a),exampleId:void 0,example:c.value,options:{isParameter:!1,ignoreOptionals:!0}});m!=null&&o.push({messageType:c.type,payload:m,description:void 0})}u.push({name:l.summary,queryParameters:d,headers:s,description:l.description,messages:o})}return u}buildWebsocketSessionExample({handshake:t,messages:r}){let i={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},n=[];for(let u of t.queryParameters){let l=this.isSchemaRequired(u.schema),d=this.exampleTypeFactory.buildExample({schema:u.schema,exampleId:void 0,example:void 0,options:{name:u.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!wir(d)&&(d=void 0),l&&d==null)return;d!=null&&n.push({name:u.name,value:d})}let a=[];for(let u of t.headers){let l=this.isSchemaRequired(u.schema),d=this.exampleTypeFactory.buildExample({schema:u.schema,exampleId:void 0,example:void 0,options:{name:u.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!wir(d)&&(d=void 0),l&&d==null)return;d!=null&&a.push({name:u.name,value:d})}for(let u of r){let l=this.exampleTypeFactory.buildExample({schema:u.payload,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});l!=null&&i.messages.push({messageType:u.type,payload:l,description:void 0})}return i}isSchemaRequired(t){return gYo(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 bk={FERN_PARAMETER_OPTIONAL:"x-fern-optional",FERN_CHANNEL_ADDRESS:"x-fern-address",FERN_DISPLAY_NAME:"x-fern-display-name",FERN_SDK_GROUP_NAME:"x-fern-sdk-group-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path",FERN_ENUM:"x-fern-enum",IGNORE:"x-fern-ignore"};function mYo(e){return hf(e,bk.FERN_EXAMPLES)??[]}function PYo(e,t){return t.includes("://")?t:`${e}://${t}`}function jYo(e){return e.startsWith("/")?e:"/"+e}function aw_({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},u={};for(let[s,o]of Object.entries(n.components?.schemas??{})){let c=t0(o,!1,e,[s],r,e.namespace);a[s]=c}let l=new I5n(a,e),d={};for(let[s,o]of Object.entries(n.servers??{}))d[s]={name:s,url:PYo(o.protocol,o.url)};for(let[s,o]of Object.entries(n.channels??{})){let c=hf(o,bk.IGNORE);if(c!=null&&c){e.logger.debug(`Channel ${s} is marked with x-fern-ignore. Skipping.`);continue}let b=[];if(o.parameters!=null)for(let[E,q]of Object.entries(o.parameters??{}))b.push({name:E,description:q.description,parameterNameOverride:void 0,schema:q.schema!=null?t0(q.schema,!1,e,t,r,e.namespace):zl.primitive({schema:up.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,namespace:void 0,groupName:void 0,nameOverride:void 0}),variableReference:void 0,availability:vJ(q),source:r});let g=[],O=[];if(o.bindings?.ws!=null){if(o.bindings.ws.headers!=null){let E=o.bindings.ws.headers.required??[];for(let[q,M]of Object.entries(o.bindings.ws.headers.properties??{})){if(sp(M)){let D=e.resolveSchemaReference(M);g.push({name:q,schema:upi(M,!1,e,t,void 0,r,e.namespace),description:D.description,parameterNameOverride:void 0,env:void 0,availability:vJ(D),source:r});continue}g.push({name:q,schema:t0(M,!E.includes(q),e,[...t,q],r,e.namespace),description:M.description,parameterNameOverride:void 0,env:void 0,availability:vJ(M),source:r})}}if(o.bindings.ws.query!=null){let E=o.bindings.ws.query.required??[];for(let[q,M]of Object.entries(o.bindings.ws.query.properties??{})){if(sp(M)){let D=e.resolveSchemaReference(M);O.push({name:q,schema:upi(M,!1,e,t,void 0,r,e.namespace),description:D.description,parameterNameOverride:void 0,availability:vJ(D),source:r});continue}O.push({name:q,schema:t0(M,!E.includes(q),e,[...t,q],r,e.namespace),description:M.description,parameterNameOverride:void 0,availability:vJ(M),source:r})}}}let m;o.publish!=null&&("oneOf"in o.publish.message?m=iw_({generatedName:o.publish.operationId??"PublishEvent",event:o.publish,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):m=nw_({action:"Publish",channelPath:s,message:o.publish.message,context:e,source:r}));let P;if(o.subscribe!=null&&("oneOf"in o.subscribe.message?P=iw_({generatedName:o.subscribe.operationId??"SubscribeEvent",event:o.subscribe,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):P=nw_({action:"Subscribe",channelPath:s,message:o.subscribe.message,context:e,source:r})),g.length>0||O.length>0||m!=null||P!=null){let E=mYo(o),q=[];if(E.length>0)q=l.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:E,handshake:{headers:g,queryParameters:O},source:r,namespace:e.namespace});else{let x=[];m!=null&&x.push({type:"publish",payload:m}),P!=null&&x.push({type:"subscribe",payload:P});let $=l.buildWebsocketSessionExample({handshake:{headers:g,queryParameters:O},messages:x});$!=null&&q.push($)}let M=hf(o,bk.FERN_CHANNEL_ADDRESS),D=M??jYo(s),C=[];m!=null&&C.push({origin:"client",name:"publish",body:qM(m)}),P!=null&&C.push({origin:"server",name:"subscribe",body:qM(P)}),u[s]={audiences:hf(o,id.AUDIENCES)??[],handshake:{headers:g.map(x=>({...x,schema:qM(x.schema),env:x.env})),queryParameters:O.map(x=>({...x,schema:qM(x.schema)})),pathParameters:b.map(x=>({...x,parameterNameOverride:void 0,schema:qM(x.schema)}))},groupName:e.resolveGroupName([hf(o,bk.FERN_SDK_GROUP_NAME)??s]),messages:C,servers:(o.servers?.map(x=>d[x])??Object.values(d)).filter(x=>x!=null),summary:hf(o,bk.FERN_DISPLAY_NAME),path:D,description:o.description,examples:q,source:r}}}return{groupedSchemas:B5n(e.namespace,a),channels:u??void 0,servers:Object.values(d),basePath:hf(n,bk.BASE_PATH)}}function iw_({generatedName:e,event:t,context:r,breadcrumbs:i,source:n,options:a,asyncApiOptions:u}){if("oneOf"in t.message&&t.message.oneOf!=null){let l=[],d=[];for(let s of t.message.oneOf){let o,c={type:"notFound"};if(sp(s)){let b=r.resolveMessageReference(s);!sp(b.payload)&&u.naming==="v2"?(c=b.name?{type:"name",name:b.name}:c,o={...b.payload,title:b.name??b.payload.title,description:b.name??b.payload.description}):o=b.payload}else o=s;d.push(c),l.push(o)}return A5n({description:t.description??t.message.description,availability:vJ(t.message),subtypes:l,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:i,context:r,encoding:void 0,source:n,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?d:[]})}}function nw_({action:e,channelPath:t,message:r,context:i,source:n}){if(r.payload!=null){let a=r.payload;return sp(r.payload)&&(a=i.resolveSchemaReference(r.payload)),t0(a,!1,i,[t,e],n,i.namespace)}}var wYo=class extends C5n{getExampleMessageReference(t){return`#/channels/${t.channelId}/messages/${t.messageId}`}resolveMessageReference(t){let r="#/channels/",i="#/components/messages/";if(t.$ref.startsWith(r)){let l=t.$ref.split("/"),d=l[2],s=l[4];if(d==null||s==null||!this.document.channels?.[d])throw new Error(`Failed to resolve message reference ${t.$ref} in channel ${d}`);let c=this.document.channels[d].messages?.[s];if(c==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in c?this.resolveMessageReference(c):{name:s,...c}}let n=this.document.components;if(!t.$ref.startsWith(i)||!n?.messages)throw new Error(`Failed to resolve message reference: ${t.$ref} in v3 components`);let a=t.$ref.substring(i.length),u=n.messages[a];if(u==null)throw new Error(`${t.$ref} is undefined`);return{name:a,...u}}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}};var ow_="#/channels/",uw_="#/servers/",y0c="$message.";function cw_({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},u={},l={},d=[],s={};for(let[O,m]of Object.entries(n.components?.schemas??{}))a[O]=t0(m,!1,e,[O],r,e.namespace);for(let[O,m]of Object.entries(n.channels??{}))if(u[O]||(u[O]={}),m.messages){for(let[P,E]of Object.entries(m.messages))if(e.isReferenceObject(E)||e.isMessageWithPayload(E))if(l[P]||(l[P]=[]),e.isReferenceObject(E)){let q=e.resolveMessageReference(E);l[P].push({channelId:O,payload:q.payload})}else l[P].push({channelId:O,payload:E.payload})}for(let[O,m]of Object.entries(l))if(m.length===1){let P=m[0],E=P.channelId;u[E]=u[E]||{},u[E][O]=t0(P.payload,!1,e,[O],r,e.namespace)}else{d.push(O);for(let{channelId:P,payload:E}of m){let q=`${P}_${O}`;u[P]||(u[P]={}),u[P][q]=t0(E,!1,e,[q],r,e.namespace)}}let o=Object.values(u).reduce((O,m)=>({...O,...m}),{}),c=new I5n(o,e),b={};for(let[O,m]of Object.entries(n.servers??{}))b[O]={name:O,url:PYo(m.protocol,m.host)};let g={};for(let[O,m]of Object.entries(n.operations??{})){if(hf(m,bk.IGNORE))continue;let P=F4E(m);if(g[P]||(g[P]={subscribe:[],publish:[],__parsedMessages:[]}),m.action==="receive")g[P].subscribe.push(...m.messages);else if(m.action==="send")g[P].publish.push(...m.messages);else throw new Error(`Operation ${O} has an invalid action: ${m.action}`)}for(let[O,m]of Object.entries(g)){let P=[];P.push(...sw_({messages:m.subscribe,channelPath:O,origin:"server",messageSchemas:u[O]??{},duplicatedMessageIds:d,context:e})),P.push(...sw_({messages:m.publish,channelPath:O,origin:"client",messageSchemas:u[O]??{},duplicatedMessageIds:d,context:e})),g[O]!=null&&(g[O].__parsedMessages=P)}for(let[O,m]of Object.entries(n.channels??{})){if(hf(m,bk.IGNORE))continue;let P=[],E=[],q=[];if(m.parameters!=null)for(let[M,D]of Object.entries(m.parameters)){let{type:C,parameterKey:x}=L4E(D.location),$=hf(D,bk.FERN_PARAMETER_OPTIONAL),I=iz(T_(O))+iz(T_(M)),L={...D,type:"string",title:I,example:D.examples?.[0],default:D.default,enum:D.enum,required:void 0},V=t0(L,!1,e,[x],r,e.namespace);$&&(V=zl.optional({value:V,description:void 0,availability:void 0,generatedName:"",title:I,namespace:void 0,groupName:void 0,nameOverride:void 0,inline:void 0}));let X={name:x,description:D.description,parameterNameOverride:void 0,schema:V,variableReference:void 0,availability:vJ(D),source:r};C==="header"?P.push({...X,env:void 0}):C==="path"?E.push(X):C==="payload"&&q.push(X)}if(P.length>0||q.length>0||g[O]!=null&&(g[O].publish!=null||g[O].subscribe!=null)){let M=mYo(m),D=g[O]?.__parsedMessages??[],C=[];if(M.length>0)C=c.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:M,handshake:{headers:P,queryParameters:q},source:r,namespace:e.namespace});else{let x=[],{examplePublishMessage:$,exampleSubscribeMessage:I}=V4E({messages:D,messageSchemas:u[O]??{}});$!=null&&x.push($),I!=null&&x.push(I);let L=c.buildWebsocketSessionExample({handshake:{headers:P,queryParameters:q},messages:x});L!=null&&C.push(L)}s[O]={audiences:hf(m,id.AUDIENCES)??[],handshake:{headers:P.map(x=>({...x,schema:qM(x.schema),env:x.env})),queryParameters:q.map(x=>({...x,schema:qM(x.schema)})),pathParameters:E.map(x=>({...x,parameterNameOverride:void 0,schema:qM(x.schema)}))},groupName:e.resolveGroupName([hf(m,bk.FERN_SDK_GROUP_NAME)??O]),messages:D,summary:hf(m,bk.FERN_DISPLAY_NAME),servers:m.servers?.map(x=>U4E(b,x))??Object.values(b),path:m.address??jYo(O),description:m.description,examples:C,source:r}}}return{groupedSchemas:B5n(e.namespace,a),channels:s,servers:Object.values(b),basePath:hf(n,bk.BASE_PATH)}}function F4E(e){if(!e.channel.$ref.startsWith(ow_))throw new Error(`Failed to resolve channel path from operation ${e.channel.$ref}`);return e.channel.$ref.substring(ow_.length)}function L4E(e){try{let[t,r]=e.split("#/");if(t==null||r==null)throw new Error(`Invalid location format: ${e}; unable to parse message type and parameter key`);if(!t.startsWith(y0c))throw new Error(`Invalid location format: ${e}; expected ${y0c} prefix`);let i=t.substring(y0c.length);if(i!=="header"&&i!=="path"&&i!=="payload")throw new Error(`Invalid message type: ${i}. Must be one of: header, path, payload`);return{type:i,parameterKey:r}}catch{throw new Error(`Invalid location format: ${e}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`)}}function U4E(e,t){if(!t.$ref.startsWith(uw_))throw new Error(`Failed to resolve server name from server ref ${t.$ref}`);let r=t.$ref.substring(uw_.length),i=e[r];if(i==null)throw new Error(`Failed to find server with name ${r}`);return i}function sw_({messages:e,channelPath:t,origin:r,messageSchemas:i,duplicatedMessageIds:n,context:a}){let u=[];return e.forEach((l,d)=>{let o=a.resolveMessageReference(l).name;n.includes(o)&&(o=`${t}_${o}`);let c=i[o];c!=null&&u.push({origin:r,name:o??`${r}Message${d+1}`,body:qM(c)})}),u}function V4E({messages:e,messageSchemas:t}){let r=e.find(u=>u.origin==="client")?.name,i=e.find(u=>u.origin==="server")?.name,n=r!=null?t[r]:void 0,a=i!=null?t[i]:void 0;return{examplePublishMessage:n!=null&&r!=null?{type:r,payload:n}:void 0,exampleSubscribeMessage:a!=null&&i!=null?{type:i,payload:a}:void 0}}function lw_({document:e,taskContext:t,options:r,source:i,asyncApiOptions:n,namespace:a}){let u=[];if(a!=null&&u.push(a),parseFloat(e.asyncapi)<3){let l=e;l.tags?.[0]!=null?u.push(l.tags[0].name):n.naming!=="v2"&&u.push("websocket");let d=new bYo({document:l,taskContext:t,options:r,namespace:a});return aw_({context:d,breadcrumbs:u,source:i,asyncApiOptions:n,document:l})}else{let l=e,d=new wYo({document:l,taskContext:t,options:r,namespace:a});return cw_({context:d,breadcrumbs:u,source:i,asyncApiOptions:n,document:l})}}function fw_(e){let t=W4E(e),r={};return v0c({obj:t,occurrences:r,breadcrumbs:[]}),r}function v0c({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let i of e)v0c({obj:i,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let i=e.$ref;t[i]==null?t[i]=1:t[i]+=1;return}for(let i in e)v0c({obj:e[i],occurrences:t,breadcrumbs:[...r,i]})}}}function W4E(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?exa(r.get):void 0,put:r?.put!=null?exa(r.put):void 0,post:r?.post!=null?exa(r.post):void 0,patch:r?.patch!=null?exa(r.patch):void 0,delete:r?.delete!=null?exa(r.delete):void 0}]))}}function exa(e){return{...e,requestBody:e.requestBody!=null?sp(e.requestBody)?e.requestBody:H4E(e.requestBody):void 0}}function H4E(e){let t,r;for(let i in e.content){let n=mM.parse(i);n!=null&&(n.isJSON()?t=e.content[i]:n.isMultipart()&&(r=e.content[i]))}return r!=null&&t!=null?{...e,content:{[mM.MULTIPART_FORM_DATA]:r}}:e}var SYo=class{endpoints;parser=new IHi;constructor({context:t,options:r}){this.endpoints=r.filter?.endpoints?new Set(this.validateAndFilterEndpoints({context:t,endpoints:r.filter.endpoints})):void 0}skipEndpoint({method:t,path:r}){return this.endpoints!=null&&!this.endpoints.has(`${t} ${r}`)}hasEndpoints(){return this.endpoints!=null}validateAndFilterEndpoints({context:t,endpoints:r}){let i=[];for(let n of r){let a=this.parser.tryParse(n);if(a==null){t.logger.debug(`Ignoring configured filter endpoint "${n}"; expected format "POST /users/get"`);continue}i.push(`${a.method} ${a.path}`)}return i}};var dw_="#/components/parameters/",pw_="#/components/responses/",_w_="#/components/examples/",hw_="#/components/requestBodies/",z5n=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;filter;namespace;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=i,this.refOccurrences=fw_(t),this.options=n,this.source=a,this.filter=new SYo({context:r,options:n}),this.DUMMY=this.getDummy(),this.namespace=u}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};r.push(i)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return{"x-fern-type":"unknown"};if(Array.isArray(i)){let a=parseInt(n,10);if(isNaN(a)||a<0||a>=i.length)return{"x-fern-type":"unknown"};i=i[a]}else i=i[n]}return i==null?(this.logger.warn(`Encountered undefined reference: ${t.$ref}`),{"x-fern-type":"unknown"}):(sp(i)&&(i=this.resolveSchemaReference(i)),i)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(dw_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(dw_.length),i=this.document.components.parameters[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return sp(i)?this.resolveParameterReference(i):i}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(hw_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(hw_.length),i=this.document.components.requestBodies[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return sp(i)?this.resolveRequestBodyReference(i):i}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(pw_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(pw_.length),i=this.document.components.responses[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return sp(i)?this.resolveResponseReference(i):i}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(_w_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(_w_.length),i=this.document.components.examples[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return sp(i)?this.resolveExampleReference(i):i}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}};var x5n=class extends z5n{constructor({document:t,taskContext:r,options:i,source:n,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:i,source:n,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,i){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,i){}getDiscriminatedUnionMetadata(t){}};var DYo=class extends z5n{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discriminatedUnionReferences={};discriminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u})}getDummy(){return new x5n({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,i){let n=this.discriminatedUnionReferences[t.$ref];n!=null?(n.discriminants.add(r),n.numReferences+=i):this.discriminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:i}}getReferencesFromDiscriminatedUnion(t){return this.discriminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,i){let n=this.discriminatedUnionMetadata[t.$ref];n!=null?n.discriminants.set(r,i):this.discriminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,i]])}}getDiscriminatedUnionMetadata(t){return this.discriminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function yw_(e){return hf(e,id.ASYNC_CONFIG)}var vw_="$request.";function bw_(e){let t=hf(e,id.STREAMING);if(t!=null)return typeof t=="boolean"?t?{type:"stream",format:"json"}:void 0:t["stream-condition"]==null&&t.format!=null?{type:"stream",format:t.format}:{type:"streamCondition",format:t.format??"json",streamDescription:t["stream-description"],streamConditionProperty:$4E(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function $4E(e){return e.startsWith(vw_)?e.slice(vw_.length):e}function gw_(e){let t=e;if(t.cursor!=null)return bFe.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});if("offset"in e){let r=e;return bFe.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}if("type"in e&&e.type==="custom"){let r=e;return bFe.custom({results:r.results})}throw new Error("Invalid pagination extension")}function Ow_(e,t){let r=hf(t,id.PAGINATION);if(r!=null){if(typeof r=="boolean"){let i=hf(e,id.PAGINATION);if(typeof i=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return i==null?void 0:gw_(i)}return gw_(r)}}var G4E=hu.object({lang:hu.string(),label:hu.optional(hu.string()),source:hu.string()}),b0c=hu.array(G4E);var mw_={README_EXT:"x-readme"};function Q4E(e){if(!Array.isArray(e))return!1;for(let t of e)if(!Jj(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function Pw_(e){let t=hf(e,mw_.README_EXT);if(!Jj(t))return[];let r=t["code-samples"];if(!Q4E(r))return[];let i=[];for(let n of r)i.push({name:n.name,language:n.language,code:n.code,install:n.install,docs:void 0});return i}function jw_(e,t,r){let n=(hf(t,id.EXAMPLES)??[]).filter(s=>{let o=JN.serialization.ExampleEndpointCallSchema.parse(s);return o.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),o.ok}),a=Yza(t,cH.REDOCLY_CODE_SAMPLES_KEBAB,b0c,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],l=[...Yza(t,cH.REDOCLY_CODE_SAMPLES_CAMEL,b0c,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...a];l.length>0&&n.push({"code-samples":l.map(s=>({name:s.label??s.lang,language:s.lang,code:s.source,install:void 0,docs:void 0}))});let d=Pw_(t);return d.length>0&&n.push({"code-samples":d}),n.map(cHt.unknown)}function ww_(e){let t=hf(e,id.AVAILABILITY);if(t==="ga"||t==="generally-available")return eH.GenerallyAvailable;if(t==="beta"||t==="pre-release")return eH.Beta;if(t==="deprecated")return eH.Deprecated;if(e.deprecated)return eH.Deprecated}function EYo(e){return{url:J4E({url:e.url,variables:e.variables??{}}),description:e.description,name:K4E(e),audiences:hf(e,id.AUDIENCES)}}function J4E({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([i,n])=>[i,n.default]));for(let[i,n]of Object.entries(r))e=e.replace(`{${i}}`,n);return e}function K4E(e){let t=hf(e,[id.SERVER_NAME_V1,id.SERVER_NAME_V2]);if(t!=null)return t;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox"}function Sw_(e){return hf(e,id.PARAMETER_NAME)}function Dw_(e){return hf(e,id.SDK_VARIABLE)}function MYo({path:e,httpMethod:t,parameters:r,context:i,requestBreadcrumbs:n,source:a}){let u={pathParameters:[],queryParameters:[],headers:[]};for(let l of r){let d=hf(l,id.IGNORE);if(d!=null&&d){i.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let s=sp(l)?i.resolveParameterReference(l):l,o=s.required??!1,c=vJ(s),b=[...n,s.name],g=s8(b,i.options.preserveSchemaIds),O=s.schema!=null?t0(s.schema,!o,i,b,a,i.namespace,!1,new Set,Pir({schema:s,logger:i.logger})):o?zl.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:up.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:Pir({schema:s,logger:i.logger})}),description:void 0,availability:c,namespace:void 0,groupName:void 0}):zl.optional({nameOverride:void 0,generatedName:g,title:void 0,value:zl.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:up.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:Pir({schema:s,logger:i.logger})}),description:void 0,availability:void 0,namespace:void 0,groupName:void 0}),description:void 0,availability:c,namespace:void 0,groupName:void 0,inline:void 0});if(s.in==="header"&&s.schema!=null&&!sp(s.schema)&&s.schema.default!=null){let P=s.schema.default;typeof P=="string"&&P.length>0&&(O=zl.literal({nameOverride:void 0,generatedName:g,title:void 0,value:vz.string(P),description:void 0,availability:c,namespace:void 0,groupName:void 0}))}let m={name:s.name,schema:O,description:s.description,parameterNameOverride:Sw_(s),availability:c,source:a};s.in==="query"?u.queryParameters.push(m):s.in==="path"?u.pathParameters.push({...m,variableReference:Dw_(s)}):s.in==="header"?!Y4E.has(s.name.toLowerCase())&&!i.authHeaders.has(s.name)?u.headers.push({...m,env:void 0}):i.logger.debug(`Ignoring ${s.name} header, in ${t.toUpperCase()} ${e}`):i.logger.warn(`Skipping ${s.in} parameter, ${s.name}, in ${t.toUpperCase()} ${e}`)}return u}var Y4E=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function Ew_(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r,schema:n??{},examples:txa(i,t)}}}function R5n(e,t){for(let r of Object.keys(e))if(r.includes("json")||r==="*/*"){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r.includes("*")?void 0:r,schema:n??{},examples:txa(i,t)}}}function Mw_(e,t){for(let r of Object.keys(e)){let i=e[r];if(i==null)continue;return{schema:i.schema??{},examples:txa(i,t)}}}function txa(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let i=hf(e,cH.EXAMPLES);return i!=null&&Object.keys(i).length>0&&r.push(...Object.entries(i).map(([n,a])=>({name:a.summary??n,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([n,a])=>{let u=sp(a)?t.resolveExampleReference(a):a;return{name:u.summary??n,value:u.value,description:u.description}})),r}function X4E(e,t){for(let[r,i]of Object.entries(e.content))if(mM.parse(r)?.isURLEncoded())return{schema:i.schema,contentType:r,examples:txa(i,t)}}function Z4E(e){for(let[t,r]of Object.entries(e.content))if(mM.parse(t)?.isMultipart())return{schema:r.schema,encoding:r.encoding}}function k4E(e){for(let t in e.content)if(mM.parse(t)?.isOctetStream())return!0;return!1}function e2E(e,t){let r=sp(e)?g0c(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([i,n])=>!sp(n)&&n.type==="string"&&n.format==="binary")!=null}function N5n({requestBody:e,document:t,context:r,requestBreadcrumbs:i,source:n,namespace:a}){let u=sp(e)?r.resolveRequestBodyReference(e):e,l=Z4E(u),d=l?.schema,s=l?.encoding,o=X4E(u,r),c=R5n(u.content,r);if(k4E(u))return EMe.octetStream({description:u.description,source:n});if(d!=null&&c==null||d!=null&&e2E(d,t)){let b=sp(d)?g0c(d,t):{id:void 0,schema:d},g=t0(b.schema,!1,r,i,n,a),O=[];if(g.type==="object")for(let m of g.properties){let{isFile:P,isOptional:E,isArray:q,description:M}=AYo({schema:m.schema});if(P){let D=Aw_(m.key,s);O.push({key:m.key,schema:$di.file({isOptional:E,isArray:q,description:M}),description:M,contentType:D,exploded:!1,encoding:D==null?r.options.defaultFormParameterEncoding:void 0})}else{let D=Aw_(m.key,s);O.push({key:m.key,schema:$di.json(m.schema),description:void 0,contentType:D,exploded:s?.[m.key]?.explode,encoding:D==null?r.options.defaultFormParameterEncoding:void 0})}}return EMe.multipart({name:sp(d)&&r.getNumberOfOccurrencesForRef(d)===1?b.id:void 0,description:b.schema.description,properties:O,source:n})}if(c!=null){let b=t0(c.schema,!1,r,i,n,a,!0);return EMe.json({description:void 0,schema:b,contentType:c.contentType,fullExamples:c.examples,additionalProperties:!sp(c.schema)&&E5n(c.schema.additionalProperties,r.options),source:n})}if(o!=null&&o.schema!=null){let b=t0(o.schema,!1,r,i,n,a);return EMe.json({schema:b,description:u.description,contentType:o.contentType,source:n,fullExamples:o.examples,additionalProperties:!1})}}function g0c(e,t){if(!e.$ref.startsWith(YJi))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=uAi(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let i=t.components?.schemas?.[r];if(i==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return sp(i)?g0c(i,t):{id:r,schema:i}}function AYo({schema:e,isOptional:t,isArray:r,description:i}){return r2E(e)?AYo({schema:e.value,isOptional:!0,isArray:r,description:e.description}):i2E(e)?AYo({schema:e.value,isOptional:t,isArray:r,description:e.description}):n2E(e)?AYo({schema:e.value,isOptional:t,isArray:!0,description:e.description}):t2E(e)?{isFile:!0,isOptional:t??!1,isArray:r??!1,description:i??e.description}:{isFile:!1,isOptional:t??!1,isArray:r??!1,description:void 0}}function t2E(e){return e.type==="primitive"&&e.schema.type==="string"&&e.schema.format==="binary"}function r2E(e){return e.type==="optional"}function i2E(e){return e.type==="nullable"}function n2E(e){return e.type==="array"}function Aw_(e,t){return t?.[e]?.contentType}var O0c={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",498:"InvalidTokenError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},qw_=new Set(Object.values(O0c));var a2E=["200","201","202","204"];function Cw_({operationContext:e,responses:t,context:r,responseBreadcrumbs:i,responseStatusCode:n,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let l=o2E({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,s;for(let o of n!=null?[n]:a2E){let c=t[o];c!=null&&(d=!0,s==null&&(s=Tw_({operationContext:e,response:c,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace,statusCode:typeof o=="string"?parseInt(o):o})))}if(s==null&&!d&&t.default!=null&&(s=Tw_({operationContext:e,response:t.default,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace})),s!=null)switch(s.type){case"json":return{value:s,errors:l};case"streamingJson":case"streamingSse":return{value:s,errors:l};case"bytes":case"file":case"text":case"streamingText":return{value:s,errors:l};default:mo(s)}return{value:void 0,errors:l}}function Tw_({operationContext:e,streamFormat:t,response:r,context:i,responseBreadcrumbs:n,source:a,namespace:u,statusCode:l}){let d=sp(r)?i.resolveResponseReference(r):r;if(d.content!=null&&Object.entries(d.content).find(([b,g])=>{if(g.schema==null)return!1;let O=sp(g.schema)?i.resolveSchemaReference(g.schema):g.schema;return O.type==="string"&&O.format==="binary"}))return i.options.useBytesForBinaryResponse&&t==null?vC.bytes({description:d.description,source:a,statusCode:l}):vC.file({description:d.description,source:a,statusCode:l});let s=Ew_(d.content??{},i);if(s!=null&&t!=null)switch(t){case"json":return vC.streamingJson({statusCode:l,description:d.description,responseProperty:hf(e.operation,id.RESPONSE_PROPERTY),fullExamples:s.examples,schema:t0(s.schema,!1,i,n,a,u),source:a});case"sse":return vC.streamingSse({description:d.description,responseProperty:void 0,fullExamples:s.examples,schema:t0(s.schema,!1,i,n,a,u),source:a,statusCode:l})}let o=R5n(d.content??{},i);if(o!=null){if(t!=null)switch(t){case"json":return vC.streamingJson({description:d.description,responseProperty:void 0,fullExamples:o.examples,schema:t0(o.schema,!1,i,n,a,u),source:a,statusCode:l});case"sse":return vC.streamingSse({description:d.description,responseProperty:void 0,fullExamples:o.examples,schema:t0(o.schema,!1,i,n,a,u),source:a,statusCode:l})}return vC.json({description:d.description,schema:t0(o.schema,!1,i,n,a,u),responseProperty:hf(e.operation,id.RESPONSE_PROPERTY),fullExamples:o.examples,source:a,statusCode:l})}for(let[c,b]of Object.entries(d.content??{})){let g=mM.parse(c);if(g!=null){if(g.isOctetStream()||g.isPDF()||g.isAudio()||g.isImage()||g.isVideo())return vC.file({description:d.description,source:a,statusCode:l});if(g.isPlainText()){let O=b.schema;if(O==null)return vC.text({description:d.description,source:a,statusCode:l});let m=sp(O)?i.resolveSchemaReference(O):O;return m.type==="string"&&m.format==="byte"?vC.file({description:d.description,source:a,statusCode:l}):vC.text({description:d.description,source:a,statusCode:l})}}}}function o2E({responses:e,context:t,source:r,namespace:i}){let n={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let l=parseInt(a);if(l<400||l>600)continue;let d=sp(u)?t.resolveResponseReference(u):u,s=Mw_(d.content??{},t),o=O0c[l];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}n[l]={statusCode:l,nameOverride:void 0,generatedName:o,description:d.description,schema:t0(s?.schema??{},!1,t,[o,"Body"],r,i),fullExamples:s?.examples,source:r}}return n}function spi({operationContext:e,context:t,responseStatusCode:r,suffix:i,streamFormat:n,source:a}){let{document:u,operation:l,path:d,method:s,baseBreadcrumbs:o,sdkMethodName:c}=e,b=hf(l,id.IDEMPOTENT),g=hf(l,[id.REQUEST_NAME_V1,id.REQUEST_NAME_V2]),O=[...o,"Request"],m=MYo({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:O,path:d,httpMethod:s,source:a}),P=/{([^}]+)}/g,q=[...d.matchAll(P)].map(L=>L[1]).filter(L=>!m.pathParameters.some(V=>V.name===L));if(q.length>0)for(let L of q)m.pathParameters.push({name:L??"",variableReference:void 0,parameterNameOverride:void 0,availability:void 0,source:a,schema:zl.primitive({schema:up.string({default:void 0,example:void 0,format:void 0,maxLength:void 0,minLength:void 0,pattern:void 0}),description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0,availability:void 0,title:void 0}),description:void 0});let M=l.requestBody!=null?N5n({requestBody:l.requestBody,document:u,context:new x5n({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:O,source:a,namespace:t.namespace}):void 0;s2E({context:t,convertedParameters:m})&&M!=null&&M.type==="json"&&M.schema.type!=="object"&&l.requestBody!=null?M=N5n({requestBody:l.requestBody,document:u,context:t,requestBreadcrumbs:[...O,"Body"],source:a,namespace:t.namespace}):l.requestBody!=null&&(M=N5n({requestBody:l.requestBody,document:u,context:t,requestBreadcrumbs:[...O],source:a,namespace:t.namespace}));let D=[...o,"Response"],C=Cw_({operationContext:e,streamFormat:n,responses:l.responses,context:t,responseBreadcrumbs:D,responseStatusCode:r,source:a});e.method==="GET"&&(M=void 0);let x=ww_(l),$=jw_(e,l,t),I=hf(l,id.SERVER_NAME_V2);return{summary:l.summary,internal:hf(l,cH.INTERNAL),idempotent:b,audiences:hf(l,id.AUDIENCES)??[],operationId:l.operationId!=null&&i!=null?l.operationId+"_"+i:l.operationId,tags:t.resolveTagsToTagIds(l.tags),namespace:t.namespace,sdkName:c,pathParameters:m.pathParameters,queryParameters:m.queryParameters,headers:m.headers,requestNameOverride:g??void 0,generatedRequestName:s8(O,t.options.preserveSchemaIds),request:M,response:C.value,errors:C.errors,servers:I!=null?[{name:I,url:void 0,audiences:void 0}]:(l.servers??[]).map(L=>EYo(L)),description:l.description,authed:u2E(l,u),availability:x,method:s,path:d,examples:$,pagination:e.pagination,source:a}}function u2E(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function s2E({context:e,convertedParameters:t}){return e.options.inlinePathParameters&&t.pathParameters.length>0||t.queryParameters.length>0||t.headers.length>0}function Iw_({operationContext:e,context:t,asyncExtension:r,source:i}){let{operation:n,pathItemParameters:a,operationParameters:u}=e,l=r.discriminant.name,d=r.discriminant.value,s=r["response-status-code"],o=Bw_({context:t,headerToIgnore:l,parameters:a}),c=Bw_({context:t,headerToIgnore:l,parameters:u}),b=spi({operationContext:{...e,pathItemParameters:o,operationParameters:c,operation:{...n,responses:Object.fromEntries(Object.entries(n.responses).filter(([O])=>parseInt(O)!==s))}},context:t,streamFormat:void 0,source:i}),g=spi({operationContext:{...e,pathItemParameters:o,operationParameters:c,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:s,streamFormat:void 0,source:i});return g.headers.push({name:l,schema:zl.literal({nameOverride:void 0,generatedName:s8([l],t.options.preserveSchemaIds),title:void 0,description:void 0,availability:void 0,value:vz.string(d),namespace:void 0,groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:i}),{sync:b,async:g}}function Bw_({context:e,headerToIgnore:t,parameters:r}){return r.filter(i=>{let n=sp(i)?e.resolveParameterReference(i):i;return!(n.in==="header"&&n.name===t)})}var m0c="stream";function Nw_({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:spi({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let i=zw_({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(i?.schemaReference!=null){let s=uAi(i.schemaReference);s!=null&&t.excludeSchema(s)}let n=xw_({operation:e.operation,response:r.responseStream}),a=spi({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+m0c}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:i?.requestBody,responses:n},baseBreadcrumbs:[...e.baseBreadcrumbs,m0c]},context:t,streamFormat:r.format,suffix:m0c,source:t.source});a.examples=a.examples.filter(s=>Rw_(s,t)!==!1);let u=zw_({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),l=xw_({operation:e.operation,response:r.response}),d=spi({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u?.requestBody,responses:l}},context:t,source:t.source});return d.examples=d.examples.filter(s=>Rw_(s,t)!==!0),{streaming:a,nonStreaming:d}}default:mo(r)}}function zw_({context:e,operation:t,streamingExtension:r,isStreaming:i}){if(t.requestBody==null)return;let n=sp(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=R5n(n.content,e);if(a==null)return;let u=sp(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let l=u.properties?.[r.streamConditionProperty];l!=null&&sp(l)&&(l=void 0);let d={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":i,...l??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[mM.APPLICATION_JSON]:{schema:d}}},schemaReference:sp(a.schema)?a.schema:void 0}}function xw_({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[mM.APPLICATION_JSON]:{schema:t}}}}}function Rw_(e,t){return e._visit({unknown:r=>{let i=JN.serialization.ExampleEndpointCallSchema.parse(r);if(i.ok&&i.value.response!=null)return i.value.response.stream!=null},full:()=>{},_other:()=>{}})}function Fw_({context:e,operationContext:t,source:r}){let{document:i,operation:n,path:a,method:u,baseBreadcrumbs:l,sdkMethodName:d}=t,s=[...l,"Payload"],o=MYo({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:s,path:a,httpMethod:u,source:r});if(n.requestBody==null){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Missing a request body`);return}if(u!=="POST"&&u!=="GET"){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Not POST or GET`);return}let c=N5n({requestBody:n.requestBody,document:i,context:e,requestBreadcrumbs:[...l,"Payload"],source:r,namespace:e.namespace});if(c==null||c.type!=="json"){e.logger.error(`Skipping webhook ${a} because non-json request body`);return}if(n.operationId==null){e.logger.error(`Skipping webhook ${a} because no operation id present`);return}return{summary:n.summary,audiences:hf(n,id.AUDIENCES)??[],sdkName:d,namespace:e.namespace,method:u,operationId:n.operationId,tags:e.resolveTagsToTagIds(n.tags),headers:o.headers,generatedPayloadName:s8(s,e.options.preserveSchemaIds),payload:c.schema,description:n.description,examples:c2E(c.fullExamples),source:r}}function c2E(e){if(e==null)return[];let t=[];for(let r of e){let i=sAi(r.value);i!=null&&t.push({description:r.description,name:r.name,payload:i})}return t}function P0c({context:e,pathItemContext:t,operation:r,convertToWebhook:i}){let n=hf(r,id.IGNORE);if(n!=null&&n){e.logger.debug(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=l2E(r,e),u=Ow_(e.document,r),l={...t,sdkMethodName:a,baseBreadcrumbs:f2E({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path,shouldUseIdiomaticRequestNames:e.options.shouldUseIdiomaticRequestNames}),operation:r,operationParameters:r.parameters??[],pagination:u};if(i){let c=Fw_({context:e,operationContext:l,source:e.source});return c!=null?{type:"webhook",value:c}:void 0}let d=bw_(r);if(d!=null){let c=Nw_({context:e,operationContext:l,streamingExtension:d});return c!=null?{type:"streaming",streaming:c.streaming,nonStreaming:c.nonStreaming}:void 0}let s=yw_(r);if(s!=null){let c=Iw_({context:e,operationContext:l,asyncExtension:s,source:e.source});return{type:"async",async:c.async,sync:c.sync}}return{type:"http",value:spi({context:e,operationContext:l,streamFormat:void 0,source:e.source})}}function l2E(e,t){let r=hf(e,id.SDK_METHOD_NAME),i=hf(e,id.SDK_GROUP_NAME)??[];if(r!=null){let n=typeof i=="string"?[i]:i;return n=t.resolveGroupName(n),{groupName:n,methodName:r}}}function f2E({sdkMethodName:e,operation:t,httpMethod:r,path:i,shouldUseIdiomaticRequestNames:n}){let a=[];if(e!=null){if(n&&a.push(e.methodName),e.groupName.length>0){let u=e.groupName[e.groupName.length-1];u!=null&&a.push(typeof u=="string"?u:u.name)}n||a.push(e.methodName)}else t.operationId!=null?a.push(t.operationId):a.push(T_(`${r}_${i.split("/").join("_")}`));return a}function Lw_(e,t,r,i){let n=[],a=Vw_(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let l of a){if(i.filter.skipEndpoint({method:l.method,path:e})){i.logger.debug(`Skipping endpoint "${l.method} ${e}"`);continue}let d=d2E({operation:l.operation}),s=P0c({context:i,pathItemContext:{...u,method:l.method},operation:l.operation,convertToWebhook:d});s!=null&&n.push(s)}return n}function Uw_(e,t,r,i){let n=[],a=Vw_(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let l of a){if(i.filter.skipEndpoint({method:l.method,path:e})){i.logger.debug(`Skipping endpoint "${l.method} ${e}"`);continue}let d=P0c({context:i,pathItemContext:{...u,method:l.method},operation:l.operation,convertToWebhook:!0});d!=null&&n.push(d)}return n}function Vw_(e){let t=[];return e.get!=null&&t.push({method:rH.Get,operation:e.get}),e.post!=null&&t.push({method:rH.Post,operation:e.post}),e.put!=null&&t.push({method:rH.Put,operation:e.put}),e.delete!=null&&t.push({method:rH.Delete,operation:e.delete}),e.patch!=null&&t.push({method:rH.Patch,operation:e.patch}),e.head!=null&&t.push({method:rH.Head,operation:e.head}),t}function d2E({operation:e}){return hf(e,[id.WEBHOOK])??!1}function Ww_(e){let t=hf(e,id.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=hf(e,id.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function Hw_(e){return hf(e,id.FERN_BASIC_AUTH)}function j0c(e,t){if(sp(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return p2E(e,t)}function p2E(e,t){if(e.type==="apiKey"&&e.in==="header"){let r=hf(e,cH.BEARER_FORMAT),i=hf(e,id.FERN_HEADER_AUTH);return nL.header({headerName:e.name,prefix:r!=null?"Bearer":i?.prefix,headerVariableName:i?.name??hf(e,id.HEADER_VARIABLE_NAME),headerEnvVar:i?.env})}else if(e.type==="http"&&e.scheme==="bearer"){let r=hf(e,id.FERN_BEARER_TOKEN);return nL.bearer({tokenVariableName:r?.name??hf(e,id.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:r?.env})}else if(e.type==="http"&&e.scheme==="basic"){let r=Hw_(e),i=Ww_(e);return nL.basic({usernameVariableName:r?.username?.name??i.usernameVariable,usernameEnvVar:r?.username?.env,passwordVariableName:r?.password?.name??i.passwordVariable,passwordEnvVar:r?.password?.env})}else{if(e.type==="openIdConnect")return nL.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return nL.oauth({scopesEnum:_2E(e,t)})}}function _2E(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let i=oAi({nameOverride:void 0,generatedName:"OauthScope",title:void 0,enumValues:Object.keys(r),fernEnum:Object.fromEntries(Object.entries(r).map(([a,u])=>[a,{description:u}])),_default:void 0,description:void 0,availability:void 0,enumVarNames:void 0,wrapAsNullable:!1,namespace:void 0,groupName:void 0,context:void 0,source:t,inline:void 0}),n=qM(i);if(n.type==="enum")return n}}function $w_(e){return hf(e,id.BASE_PATH)}var h2E=hu.record(hu.string(),hu.object({summary:hu.string().optional(),description:hu.string().optional()}));function Gw_({document:e,context:t}){return Yza(e,id.GROUPS,h2E,t.logger)}function Qw_({context:e,document:t}){return hf(t,id.FERN_VERSION)??void 0}function Jw_(e){let t=hf(e,id.FERN_GLOBAL_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?Xza({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function Kw_(e){let t=hf(e,id.FERN_IDEMPOTENCY_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?Xza({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function Yw_(e,t){let r=hf(e,id.SDK_VARIABLES);return r==null?{}:Object.fromEntries(Object.entries(r).map(([i,n])=>{if(n.type==="string")return[i,{nameOverride:void 0,generatedName:s8([i],t),title:n.title,schema:Xj.string({default:q5n(n),pattern:n.pattern,format:n.format,minLength:n.minLength,maxLength:n.maxLength}),description:n.description,availability:void 0,namespace:void 0,groupName:void 0}];throw new Error(`Variable ${i} has unsupported schema ${JSON.stringify(n)}`)}))}var y2E="webhooks";function Xw_(e){return hf(e,y2E)??{}}function Zw_(e){return hf(e,id.RESOLUTIONS)}function kw_({openapi:e}){let t=Zw_(e);if(t==null)return e;let r={};for(let i of t){let n=`#/components/schemas/${i.name}`;for(let a of i.resolutions)e=v2E({openapi:e,schemaReference:a,schemaName:i.name}),e=e1_({openapi:e,replaceReference:a,schemaReference:n,replacedReferences:r}),r={...r,...Object.fromEntries(i.resolutions.map(u=>[n,u]))}}return e}function v2E({openapi:e,schemaReference:t,schemaName:r}){let i=t.replace("#/","").split("/").map(a=>a.replaceAll("~1","/")),n=e;for(let a of i){let u=n[a];if(u==null)return e;n=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=n,e}function e1_({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:i}){let n=Object.keys(i).filter(d=>t.startsWith(d)).sort((d,s)=>s.length-d.length)[0];if(n!=null){let d=i[n];if(d!=null){let s=r.replace(n,d);return e1_({openapi:e,replaceReference:t,schemaReference:s,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replaceAll("~1","/")),u=e;for(let d of a.slice(0,-1)){let s=u[d];if(s==null)return e;u=s}let l=a[a.length-1];return l==null||(u[l]={$ref:r}),e}function r1_({openApi:e,taskContext:t,options:r,source:i,namespace:n}){e=kw_({openapi:e});let a=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([I,L])=>j0c(L,i)==null?[]:[I,j0c(L,i)])),u=new Set(...Object.entries(a).map(([I,L])=>L.type==="basic"||L.type==="bearer"?"Authorization":L.type==="header"?L.headerName:null)),l=Yw_(e,r.preserveSchemaIds),d=Jw_(e),s=Kw_(e),o=r.audiences??[],c=[],b=[],g=new DYo({document:e,taskContext:t,authHeaders:u,options:r,source:i,namespace:n});g.filter.hasEndpoints()&&t.logger.debug("Endpoint filter applied..."),Object.entries(e.paths??{}).forEach(([I,L])=>{if(L==null)return;t.logger.debug(`Converting path ${I}`);let V=Lw_(I,L,e,g);for(let X of V){let K=t1_({operation:X});if(!(o.length>0&&!o.some(Z=>K.includes(Z))))switch(X.type){case"async":c.push(X.sync),c.push(X.async);break;case"http":c.push(X.value);break;case"streaming":c.push(X.streaming),X.nonStreaming&&c.push(X.nonStreaming);break;case"webhook":b.push(X.value);break;default:mo(X)}}}),Object.entries(Xw_(e)).forEach(([I,L])=>{if(L==null)return;t.logger.debug(`Converting path ${I}`);let V=Uw_(I,L,e,g);for(let X of V){let K=t1_({operation:X});o.length>0&&!o.some(Z=>K.includes(Z))||b.push(X.value)}});let O=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([I,L])=>{let V=hf(L,id.SDK_NAMESPACE);if(!sp(L)){let X=hf(L,id.IGNORE);if(X!=null&&X)return[];if(qw_.has(I))return[I,t0({...L,"x-fern-type-name":`${I}Body`},!1,g,[I],i,V??n)]}return[I,t0(L,!1,g,[I],i,V??n)]}).filter(I=>I.length>0)),m=b2E(O,g,i),P=g2E(m,g),E={};for(let[I,L]of Object.entries(P)){let V=qM(L);g.isSchemaExcluded(I)||(E[I]=V,t.logger.debug(`Converted schema ${I}`))}let q=new cAi(P,g.nonRequestReferencedSchemas,g),M=b.map(I=>{let V=I.examples;if(!r.disableExamples&&V.length===0){let X=q.buildExample({schema:I.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});X!=null&&(V=[{name:void 0,description:void 0,payload:X}])}return{...I,payload:qM(I.payload),examples:V}}),D=new OYo(P,g),C=c.map(I=>{let L=I.examples,V=L;if(!r.disableExamples&&(L.length===0||L.every(kza))){let Z=D.buildEndpointExample(I);Z.length>0&&(V=[...Z,...L.filter(fe=>!kza(fe))])}let X=I.request,K=I.response;return{...I,request:X?.type==="json"?{...X,schema:qM(X.schema)}:X,response:K?.type==="json"?{...K,schema:qM(K.schema)}:K,queryParameters:I.queryParameters.map(Z=>({description:Z.description,name:Z.name,schema:qM(Z.schema),parameterNameOverride:Z.parameterNameOverride,availability:Z.availability,source:Z.source})),pathParameters:I.pathParameters.map(Z=>({description:Z.description,name:Z.name,schema:qM(Z.schema),parameterNameOverride:Z.parameterNameOverride,variableReference:Z.variableReference,availability:Z.availability,source:Z.source})),headers:I.headers.map(Z=>({description:Z.description,name:Z.name,schema:qM(Z.schema),parameterNameOverride:Z.parameterNameOverride,env:Z.env,availability:Z.availability,source:Z.source})),examples:V,errors:dd(I.errors,Z=>{let fe=Z.fullExamples?.map(me=>{let _e=sAi(me.value);if(_e!=null)return{name:me.name,description:me.description,example:_e}}).filter(V0);if(fe?.length===0){let me=q.buildExample({schema:Z.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});me!=null&&fe.push({name:void 0,description:void 0,example:me})}return{generatedName:Z.generatedName,nameOverride:Z.nameOverride,schema:qM(Z.schema),description:Z.description,source:Z.source,examples:fe}})}}),x=Gw_({document:e,context:g});return{apiVersion:Qw_({context:g,document:e}),basePath:$w_(e),title:e.info.title??"",description:e.info.description,groups:Object.fromEntries(Object.entries(x??{}).map(([I,L])=>[I,{summary:L.summary??void 0,description:L.description??void 0}])),servers:(e.servers??[]).map(I=>EYo(I)),websocketServers:[],tags:{tagsById:Object.fromEntries((e.tags??[]).map(I=>[I.name,{id:I.name,description:I.description}])),orderedTagIds:e.tags?.map(I=>I.name)},endpoints:C,webhooks:M,channels:{},groupedSchemas:B5n(n,E),securitySchemes:a,hasEndpointsMarkedInternal:C.some(I=>I.internal),nonRequestReferencedSchemas:g.getReferencedSchemas(),variables:l,globalHeaders:d,idempotencyHeaders:s}}function b2E(e,t,r){let i={};for(let[n,a]of Object.entries(e)){if(a.type!=="object"){i[n]=a;continue}let u={$ref:`#/components/schemas/${n}`},l=t.getReferencesFromDiscriminatedUnion(u);if(l==null){i[n]=a;continue}let d={...a,type:"object",properties:a.properties.filter(o=>!l.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!l.discriminants.has(o.propertyKey)),source:r};i[n]=d;let s=i1_({schema:a,schemas:e});for(let o of[...new Set(s)]){let c=i[o]??e[o];c==null||c.type!=="object"||(i[o]={...c,type:"object",properties:c.properties.filter(b=>!l.discriminants.has(b.key)),allOfPropertyConflicts:c.allOfPropertyConflicts.filter(b=>!l.discriminants.has(b.propertyKey))})}}return i}function g2E(e,t){let r={};for(let[i,n]of Object.entries(e)){if(n.type!=="object"){r[i]=n;continue}let a={$ref:`#/components/schemas/${i}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[i]=n;continue}let l=[];for(let s of n.properties)if(u.discriminants.has(s.key)){let o=u.discriminants.get(s.key);o!=null&&l.push({...s,schema:zl.literal({nameOverride:void 0,generatedName:s8([n.generatedName,o],t.options.preserveSchemaIds),title:void 0,value:vz.string(o),namespace:void 0,groupName:void 0,description:void 0,availability:n.availability})})}else l.push(s);let d={...n,type:"object",properties:l};r[i]=d}return r}function i1_({schema:e,schemas:t}){let r=[];for(let i of e.allOf){r.push(i.schema);let n=t[i.schema];n!=null&&n.type==="object"&&r.push(...i1_({schema:n,schemas:t}))}return r}function t1_({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":t=e.value.audiences;break;default:mo(e)}return t}function XJi({context:e,documents:t,options:r}){let i={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],websocketServers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channels:{},groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}};for(let n of t){let a=n.source!=null?n.source:Gae.openapi({file:"<memory>"});switch(n.type){case"openapi":{let u=r1_({taskContext:e,openApi:n.value,options:s0c({options:n.settings,overrides:r}),source:a,namespace:n.namespace});i=m2E(i,u);break}case"asyncapi":{let u=lw_({document:n.value,taskContext:e,options:s0c({options:n.settings,overrides:r}),source:a,asyncApiOptions:O2E({options:n.settings}),namespace:n.namespace});u.servers!=null&&(i.websocketServers=[...i.websocketServers,...u.servers.map(l=>({...l,audiences:void 0,description:void 0}))]),u.channels!=null&&(i.channels={...i.channels,...u.channels}),u.groupedSchemas!=null&&(i.groupedSchemas=n1_(i.groupedSchemas,u.groupedSchemas)),u.basePath!=null&&(i.basePath=u.basePath);break}default:mo(n)}}return i}function O2E({options:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??Tj_.naming}}function m2E(e,t){return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],websocketServers:[...e.websocketServers,...t.websocketServers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channels:{...e.channels,...t.channels},groupedSchemas:n1_(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 n1_(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,i]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...i}:e.namespacedSchemas[r]=i;return e}var qYo={config:new a1_.Config({apis:{},styleguide:{plugins:[u0c],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0};function rxa(e){return e.swagger!=null}function w0c(e){return e.openapi!=null}function lAi(e,t={}){return{...Object.fromEntries(t3(e.namedDefinitionFiles).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...t3(e.importedDefinitions).reduce((r,[i,n])=>({...r,...Hwa(lAi(n.definition,{defaultURL:n.url}),(a,u)=>WN(i,yy.of(u)))}),{})}}function ixa(e,t={}){return{...Object.fromEntries(t3(e.packageMarkers).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...t3(e.importedDefinitions).reduce((r,[i,n])=>({...r,...Hwa(ixa(n.definition,{defaultURL:n.url}),(a,u)=>WN(i,yy.of(u)))}),{})}}function cpi(e){return{...ixa(e),...lAi(e)}}function eoe(e,t){return cpi(e.definition)[t]?.contents}function I3(e,t){for(let[r,i]of t3(cpi(e.definition)))t(r,i.contents,{isPackageMarker:uWi(r)===zS,defaultUrl:i.defaultUrl})}function ZJi(e,t){for(let[r,i]of t3(ixa(e.definition)))t(r,i.contents)}var _M_=ci(pM_(),1);async function Kxa(e){return(await(0,_M_.convertObj)(e,{})).openapi}var yM_=require("fs/promises");var hM_=require("fs/promises");async function i9n({absoluteFilePathToOverrides:e,data:t,context:r,allowNullKeys:i}){let n=null;try{let a=(await(0,hM_.readFile)(e,"utf8")).toString();try{n=JSON.parse(a)}catch{n=qd.load(a,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return w3s({data:t,overrides:n,allowNullKeys:i})}async function EOc({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,yM_.readFile)(t)).toString(),n=await qd.load(i);return r!=null?await i9n({absoluteFilePathToOverrides:r,context:e,data:n}):n}var Xxa=ci(lYo(),1);var vM_=ci(lYo(),1),MOc=ci(require("path"),1);var Yxa=class extends vM_.BaseResolver{absolutePathToOpenAPIOverrides;constructor(t){super(),this.absolutePathToOpenAPIOverrides=t}resolveExternalRef(t,r){let i=super.resolveExternalRef(t,r);return Bli($l.of(i))?i:this.absolutePathToOpenAPIOverrides!=null?MOc.default.resolve(MOc.default.dirname(this.absolutePathToOpenAPIOverrides),r):i}};async function AOc({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,parsed:r}){return(r!=null?await(0,Xxa.bundle)({...qYo,doc:{source:new Xxa.Source(e,"<openapi>"),parsed:r},externalRefResolver:new Yxa(t)}):await(0,Xxa.bundle)({...qYo,ref:e,externalRefResolver:new Yxa(t)})).bundle.parsed}var BVE=["examples","example",id.EXAMPLES,cH.REDOCLY_CODE_SAMPLES_CAMEL,cH.REDOCLY_CODE_SAMPLES_KEBAB];async function Zxa({context:e,absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r}){let i=await AOc({absolutePathToOpenAPI:t}),n;if(r!=null?n=r:typeof i=="object"&&i[id.OPENAPI_OVERIDES_FILEPATH]!=null&&(n=Vu(Xd(t),Qa.of(i[id.OPENAPI_OVERIDES_FILEPATH]))),n!=null){let a=await i9n({absoluteFilePathToOverrides:n,context:e,data:i,allowNullKeys:BVE});return await AOc({absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r,parsed:a})}return i}var wHt=class{absoluteFilePath;constructor(t){this.absoluteFilePath=t}async loadDocuments({context:t,specs:r}){let i=[];for(let n of r){let a=(await(0,bM_.readFile)(n.absoluteFilepath)).toString(),u=xq(this.absoluteFilePath,n.source.file);n.source.relativePathToDependency!=null&&(u=Vu(n.source.relativePathToDependency,u));let l=n.source.type==="protobuf"?Gae.protobuf({file:u}):Gae.openapi({file:u});if(a.includes("openapi")||a.includes("swagger")){let d=await Zxa({absolutePathToOpenAPI:n.absoluteFilepath,context:t,absolutePathToOpenAPIOverrides:n.absoluteFilepathToOverrides});if(w0c(d)){i.push({type:"openapi",value:d,source:l,namespace:n.namespace,settings:n.settings});continue}else if(rxa(d)){let s=await Kxa(d);i.push({type:"openapi",value:s,source:l,namespace:n.namespace,settings:n.settings});continue}}if(a.includes("asyncapi")){let d=await EOc({context:t,absoluteFilePath:n.absoluteFilepath,absoluteFilePathToOverrides:n.absoluteFilepathToOverrides});i.push({type:"asyncapi",value:d,source:l,namespace:n.namespace,settings:n.settings});continue}if(a.includes("openrpc")){let d=await EOc({context:t,absoluteFilePath:n.absoluteFilepath,absoluteFilePathToOverrides:n.absoluteFilepathToOverrides});i.push({type:"asyncapi",value:d,source:l,namespace:n.namespace,settings:n.settings});continue}t.failAndThrow(`${n.absoluteFilepath} is not a valid OpenAPI or AsyncAPI file`)}return i}};var JXo=require("fs/promises"),QA_=ci(fne(),1);var GA_=ci($A_(),1);function $Xo(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...u}={}){let l=n.reduce((s,o)=>({...s,[o]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[s,o]of Object.entries(l))d=d.replaceAll(s,o);return e?.debug(`+ ${d}`),(0,GA_.default)(t,r,u)}async function x3(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...u}={}){let l=$Xo(e,t,r,{doNotPipeOutput:i,secrets:n,substitutions:a,...u});i||(l.stdout?.pipe(process.stdout),l.stderr?.pipe(process.stderr));let d=await l;return d.stdout==null&&(d.stdout=""),d.stderr==null&&(d.stderr=""),d}function GXo(e,{logger:t,...r}={}){return(i,n)=>x3(t,e,i,{...r,...n})}var DHE="buf.gen.yaml",JA_="output",EHE=`${JA_}/openapi.yaml`,QXo=class{context;constructor({context:t}){this.context=t}async generate({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,relativeFilepathToProtobufRoot:i,local:n}){return n?this.generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,relativeFilepathToProtobufRoot:i}):this.generateRemote()}async generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,relativeFilepathToProtobufRoot:i}){let n=await this.setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t,relativeFilepathToProtobufRoot:i}),a=xq(t,r);return this.doGenerateLocal({cwd:n,target:a})}async setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t,relativeFilepathToProtobufRoot:r}){let i=$l.of((await QA_.default.dir()).path);return await(0,JXo.cp)(t,i,{recursive:!0}),await(0,JXo.writeFile)(Vu(i,Qa.of(DHE)),MHE({relativeFilepathToProtobufRoot:r})),i}async doGenerateLocal({cwd:t,target:r}){let i=GXo("which",{cwd:t,logger:this.context.logger});try{await i(["buf"])}catch{this.context.failAndThrow("Missing required dependency; please install 'buf' to continue (e.g. 'brew install buf').")}try{await i(["protoc-gen-openapi"])}catch{this.context.failAndThrow("Missing required dependency; please install 'protoc-gen-openapi' to continue (e.g. 'brew install go && go install github.com/fern-api/protoc-gen-openapi/cmd/protoc-gen-openapi@latest').")}let n=GXo("buf",{cwd:t,logger:this.context.logger});return await n(["config","init"]),await n(["generate",r]),Vu(t,Qa.of(EHE))}async generateRemote(){this.context.failAndThrow("Remote Protobuf generation is unimplemented.")}};function MHE({relativeFilepathToProtobufRoot:e}){return`
|
|
1951
1951
|
version: v1
|
|
1952
1952
|
plugins:
|
|
1953
1953
|
- plugin: openapi
|
|
@@ -1957,7 +1957,7 @@ plugins:
|
|
|
1957
1957
|
- enum_type=string
|
|
1958
1958
|
- default_response=false
|
|
1959
1959
|
- source_root=${e}
|
|
1960
|
-
`}async function CFe({context:e,specs:t,relativePathToDependency:r}){let i=new QXo({context:e}),n=t.filter(l=>l.type==="openapi").map(l=>({...l,relativePathToDependency:r})),a=t.filter(l=>l.type==="protobuf"),u=await Promise.all(a.map(async l=>AHE({generator:i,protobufSpec:l,relativePathToDependency:r})));return[...n,...u]}async function AHE({generator:e,protobufSpec:t,relativePathToDependency:r}){return{type:"openapi",absoluteFilepath:await e.generate({absoluteFilepathToProtobufRoot:t.absoluteFilepathToProtobufRoot,absoluteFilepathToProtobufTarget:t.absoluteFilepathToProtobufTarget,relativeFilepathToProtobufRoot:t.relativeFilepathToProtobufRoot,local:t.generateLocally}),absoluteFilepathToOverrides:t.absoluteFilepathToOverrides,settings:t.settings,source:{type:"protobuf",relativePathToDependency:r,root:t.absoluteFilepathToProtobufRoot,file:t.absoluteFilepathToProtobufTarget}}}var GC_=require("fs"),C9n=require("fs/promises");var QC_=require("os"),JC_=ci(require("path"),1),KC_=require("stream/promises"),YC_=ci(tko(),1),XC_=ci(fne(),1);var BPc=ci(e$i(),1);var zP;(function(e){e.FILE_READ="FILE_READ",e.FILE_PARSE="FILE_PARSE",e.FILE_MISSING="FILE_MISSING",e.STRUCTURE_VALIDATION="STRUCTURE_VALIDATION",e.JSONSCHEMA_VALIDATION="JSONSCHEMA_VALIDATION",e.DEPENDENCY_NOT_LISTED="DEPENDENCY_NOT_LISTED",e.FAILED_TO_LOAD_DEPENDENCY="FAILED_TO_LOAD_DEPENDENCY",e.EXPORTING_PACKAGE_MARKER_OTHER_KEYS="EXPORTING_PACKAGE_MARKER_OTHER_KEYS",e.EXPORT_PACKAGE_HAS_DEFINITIONS="EXPORT_PACKAGE_HAS_DEFINITIONS",e.MISCONFIGURED_DIRECTORY="MISCONFIGURED_DIRECTORY"})(zP||(zP={}));var aQE=Efi();async function ZC_({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:i,cliVersion:n,settings:a,loadAPIWorkspace:u}){let l,d={type:zP.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},s=t.dependencies[e];return s==null?d={type:zP.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${dQE(s)}`},async o=>{switch(s.type){case"version":l=await lQE({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;case"local":l=await cQE({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;default:mo(s)}}),l!=null?{didSucceed:!0,definition:l}:{didSucceed:!1,failure:d}}var kC_="dependencies";var oQE="metadata.json",uQE=".fern";function sQE(e){return Vu($l.of((0,QC_.homedir)()),Qa.of(uQE),Qa.of(kC_),Qa.of(e.organization),Qa.of(e.apiName),Qa.of(e.version))}async function cQE({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){if(n==null){t.failWithoutThrowing("Failed to load api definition");return}t.logger.info("Parsing...");let a=await n({absolutePathToWorkspace:e.absoluteFilepath,context:t,cliVersion:r,workspaceName:void 0});if(!a.didSucceed){t.failWithoutThrowing("Failed to load api definition",a.failures);return}t.logger.info("Modifying source filepath ...");let u=await a.workspace.getDefinition({context:t,relativePathToDependency:Qa.of(e.path)},i);return t.logger.info("Loaded..."),u}async function lQE({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){let a=sQE(e),u=Vu(a,Qa.of(kC_)),l=Vu(a,Qa.of(oQE)),d;if(!await Cf(u)||!await Cf(l)){t.logger.info("Downloading manifest...");let c=await aQE.definitionRegistry.get(BPc.FernFiddle.OrganizationId(e.organization),BPc.FernFiddle.ApiId(e.apiName),e.version);if(!c.ok){c.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:m=>{t.failWithoutThrowing("Failed to download API manifest",m)}});return}let b=c.body.yamlSchemaVersion!=null?parseInt(c.body.yamlSchemaVersion):void 0,g=sJi(r),O=sJi(c.body.cliVersion);if(b!=null){if(b>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${c.body.cliVersion}`);return}else if(b<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(g.major!==O.major||g.minor!==O.minor){t.failWithoutThrowing(`CLI version is ${c.body.cliVersion}. Expected ${g.major}.${g.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+c.body.definitionS3DownloadUrl),await(0,C9n.mkdir)(u,{recursive:!0});try{await fQE({s3PreSignedReadUrl:c.body.definitionS3DownloadUrl,absolutePathToLocalOutput:u})}catch(m){t.failWithoutThrowing("Failed to download API",m);return}d=c.body,await(0,C9n.writeFile)(l,JSON.stringify(d))}else d=JSON.parse((await(0,C9n.readFile)(l)).toString());if(t.logger.info("Parsing..."),n==null){t.failWithoutThrowing("Failed to load API");return}let s=await n({absolutePathToWorkspace:u,context:t,cliVersion:d.cliVersion,workspaceName:void 0});if(!s.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",s.failures);return}if(s.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await s.workspace.getDefinition({context:t},i)}async function fQE({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await rF.get(e,{responseType:"stream"}),i=await XC_.default.dir(),n=JC_.default.join(i.path,"api.tgz");await(0,KC_.pipeline)(r.data,(0,GC_.createWriteStream)(n)),await(0,YC_.extract)({file:n,cwd:t})}function dQE(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:mo(e)}}var dB_=ci(aB_(),1);function rko(e,t){for(let[r,i]of t3(e))_QE({relativeFilepath:r,failure:i,logger:t})}function _QE({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case zP.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 zP.FILE_READ:r.error("Failed to open file: "+e);break;case zP.FILE_MISSING:r.error("Missing file: "+e);break;case zP.FILE_PARSE:t.error instanceof vSa?r.error(vFe({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case zP.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of hQE(i))r.error(vFe({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case zP.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case zP.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${VOo}: `+t.dependencyName);break;case zP.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case zP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case zP.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(vFe({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(i=>i!=="")]}));for(let i of t.error.allErrors)i!==t.error.error&&r.debug(vFe({title:i.message??"Unknown error",breadcrumbs:[e,...i.instancePath.split("/").filter(n=>n!=="")]}));break;default:mo(t)}}function hQE(e){switch(e.code){case Jl.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${Gs.underline(e.expected)} but received ${Gs.underline(e.received)}`}];case Jl.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${Gs.underline(t)}`}));case Jl.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>Gs.underline(t)).join(", ")}`}];case Jl.invalid_union:case Jl.invalid_arguments:case Jl.invalid_return_type:case Jl.invalid_date:case Jl.invalid_string:case Jl.too_small:case Jl.too_big:case Jl.invalid_intersection_types:case Jl.not_multiple_of:case Jl.custom:default:return[{title:e.message}]}}var oB_=require("fs/promises");async function uB_(e,t){let r=[];for(let i of await Fxe(e,t))r.push(await yQE({relativeFilepath:xq(e,i),absoluteFilepath:i}));return r}async function yQE({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,oB_.readFile)(t)).toString()}}async function sB_(e){let t={},r={};function i(n){try{t[n.relativeFilepath]={defaultUrl:void 0,contents:qd.load(n.fileContents,{schema:qd.CORE_SCHEMA}),rawContents:n.fileContents}}catch(a){r[n.relativeFilepath]={type:zP.FILE_PARSE,error:a}}}return await Promise.all(e.map(i)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}async function cB_({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:i,settings:n,loadAPIWorkspace:a}){let u={},l={},d={};return await Promise.all(t3(t.packageMarkers).map(async([s,o])=>{if(o.contents.export==null)u[s]=o;else{let{export:c,...b}=o.contents;if(fZ(b)>0)d[s]={type:zP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:s};else{let g=Xd(s);if(uVt(t.namedDefinitionFiles).some(m=>m!==s&&m.startsWith(g)))d[s]={type:zP.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:g};else{let m=await ZC_({dependencyName:typeof o.contents.export=="string"?o.contents.export:o.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:i,settings:n,loadAPIWorkspace:a});m.didSucceed?l[Xd(s)]={definition:m.definition,url:typeof o.contents.export=="object"?o.contents.export.url:void 0}:d[s]=m.failure}}}})),fZ(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:u,importedDefinitions:l}}var lB_=ci(require("path"),1);var xPc={};jo(xPc,{additionalProperties:()=>OQE,default:()=>PQE,definitions:()=>mQE,properties:()=>bQE,required:()=>gQE,type:()=>vQE});var vQE="object",bQE={docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},"default-url":{oneOf:[{type:"string"},{type:"null"}]},"default-environment":{oneOf:[{type:"string"},{type:"null"}]},environments:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/environments.EnvironmentSchema"}},{type:"null"}]},auth:{oneOf:[{$ref:"#/definitions/auth.ApiAuthSchema"},{type:"null"}]},"auth-schemes":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/auth.AuthSchemeDeclarationSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},name:{type:"string"},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},"error-discrimination":{oneOf:[{$ref:"#/definitions/file.ErrorDiscriminationSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},errors:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"idempotency-headers":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},variables:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/variables.VariableDeclarationSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"null"}]},product:{oneOf:[{$ref:"#/definitions/products.ProductDeclarationSchema"},{type:"null"}]},version:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},gQE=["name"],OQE=!1,mQE={"environments.SingleBaseUrlEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},url:{type:"string"}},required:["url"],additionalProperties:!1},"environments.MultipleBaseUrlsEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},urls:{type:"object",additionalProperties:{type:"string"}}},required:["urls"],additionalProperties:!1},"environments.EnvironmentSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/environments.SingleBaseUrlEnvironmentSchema"},{$ref:"#/definitions/environments.MultipleBaseUrlsEnvironmentSchema"}]},"auth.AuthSchemeReferenceSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{type:"string"}},required:["scheme"],additionalProperties:!1},"auth.AnyAuthItem":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"}]},"auth.AnyAuthSchemesSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},any:{type:"array",items:{$ref:"#/definitions/auth.AnyAuthItem"}}},required:["any"],additionalProperties:!1},"auth.ApiAuthSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"},{$ref:"#/definitions/auth.AnyAuthSchemesSchema"}]},"auth.OAuthAccessTokenRequestPropertiesSchema":{type:"object",properties:{"client-id":{oneOf:[{type:"string"},{type:"null"}]},"client-secret":{oneOf:[{type:"string"},{type:"null"}]},scopes:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthAccessTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthGetTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthRefreshTokenRequestPropertiesSchema":{type:"object",properties:{"refresh-token":{type:"string"}},required:["refresh-token"],additionalProperties:!1},"auth.OAuthRefreshTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthRefreshTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"oauth"},type:{const:"client-credentials"},scopes:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"client-id-env":{oneOf:[{type:"string"},{type:"null"}]},"client-secret-env":{oneOf:[{type:"string"},{type:"null"}]},"token-prefix":{oneOf:[{type:"string"},{type:"null"}]},"token-header":{oneOf:[{type:"string"},{type:"null"}]},"get-token":{$ref:"#/definitions/auth.OAuthGetTokenEndpointSchema"},"refresh-token":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenEndpointSchema"},{type:"null"}]}},required:["scheme","type","get-token"],additionalProperties:!1},"auth.HeaderAuthSchemeSchema":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},header:{type:"string"},type:{oneOf:[{type:"string"},{type:"null"}]},prefix:{oneOf:[{type:"string"},{type:"null"}]}},required:["header"],additionalProperties:!1},"auth.AuthVariable":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.BasicAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"basic"},username:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]},password:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.BearerAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},token:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.AuthSchemeDeclarationSchema":{anyOf:[{$ref:"#/definitions/auth.OAuthSchemeSchema"},{$ref:"#/definitions/auth.HeaderAuthSchemeSchema"},{$ref:"#/definitions/auth.BasicAuthSchemeSchema"},{$ref:"#/definitions/auth.BearerAuthSchemeSchema"}]},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"file.PropertyBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"property"},"property-name":{type:"string"}},required:["strategy","property-name"],additionalProperties:!1},"file.StatusCodeBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"status-code"}},required:["strategy"],additionalProperties:!1},"file.ErrorDiscriminationSchema":{anyOf:[{$ref:"#/definitions/file.PropertyBasedErrorDiscrimination"},{$ref:"#/definitions/file.StatusCodeBasedErrorDiscrimination"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"variables.VariableDeclarationDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"variables.VariableDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/variables.VariableDeclarationDetailed"}]},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"versioning.VersionValueDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionValue":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionValueDetailed"}]},"versioning.VersionDeclarationHeaderObjectSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionDeclarationHeaderSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionDeclarationHeaderObjectSchema"}]},"versioning.VersionDeclarationSchema":{type:"object",properties:{default:{oneOf:[{type:"string"},{type:"null"}]},values:{type:"array",items:{$ref:"#/definitions/versioning.VersionValue"}},header:{$ref:"#/definitions/versioning.VersionDeclarationHeaderSchema"}},required:["values","header"],additionalProperties:!1},"products.ProductValueDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},versions:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"products.ProductValue":{anyOf:[{type:"string"},{$ref:"#/definitions/products.ProductValueDetailed"}]},"products.ProductDeclarationHeaderObjectSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"products.ProductDeclarationHeaderSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/products.ProductDeclarationHeaderObjectSchema"}]},"products.ProductDeclarationSchema":{type:"object",properties:{default:{oneOf:[{type:"string"},{type:"null"}]},values:{type:"array",items:{$ref:"#/definitions/products.ProductValue"}},header:{$ref:"#/definitions/products.ProductDeclarationHeaderSchema"}},required:["values","header"],additionalProperties:!1}},PQE={type:vQE,properties:bQE,required:gQE,additionalProperties:OQE,definitions:mQE};var RPc={};jo(RPc,{additionalProperties:()=>SQE,default:()=>EQE,definitions:()=>DQE,properties:()=>wQE,type:()=>jQE});var jQE="object",wQE={docs:{oneOf:[{type:"string"},{type:"null"}]},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]}},SQE=!1,DQE={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE","HEAD"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{type:"boolean"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1}},EQE={type:jQE,properties:wQE,additionalProperties:SQE,definitions:DQE};var NPc={};jo(NPc,{additionalProperties:()=>qQE,default:()=>CQE,definitions:()=>TQE,properties:()=>AQE,type:()=>MQE});var MQE="object",AQE={imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},navigation:{oneOf:[{$ref:"#/definitions/file.Navigation"},{type:"null"}]},export:{oneOf:[{$ref:"#/definitions/file.Export"},{type:"null"}]}},qQE=!1,TQE={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE","HEAD"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{type:"boolean"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1},"file.Navigation":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"file.ExportDetailed":{type:"object",properties:{dependency:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]}},required:["dependency"],additionalProperties:!1},"file.Export":{anyOf:[{type:"string"},{$ref:"#/definitions/file.ExportDetailed"}]}},CQE={type:MQE,properties:AQE,additionalProperties:qQE,definitions:TQE};function fB_({files:e,absolutePathToDefinition:t}){let r,i={},n={},a={};for(let[u,l]of t3(e)){let d=l.contents,s=o=>{a[u]={type:zP.JSONSCHEMA_VALIDATION,error:o}};if(u===i3){let o=pVt(d,xPc);if(o.success){let c=JN.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:c["default-url"],contents:c,rawContents:l.rawContents}}else s(o)}else if(lB_.default.basename(u)===zS){let o=pVt(d,NPc);if(o.success){let c=JN.serialization.PackageMarkerFileSchema.parseOrThrow(d);n[u]={defaultUrl:typeof c.export=="object"?c.export.url:void 0,contents:c,rawContents:l.rawContents}}else s(o)}else{let o=pVt(d,RPc);if(o.success){let c=JN.serialization.DefinitionFileSchema.parseOrThrow(d);i[u]={defaultUrl:void 0,contents:c,rawContents:l.rawContents,absoluteFilePath:Vu(t,u)}}else s(o)}}return r==null?{didSucceed:!1,failures:{[Qa.of(i3)]:{type:zP.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:i,rootApiFile:r,packageMarkers:n}}var Fir=class extends sHt{type="fern";context;fernWorkspaces={};loadAPIWorkspace;constructor({context:t,loadAPIWorkspace:r,...i}){super(i),this.context=t,this.loadAPIWorkspace=r}async getDefinition({context:t},r){return(await this.toFernWorkspace({context:t},r)).definition}async toFernWorkspace({context:t},r){let i=(0,dB_.default)(r??{}),n=this.fernWorkspaces[i];if(n==null){let a=t||this.context,u=Vu(this.absoluteFilePath,Qa.of(v9)),l=await x2s({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await uB_(u,"{yml,yaml}"),s=await sB_(d);if(!s.didSucceed)return rko(s.failures,a.logger),a.failAndThrow();let o=fB_({files:s.files,absolutePathToDefinition:u});if(!o.didSucceed)return rko(o.failures,a.logger),a.failAndThrow();let c=await cB_({dependenciesConfiguration:l,structuralValidationResult:o,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!c.didSucceed)return rko(c.failures,a.logger),a.failAndThrow();let b={absoluteFilePath:u,rootApiFile:o.rootApiFile,namedDefinitionFiles:o.namedDefinitionFiles,packageMarkers:c.packageMarkers,importedDefinitions:c.importedDefinitions};r?.auth!=null&&(b={...b,rootApiFile:{...b.rootApiFile,contents:{...b.rootApiFile.contents,auth:r?.auth}}}),n=new DMe({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:l,workspaceName:this.workspaceName,definition:b,cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[i]=n}return n}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var w0=class e{breadcrumbs=[];context;static STRING=Ws.TypeReference.primitive({v1:"STRING",v2:Ws.PrimitiveTypeV2.string({default:void 0,validation:void 0})});static OPTIONAL_STRING=Ws.TypeReference.container(Ws.ContainerType.optional(e.STRING));constructor({breadcrumbs:t=[],context:r}){this.breadcrumbs=t,this.context=r}};var pB_={[hy.GenerationLanguage.PHP]:new Set(["abstract","and","as","break","callable","case","catch","class","clone","const","continue","declare","default","do","echo","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","extends","final","finally","fn","for","foreach","function","global","goto","list","if","implements","include","include_once","instanceof","insteadof","interface","match","namespace","new","or","parent","Parent","print","private","protected","public","readonly","require","require_once","return","static","switch","throw","trait","try","use","var","while","xor","yield"].flatMap(e=>[e,iz(e)])),[hy.GenerationLanguage.TYPESCRIPT]:new Set(["any","as","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","module","new","null","number","of","package","private","protected","public","require","return","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","var","void","while","with","yield","Date","Error","File","Object","Record"]),[hy.GenerationLanguage.JAVA]:new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","try","void","volatile","while"]),[hy.GenerationLanguage.PYTHON]:new Set(["False","None","True","and","as","assert","async","","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","float","int","complex","bool","uuid","list","set","map","long","self","all"]),[hy.GenerationLanguage.GO]:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[hy.GenerationLanguage.RUBY]:new Set(["__ENCODING__","__LINE__","__FILE__","alias","and","begin","break","case","class","def","defined","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","Object","JSON","Date","DateTime"]),[hy.GenerationLanguage.CSHARP]:new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while","add","and","alias","ascending","args","async","","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","managed","nameof","nint","not","notnull","nuint","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value","var","when","where","with","yield"]),[hy.GenerationLanguage.SWIFT]:new Set([])};var BQE=["go","ruby"];function RMe({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let u=c=>({unsafeName:c,safeName:IQE({name:c,keywords:zQE({generationLanguage:e,keywords:t})})}),l=T_(n),d=iz(l),s=AVi(n),o=SVi(l);return r&&(!NQE(o)&&(e==null||BQE.includes(e))&&(l=o.map((c,b)=>{if(b>0){let g=iko(c);if(g!=null)return g;if(nko(c))return c.toUpperCase()}return c}).join(""),d=o.map((c,b)=>{let g=iko(c);return g??(nko(c)?c.toUpperCase():b===0?iz(c):c)}).join("")),s=n.split(" ").map(c=>c.split(/(\d+)/).map(AVi).join("")).join("_")),{originalName:n,camelCase:u(a?.casingOverrides?.camel??l),snakeCase:u(a?.casingOverrides?.snake??s),screamingSnakeCase:u(a?.casingOverrides?.["screaming-snake"]??s.toUpperCase()),pascalCase:u(a?.casingOverrides?.pascal??d)}},generateNameAndWireValue:({name:n,wireValue:a,opts:u})=>({name:i.generateName(n,u),wireValue:a})};return i}function IQE({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":RQE(e)?"_"+e:e}function zQE({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return pB_[e]}var xQE=/^[0-9]/;function RQE(e){return xQE.test(e)}function NQE(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=iko(i)!=null||nko(i),a=iko(t)!=null||nko(t);return n&&a})}function iko(e){return LQE.get(e.toUpperCase())}function nko(e){return FQE.has(e.toUpperCase())}var FQE=new Set(["ACL","API","ASCII","CPU","CSS","DNS","EOF","GUID","HTML","HTTP","HTTPS","ID","IP","JSON","LHS","QPS","RAM","RHS","RPC","SAML","SCIM","SLA","SMTP","SQL","SSH","SSO","TCP","TLS","TTL","UDP","UI","UID","UUID","URI","URL","UTF8","VM","XML","XMPP","XSRF","XSS"]),LQE=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]);var hB_=require("fs/promises");var FPc=class{_map;_path;_lastScalar;_fragments;_count;constructor(){this._map={},this._path=[],this._lastScalar="",this._fragments=[],this._count=0}get map(){return this._map}resolveNode(t,r){if(t.path==="."&&(r="."),!this._map[r]){let{line:i,position:n,lineStart:a}=t;this._map[r]={line:i,position:n,lineStart:a}}t.children&&t.children.length>0&&t.children.forEach(i=>{this.resolveNode(i,(r==="."?"":r)+"."+i.path)})}iterFragments(t,r){for(let i=this._fragments.length-1;i>=0;i--){if(!this._fragments[i].path.startsWith(t)||this._fragments[i].path===t)continue;let n=this._fragments.pop();r(n)}}handleState(t,r){if(t==="close"){let i=r.result,n=r.kind,a=this._path.join(".");if(n==="scalar"){this._path.pop(),this._lastScalar=`${i}`;let{line:u,position:l,lineStart:d}=r;this._path.length===0?this._map["."+i]={line:u,position:l,lineStart:d}:this._fragments.push({path:this._path.join(".")+"."+i,line:u,position:l,lineStart:d})}else if(n==="mapping"){let u={path:a,children:[],line:0,position:0,lineStart:0},l=0;this.iterFragments(a,d=>{l++,!((!d.children||d.children.length===0)&&l%2===1)&&(this._path.length===1?this.resolveNode(d,d.path):(u.children.push({...d,path:d.path.slice(a.length+1)}),u.line=d.line,u.position=d.position,u.lineStart=d.lineStart))}),u.children&&u.children.length>0&&this._fragments.push(u),this._path.pop()}else if(n==="sequence"){let u={path:a,children:[],line:0,position:0,lineStart:0},l=new Set,d=i.length;this.iterFragments(a,s=>{l.has(s.position)||(d--,l.add(s.position),this._path.length===1?this.resolveNode(s,`${a}.${d}`):(u.children.push({...s,path:d.toString()}),u.line=s.line,u.position=s.position,u.lineStart=s.lineStart))}),u.children&&u.children.length>0&&this._fragments.push(u),this._path.pop()}else this._path.pop()}if(t==="open"){if(this._count===0){let{line:i,position:n,lineStart:a}=r;this._map["."]={line:i,position:n,lineStart:a}}this._path.push(this._lastScalar),this._count++}}listen(){return this.handleState.bind(this)}lookup(t){let r=t instanceof Array?t.map(n=>`${n}`).join("."):`${t}`;r.startsWith(".")||(r="."+r),r.startsWith("..")&&(r=r.slice(1)),r=r.replace(/\[/g,".").replace(/\]/g,"");let i=this._map[r];if(i)return{line:i.line+1,column:i.position-i.lineStart+1,position:i.position}}},_B_=FPc;var Lir;(function(e){e.WARNING="warning",e.ERROR="error"})(Lir||(Lir={}));var z9n=class{errors=[];logger;breadcrumbToLineNumberMapper;relativeFilepathToSpec;constructor({logger:t,relativeFilepathToSpec:r}){this.logger=t,this.relativeFilepathToSpec=r,r&&(this.breadcrumbToLineNumberMapper=new LPc({logger:t,relativePathToFile:Qa.of(r)}))}collect(t){this.errors.push(t)}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}dedupe(){let t=[],r=new Set,i=0;for(let n of this.errors){let a=n.path?n.path.join("->"):"",u=`${n.message}|${n.level||Lir.WARNING}|${a}`;r.has(u)?i++:(r.add(u),t.push(n))}return this.errors=t,i}getErrorStats(){this.dedupe();let t=0,r=0;for(let i of this.errors)i.level===Lir.ERROR?t++:r++;return{numErrors:t,numWarnings:r}}async logErrors({logWarnings:t}){this.dedupe();for(let r of this.errors)if(!(r.level===Lir.WARNING&&!t)){switch(r.level){case Lir.ERROR:if(this.logger.log(Pb.Error,r.message),r.path&&r.path.length>0){let i=await this.breadcrumbToLineNumberMapper?.getSourceLocation(r.path),n=i?`${this.relativeFilepathToSpec}:${i.line}:${i.column}`:r.path.join(" -> ");this.logger.log(Pb.Error,` - at location (${n})`)}break;case Lir.WARNING:default:if(this.logger.log(Pb.Warn,r.message),r.path&&r.path.length>0){let i=await this.breadcrumbToLineNumberMapper?.getSourceLocation(r.path),n=i?`${this.relativeFilepathToSpec}:${i.line}:${i.column}`:r.path.join(" -> ");this.logger.log(Pb.Warn,` - at location (${n})`)}}this.logger.log(Pb.Info,"")}}},LPc=class{logger;relativePathToFile;map=new _B_;initialized=!1;constructor({relativePathToFile:t,logger:r}){this.relativePathToFile=t,this.logger=r}async initialize(){if(!this.initialized)try{let t=await(0,hB_.readFile)(this.relativePathToFile,"utf-8");qd.load(t,{listener:this.map.listen()}),this.initialized=!0}catch(t){this.logger.log(Pb.Warn,`Failed to initialize line number mapping for ${this.relativePathToFile}: ${JSON.stringify(t)}`)}}async getSourceLocation(t){return this.initialized||await this.initialize(),this.map.lookup(t)}};var f8=class e{args;spec;settings;errorCollector;logger;generationLanguage;smartCasing;casingsGenerator;namespace;exampleGenerationArgs;authOverrides;environmentOverrides;globalHeaderOverrides;enableUniqueErrorsPerEndpoint;constructor(t){this.args=t,this.spec=t.spec,this.settings=t.settings,this.errorCollector=t.errorCollector,this.logger=t.logger,this.generationLanguage=t.generationLanguage,this.smartCasing=t.smartCasing,this.namespace=t.namespace,this.casingsGenerator=RMe({generationLanguage:t.generationLanguage,keywords:void 0,smartCasing:t.smartCasing}),this.exampleGenerationArgs=t.exampleGenerationArgs,this.authOverrides=t.authOverrides,this.environmentOverrides=t.environmentOverrides,this.globalHeaderOverrides=t.globalHeaderOverrides,this.enableUniqueErrorsPerEndpoint=t.enableUniqueErrorsPerEndpoint}static BREADCRUMBS_TO_IGNORE=["properties","allOf","anyOf"];convertBreadcrumbsToName(t){let r=t.filter((n,a)=>!(/^\d+$/.test(n)||e.BREADCRUMBS_TO_IGNORE.includes(n)||a===0&&n==="components"||a===1&&n==="schemas"||t[0]==="paths"&&(a===0||a===1&&["get","post","put","delete","patch"].includes(n)||a===2&&t[1]!=null&&["get","post","put","delete","patch"].includes(t[1])&&n==="parameters"))),i=T_(r.join("_"));return i.charAt(0).toUpperCase()+i.slice(1)}createFernFilepath(t={}){let r=this.namespace!=null?[this.casingsGenerator.generateName(this.namespace)]:[],i=t.name!=null?this.casingsGenerator.generateName(t.name):void 0;return{allParts:i?[...r,i]:r,packagePath:r,file:i}}resolveReference({reference:t,breadcrumbs:r,skipErrorCollector:i}){let n=this.spec,a=t.$ref.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(u=>u.replace(/~1/g,"/"));for(let u of a){if(typeof n!="object"||n==null)return i||this.errorCollector.collect({level:Lir.ERROR,message:this.getErrorMessageForMissingRef({reference:t}),path:r}),{resolved:!1};n=n[u]}return n==null?(i||this.errorCollector.collect({level:Lir.ERROR,message:this.getErrorMessageForMissingRef({reference:t}),path:r}),{resolved:!1}):{resolved:!0,value:n}}getErrorMessageForMissingRef({reference:t}){let r=t.$ref.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/");return r.length>=3&&r[0]==="components"&&r[1]==="schemas"?`Schema ${r[2]} does not exist`:`${t.$ref} does not exist`}async resolveMaybeExternalReference(t){let r=this.spec,i,n=!1,a=null,u;if(this.isExternalReference(t.$ref)){n=!0;let d=t.$ref.split("#"),s=d[0];if(i=d[1],!s)return{resolved:!1};u=s;let o=await fetch(s);if(!o.ok)return{resolved:!1};try{let c=await o.text();try{a=JSON.parse(c),r=a}catch{a=qd.load(c),r=a}if(r==null)return{resolved:!1}}catch{return{resolved:!1}}if(!i)return{resolved:!0,value:r}}let l=(i??t.$ref).replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(d=>d.replace(/~1/g,"/"));for(let d of l){if(typeof r!="object"||r==null)return{resolved:!1};r=r[d]}if(r==null)return{resolved:!1};if(n&&typeof r=="object"&&r!==null){let d=new Set;d.add(t.$ref),r=await this.resolveNestedExternalReferences(r,a,d,u)}return{resolved:!0,value:r}}async resolveNestedExternalReferences(t,r,i,n){if(t===null||typeof t!="object")return t;if(Array.isArray(t)){let u=[];for(let l of t)u.push(await this.resolveNestedExternalReferences(l,r,i,n));return u}if(this.isReferenceObject(t)){let u=t.$ref;if(this.isExternalReference(u)){if(i.has(u))return t;i.add(u);let l=await this.resolveMaybeExternalReference({$ref:u});if(i.delete(u),l.resolved)return l.value}else{let l=`${n}${u}`;if(i.has(l))return t;i.add(l);let d=r,s=u.substring(2).split("/").map(o=>o.replace(/~1/g,"/").replace(/~0/g,"~"));for(let o of s){if(typeof d!="object"||d===null)return t;d=d[o]}if(d!=null){let o=await this.resolveNestedExternalReferences(d,r,i,n);return i.delete(u),o}i.delete(u)}return t}let a={};for(let[u,l]of Object.entries(t))typeof l=="object"&&l!==null?a[u]=await this.resolveNestedExternalReferences(l,r,i,n):a[u]=l;return a}getExamplesFromSchema({schema:t,breadcrumbs:r}){if(t==null)return[];let i=t.example!=null?[t.example]:[];return t.examples!=null&&(Array.isArray(t.examples)?i.push(...t.examples):this.errorCollector.collect({message:"Received non-array schema examples",path:r})),i}getNamedExamplesFromMediaTypeObject({mediaTypeObject:t,breadcrumbs:r,defaultExampleName:i}){if(t==null)return[];let n=[];if(t.example!=null){let a=this.generateUniqueName({prefix:i??`${r.join("_")}_example`,existingNames:[]});n.push([a,t.example])}return t.examples!=null&&n.push(...Object.entries(t.examples)),n}resolveMaybeReference({schemaOrReference:t,breadcrumbs:r,skipErrorCollector:i}){if(this.isReferenceObject(t)){let n=this.resolveReference({reference:t,breadcrumbs:r,skipErrorCollector:i});return n.resolved?n.value:void 0}return t}resolveExample(t){if(!this.isReferenceObject(t))return t;let r=this.resolveReference({reference:t});return r.resolved?this.returnExampleValue(r.value):void 0}resolveExampleWithValue(t){if(!this.isReferenceObject(t))return this.returnExampleValue(t);let r=this.resolveReference({reference:t});return r.resolved?this.returnExampleValue(r.value):void 0}returnExampleValue(t){return this.isExampleWithValue(t)?t.value:t}getPropertyAccess(t){let r=t;for(;this.isReferenceObject(r);){let i=this.resolveReference({reference:r});if(!i.resolved)return;r=i.value}if(!(r.readOnly&&r.writeOnly)){if(r.readOnly)return Rkt.ReadOnly;if(r.writeOnly)return Rkt.WriteOnly}}getAudiences({operation:t,breadcrumbs:r}){let n=new pH.AudienceExtension({operation:t,breadcrumbs:r,context:this}).convert();if(n!=null)return n.audiences}getAvailability({node:t,breadcrumbs:r}){for(;this.isReferenceObject(t);){let a=this.resolveReference({reference:t});if(!a.resolved)return;t=a.value}let n=new pH.FernAvailabilityExtension({node:t,breadcrumbs:r,context:this}).convert();if(n!=null)return{status:n,message:void 0};if(t.deprecated===!0)return{status:B9.Deprecated,message:void 0}}getTypeIdFromSchemaReference(t){let r=t.$ref.match(/\/schemas\/(.+)$/);if(!(!r||!r[1]))return r[1]}createNamedTypeReference(t,r){return gf.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(t),typeId:t,displayName:r,default:void 0,inline:!1})}typeReferenceToDeclaredTypeName(t){if(t.type!=="named")return;let r=t.typeId;return{typeId:r,fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r),displayName:t.displayName}}removeSchemaFromInlinedTypes({id:t,inlinedTypes:r}){return Object.fromEntries(Object.entries(r).filter(([i])=>i!==t))}static maybeTrimPrefix(t,r){return t.startsWith(r)?t.slice(r.length):t}generateUniqueName({prefix:t,existingNames:r}){if(!r.includes(t))return t;let i=0;for(;r.includes(`${t}_${i}`);)i++;return`${t}_${i}`}isReferenceObject(t){return typeof t=="object"&&t!==null&&"$ref"in t}isExternalReference(t){return t.startsWith("http://")||t.startsWith("https://")}isReferenceObjectWithIdentifier(t){return this.isReferenceObject(t)&&("title"in t||"name"in t||"messageId"in t)}isExampleWithSummary(t){return typeof t=="object"&&t!=null&&"summary"in t}isExampleWithValue(t){return typeof t=="object"&&t!=null&&"value"in t}isOptional(t){return t.type==="container"&&t.container.type==="optional"}isNullable(t){return t.type==="container"&&t.container.type==="nullable"}isList(t){return t.type==="container"&&t.container.type==="list"}isFile(t){return t.type==="primitive"&&t.primitive.v2?.type==="string"&&t.primitive.v2.validation?.format==="binary"}getAsString(t){if(typeof t=="string")return t}getAsInteger(t){if(typeof t=="number"&&Number.isInteger(t))return t}getAsNumber(t){if(typeof t=="number")return t}getAsBoolean(t){if(typeof t=="boolean")return t}getAsArray(t){if(Array.isArray(t))return t}getAsObject(t){if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t}getGroup({groupParts:t,namespace:r}){let i=[];return r!=null&&i.push(r),i.push(...t??[]),i}isObjectSchemaType(t){return t.type==="object"||t.properties!=null}};var Aj=class{breadcrumbs;context;constructor(t){this.breadcrumbs=t.breadcrumbs,this.context=t.context}getExtensionValue(t,r){if(typeof t!="object"||t==null)return;let i=t[this.key];if(i!=null)return i;if(r!=null)return t[r]}};function lF(e){let t=VQE(e),{value:r,done:i}=UPc(t,"{");return i?{head:r,parts:[]}:{head:r,parts:[...UQE(t)]}}function*UQE(e){let t;do{let{value:r}=UPc(e,"}"),i=UPc(e,"{");t=i.done,yield{pathParameter:r,tail:i.value}}while(!t)}function*VQE(e){for(let t of e)yield t}function UPc(e,t){let r="",i=e.next();for(;i.done!==!0&&i.value!==t;)r+=i.value,i=e.next();return{value:r,done:i.done??!1}}function DRa(e){let t=2166136261;function r(n,a){if(typeof n=="object"&&n!=null){if(a>64){i("[MaxDepthExceeded]");return}if(Array.isArray(n)){i("[");for(let u=0;u<n.length;u++)u>0&&i(","),r(n[u],a+1);i("]")}else i("{"),Object.keys(n).sort().forEach((l,d)=>{d>0&&i(","),i(l),i(":"),r(n[l],a+1)}),i("}")}else i(String(n))}function i(n){for(let a=0;a<n.length;a++){let u=n.charCodeAt(a);t^=u,t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24),t>>>=0}}return r(e,0),t.toString(16)}function Uir({typeReference:e,typeDeclarations:t}){if(e.type==="container"&&e.container.type==="optional")return!0;if(e.type==="named"){let r=t?.[e.typeId];if(r?.shape.type==="alias"&&r?.shape.resolvedType.type==="container"&&r?.shape.resolvedType.container.type==="optional")return!0}return!1}function yB_({fieldName:e,containerType:t,maxDepth:r,currentDepth:i,typeDeclarations:n,skipOptionalProperties:a}){if(i>=r)return Vir({containerType:t});switch(t.type){case"list":{let u=Gq({fieldName:e,typeReference:t.list,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?Vir({containerType:t}):{type:"success",example:bm.list({list:[u.example,u.example],itemType:t.list}),jsonExample:[u.jsonExample,u.jsonExample]}}case"literal":return{type:"success",example:bm.literal({literal:t.literal._visit({boolean:u=>Rd.boolean(u),string:u=>Rd.string({original:u}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:t.literal._visit({boolean:u=>u,string:u=>u,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":{if(a)return Vir({containerType:t});let u=Gq({fieldName:e,typeReference:t.optional,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?Vir({containerType:t}):{type:"success",example:bm.optional({optional:u.example,valueType:t.optional}),jsonExample:u.jsonExample}}case"nullable":{if(a)return Vir({containerType:t});let u=Gq({fieldName:e,typeReference:t.nullable,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?Vir({containerType:t}):{type:"success",example:bm.nullable({nullable:u.example,valueType:t.nullable}),jsonExample:u.jsonExample}}case"set":{let u=Gq({fieldName:e,typeReference:t.set,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?Vir({containerType:t}):{type:"success",example:bm.set({set:[u.example],itemType:t.set}),jsonExample:[u.jsonExample]}}case"map":{let u=Gq({fieldName:e,typeReference:t.keyType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a}),l=Gq({fieldName:e,typeReference:t.valueType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"||l.type==="failure"?Vir({containerType:t}):{type:"success",example:bm.map({map:[{key:u.example,value:l.example}],keyType:t.keyType,valueType:t.valueType}),jsonExample:{[u.jsonExample]:l.jsonExample}}}default:mo(t)}}function Vir({containerType:e}){switch(e.type){case"list":return{type:"success",example:bm.list({list:[],itemType:e.list}),jsonExample:[]};case"literal":return{type:"success",example:bm.literal({literal:e.literal._visit({boolean:t=>Rd.boolean(t),string:t=>Rd.string({original:t}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:e.literal._visit({boolean:t=>t,string:t=>t,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":return{type:"success",example:bm.optional({optional:void 0,valueType:e.optional}),jsonExample:void 0};case"nullable":return{type:"success",example:bm.nullable({nullable:void 0,valueType:e.nullable}),jsonExample:void 0};case"set":return{type:"success",example:bm.set({set:[],itemType:e.set}),jsonExample:[]};case"map":return{type:"success",example:bm.map({map:[],keyType:e.keyType,valueType:e.valueType}),jsonExample:{}};default:mo(e)}}function bB_({fieldName:e,primitiveType:t}){switch(t.v1){case"STRING":return QQE({fieldName:e,default_:WQE(t.v2),validation:HQE(t.v2)});case"BASE_64":return{type:"success",example:Rd.base64(Gy.BASE64),jsonExample:Gy.BASE64};case"BOOLEAN":return{type:"success",example:Rd.boolean(Gy.BOOLEAN),jsonExample:Gy.BOOLEAN};case"DATE":return{type:"success",example:Rd.date(Gy.DATE),jsonExample:Gy.DATE};case"DATE_TIME":return{type:"success",example:Rd.datetime({datetime:new Date(Gy.DATE_TIME),raw:Gy.DATE_TIME}),jsonExample:Gy.DATE_TIME};case"DOUBLE":return JQE({fieldName:e,validation:$QE(t.v2)});case"FLOAT":return{type:"success",example:Rd.float(Gy.FLOAT),jsonExample:Gy.FLOAT};case"INTEGER":return KQE({fieldName:e,validation:GQE(t.v2)});case"UINT_64":return{type:"success",example:Rd.uint64(Gy.INT64),jsonExample:Gy.INT64};case"UINT":return{type:"success",example:Rd.uint(Gy.UINT),jsonExample:Gy.UINT};case"BIG_INTEGER":return{type:"success",example:Rd.bigInteger(Gy.INT64.toString()),jsonExample:`${Gy.INT64}`};case"LONG":return{type:"success",example:Rd.long(Gy.INT64),jsonExample:Gy.INT64};case"UUID":return{type:"success",example:Rd.uuid(Gy.UUID),jsonExample:Gy.UUID};default:mo(t.v1)}}function WQE(e){if(e?.type==="string")return e.default}function HQE(e){if(e?.type==="string")return e.validation}function $QE(e){if(e?.type==="double")return e.validation}function GQE(e){if(e?.type==="integer")return e.validation}function vB_(e){if(e<=Gy.SAMPLE_STRINGS.length){let t=Gy.SAMPLE_STRINGS[e-1];if(t)return t;throw new Error(`Unexpected undefined value in SAMPLE_STRINGS at index ${e-1}`)}return Gy.SAMPLE_STRINGS[Gy.SAMPLE_STRINGS.length-1]+".".repeat(e-Gy.SAMPLE_STRINGS.length)}function QQE({fieldName:e,default_:t,validation:r}){if(t!=null)return{type:"success",example:Rd.string({original:t}),jsonExample:t};if(r){let n=r.minLength,a=r.maxLength;if(n){let u=vB_(n);return{type:"success",example:Rd.string({original:u}),jsonExample:u}}else if(a){let u=vB_(a);return{type:"success",example:Rd.string({original:u}),jsonExample:u}}}let i=e??Gy.STRING;return{type:"success",example:Rd.string({original:i}),jsonExample:i}}function JQE({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Rd.double(r),jsonExample:r};if(i)return{type:"success",example:Rd.double(i),jsonExample:i}}return{type:"success",example:Rd.double(Gy.DOUBLE),jsonExample:Gy.DOUBLE}}function KQE({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Rd.integer(r),jsonExample:r};if(i)return{type:"success",example:Rd.integer(i),jsonExample:i}}return{type:"success",example:Rd.integer(Gy.INT),jsonExample:Gy.INT}}function x9n({fieldName:e,typeDeclarations:t,typeDeclaration:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){switch(r.shape.type){case"alias":{let u=Gq({fieldName:e,typeDeclarations:t,typeReference:r.shape.aliasOf,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(u.type==="failure")return u;let{example:l,jsonExample:d}=u;return{type:"success",example:Iw.alias({value:l}),jsonExample:d}}case"enum":{let u=r.shape.values[0];return u==null?{type:"failure",message:"No enum values present"}:{type:"success",example:Iw.enum({value:u.name}),jsonExample:u.name.wireValue}}case"object":{let u={},l=[];if(r.shape.extends!=null)for(let c of r.shape.extends){let b=t[c.typeId];if(b==null)continue;let g=x9n({fieldName:e,typeDeclaration:b,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});g!=null&&g.type==="success"&&g.example.type==="object"&&(Object.assign(u,g.jsonExample),l.push(...g.example.properties))}let d=YQE({fieldName:e,typeDeclaration:r,objectTypeDeclaration:r.shape,typeDeclarations:t,currentDepth:n,maxDepth:i,skipOptionalProperties:a});if(d.type==="failure")return d;let{example:s,jsonExample:o}=d;return{type:"success",example:Iw.object({...s,properties:[...l,...s.properties]}),jsonExample:Object.assign({},u,o)}}case"undiscriminatedUnion":{let u=0;for(let l of r.shape.members){let d=Gq({fieldName:e,typeReference:l.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(d.type==="failure"){++u;continue}let{example:s,jsonExample:o}=d;return{type:"success",example:Iw.undiscriminatedUnion({index:u,singleUnionType:s}),jsonExample:o}}break}case"union":{let u=r.shape.discriminant,l={};if(r.shape.baseProperties!=null)for(let d of r.shape.baseProperties){let s=Gq({fieldName:d.name.wireValue,typeReference:d.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});s.type==="success"&&(l[d.name.wireValue]=s.jsonExample)}for(let d of r.shape.types){let s=d.shape._visit({noProperties:()=>({type:"success",example:Iw.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:h3.noProperties()}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,...l}}),samePropertiesAsObject:o=>{let c=t[o.typeId];if(c==null)return{type:"failure",message:`Failed to find type declaration with id ${o.typeId}`};let b=x9n({currentDepth:n,maxDepth:i,fieldName:e,typeDeclaration:c,typeDeclarations:t,skipOptionalProperties:a});if(b==null)return{type:"failure",message:"Failed to generate example for type reference"};if(b.type==="failure")return b;let{example:g,jsonExample:O}=b;return{type:"success",example:Iw.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:h3.samePropertiesAsObject({typeId:c.name.typeId,object:g.type==="object"?g:{properties:[]}})}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,...typeof O=="object"?O:{},...l}}},singleProperty:o=>{let c=Gq({currentDepth:n+1,maxDepth:i,fieldName:e,typeReference:o.type,typeDeclarations:t,skipOptionalProperties:a});if(c.type==="failure")return c;let{example:b,jsonExample:g}=c;return{type:"success",example:Iw.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:h3.singleProperty(b)}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,[o.name.wireValue]:g,...l}}},_other:()=>{throw new Error("Encountered unknown union type")}});if(s.type!=="failure")return s}}}return{type:"failure",message:"Failed to generate example for type reference"}}function YQE({fieldName:e,typeDeclaration:t,objectTypeDeclaration:r,typeDeclarations:i,maxDepth:n,currentDepth:a,skipOptionalProperties:u}){let l={},d=[];for(let s of[...r.properties??[],...r.extendedProperties??[]]){let o=Gq({fieldName:s.name.wireValue,typeReference:s.valueType,typeDeclarations:i,currentDepth:a+1,maxDepth:n,skipOptionalProperties:u});if(o.type==="failure"&&!Uir({typeDeclarations:i,typeReference:s.valueType}))return{type:"failure",message:`Failed to generate required property ${s.name.wireValue} b/c ${o.message}`};if(o.type==="failure")continue;let{example:c,jsonExample:b}=o;d.push({name:s.name,originalTypeDeclaration:t.name,value:c}),l[s.name.wireValue]=b}return{type:"success",example:Iw.object({properties:d}),jsonExample:l}}function Gq({fieldName:e,typeReference:t,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){if(n>i)return{type:"failure",message:"Exceeded max depth"};switch(t.type){case"named":{let u=r[t.typeId];if(u==null)return{type:"failure",message:`Failed to find type declaration with id ${t.typeId}`};let l=x9n({fieldName:e,typeDeclaration:u,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(l==null)return{type:"failure",message:"Failed to generate example for type declaration"};if(l.type==="failure")return l;let{example:d,jsonExample:s}=l;return{type:"success",example:{jsonExample:s,shape:Nh.named({shape:d,typeName:u.name})},jsonExample:s}}case"container":{let u=yB_({fieldName:e,containerType:t.container,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(u.type==="failure"){let{example:s,jsonExample:o}=Vir({containerType:t.container});return{type:"success",example:{jsonExample:o,shape:Nh.container(s)},jsonExample:o}}let{example:l,jsonExample:d}=u;return{type:"success",example:{jsonExample:d,shape:Nh.container(l)},jsonExample:d}}case"primitive":{let{jsonExample:u,example:l}=bB_({fieldName:e,primitiveType:t.primitive});return{type:"success",example:{jsonExample:u,shape:Nh.primitive(l)},jsonExample:u}}case"unknown":{let u={key:"value"};return{type:"success",example:{jsonExample:u,shape:Nh.unknown(u)},jsonExample:u}}}}function PKi(e,t){let r=[];for(let i of e){let n=Gq({fieldName:i.name.originalName,currentDepth:0,maxDepth:t.maxDepth??1,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,value:n.example})}return{type:"success",example:r,jsonExample:void 0}}function R9n(e,t){let r=[];for(let i of e){if(t.skipOptionalRequestProperties&&Uir({typeDeclarations:t.typeDeclarations,typeReference:i.valueType}))continue;let n=Gq({fieldName:i.name.name.originalName,currentDepth:0,maxDepth:t.maxDepth??1,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,value:n.example})}return{type:"success",example:r,jsonExample:void 0}}function ako(e,t){let r=[];for(let i of e){if(t.skipOptionalRequestProperties&&Uir({typeDeclarations:t.typeDeclarations,typeReference:i.valueType}))continue;let n=Gq({fieldName:i.name.name.originalName,currentDepth:0,maxDepth:t.maxDepth??10,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,shape:i.allowMultiple?$2.exploded():$2.single(),value:n.example})}return{type:"success",example:r,jsonExample:void 0}}var VPc=gf.primitive({v1:O0.String,v2:Lp.string({default:void 0,validation:void 0})});function ERa({ir:e,endpoint:t,service:r,typeDeclarations:i,skipOptionalRequestProperties:n,generationResponse:a}){let u={name:void 0,endpointHeaders:[],endpointPathParameters:[],queryParameters:[],servicePathParameters:[],serviceHeaders:[],rootPathParameters:[],request:void 0,response:RT.ok(kC.body(void 0)),docs:void 0},l=PKi(t.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(l.type==="failure")return l;u.endpointPathParameters=l.example;let d=PKi(r.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(d.type==="failure")return d;u.servicePathParameters=d.example;let s=PKi(e.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(s.type==="failure")return s;u.rootPathParameters=s.example;let o=ako(t.queryParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:10});if(o.type==="failure")return o;u.queryParameters=o.example;let c=R9n(t.headers,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(c.type==="failure")return c;u.endpointHeaders=c.example;let b=R9n(r.headers,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(b.type==="failure")return b;if(u.serviceHeaders=b.example,t.requestBody!=null)switch(t.requestBody.type){case"bytes":return{type:"failure",message:"Bytes request unsupported"};case"fileUpload":return{type:"failure",message:"File upload unsupported"};case"inlinedRequestBody":{let g={},O=[];if(t.requestBody.extends!=null)for(let m of t.requestBody.extends){let P=i[m.typeId];if(P==null)throw new Error(`Failed to find extended type declaration with id ${m.typeId}`);let E=x9n({typeDeclaration:P,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});E!=null&&E.type==="success"&&Object.assign(g,E.jsonExample)}for(let m of[...t.requestBody.properties??[],...t.requestBody.extendedProperties??[]]){let P=Gq({fieldName:m.name.wireValue,typeReference:m.valueType,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});if(P.type==="failure"&&!Uir({typeDeclarations:i,typeReference:m.valueType}))return{type:"failure",message:`Failed to generate required property ${m.name.wireValue} b/c ${P.message}`};if(P.type==="failure")continue;let{example:E,jsonExample:q}=P;O.push({name:m.name,originalTypeDeclaration:void 0,value:E}),g[m.name.wireValue]=q}u.request=zQ.inlinedRequestBody({jsonExample:g,properties:O});break}case"reference":{let g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.requestBody.requestBodyType,skipOptionalProperties:n});if(g.type==="failure")return g;let{example:O}=g;u.request=zQ.reference(O);break}default:mo(t.requestBody)}if(a.type==="success"&&t.response?.body!=null)switch(t.response.body.type){case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":{let g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.responseBodyType,skipOptionalProperties:!1});if(g.type==="failure")return g;let{example:O,jsonExample:m}=g;u.response=RT.ok(kC.body({...O,jsonExample:m}));break}case"streamParameter":{let g;switch(t.response.body.nonStreamResponse.type){case"bytes":return{type:"failure",message:"Bytes unsupported"};case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.nonStreamResponse.value.responseBodyType,skipOptionalProperties:!1});break;case"text":g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:VPc,skipOptionalProperties:!1});break;default:mo(t.response.body.nonStreamResponse)}if(g.type==="failure")return g;let{example:O,jsonExample:m}=g;u.response=RT.ok(kC.body({...O,jsonExample:m}));break}case"streaming":{let g;switch(t.response.body.value.type){case"sse":{if(g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),g.type==="failure")return g;let{example:O,jsonExample:m}=g;u.response=RT.ok(kC.sse([{data:{...O,jsonExample:m},event:""}]));break}case"json":{if(g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),g.type==="failure")return g;let{example:O,jsonExample:m}=g;u.response=RT.ok(kC.stream([{...O,jsonExample:m}]));break}case"text":{if(g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:VPc,skipOptionalProperties:!1}),g.type==="failure")return g;let{example:O,jsonExample:m}=g;u.response=RT.ok(kC.stream([{...O,jsonExample:m}]));break}default:mo(t.response.body.value)}break}case"text":{let g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:VPc,skipOptionalProperties:!1});if(g.type==="failure")return g;let{example:O,jsonExample:m}=g;u.response=RT.ok(kC.body({...O,jsonExample:m}));break}case"bytes":return{type:"failure",message:"Bytes unsupported"};default:mo(t.response.body)}else if(a.type==="error")if(a.declaration.type==null)u.response=RT.error({body:void 0,error:a.declaration.name});else{let g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:a.declaration.type,skipOptionalProperties:n});if(g.type==="failure")return g;let{example:O}=g;u.response=RT.error({body:O,error:a.declaration.name})}try{return{type:"success",example:{id:DRa(u),url:XQE(t,u),...u},jsonExample:void 0}}catch(g){return{type:"failure",message:`Parse failure with exceptions ${g}`}}}function XQE(e,t){let r={};[...t.rootPathParameters,...t.servicePathParameters,...t.endpointPathParameters].forEach(n=>{let a=n.value.jsonExample,u=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=u});let i=e.fullPath.head+e.fullPath.parts.map(n=>r[n.pathParameter]+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function OB_({ir:e,channel:t,typeDeclarations:r,skipOptionalRequestProperties:i}){let n={name:void 0,pathParameters:[],headers:[],queryParameters:[],messages:[],docs:void 0},a=PKi(t.pathParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(a.type==="failure")return a;n.pathParameters.push(...a.example);let u=PKi(e.pathParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(u.type==="failure")return u;n.pathParameters.push(...u.example);let l=ako(t.queryParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:10});if(l.type==="failure")return l;n.queryParameters=l.example;let d=R9n(t.headers,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(d.type==="failure")return d;n.headers.push(...d.example);let s=R9n(e.headers,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(s.type==="failure")return s;n.headers.push(...s.example);let c=t.messages.filter(O=>O.origin==="client")[0];if(c!=null){let O=gB_({message:c,typeDeclarations:r,skipOptionalRequestProperties:i});O!=null&&n.messages.push({type:c.type,body:O})}let g=t.messages.filter(O=>O.origin==="server")[0];if(g!=null){let O=gB_({message:g,typeDeclarations:r,skipOptionalRequestProperties:i});O!=null&&n.messages.push({type:g.type,body:O})}return{type:"success",example:{...n,url:ZQE(t,n)},jsonExample:void 0}}function gB_({message:e,typeDeclarations:t,skipOptionalRequestProperties:r}){if(e.body.type==="inlinedBody")return;let i=Gq({currentDepth:0,maxDepth:10,typeDeclarations:t,typeReference:e.body.bodyType,skipOptionalProperties:r});if(i.type==="success")return JEe.reference(i.example)}function ZQE(e,t){let r={};[...t.pathParameters].forEach(n=>{let a=n.value.jsonExample,u=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=u});let i=e.path.head+e.path.parts.map(n=>r[n.pathParameter]+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function N9n(e){let t=e?.userSpecifiedExamples??{},r=e?.autogeneratedExamples??{},i=Object.values(t)[0],n=Object.values(r)[0];return{userExample:i,autoExample:n}}function VAi(e){let t=e?.userSpecifiedExamples??{},r=e?.autogeneratedExamples??{};return{userExamples:t,autoExamples:r}}function mB_({service:e,endpoint:t,typeDeclarations:r,skipOptionalRequestProperties:i}){let n={pathParameters:{},queryParameters:{},headers:{}};for(let a of t.pathParameters){let{userExample:u,autoExample:l}=N9n(a.v2Examples);u!==void 0?n.pathParameters[a.name.originalName]=u:l!==void 0&&(n.pathParameters[a.name.originalName]=l)}for(let a of t.queryParameters){let{userExample:u,autoExample:l}=N9n(a.v2Examples);if(u!==void 0)n.queryParameters[a.name.name.originalName]=u;else if(l!==void 0){if(i&&Uir({typeReference:a.valueType,typeDeclarations:r}))continue;n.queryParameters[a.name.name.originalName]=l}}for(let a of t.headers){let{userExample:u,autoExample:l}=N9n(a.v2Examples);if(u!==void 0)n.headers[a.name.name.originalName]=u;else if(l!==void 0){if(i&&Uir({typeReference:a.valueType,typeDeclarations:r}))continue;n.headers[a.name.name.originalName]=l}}return n}function PB_({endpoint:e,service:t,typeDeclarations:r,skipOptionalRequestProperties:i}){let{pathParameters:n,queryParameters:a,headers:u}=mB_({service:t,endpoint:e,typeDeclarations:r,skipOptionalRequestProperties:i}),l={},d={},s={endpoint:{method:e.method,path:kQE(e)},baseUrl:void 0,environment:e.baseUrl,auth:void 0,pathParameters:n,queryParameters:a,headers:u,requestBody:void 0,docs:void 0};if(e.requestBody!=null)switch(e.requestBody.type){case"bytes":break;case"fileUpload":{let{userExamples:o,autoExamples:c}=VAi(e.requestBody.v2Examples);for(let[b,g]of Object.entries(o))l[b]={...s,requestBody:g};for(let[b,g]of Object.entries(c))d[b]={...s,requestBody:g};break}case"inlinedRequestBody":{let{userExamples:o,autoExamples:c}=VAi(e.requestBody.v2Examples);for(let[b,g]of Object.entries(o))l[b]={...s,requestBody:g};for(let[b,g]of Object.entries(c))d[b]={...s,requestBody:g};break}case"reference":{let{userExamples:o,autoExamples:c}=VAi(e.requestBody.v2Examples);for(let[b,g]of Object.entries(o))l[b]={...s,requestBody:g};for(let[b,g]of Object.entries(c))d[b]={...s,requestBody:g};break}default:mo(e.requestBody)}return{userRequestExamples:l,autoRequestExamples:d,baseExample:s}}function kQE(e){let t={};[...e.pathParameters,...e.allPathParameters].forEach(i=>{let{userExample:n,autoExample:a}=N9n(i.v2Examples),u=n??a,l;u==null?l=i.name.originalName:l=typeof u=="string"?u:JSON.stringify(u),t[i.name.originalName]=l});let r=e.fullPath.head+e.fullPath.parts.map(i=>t[i.pathParameter]+i.tail).join("");return r.startsWith("/")||r===""?r:`/${r}`}function jB_({endpoint:e}){let t={},r={},i={statusCode:e.response?.statusCode,body:void 0,docs:void 0};if(e.response==null)return{userResponseExamples:{},autoResponseExamples:{},baseExample:i};if(e.response.body==null)return e.source?.type==="openrpc"?{userResponseExamples:{},autoResponseExamples:{},baseExample:{...i,body:I9.json(MRa(null))}}:{userResponseExamples:{},autoResponseExamples:{},baseExample:i};switch(e.response.body.type){case"bytes":break;case"fileDownload":break;case"text":{let n=e.response.body,{userExamples:a,autoExamples:u}=VAi(n.v2Examples);for(let[l,d]of Object.entries(a)){let s=e.source?.type==="openrpc"?MRa(d):d;t[l]={...i,body:I9.json(s)}}for(let[l,d]of Object.entries(u)){let s=e.source?.type==="openrpc"?MRa(d):d;r[l]={...i,body:I9.json(s)}}break}case"json":{let n=e.response.body.value;if(n.type==="response"){let{userExamples:a,autoExamples:u}=VAi(n.v2Examples);for(let[l,d]of Object.entries(a)){let s=e.source?.type==="openrpc"?MRa(d):d;t[l]={...i,body:I9.json(s)}}for(let[l,d]of Object.entries(u)){let s=e.source?.type==="openrpc"?MRa(d):d;r[l]={...i,body:I9.json(s)}}}break}case"streaming":{let n=e.response.body.value;if(n.type==="json"){let{userExamples:a,autoExamples:u}=VAi(n.v2Examples);for(let[l,d]of Object.entries(a))t[l]={...i,body:I9.stream([d])};for(let[l,d]of Object.entries(u))r[l]={...i,body:I9.stream([d])}}break}case"streamParameter":break;default:mo(e.response.body)}return{userResponseExamples:t,autoResponseExamples:r,baseExample:i}}function MRa(e,t=1){return{id:t,jsonrpc:"2.0",result:e}}function wB_({endpoint:e,service:t,typeDeclarations:r,skipOptionalRequestProperties:i}){let n={},a={},{userRequestExamples:u,autoRequestExamples:l,baseExample:d}=PB_({endpoint:e,service:t,typeDeclarations:r,skipOptionalRequestProperties:i}),{userResponseExamples:s,autoResponseExamples:o,baseExample:c}=jB_({endpoint:e}),b=Object.keys(l)[0],g=Object.values(l)[0],O=Object.values(o)[0];for(let[m,P]of Object.entries(u))n[m]={request:P,response:s[m]??O??c,codeSamples:void 0};for(let[m,P]of Object.entries(s))n[m]={request:u[m]??g??d,response:P,codeSamples:void 0};return Object.keys(n).length===0&&(a[b??T_(`${e.name.originalName}_example`)]={request:g??d,response:O??c,codeSamples:void 0}),{userFullExamples:n,autoFullExamples:a}}function ARa({ir:e,exampleGeneration:t}){for(let[r,i]of Object.entries(e.services))for(let n of i.endpoints){if(n.userSpecifiedExamples.length>0&&t?.skipAutogenerationIfManualExamplesExist===!0)continue;let a=ERa({ir:e,service:i,endpoint:n,typeDeclarations:e.types,skipOptionalRequestProperties:!t?.includeOptionalRequestPropertyExamples,generationResponse:{type:"success"}});if(a.type==="failure")continue;let{example:u}=a;n.autogeneratedExamples=[{example:u}]}for(let[r,i]of Object.entries(e.websocketChannels??{})){if(i.examples.length>0&&t?.skipAutogenerationIfManualExamplesExist===!0)continue;let n=OB_({ir:e,channel:i,typeDeclarations:e.types,skipOptionalRequestProperties:!t?.includeOptionalRequestPropertyExamples});if(n.type==="failure")continue;let{example:a}=n;i.examples=[...i.examples,a]}return e}function WPc({ir:e,exampleGeneration:t}){for(let[r,i]of Object.entries(e.services))for(let n of i.endpoints){n.v2Examples==null&&(n.v2Examples={userSpecifiedExamples:{},autogeneratedExamples:{}});let{userFullExamples:a,autoFullExamples:u}=wB_({service:i,endpoint:n,typeDeclarations:e.types,skipOptionalRequestProperties:!t?.includeOptionalRequestPropertyExamples});if(Object.keys(n.v2Examples.userSpecifiedExamples).length>0){if(Object.values(n.v2Examples.userSpecifiedExamples).some(d=>d.request!=null||d.response!=null))continue;let l=Object.values(n.v2Examples.userSpecifiedExamples)[0]?.codeSamples;for(let[d,s]of Object.entries(u))u[d]={...s,codeSamples:l};for(let[d,s]of Object.entries(a))a[d]={...s,codeSamples:l}}n.v2Examples.autogeneratedExamples=u,n.v2Examples.userSpecifiedExamples=a}return e}function oko(e,t,r){let{environments:i,changedBaseUrlIds1:n,changedBaseUrlIds2:a}=tJE(e.environments,t.environments,r),{services:u,websocketChannels:l}=rJE(e,t,n,a);return{apiName:e.apiName,basePath:e.basePath,selfHosted:e.selfHosted&&t.selfHosted,apiDisplayName:e.apiDisplayName??t.apiDisplayName,apiDocs:e.apiDocs??t.apiDocs,auth:e.auth??t.auth,headers:[...e.headers??[],...t.headers??[]],environments:i,types:{...e.types??{},...t.types??{}},constants:{...e.constants??{},...t.constants??{}},errors:{...e.errors??{},...t.errors??{}},services:u,webhookGroups:{...e.webhookGroups??{},...t.webhookGroups??{}},subpackages:eJE(e.subpackages,t.subpackages),websocketChannels:l,rootPackage:{service:e.rootPackage.service??t.rootPackage.service,types:[...e.rootPackage.types??[],...t.rootPackage.types??[]],errors:[...e.rootPackage.errors??[],...t.rootPackage.errors??[]],subpackages:[...e.rootPackage.subpackages??[],...(t.rootPackage.subpackages??[]).filter(d=>!e.rootPackage.subpackages?.includes(d))],fernFilepath:e.rootPackage.fernFilepath??t.rootPackage.fernFilepath,webhooks:e.rootPackage.webhooks??t.rootPackage.webhooks,websocket:e.rootPackage.websocket??t.rootPackage.websocket,hasEndpointsInTree:e.rootPackage.hasEndpointsInTree||t.rootPackage.hasEndpointsInTree,navigationConfig:e.rootPackage.navigationConfig??t.rootPackage.navigationConfig,docs:e.rootPackage.docs??t.rootPackage.docs},fdrApiDefinitionId:e.fdrApiDefinitionId??t.fdrApiDefinitionId,apiVersion:e.apiVersion??t.apiVersion,idempotencyHeaders:[...e.idempotencyHeaders??[],...t.idempotencyHeaders??[]],pathParameters:[...e.pathParameters??[],...t.pathParameters??[]],errorDiscriminationStrategy:e.errorDiscriminationStrategy??t.errorDiscriminationStrategy,variables:[...e.variables??[],...t.variables??[]],serviceTypeReferenceInfo:e.serviceTypeReferenceInfo??t.serviceTypeReferenceInfo,readmeConfig:e.readmeConfig??t.readmeConfig,sourceConfig:e.sourceConfig??t.sourceConfig,publishConfig:e.publishConfig??t.publishConfig,dynamic:e.dynamic??t.dynamic,sdkConfig:e.sdkConfig??t.sdkConfig}}function eJE(e,t){let r=e;for(let[i,n]of Object.entries(t))r[i]==null?r[i]=n:r[i]={name:n.name,fernFilepath:n.fernFilepath,hasEndpointsInTree:r[i].hasEndpointsInTree||n.hasEndpointsInTree,navigationConfig:r[i].navigationConfig??n.navigationConfig,docs:r[i].docs??n.docs,service:r[i].service??n.service,subpackages:[...r[i].subpackages??[],...(n.subpackages??[]).filter(a=>!r[i]?.subpackages?.includes(a))],webhooks:r[i].webhooks??n.webhooks,websocket:r[i].websocket??n.websocket,errors:[...r[i].errors??[],...n.errors??[]],types:[...r[i].types??[],...n.types??[]]};return r}function tJE(e,t,r){if(e==null&&t==null)return{environments:void 0,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(t==null)return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(e==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(JSON.stringify(e)===JSON.stringify(t))return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let i=SB_(e),n=SB_(t);if(i&&n&&e.environments.type==="singleBaseUrl"&&t.environments.type==="singleBaseUrl")return{environments:{defaultEnvironment:e.defaultEnvironment??t.defaultEnvironment,environments:cx.singleBaseUrl({environments:[...e.environments.environments,...t.environments.environments]})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let a=i?t.defaultEnvironment:e.defaultEnvironment,u=e.environments,l=t.environments;if(u.type==="singleBaseUrl"&&l.type==="singleBaseUrl"){let d=i?l:u,s=i?u:l,o={},{deconflictedEnvironments2:c,changedBaseUrlIds2:b}=iJE(d,s,r);if(d.environments[0]==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let g="Base",O=r.generateName("Base");return d.environments.forEach(m=>{o[m.id]=g}),{environments:{defaultEnvironment:a,environments:cx.multipleBaseUrls({baseUrls:[{id:g,name:O},...c.environments.map(m=>({id:m.id,name:m.name}))],environments:d.environments.map(m=>({id:m.id,name:m.name,urls:{[g]:m.url,...Object.fromEntries(c.environments.map(P=>[P.id,P.url]))},docs:void 0}))})},changedBaseUrlIds1:i?b:o,changedBaseUrlIds2:i?o:b}}if(u.type==="multipleBaseUrls"&&l.type==="singleBaseUrl"||u.type==="singleBaseUrl"&&l.type==="multipleBaseUrls"){let d=u.type==="singleBaseUrl"?u:l,s=u.type==="multipleBaseUrls"?u:l,{deconflictedEnvironments1:o,changedBaseUrlIds1:c}=nJE(d,s,r);return{environments:{defaultEnvironment:a,environments:cx.multipleBaseUrls({baseUrls:[...s.baseUrls,...o.environments.map(b=>({id:b.id,name:b.name}))],environments:s.environments.map(b=>({...b,urls:{...b.urls,...Object.fromEntries(o.environments.map(g=>[g.id,g.url]))}}))})},changedBaseUrlIds1:u.type==="singleBaseUrl"?c:void 0,changedBaseUrlIds2:u.type==="singleBaseUrl"?void 0:c}}if(u.type==="multipleBaseUrls"&&l.type==="multipleBaseUrls"){let{deconflictedEnvironments:d,changedBaseUrlIds:s}=aJE(u,l,r);return{environments:{defaultEnvironment:a,environments:cx.multipleBaseUrls({baseUrls:[...u.baseUrls,...d.baseUrls],environments:u.environments.flatMap(o=>d.environments.map(c=>({...o,urls:{...o.urls,...c.urls}})))})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:s}}return{environments:e??t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0}}function rJE(e,t,r,i){if(r!=null)for(let[u,l]of Object.entries(r)){for(let d of Object.values(e.services))for(let s of Object.values(d.endpoints))s.baseUrl==u&&(s.baseUrl=l),s.v2BaseUrls?.includes(u)&&(s.v2BaseUrls=s.v2BaseUrls.map(o=>o===u?l:o));for(let d of Object.values(e.websocketChannels??{}))d.baseUrl==u&&(d.baseUrl=l)}if(i!=null)for(let[u,l]of Object.entries(i)){for(let d of Object.values(t.services))for(let s of Object.values(d.endpoints))s.baseUrl==u&&(s.baseUrl=l),s.v2BaseUrls?.includes(u)&&(s.v2BaseUrls=s.v2BaseUrls.map(o=>o===u?l:o));for(let d of Object.values(t.websocketChannels??{}))d.baseUrl==u&&(d.baseUrl=l)}let n=e.services;for(let[u,l]of Object.entries(t.services))n[u]==null?n[u]=l:n[u]={availability:l.availability,name:l.name,displayName:l.displayName,basePath:l.basePath,endpoints:[...n[u].endpoints??[],...l.endpoints],pathParameters:[...n[u].pathParameters??[],...l.pathParameters??[]],headers:[...n[u].headers??[],...l.headers??[]],encoding:l.encoding,transport:l.transport};let a={...e.websocketChannels??{},...t.websocketChannels??{}};return{services:n,websocketChannels:a}}function iJE(e,t,r){let i={},n=new Set(e.environments.map(s=>s.id)),a=new Set(e.environments.map(s=>s.name)),u=new Map(e.environments.map(s=>[s.url,s.id])),l=t.environments.filter(s=>{let o=u.get(s.url);return o!=null?(i[s.id]=o,!1):!0}).map(s=>{if(n.has(s.id)||a.has(s.name)){let o=HPc(s.id,n);return i[s.id]=o,{...s,id:o,name:r.generateName(o)}}return s});return{deconflictedEnvironments2:cx.singleBaseUrl({environments:l}),changedBaseUrlIds2:i}}function nJE(e,t,r){let i={},n=new Set(t.baseUrls.map(d=>d.id)),a=new Set(t.baseUrls.map(d=>d.name)),u=e.environments.map(d=>{if(n.has(d.id)||a.has(d.name)){let s=HPc(d.id,n);return i[d.id]=s,{...d,id:s,name:r.generateName(s)}}return d});return{deconflictedEnvironments1:cx.singleBaseUrl({environments:u}),changedBaseUrlIds1:i}}function aJE(e,t,r){let i={},n=new Set(e.baseUrls.map(s=>s.id)),a=new Set(e.baseUrls.map(s=>s.name)),u=t.baseUrls.map(s=>{if(n.has(s.id)||a.has(s.name)){let o=HPc(s.id,n);return i[s.id]=o,{...s,id:o,name:r.generateName(o)}}return s}),l=t.environments.map(s=>({...s,urls:Object.fromEntries(Object.entries(s.urls).map(([o,c])=>[i[o]??o,c]))}));return{deconflictedEnvironments:cx.multipleBaseUrls({baseUrls:u,environments:l}),changedBaseUrlIds:i}}function SB_(e){return e.environments.type==="singleBaseUrl"?e.environments.environments.some(t=>t.url&&(t.url.startsWith("ws://")||t.url.startsWith("wss://"))):e.environments.type==="multipleBaseUrls"?e.environments.environments.some(t=>Object.values(t.urls).some(r=>r&&(r.startsWith("ws://")||r.startsWith("wss://")))):!1}function HPc(e,t){let r=e,i=1;for(;t.has(r);)r=`${e}-${i}`,i++;return r}function GPc({rawApiFileSchema:e,casingsGenerator:t}){if(e.auth==null)return{docs:void 0,requirement:pRe.All,schemes:[]};let r=typeof e.auth!="string"?e.auth.docs:void 0;return BHi(e.auth,{single:i=>{let n=DB_({reference:i,authSchemeDeclarations:e["auth-schemes"],casingsGenerator:t});return{docs:r,requirement:pRe.All,schemes:[n]}},any:({any:i})=>({docs:r,requirement:pRe.Any,schemes:i.map(n=>DB_({reference:n,authSchemeDeclarations:e["auth-schemes"],casingsGenerator:t}))})})}function DB_({reference:e,authSchemeDeclarations:t,casingsGenerator:r}){let i=(a,u)=>{let l=t?.[a];if(l==null)throw new Error("Unknown auth scheme: "+a);return BDa(l,{header:d=>CB.header({docs:u,name:r.generateNameAndWireValue({name:d.name??a,wireValue:d.header}),valueType:gf.primitive({v1:O0.String,v2:Lp.string({default:void 0,validation:void 0})}),prefix:d.prefix,headerEnvVar:d.env}),basic:d=>EB_({casingsGenerator:r,docs:u,rawScheme:d}),bearer:d=>$Pc({casingsGenerator:r,docs:u,rawScheme:d}),oauth:d=>$Pc({casingsGenerator:r,docs:u,rawScheme:void 0})})},n=typeof e=="string"?e:e.scheme;switch(n){case"bearer":case"oauth":return $Pc({casingsGenerator:r,docs:void 0,rawScheme:void 0});case"basic":return EB_({casingsGenerator:r,docs:void 0,rawScheme:void 0});default:return i(n,typeof e!="string"?e.docs:void 0)}}function $Pc({casingsGenerator:e,docs:t,rawScheme:r}){return CB.bearer({docs:t,token:e.generateName(r?.token?.name??"token"),tokenEnvVar:r?.token?.env})}function EB_({casingsGenerator:e,docs:t,rawScheme:r}){return CB.basic({docs:t,username:e.generateName(r?.username?.name??"username"),usernameEnvVar:r?.username?.env,password:e.generateName(r?.password?.name??"password"),passwordEnvVar:r?.password?.env})}function qRa({rawApiFileSchema:{"default-environment":e,environments:t},casingsGenerator:r}){if(t==null)return;let i=Object.values(t)[0];if(i!=null)return{environmentsConfig:{defaultEnvironment:e??void 0,environments:$kt(i,{singleBaseUrl:()=>cx.singleBaseUrl(oJE({environments:t,casingsGenerator:r})),multipleBaseUrls:n=>cx.multipleBaseUrls(uJE({baseUrls:Object.keys(n.urls),environments:t,casingsGenerator:r}))})},audiences:{...Object.fromEntries(Object.entries(t).map(([n,a])=>[n,$kt(a,{singleBaseUrl:u=>[...typeof u=="string"?[]:u.audiences??[]],multipleBaseUrls:u=>[...u.audiences??[]]})]))}}}function oJE({environments:e,casingsGenerator:t}){return{environments:Object.entries(e).map(([r,i])=>$kt(i,{singleBaseUrl:n=>({docs:typeof n=="string"?void 0:n.docs,id:r,name:t.generateName(r),url:MB_(typeof n=="string"?n:n.url)}),multipleBaseUrls:()=>{throw new Error(`Environment ${r} has multiple base URLs`)}}))}}function uJE({baseUrls:e,environments:t,casingsGenerator:r}){return{baseUrls:e.map(i=>({id:i,name:r.generateName(i)})),environments:Object.entries(t).map(([i,n])=>$kt(n,{multipleBaseUrls:a=>({docs:a.docs,id:i,name:r.generateName(i),urls:dd(a.urls,u=>MB_(u))}),singleBaseUrl:()=>{throw new Error(`Environment ${i} does not have multiple base URLs`)}}))}}function MB_(e){return e.endsWith("/")?e.slice(0,-1):e}function NMe(e){return e.allParts.map(t=>t.originalName).join("/")}var Pm={generateTypeId:e=>`type_${NMe(e.fernFilepath)}:${e.name.originalName}`,generateErrorId:e=>`error_${NMe(e.fernFilepath)}:${e.name.originalName}`,generateServiceId:e=>`service_${NMe(e.fernFilepath)}`,generateServiceIdFromFernFilepath:e=>`service_${NMe(e)}`,generateSubpackageId:e=>`subpackage_${NMe(e)}`,generateEndpointId:(e,t)=>{let r=NMe(e.fernFilepath),i=t.name.originalName;return`endpoint_${r}.${i}`},generateWebhookGroupId:e=>`webhooks_${NMe(e)}`,generateWebhookId:(e,t)=>`webhooks_${NMe(e)}.${t}`,generateWebSocketChannelId:e=>`channel_${NMe(e)}`};function F9n(e){return e.type!=null}var uko=class{environments=new Set;types=new Set;properties;errors=new Set;services=new Set;endpoints=new Set;requestProperties;queryParameters;webhooks=new Set;webhookPayloadProperties;channels=new Set;subpackages=new Set;constructor({types:t,properties:r,errors:i,environments:n,services:a,endpoints:u,webhooks:l,subpackages:d,queryParameters:s,requestProperties:o,webhookPayloadProperties:c,channels:b}){this.environments=n,this.types=t,this.properties=r,this.errors=i,this.services=a,this.endpoints=u,this.webhooks=l,this.webhookPayloadProperties=c,this.subpackages=d,this.requestProperties=o,this.queryParameters=s,this.channels=b}hasTypeId(t){return this.types.has(t)}hasErrorId(t){return this.errors.has(t)}hasServiceId(t){return this.services.has(t)}hasSubpackageId(t){return this.subpackages.has(t)}hasType(t){let r=Pm.generateTypeId(t.name);return this.types.has(r)}hasProperty(t,r){let i=this.properties[t];return i==null?!0:i.has(r)}hasError(t){let r=Pm.generateErrorId(t.name);return this.errors.has(r)}hasService(t){let r=Pm.generateServiceId(t.name);return this.services.has(r)}hasEnvironmentId(t){return this.environments.has(t)}hasEndpoint(t){return this.endpoints.has(t.id)}hasRequestProperty(t,r){let i=this.requestProperties[t];return i==null?!0:i.has(r)}hasQueryParameter(t,r){let i=this.queryParameters[t];return i==null?!0:i.has(r)}hasSubpackage(t){return this.subpackages.has(t)}hasWebhook(t){return t.id?this.webhooks.has(t.id):!0}hasChannel(t){return t.name.originalName?this.channels.has(t.name.originalName):!0}hasWebhookPayloadProperty(t,r){let i=this.webhookPayloadProperties[t];return i==null?!0:i.has(r)}};function jKi(e){let t={};for(let[r,i]of Object.entries(e))if(typeof i!="string")for(let n of i.audiences??[])t[n]==null&&(t[n]=new Set),t[n]?.add(r);return t}var wKi=class{types={};properties={};queryParameters={};requestProperties={};webhookProperties={};errors={};endpoints={};webhooks={};channels={};audiences;typesReferencedByService={};environmentsNeededForAudience=new Set;typesNeededForAudience=new Set;servicesNeededForAudience=new Set;endpointsNeededForAudience=new Set;webhooksNeededForAudience=new Set;channelsNeededForAudience=new Set;subpackagesNeededForAudience=new Set;constructor(t){this.audiences=sJE(t)}addType({declaredTypeName:t,descendantTypeIds:r,descendantFilepaths:i,descendantTypeIdsByAudience:n,propertiesByAudience:a}){let u=Pm.generateTypeId(t),l={typeId:u,allDescendants:r,descendantsByAudience:n,referencedSubpackages:i};this.types[u]=l,this.typesReferencedByService[u]==null&&(this.typesReferencedByService[u]=new Set),this.properties[u]={typeId:u,propertiesByAudience:a}}markTypeForAudiences(t,r){let i=Pm.generateTypeId(t);this.hasAudience(r)&&(this.typesNeededForAudience.add(i),this.addSubpackages(t.fernFilepath),this.types[i]?.referencedSubpackages.forEach(n=>{this.addSubpackages(n)}))}markEnvironmentForAudiences(t,r,i){t&&(this.hasAudience(r)||i)&&this.environmentsNeededForAudience.add(t.id)}getTypesReferencedByService(){for(let t of Object.values(this.endpoints))for(let r of t.referencedTypes)this.markTypeForService(r,t.serviceId);return this.typesReferencedByService}addError(t){let r=Pm.generateErrorId(t.name),i=new Set,n=new Set;t.type!=null&&jR(t.type,i,n);let a={errorId:r,referencedTypes:i,referencedSubpackages:n};this.errors[r]=a}addEndpoint(t,r,i){let n=Pm.generateServiceId(t.name),a=r.id,u=new Set,l=new Set,d=new Set;for(let s of[...t.headers,...r.headers])jR(s.valueType,u,d);for(let s of[...t.pathParameters,...r.pathParameters])jR(s.valueType,u,d);for(let s of r.queryParameters)jR(s.valueType,u,d);if(i!=null&&i.request!=null&&typeof i.request!="string"){let s=jKi(i.request["query-parameters"]??{});this.queryParameters[a]={endpointId:a,parametersByAudience:s}}r.requestBody!=null&&ZC._visit(r.requestBody,{inlinedRequestBody:s=>{for(let o of s.extends)sko(o,u,d);for(let o of s.properties)jR(o.valueType,u,d);if(i!=null&&typeof i.request=="object"&&typeof i.request.body=="object"&&XC(i.request.body)){let o=jKi(i.request.body.properties??{});this.requestProperties[a]={endpointId:a,propertiesByAudience:o}}},reference:({requestBodyType:s})=>{jR(s,u,d)},fileUpload:({properties:s})=>{for(let o of s)z9._visit(o,{file:Go,bodyProperty:({valueType:c})=>{jR(c,u,d)},_other:()=>{throw new Error("Unknown FileUploadRequestProperty: "+o.type)}})},bytes:()=>{},_other:()=>{throw new Error("Unknown HttpRequestBody: "+r.requestBody?.type)}}),r.response?.body!=null&&gE._visit(r.response.body,{fileDownload:Go,json:s=>{jR(s.responseBodyType,u,d)},streaming:s=>{s._visit({sse:o=>jR(o.payload,u,d),json:o=>jR(o.payload,u,d),text:Go,_other:()=>{throw new Error("Unknown streamingResponse type: "+s.type)}})},streamParameter:s=>{s.streamResponse._visit({sse:o=>jR(o.payload,u,d),json:o=>jR(o.payload,u,d),text:Go,_other:()=>{throw new Error("Unknown streamingResponse type: "+s.streamResponse.type)}}),s.nonStreamResponse.type==="json"&&jR(s.nonStreamResponse.value.responseBodyType,u,d)},text:Go,bytes:Go,_other:()=>{throw new Error("Unknown HttpResponse: "+r.response?.body?.type)}}),r.errors.forEach(s=>{l.add(Pm.generateErrorId(s.error)),d.add(s.error.fernFilepath)}),this.endpoints[a]={endpointId:a,serviceId:n,referencedTypes:u,referencedErrors:l,referencedSubpackages:d}}markEndpointForAudience(t,r,i){if(this.hasAudience(i)){let n=Pm.generateServiceId(t);this.servicesNeededForAudience.add(n),r.forEach(a=>{let u=a.id;this.endpointsNeededForAudience.add(u),this.endpoints[u]?.referencedSubpackages.forEach(l=>{this.addSubpackages(l)})}),this.servicesNeededForAudience.add(n),this.addSubpackages(t.fernFilepath)}}getFilteredSubpackages(){return this.subpackagesNeededForAudience}getFilteredServices(){return this.servicesNeededForAudience}getFilteredEndpoints(){return this.endpointsNeededForAudience}getFilteredChannels(){return this.channelsNeededForAudience}getFilteredWebhooks(){return this.webhooksNeededForAudience}addWebhook(t,r,i){let n=r.id;if(n==null)return;let a=new Set,u=new Set;r.payload!=null&&EW._visit(r.payload,{inlinedPayload:l=>{for(let d of l.extends)sko(d,a,u);for(let d of l.properties)jR(d.valueType,a,u);if(i?.payload!=null&&typeof i.payload=="object"&&!F9n(i.payload)){let d=jKi(i.payload.properties??{});this.webhookProperties[n]={webhookId:n,propertiesByAudience:d}}},reference:({payloadType:l})=>{jR(l,a,u)},_other:()=>{throw new Error("Unknown WebhookPayload: "+r.payload?.type)}}),u.add(t),this.webhooks[n]={webhookId:n,referencedTypes:a,referencedSubpackages:u}}markWebhookForAudiences(t,r,i){let n=r.id;n!=null&&this.hasAudience(i)&&(this.webhooksNeededForAudience.add(n),this.addSubpackages(t))}addChannel(t,r,i,n){if(r==null)return;let a=new Set,u=new Set;for(let l of i.messages)R9._visit(l.body,{reference:({bodyType:d})=>{jR(d,a,u)},inlinedBody:d=>{for(let s of d.extends)sko(s,a,u);for(let s of d.properties)jR(s.valueType,a,u)},_other:()=>{}});u.add(t),this.channels[r]={channelId:r,referencedTypes:a,referencedSubpackages:u}}markChannelForAudiences(t,r,i){r!=null&&this.hasAudience(i)&&(this.channelsNeededForAudience.add(r),this.addSubpackages(t))}build(){let t=new Set,r=new Set;for(let l of this.endpointsNeededForAudience.keys()){let d=this.getEndpointNode(l);for(let s of d.referencedErrors){if(r.has(s))continue;r.add(s);let o=this.getErrorNode(s);this.addReferencedTypes(t,o.referencedTypes)}this.addReferencedTypes(t,d.referencedTypes)}this.addReferencedTypes(t,this.typesNeededForAudience);for(let l of this.webhooksNeededForAudience.keys()){let d=this.getWebhookNode(l);this.addReferencedTypes(t,d.referencedTypes)}for(let l of this.channelsNeededForAudience.keys()){let d=this.getChannelNode(l);this.addReferencedTypes(t,d.referencedTypes)}let i={},n={},a={},u={};if(this.audiences.type==="filtered"){for(let[l,d]of Object.entries(this.properties)){if(!t.has(l))continue;let s=new Set;for(let o of this.audiences.audiences){let c=d.propertiesByAudience[o];c?.forEach(b=>{s.add(b)})}s.size>0&&(i[l]=s),i[l]=s.size>0?s:void 0}for(let[l,d]of Object.entries(this.requestProperties)){if(!this.endpointsNeededForAudience.has(l))continue;let s=new Set;for(let o of this.audiences.audiences){let c=d.propertiesByAudience[o];c?.forEach(b=>{s.add(b)})}n[l]=s.size>0?s:void 0}for(let[l,d]of Object.entries(this.queryParameters)){if(!this.endpointsNeededForAudience.has(l))continue;let s=new Set;for(let o of this.audiences.audiences){let c=d.parametersByAudience[o];c?.forEach(b=>{s.add(b)})}a[l]=s.size>0?s:void 0}for(let[l,d]of Object.entries(this.webhookProperties)){if(!this.webhooksNeededForAudience.has(l))continue;let s=new Set;for(let o of this.audiences.audiences){let c=d.propertiesByAudience[o];c?.forEach(b=>{s.add(b)})}u[l]=s.size>0?s:void 0}}return new uko({types:t,properties:i,errors:r,requestProperties:n,queryParameters:a,environments:this.environmentsNeededForAudience,services:this.servicesNeededForAudience,endpoints:this.endpointsNeededForAudience,webhooks:this.webhooksNeededForAudience,webhookPayloadProperties:u,subpackages:this.subpackagesNeededForAudience,channels:this.channelsNeededForAudience})}markTypeForService(t,r){let i=this.typesReferencedByService[t]??=new Set;if(i.has(r))return;i.add(r);let n=this.getTypeNode(t);for(let a of n.allDescendants)this.markTypeForService(a,r)}addReferencedTypes(t,r){for(let i of r){if(t.has(i))continue;t.add(i);let n=this.getTypeNode(i);if(this.audiences.type==="filtered")for(let a of this.audiences.audiences){let u=n.descendantsByAudience[a];if(u!=null)u.forEach(l=>{t.add(l)});else{n.allDescendants.forEach(l=>{t.add(l)});break}}else n.allDescendants.forEach(a=>{t.add(a)})}}getTypeNode(t){let r=this.types[t];if(r==null)throw new Error(`Failed to find type node with id ${t}`);return r}getErrorNode(t){let r=this.errors[t];if(r==null)throw new Error(`Failed to find error node with id ${t}`);return r}getEndpointNode(t){let r=this.endpoints[t];if(r==null)throw new Error(`Failed to find endpoint node with id ${t}`);return r}getWebhookNode(t){let r=this.webhooks[t];if(r==null)throw new Error(`Failed to find webhook node with id ${t}`);return r}getChannelNode(t){let r=this.channels[t];if(r==null)throw new Error(`Failed to find channel node with id ${t}`);return r}hasNoAudiences(){return this.audiences.type==="none"}hasAudience(t){let r=this.audiences;switch(r.type){case"none":return!0;case"filtered":return t.some(i=>r.audiences.has(i));default:mo(r)}}addSubpackages(t){for(let r=1;r<=t.allParts.length;++r){let i={...t,allParts:t.allParts.slice(0,r)};this.subpackagesNeededForAudience.add(Pm.generateSubpackageId(i))}}};function sJE(e){switch(e.type){case"all":return{type:"none"};case"select":return{type:"filtered",audiences:new Set(e.audiences)};default:mo(e)}}function jR(e,t,r){gf._visit(e,{container:i=>{cJE(i,t,r)},named:i=>{sko(i,t,r)},primitive:Go,unknown:Go,_other:Go})}function sko(e,t,r){t.add(Pm.generateTypeId(e)),r.add(e.fernFilepath)}function cJE(e,t,r){_b._visit(e,{list:i=>{jR(i,t,r)},map:i=>{jR(i.keyType,t,r),jR(i.valueType,t,r)},optional:i=>{jR(i,t,r)},nullable:i=>{jR(i,t,r)},set:i=>{jR(i,t,r)},literal:Go,_other:Go})}var QPc=class{errors;constructor(){this.errors=[]}add(t){this.errors.push({message:t})}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}},TRa=class{errors;constructor(){this.errors=new QPc}async check({from:t,to:r}){let i=this.checkBreaking({from:t,to:r});return{bump:i.isBreaking?"major":"minor",isBreaking:i.isBreaking,errors:i.errors}}checkBreaking({from:t,to:r}){this.checkTypeBreakingChanges({from:t.types,to:r.types}),this.checkErrorsBreakingChanges({from:t.errors,to:r.errors}),this.checkServicesBreakingChanges({from:t.services,to:r.services});let i=this.errors.hasErrors();return{bump:i?"major":"minor",isBreaking:i,errors:this.errors.getErrors()}}checkTypeBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){let a=r[i];if(!a){this.errors.add(`Type "${i}" was removed.`);continue}this.areTypeDeclarationsCompatible({from:n,to:a})||this.errors.add(`Type "${i}" has an incompatible change.`)}}checkErrorsBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){let a=Object.values(r).find(u=>u.name.errorId===n.name.errorId);if(!a){this.errors.add(`Error "${n.name.errorId}" with status code "${n.statusCode}" was removed.`);continue}this.checkErrorBreakingChanges({from:n,to:a})}}checkErrorBreakingChanges({from:t,to:r}){if(t.type!=null){if(r.type==null){this.errors.add(`Error "${t.name.errorId}" with status code "${t.statusCode}" had its type removed.`);return}this.areTypeReferencesCompatible({from:t.type,to:r.type})||this.errors.add(`Error "${t.name.errorId}" type reference changed.`)}this.areDeclaredErrorNamesCompatible({from:t.name,to:r.name})||this.errors.add(`Error "${t.name.errorId}" name changed.`),this.areNameAndWireValuesCompatible({from:t.discriminantValue,to:r.discriminantValue})||this.errors.add(`Error "${t.name.errorId}" discriminant value changed.`)}checkServicesBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){let a=r[i];if(!a){this.errors.add(`Service "${i}" was removed.`);continue}this.checkServiceBreakingChanges({id:i,from:n,to:a})}}checkServiceBreakingChanges({id:t,from:r,to:i}){this.checkHeadersBreakingChanges({id:t,from:r.headers,to:i.headers}),this.checkEndpointsBreakingChanges({id:t,from:r,to:i})}checkEndpointsBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.endpoints.map(u=>[u.id,u])),a=Object.fromEntries(i.endpoints.map(u=>[u.id,u]));for(let[u,l]of Object.entries(n)){let d=a[u];if(!d){this.errors.add(`Endpoint "${u}" was removed.`);continue}this.checkEndpointBreakingChanges({id:u,from:l,to:d})}}checkEndpointBreakingChanges({id:t,from:r,to:i}){this.checkHttpMethodsBreakingChanges({id:t,from:r.method,to:i.method}),this.checkHttpPathsBreakingChanges({id:t,from:r.fullPath,to:i.fullPath}),this.checkPathParametersBreakingChanges({id:t,from:r.pathParameters,to:i.pathParameters}),this.checkQueryParametersBreakingChanges({id:t,from:r.queryParameters,to:i.queryParameters}),this.checkHeadersBreakingChanges({id:t,from:r.headers,to:i.headers}),r.requestBody!=null&&(i.requestBody!=null?this.checkHttpRequestBodiesCompatible({id:t,from:r.requestBody,to:i.requestBody}):this.errors.add(`Request body was removed from endpoint "${r.id}".`)),r.response!=null&&(i.response!=null?this.checkHttpResponseBreakingChanges({id:t,from:r.response,to:i.response}):this.errors.add(`Response was removed from endpoint "${r.id}".`)),(r.pagination!=null&&i.pagination==null||r.pagination==null&&i.pagination!=null)&&this.errors.add(`Pagination was ${r.pagination!=null?"added":"removed"} from endpoint "${r.id}".`)}checkPathParametersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(u=>[u.name.originalName,u])),a=Object.fromEntries(i.map(u=>[u.name.originalName,u]));for(let[u,l]of Object.entries(n)){let d=a[u];if(!d){this.errors.add(`Path parameter "${u}" was removed from endpoint "${t}".`);continue}this.areTypeReferencesCompatible({from:l.valueType,to:d.valueType})||this.errors.add(`Path parameter "${u}" type changed in endpoint "${t}".`)}}checkQueryParametersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(u=>[u.name.wireValue,u])),a=Object.fromEntries(i.map(u=>[u.name.wireValue,u]));this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(n).map(([u,l])=>[u,l.valueType])),to:Object.fromEntries(Object.entries(a).map(([u,l])=>[u,l.valueType]))});for(let[u,l]of Object.entries(n)){let d=a[u];if(!d){this.errors.add(`Query parameter "${u}" was removed from endpoint "${t}".`);continue}this.areTypeReferencesCompatible({from:l.valueType,to:d.valueType})||this.errors.add(`Query parameter "${u}" type changed in endpoint "${t}".`),l.allowMultiple!==d.allowMultiple&&this.errors.add(`Query parameter "${u}" allow-multiple values changed in endpoint "${t}".`)}}checkHeadersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(u=>[u.name.wireValue,u])),a=Object.fromEntries(i.map(u=>[u.name.wireValue,u]));this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(n).map(([u,l])=>[u,l.valueType])),to:Object.fromEntries(Object.entries(a).map(([u,l])=>[u,l.valueType]))});for(let[u,l]of Object.entries(n)){let d=a[u];if(!d){this.errors.add(`Header "${u}" was removed from ${t}.`);continue}this.areTypeReferencesCompatible({from:l.valueType,to:d.valueType})||this.errors.add(`Header "${u}" type changed in ${t}.`)}}checkHttpMethodsBreakingChanges({id:t,from:r,to:i}){r!==i&&this.errors.add(`HTTP method changed in ${t}.`)}checkHttpPathsBreakingChanges({id:t,from:r,to:i}){this.areHttpPathsCompatible({from:r,to:i})||this.errors.add(`HTTP path changed in ${t}.`)}areHttpPathsCompatible({from:t,to:r}){if(t.head!==r.head||t.parts.length!==r.parts.length)return!1;for(let i=0;i<t.parts.length;i++){let n=t.parts[i];if(n==null)return!1;let a=r.parts[i];if(a==null||n.pathParameter!==a.pathParameter||n.tail!==a.tail)return!1}return!0}checkHttpRequestBodiesCompatible({id:t,from:r,to:i}){switch(r.type){case"inlinedRequestBody":if(i.type==="inlinedRequestBody"&&this.areInlinedRequestBodiesCompatible({from:r,to:i}))return;break;case"reference":if(i.type==="reference"&&this.areReferenceRequestBodiesCompatible({from:r,to:i}))return;break;case"fileUpload":if(i.type==="fileUpload"&&this.areFileUploadRequestBodiesCompatible({from:r,to:i}))return;break;case"bytes":if(i.type==="bytes")return;break;default:mo(r)}this.errors.add(`Request body type changed from "${r.type}" to "${i.type}" in endpoint "${t}".`)}areInlinedRequestBodiesCompatible({from:t,to:r}){let i=this.getInlinedRequestBody(t),n=this.getInlinedRequestBody(r);return this.checkForNewInlinedRequestBodyProperties({from:i,to:n}),Object.entries(i).every(([a,u])=>{let l=n[a];return l?this.areTypeReferencesCompatible({from:u,to:l}):(this.errors.add(`Request body property "${a}" was removed.`),!1)})}areReferenceRequestBodiesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.requestBodyType,to:r.requestBodyType})}areFileUploadRequestBodiesCompatible({from:t,to:r}){let i=this.getFileUploadRequest(t.properties),n=this.getFileUploadRequest(r.properties);this.checkForNewFileUploadRequestProperties({from:i,to:n});for(let[a,u]of Object.entries(i)){let l=n[a];if(!l)return this.errors.add(`File upload property "${a}" was removed.`),!1;if(u==="file"&&l!=="file")return this.errors.add(`File upload property "${a}" type changed.`),!1;if(u==="fileArray"&&l!=="fileArray")return this.errors.add(`File upload property "${a}" type changed.`),!1;if(u!=="file"&&u!=="fileArray"&&l!=="file"&&l!=="fileArray"&&!this.areTypeReferencesCompatible({from:u,to:l}))return this.errors.add(`File upload property "${a}" type changed.`),!1}return!0}checkHttpResponseBreakingChanges({id:t,from:r,to:i}){if(r.statusCode!==i.statusCode&&this.errors.add(`Response status code changed from "${r.statusCode}" to "${i.statusCode}".`),!(r.body==null&&i.body==null)){if(r.body==null||i.body==null){this.errors.add(`Response body was ${r.body==null?"added":"removed"}.`);return}switch(r.body.type){case"json":if(i.body.type==="json"){this.areJsonResponsesCompatible({from:r.body.value,to:i.body.value});return}break;case"fileDownload":if(i.body.type==="fileDownload")return;break;case"text":if(i.body.type==="text")return;break;case"bytes":if(i.body.type==="bytes")return;break;case"streaming":if(i.body.type==="streaming"){this.areStreamingResponsesCompatible({from:r.body.value,to:i.body.value});return}break;case"streamParameter":if(i.body.type==="streamParameter"){this.areStreamingResponsesCompatible({from:r.body.streamResponse,to:i.body.streamResponse});return}break;default:mo(r.body)}this.errors.add(`HTTP response type "${r.body.type}" defined for endpoint "${t}" is not compatible with type "${i.body.type}".`)}}areJsonResponsesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.responseBodyType,to:r.responseBodyType})}areStreamingResponsesCompatible({from:t,to:r}){switch(t.type){case"json":if(r.type==="json")return this.areTypeReferencesCompatible({from:t.payload,to:r.payload});break;case"sse":if(r.type==="sse")return this.areTypeReferencesCompatible({from:t.payload,to:r.payload});break;case"text":if(r.type==="text")return!0;break;default:mo(t)}return this.errors.add(`Streaming response type "${t.type}" is not compatible with type "${r.type}".`),!1}areTypeDeclarationsCompatible({from:t,to:r}){return this.areDeclaredTypeNamesCompatible({from:t.name,to:r.name})&&this.areTypeShapesCompatible({from:t.shape,to:r.shape})}areTypeShapesCompatible({from:t,to:r}){switch(t.type){case"alias":if(r.type==="alias")return this.areAliasTypesCompatible({from:t,to:r});break;case"enum":if(r.type==="enum")return this.areEnumTypesCompatible({from:t,to:r});break;case"object":if(r.type==="object")return this.areObjectTypesCompatible({from:t,to:r});break;case"union":if(r.type==="union")return this.areUnionTypesCompatible({from:t,to:r});break;case"undiscriminatedUnion":if(r.type==="undiscriminatedUnion")return this.areUndiscriminatedUnionTypesCompatible({from:t,to:r});break;default:mo(t)}return this.errors.add(`Type "${t.type}" is not compatible with type "${r.type}".`),!1}areAliasTypesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.aliasOf,to:r.aliasOf})}areEnumTypesCompatible({from:t,to:r}){let i=Object.fromEntries(t.values.map(a=>[a.name.wireValue,a])),n=Object.fromEntries(r.values.map(a=>[a.name.wireValue,a]));return Object.keys(i).length!==Object.keys(n).length?!1:Object.values(i).every(a=>{let u=n[a.name.wireValue];return u?this.areNameAndWireValuesCompatible({from:a.name,to:u.name}):(this.errors.add(`Enum value "${a.name.wireValue}" was removed.`),!1)})}areObjectTypesCompatible({from:t,to:r}){let i=Object.fromEntries([...t.properties.map(a=>[a.name.wireValue,a]),...t.extendedProperties?.map(a=>[a.name.wireValue,a])??[]]),n=Object.fromEntries([...r.properties.map(a=>[a.name.wireValue,a]),...r.extendedProperties?.map(a=>[a.name.wireValue,a])??[]]);return this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(i).map(([a,u])=>[a,u.valueType])),to:Object.fromEntries(Object.entries(n).map(([a,u])=>[a,u.valueType]))}),Object.values(i).every(a=>{let u=n[a.name.wireValue];return u?this.areObjectPropertiesCompatible({from:a,to:u}):(this.errors.add(`Object property "${a.name.wireValue}" was removed.`),!1)})}areObjectPropertiesCompatible({from:t,to:r}){return this.areNameAndWireValuesCompatible({from:t.name,to:r.name})&&this.areTypeReferencesCompatible({from:t.valueType,to:r.valueType})}areUnionTypesCompatible({from:t,to:r}){if(!this.areNameAndWireValuesCompatible({from:t.discriminant,to:r.discriminant}))return this.errors.add(`Union type with discriminant value "${t.discriminant.wireValue}" changed.`),!1;let i=new Set(t.extends.map(s=>this.getKeyForDeclaration(s))),n=new Set(r.extends.map(s=>this.getKeyForDeclaration(s)));for(let s of i)if(!n.has(s))return this.errors.add(`Extended type "${s}" was removed.`),!1;let a=Object.fromEntries(t.baseProperties.map(s=>[s.name.wireValue,s])),u=Object.fromEntries(r.baseProperties.map(s=>[s.name.wireValue,s]));for(let s of Object.values(a)){let o=u[s.name.wireValue];if(!o)return this.errors.add(`Union type with discriminant value "${s.name.wireValue}" no longer has a property named "${s.name.wireValue}".`),!1;if(!this.areObjectPropertiesCompatible({from:s,to:o}))return!1}this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(a).map(([s,o])=>[s,o.valueType])),to:Object.fromEntries(Object.entries(u).map(([s,o])=>[s,o.valueType]))});let l=Object.fromEntries(t.types.map(s=>[s.discriminantValue.wireValue,s])),d=Object.fromEntries(r.types.map(s=>[s.discriminantValue.wireValue,s]));return Object.values(l).every(s=>{let o=d[s.discriminantValue.wireValue];return o?this.areSingleUnionTypesCompatible({from:s.shape,to:o.shape}):(this.errors.add(`Union type for discriminant value "${s.discriminantValue.wireValue}" was removed.`),!1)})}areSingleUnionTypesCompatible({from:t,to:r}){switch(t.propertiesType){case"samePropertiesAsObject":if(r.propertiesType==="samePropertiesAsObject")return this.areDeclaredTypeNamesCompatible({from:t,to:r});break;case"singleProperty":if(r.propertiesType==="singleProperty")return this.areNameAndWireValuesCompatible({from:t.name,to:r.name})&&this.areTypeReferencesCompatible({from:t.type,to:r.type});break;case"noProperties":if(r.propertiesType==="noProperties")return!0;break;default:mo(t)}return this.errors.add(`Single union type of style "${t.propertiesType}" is not compatible with style "${r.propertiesType}".`),!1}areUndiscriminatedUnionTypesCompatible({from:t,to:r}){return t.members.every((i,n)=>{let a=r.members[n];return a?this.areTypeReferencesCompatible({from:i.type,to:a.type}):(this.errors.add(`Undiscriminated union member at index ${n} was removed.`),!1)})}checkForNewRequiredTypeReferences({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}checkForNewFileUploadRequestProperties({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||n==="file"||n==="fileArray"||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}checkForNewInlinedRequestBodyProperties({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}areTypeReferencesCompatible({from:t,to:r}){switch(t.type){case"primitive":if(r.type==="primitive")return this.arePrimitiveTypesCompatible({from:t,to:r});break;case"container":if(r.type==="container")return this.areContainerTypesCompatible({from:t.container,to:r.container});break;case"named":if(r.type==="named")return this.areNamedTypesCompatible({from:t,to:r});break;case"unknown":if(r.type==="unknown")return!0;break;default:mo(t)}return this.errors.add(`TypeReference "${t.type}" is not compatible with type "${r.type}".`),!1}arePrimitiveTypesCompatible({from:t,to:r}){return t.primitive.v1===r.primitive.v1}areContainerTypesCompatible({from:t,to:r}){switch(t.type){case"list":if(r.type==="list")return this.areTypeReferencesCompatible({from:t.list,to:r.list});break;case"set":if(r.type==="set")return this.areTypeReferencesCompatible({from:t.set,to:r.set});break;case"map":if(r.type==="map")return this.areTypeReferencesCompatible({from:t.keyType,to:r.keyType})&&this.areTypeReferencesCompatible({from:t.valueType,to:r.valueType});break;case"optional":if(r.type==="optional")return this.areTypeReferencesCompatible({from:t.optional,to:r.optional});break;case"nullable":if(r.type==="nullable")return this.areTypeReferencesCompatible({from:t.nullable,to:r.nullable});break;case"literal":if(r.type==="literal")return this.areLiteralsCompatible({from:t.literal,to:r.literal});break;default:mo(t)}return this.errors.add(`Container type "${t.type}" is not compatible with type "${r.type}".`),!1}areNamedTypesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areDeclaredTypeNamesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areDeclaredErrorNamesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areNameAndWireValuesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&t.wireValue===r.wireValue}areLiteralsCompatible({from:t,to:r}){switch(t.type){case"boolean":if(r.type==="boolean")return t.boolean===r.boolean;break;case"string":if(r.type==="string")return t.string===r.string;break;default:mo(t)}return!1}areFernFilepathsCompatible({from:t,to:r}){return t.allParts.length!==r.allParts.length?!1:t.allParts.every((i,n)=>{let a=r.allParts[n];return a==null?!1:this.areNamesCompatible({from:i,to:a})})}areNamesCompatible({from:t,to:r}){return t.originalName===r.originalName}getInlinedRequestBody(t){let r={};for(let i of[...t.extendedProperties??[],...t.properties])r[i.name.wireValue]=i.valueType;return r}getFileUploadRequest(t){let r={};for(let i of t)switch(i.type){case"file":r[i.value.key.wireValue]="file";break;case"bodyProperty":r[i.name.wireValue]=i.valueType;break;default:mo(i)}return r}getKeyForDeclaration({name:t,fernFilepath:r}){return`${r.allParts.map(n=>n.camelCase.unsafeName).join(".")}.${t.pascalCase.unsafeName}`}};function qB_({filteredIr:e,singleUnionTypeProperties:t}){return t._visit({samePropertiesAsObject:r=>{let i=e.hasTypeId(r.typeId)?{...r,object:{properties:r.object.properties.filter(n=>e.hasProperty(n.originalTypeDeclaration.typeId,n.name.wireValue)).map(n=>({...n,value:wR({filteredIr:e,exampleTypeReference:n.value})})).filter(n=>n.value!==void 0)}}:void 0;return i!==void 0?h3.samePropertiesAsObject(i):void 0},singleProperty:r=>{let i=wR({filteredIr:e,exampleTypeReference:r});return i!==void 0?h3.singleProperty(i):void 0},noProperties:()=>t,_other:()=>{throw new Error("Received unknown type for example.")}})}function wR({filteredIr:e,exampleTypeReference:t}){return t.shape._visit({primitive:()=>t,container:r=>r._visit({list:i=>({...t,shape:Nh.container(bm.list({...i,list:i.list.map(n=>wR({filteredIr:e,exampleTypeReference:n})).filter(n=>n!==void 0)}))}),set:i=>({...t,shape:Nh.container(bm.set({...i,set:i.set.map(n=>wR({filteredIr:e,exampleTypeReference:n})).filter(n=>n!==void 0)}))}),optional:i=>{let n=i.optional!=null?wR({filteredIr:e,exampleTypeReference:i.optional}):void 0;return n!=null?{...t,shape:Nh.container(bm.optional({optional:n,valueType:i.valueType}))}:void 0},nullable:i=>{let n=i.nullable!=null?wR({filteredIr:e,exampleTypeReference:i.nullable}):void 0;return n!=null?{...t,shape:Nh.container(bm.nullable({nullable:n,valueType:i.valueType}))}:void 0},map:i=>({...t,shape:Nh.container(bm.map({...i,map:i.map.map(n=>{let a=wR({filteredIr:e,exampleTypeReference:n.key}),u=wR({filteredIr:e,exampleTypeReference:n.value});return a!==void 0&&u!==void 0?{key:a,value:u}:void 0}).filter(n=>n!==void 0)}))}),literal:()=>t,_other:()=>{throw new Error("Received unknown type for example.")}}),named:r=>e.hasTypeId(r.typeName.typeId)?r.shape._visit({alias:i=>{let n=wR({filteredIr:e,exampleTypeReference:i.value});return n!==void 0?{...t,shape:Nh.named({...r,shape:Iw.alias({...i,value:n})})}:void 0},enum:i=>({...t,shape:Nh.named({...r,shape:Iw.enum(i)})}),object:i=>({...t,shape:Nh.named({...r,shape:Iw.object({...i,properties:i.properties.filter(n=>e.hasProperty(n.originalTypeDeclaration.typeId,n.name.wireValue)).map(n=>({...n,value:wR({filteredIr:e,exampleTypeReference:n.value})})).filter(n=>n.value!==void 0)})})}),union:i=>{let n=qB_({filteredIr:e,singleUnionTypeProperties:i.singleUnionType.shape});return n!==void 0?{...t,shape:Nh.named({...r,shape:Iw.union({...i,singleUnionType:{...i.singleUnionType,shape:n}})})}:void 0},undiscriminatedUnion:i=>{let n=wR({filteredIr:e,exampleTypeReference:i.singleUnionType});return n!==void 0?{...t,shape:Nh.named({...r,shape:Iw.undiscriminatedUnion({...i,singleUnionType:n})})}:void 0},_other:()=>{throw new Error("Received unknown type for example.")}}):void 0,unknown:()=>t,_other:()=>t})}function JPc({filteredIr:e,pathParameters:t}){return t.map(r=>{let i=wR({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function lJE({filteredIr:e,queryParameters:t}){return t.map(r=>{let i=wR({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function AB_({filteredIr:e,headers:t}){return t.map(r=>{let i=wR({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function fJE({filteredIr:e,requestBody:t}){return t._visit({inlinedRequestBody:r=>({...t,properties:r.properties.filter(i=>i.originalTypeDeclaration?e.hasProperty(i.originalTypeDeclaration.typeId,i.name.wireValue):!0).map(i=>{let n=wR({filteredIr:e,exampleTypeReference:i.value});return n!==void 0?{...i,value:n}:void 0}).filter(i=>i!==void 0)}),reference:r=>{let i=wR({filteredIr:e,exampleTypeReference:r});return i!==void 0?zQ.reference(i):void 0},_other:()=>{throw new Error("Received unknown type for example.")}})}function dJE({filteredIr:e,response:t}){return t._visit({ok:r=>r._visit({body:i=>RT.ok(kC.body(i!=null?wR({filteredIr:e,exampleTypeReference:i}):void 0)),stream:i=>RT.ok(kC.stream(i.map(n=>wR({filteredIr:e,exampleTypeReference:n})).filter(V0))),sse:i=>RT.ok(kC.sse(i.map(({event:n,data:a})=>{let u=wR({filteredIr:e,exampleTypeReference:a});return u!==void 0?{event:n,data:u}:void 0}).filter(V0))),_other:({type:i})=>{throw new Error(`Received unknown type for OK example: ${i}`)}}),error:({error:r,body:i})=>RT.error({error:r,body:i!=null?wR({filteredIr:e,exampleTypeReference:i}):void 0}),_other:({type:r})=>{throw new Error(`Received unknown type for example: ${r}`)}})}function KPc({filteredIr:e,example:t}){return{...t,rootPathParameters:JPc({filteredIr:e,pathParameters:t.rootPathParameters}),servicePathParameters:JPc({filteredIr:e,pathParameters:t.servicePathParameters}),endpointPathParameters:JPc({filteredIr:e,pathParameters:t.endpointPathParameters}),serviceHeaders:AB_({filteredIr:e,headers:t.serviceHeaders}),endpointHeaders:AB_({filteredIr:e,headers:t.endpointHeaders}),queryParameters:lJE({filteredIr:e,queryParameters:t.queryParameters}),request:t.request!==void 0?fJE({filteredIr:e,requestBody:t.request}):void 0,response:dJE({filteredIr:e,response:t.response})}}function TB_({filteredIr:e,exampleType:t}){return t.shape._visit({alias:r=>{let i=wR({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...t,shape:Iw.alias({...r,value:i})}:void 0},enum:()=>t,object:r=>({...t,shape:Iw.object({...r,properties:r.properties.filter(i=>e.hasProperty(i.originalTypeDeclaration.typeId,i.name.wireValue)).map(i=>({...i,value:wR({filteredIr:e,exampleTypeReference:i.value})})).filter(i=>i.value!==void 0)})}),union:r=>{let i=qB_({filteredIr:e,singleUnionTypeProperties:r.singleUnionType.shape});return i!==void 0?{...t,shape:Iw.union({...r,singleUnionType:{...r.singleUnionType,shape:i}})}:void 0},undiscriminatedUnion:r=>{let i=wR({filteredIr:e,exampleTypeReference:r.singleUnionType});return i!==void 0?{...t,shape:Iw.undiscriminatedUnion({...r,singleUnionType:i})}:void 0},_other:()=>{throw new Error("Received unknown type for example.")}})}function YPc(e,t){if(t==null)return e;let r=MVi(e.types,u=>t.hasType(u)),i=Object.fromEntries(Object.entries(r).map(([u,l])=>{let d=[];if(l.userProvidedExamples=l.userProvidedExamples.map(s=>TB_({filteredIr:t,exampleType:s})).filter(s=>s!==void 0),l.shape.type==="object"){for(let s of l.shape.properties)t.hasProperty(u,s.name.wireValue)&&d.push(s);return[u,{...l,shape:lO.object({...l.shape,properties:d})}]}return[u,l]})),n=Object.fromEntries(Object.entries(e.webhookGroups).map(([u,l])=>{let d=l.filter(s=>t.hasWebhook(s)).map(s=>{let o=s.id;return s.payload.type==="inlinedPayload"&&o!=null&&(s.payload={...s.payload,properties:s.payload.properties.filter(c=>t.hasWebhookPayloadProperty(o,c.name.wireValue))}),s});return[u,d]})),a=e.environments;if(a){switch(a.environments.type){case"singleBaseUrl":{a.environments.environments=a.environments.environments.filter(u=>t.hasEnvironmentId(u.id));break}case"multipleBaseUrls":{a.environments.environments=a.environments.environments.filter(u=>t.hasEnvironmentId(u.id));break}}a.defaultEnvironment&&(t.hasEnvironmentId(a.defaultEnvironment)||(a.defaultEnvironment=void 0))}return{...e,environments:a,types:i,errors:MVi(e.errors,u=>t.hasError(u)),services:dd(MVi(e.services,u=>t.hasService(u)),u=>({...u,endpoints:u.endpoints.filter(l=>t.hasEndpoint(l)).map(l=>(l.autogeneratedExamples=l.autogeneratedExamples.map(d=>({...d,example:KPc({filteredIr:t,example:d.example})})),l.userSpecifiedExamples=l.userSpecifiedExamples.map(d=>({...d,example:d.example!=null?KPc({filteredIr:t,example:d.example}):void 0})),l.queryParameters.length>0&&(l.queryParameters=l.queryParameters.filter(d=>t.hasQueryParameter(l.id,d.name.wireValue))),l.requestBody?.type==="inlinedRequestBody"?{...l,requestBody:{...l.requestBody,properties:l.requestBody.properties.filter(d=>t.hasRequestProperty(l.id,d.name.wireValue))}}:l))})),webhookGroups:n,serviceTypeReferenceInfo:pJE(e.serviceTypeReferenceInfo,t)}}function pJE(e,t){if(t==null)return e;let r={};return Object.entries(e.typesReferencedOnlyByService).forEach(([i,n])=>{t.hasServiceId(i)&&(r[i]=n.filter(a=>t.hasTypeId(a)))}),{sharedTypes:e.sharedTypes.filter(i=>t.hasTypeId(i)),typesReferencedOnlyByService:r}}var pH={};jo(pH,{AudienceExtension:()=>cko,FernAvailabilityExtension:()=>lko,FernEnumExtension:()=>fko,FernIgnoreExtension:()=>SKi,FernOptionalExtension:()=>dko,FernTypeExtension:()=>hko,FernTypeNameExtension:()=>yko,SdkGroupNameExtension:()=>pko,SdkMethodNameExtension:()=>_ko});var cko=class extends Aj{operation;key="x-fern-audiences";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=Array.isArray(t)?t.filter(i=>typeof i=="string"):typeof t=="string"?[t]:[];if(r.length!==0)return{audiences:r}}};var lko=class extends Aj{node;key="x-fern-availability";constructor({breadcrumbs:t,node:r,context:i}){super({breadcrumbs:t,context:i}),this.node=r}convert(){let t=this.getExtensionValue(this.node);if(t==null||typeof t!="string")return;switch(t.toUpperCase().replace(/[-_\s]/g,"_")){case"IN_DEVELOPMENT":return B9.InDevelopment;case"PRE_RELEASE":return B9.PreRelease;case"GENERAL_AVAILABILITY":return B9.GeneralAvailability;case"DEPRECATED":return B9.Deprecated;default:return}}};var _JE=hu.object({snake:hu.string().optional(),camel:hu.string().optional(),screamingSnake:hu.string().optional(),pascal:hu.string().optional()}),hJE=hu.object({description:hu.string().optional(),name:hu.string().optional(),casing:_JE.optional()}),CB_=hu.record(hJE);var fko=class extends Aj{schema;key="x-fern-enum";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(t==null)return;let r=CB_.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-enum extension: ${r.error.message}`,path:this.breadcrumbs});return}return r.data}};var SKi=class extends Aj{operation;key="x-fern-ignore";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-ignore",path:this.breadcrumbs});return}return t}}};var dko=class extends Aj{parameter;key="x-fern-optional";constructor({breadcrumbs:t,parameter:r,context:i}){super({breadcrumbs:t,context:i}),this.parameter=r}convert(){let t=this.getExtensionValue(this.parameter);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-optional",path:this.breadcrumbs});return}return t}}};var pko=class extends Aj{operation;key="x-fern-sdk-group-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=Array.isArray(t)?t.filter(i=>typeof i=="string"):typeof t=="string"?[t]:[];if(r.length!==0)return{groups:r}}};var _ko=class extends Aj{operation;key="x-fern-sdk-method-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null&&typeof t=="string")return{methodName:t}}};var hko=class extends Aj{schema;key="x-fern-type";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(t!=null&&typeof t=="string")return t}};var yko=class extends Aj{schema;key="x-fern-type-name";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(typeof t=="string")return t}};var Mpi=class extends w0{ir;audiences;irGraph;constructor({breadcrumbs:t=[],context:r,audiences:i}){super({breadcrumbs:t,context:r}),this.audiences=i,this.irGraph=new wKi(i),this.ir={auth:{docs:void 0,requirement:Ws.AuthSchemesRequirement.All,schemes:[]},selfHosted:!1,types:{},services:{},errors:{},webhookGroups:{},websocketChannels:void 0,headers:[],idempotencyHeaders:[],apiVersion:void 0,apiDisplayName:void 0,apiDocs:void 0,basePath:void 0,pathParameters:[],errorDiscriminationStrategy:Ws.ErrorDiscriminationStrategy.statusCode(),variables:[],serviceTypeReferenceInfo:{sharedTypes:[],typesReferencedOnlyByService:{}},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,environments:void 0,fdrApiDefinitionId:void 0,rootPackage:this.createPackage(),subpackages:{},sdkConfig:{hasFileDownloadEndpoints:!1,hasPaginatedEndpoints:!1,hasStreamingEndpoints:!1,isAuthMandatory:!0,platformHeaders:{language:"",sdkName:"",sdkVersion:"",userAgent:void 0}}}}removeXFernIgnores({document:t,breadcrumbs:r=[]}){return Array.isArray(t)?t.filter((i,n)=>!new SKi({breadcrumbs:[...r,String(n)],operation:i,context:this.context}).convert()).map((i,n)=>this.removeXFernIgnores({document:i,breadcrumbs:[...r,String(n)]})):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([i,n])=>!new SKi({breadcrumbs:[...r,i],operation:n,context:this.context}).convert()).map(([i,n])=>[i,this.removeXFernIgnores({document:n,breadcrumbs:[...r,i]})])):t}finalizeIr(){let t={...this.ir,apiName:this.context.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:this.context.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}};return t=this.irGraph.hasNoAudiences()?t:this.filterIrForAudiences(t),{...t,...ARa({ir:t,exampleGeneration:this.context.exampleGenerationArgs}),...WPc({ir:t,exampleGeneration:this.context.exampleGenerationArgs})}}filterIrForAudiences(t){let r=this.irGraph.getFilteredEndpoints(),i=this.irGraph.getFilteredChannels(),n=this.irGraph.getFilteredWebhooks();for(let a of Object.values(t.services)){let u=[];for(let l of a.endpoints)r.has(l.id)&&u.push(l);a.endpoints=u}return t.websocketChannels=Object.fromEntries(Object.entries(t.websocketChannels??{}).filter(([a])=>i.has(a))),t.webhookGroups=Object.fromEntries(Object.entries(t.webhookGroups).filter(([a])=>n.has(a))),t}async resolveAllExternalRefs({spec:t}){let r=[t];for(;r.length>0;){let i=r.shift();i!=null&&(Array.isArray(i)?await this.resolveExternalRefsInArray(i,r):typeof i=="object"&&await this.resolveExternalRefsInObject(i,r))}return t}async resolveExternalRefsInArray(t,r){for(let i=0;i<t.length;i++)t[i]=await this.resolveReferenceChain(t[i],r)}async resolveExternalRefsInObject(t,r){for(let[i,n]of Object.entries(t))t[i]=await this.resolveReferenceChain(n,r)}async resolveReferenceChain(t,r){let i=t;if(!this.context.isReferenceObject(i))return r.push(i),t;for(;this.context.isReferenceObject(i);){let n=this.context.isExternalReference(i.$ref),a=await this.context.resolveMaybeExternalReference({$ref:i.$ref});if(a.resolved){if(i=a.value,n)return i}else return t}return t}shouldAddServerToCollectedServers({server:t,currentServers:r}){return!r.some(i=>i.url===t.url&&"x-fern-server-name"in i&&"x-fern-server-name"in t&&i["x-fern-server-name"]===t["x-fern-server-name"])}addEndpointToIr({endpoint:t,audiences:r,endpointGroup:i,serviceName:n}){let a=this.context.getGroup({groupParts:i,namespace:this.context.namespace}),u=this.getOrCreatePackage({group:i}),l=[...a].map(o=>this.context.casingsGenerator.generateName(o)),d=l[l.length-1];u.service==null&&(u.service=n??`service_${a.map(o=>T_(o)).join("/")}`),this.ir.services[u.service]==null&&(this.ir.services[u.service]=this.createNewService({allParts:l,finalpart:d})),this.ir.services[u.service]?.endpoints.push(t);let s=this.ir.services[u.service];s!=null&&(this.irGraph.addEndpoint(s,t),this.irGraph.markEndpointForAudience(s.name,[t],r))}addWebhookToIr({webhook:t,operationId:r,audiences:i,group:n}){let a=n?.join(".")??r,u=this.getOrCreatePackage({group:n});this.ir.webhookGroups[a]==null&&(this.ir.webhookGroups[a]=[]),this.ir.webhookGroups[a].push(t),u.webhooks=a;let l=this.context.createFernFilepath();this.irGraph.addWebhook(l,t),i!=null&&this.irGraph.markWebhookForAudiences(l,t,i)}addWebsocketChannelToIr({websocketChannel:t,channelPath:r,audiences:i,websocketGroup:n}){let a=T_(n?.join(".")),u=T_(r),l=this.context.namespace?`${T_(this.context.namespace)}/`:"",d=a?`channel_${l}${a}`:`channel_${l}${u}`,s=n?this.getOrCreatePackage({group:n}):this.getOrCreatePackage({group:[u]});this.ir.websocketChannels={...this.ir.websocketChannels,[d]:t},d!==""?s.websocket==null&&(s.websocket=d):this.ir.rootPackage.websocket="";let o=this.context.createFernFilepath();this.irGraph.addChannel(o,d,t),i!=null&&this.irGraph.markChannelForAudiences(o,d,i)}addAuthToIR(t){this.ir.auth=t}addErrorsToIr(t){this.ir.errors=t;for(let r of Object.values(t))this.irGraph.addError(r)}addEnvironmentsToIr({environmentConfig:t,audiences:r}){if(this.ir.environments=t,r!=null)for(let[i,n]of Object.entries(t??{}))r[i]!=null&&this.irGraph.markEnvironmentForAudiences(n,r[i])}addTypeToRootPackage(t){this.ir.rootPackage.types.push(t)}addTypeToPackage(t){let r=this.context.getGroup({groupParts:[],namespace:this.context.namespace});this.getOrCreatePackage({group:r}).types.push(t)}addTypesToIr(t){Object.assign(this.ir.types,Object.fromEntries(Object.entries(t).map(([r,i])=>[r,i.typeDeclaration])));for(let r of Object.values(t))this.irGraph.addType({declaredTypeName:r.typeDeclaration.name,descendantTypeIds:r.typeDeclaration.referencedTypes,descendantTypeIdsByAudience:{},propertiesByAudience:r.propertiesByAudience,descendantFilepaths:new Set}),this.irGraph.markTypeForAudiences(r.typeDeclaration.name,r.audiences)}updateEndpointsWithDefaultUrl(t){if(t!=null)for(let r of Object.values(this.ir.services))for(let i of r.endpoints)i.baseUrl==null&&(i.baseUrl=t)}createNewService({allParts:t,finalpart:r}){return{name:{fernFilepath:{allParts:t,packagePath:t.slice(0,-1),file:r}},displayName:void 0,basePath:lF(""),headers:[],pathParameters:[],availability:void 0,endpoints:[],transport:void 0,encoding:void 0}}createPackage(t={}){return{fernFilepath:this.context.createFernFilepath(t),service:void 0,types:[],errors:[],subpackages:[],docs:void 0,webhooks:void 0,websocket:void 0,hasEndpointsInTree:!1,navigationConfig:void 0}}getOrCreatePackage({group:t}){let r=[];if(this.context.namespace!=null&&r.push(this.context.namespace),r.push(...(t??[]).map(n=>T_(n))),r.length==0)return this.ir.rootPackage;let i=this.ir.rootPackage;for(let n=0;n<r.length;n++){let a=r[n]??"",l=`subpackage_${r.slice(0,n+1).join("/")}`;this.ir.subpackages[l]==null&&(this.ir.subpackages[l]={name:this.context.casingsGenerator.generateName(a),...this.createPackage({name:a})});let d=this.ir.subpackages[l];i.subpackages.includes(l)||i.subpackages.push(l),i=d}return i}};var QA={};jo(QA,{AbstractConverters:()=>ZPc,ExampleConverter:()=>Wir,SchemaConverters:()=>XPc,ServersConverter:()=>EHt});var ZPc={};jo(ZPc,{AbstractMediaTypeObjectConverter:()=>bko,AbstractParameterConverter:()=>gko});var Wir=class e extends w0{MAX_DEPTH=12;EXAMPLE_STRING="foo";EXAMPLE_NUMBER=42;EXAMPLE_BOOLEAN=!0;EXAMPLE_INTEGER=42;schema;example;depth;exampleGenerationStrategy;generateOptionalProperties;constructor({breadcrumbs:t,context:r,schema:i,example:n,depth:a=0,exampleGenerationStrategy:u,generateOptionalProperties:l=!1}){super({breadcrumbs:t,context:r}),this.example=n,this.schema=i,this.depth=a,this.exampleGenerationStrategy=u,this.generateOptionalProperties=l}convert(){if(this.depth>this.MAX_DEPTH)return{isValid:!0,coerced:!1,validExample:this.example,errors:[]};let t=this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});return t==null?{isValid:!1,coerced:!1,validExample:null,errors:[{message:"Schema is not resolvable",path:this.breadcrumbs}]}:typeof t!="object"?{isValid:!1,coerced:!1,validExample:null,errors:[{message:`Schema should be an object: ${JSON.stringify(t,null,2)}`,path:this.breadcrumbs}]}:"nullable"in t&&t.nullable===!0&&this.example===null?{isValid:!0,coerced:!1,validExample:this.example,errors:[]}:Array.isArray(t.type)?this.convertSchemaTypeArray({resolvedSchema:t}):t.type=="null"?this.convertNull():t.type=="boolean"?this.convertBoolean():t.enum!=null?this.convertEnum(t):t.type=="number"?this.convertNumber():t.type=="string"?this.convertString():t.type=="integer"?this.convertInteger():t.type=="array"?this.convertArray({resolvedSchema:t}):"oneOf"in t&&t.oneOf!=null?this.convertOneOf({resolvedSchema:t}):"anyOf"in t&&t.anyOf!=null?this.convertAnyOf({resolvedSchema:t}):t.type=="object"||t.properties!=null||t.allOf!=null?this.convertObject({resolvedSchema:t}):typeof t=="object"&&Object.keys(t).length===0?{isValid:!0,coerced:!1,validExample:this.example,errors:[]}:{isValid:!1,coerced:!1,validExample:null,errors:[{message:`Unsupported schema type: ${JSON.stringify(t,null,2)}`,path:this.breadcrumbs}]}}convertNull(){let t=this.example===null;return t?{isValid:t,coerced:!1,validExample:this.example,errors:[]}:{isValid:!1,coerced:!1,validExample:null,errors:[{message:`Example is not null: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertBoolean(){let t=typeof this.example=="boolean";if(t)return{isValid:t,coerced:!1,validExample:this.example,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return typeof r=="boolean"?{isValid:!0,coerced:!1,validExample:r,errors:[]}:{isValid:!1,coerced:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_BOOLEAN,errors:[{message:`Example is not a boolean: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertEnum(t){let r=t.enum?.includes(this.example)??!1;if(r)return{isValid:r,coerced:!1,validExample:this.example,errors:[]};let i=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return i!==void 0&&t.enum?.includes(i)?{isValid:!0,coerced:!1,validExample:i,errors:[]}:{isValid:r,coerced:!1,validExample:t.enum?.[0],errors:[{message:`Example is not one of the allowed enum values: ${JSON.stringify(t.enum,null,2)}`,path:this.breadcrumbs}]}}convertNumber(){if(typeof this.example=="number")return{isValid:!0,coerced:!1,validExample:this.example,errors:[]};let t=Number(this.example);if(!isNaN(t))return{isValid:!0,coerced:!0,validExample:t,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return typeof r=="number"?{isValid:!0,coerced:!1,validExample:r,errors:[]}:{isValid:!1,coerced:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_NUMBER,errors:[{message:`Example is not a number: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertString(){if(typeof this.example=="string")return{isValid:!0,coerced:!1,validExample:this.example,errors:[]};if(typeof this.example!="object"&&!Array.isArray(this.example)&&this.example!=null)return{isValid:!0,coerced:!0,validExample:String(this.example),errors:[]};let t=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return typeof t=="string"?{isValid:!0,coerced:!1,validExample:t,errors:[]}:{isValid:!1,coerced:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_STRING,errors:[{message:`Example cannot be converted to string: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertInteger(){if(typeof this.example=="number"&&Number.isInteger(this.example))return{isValid:!0,coerced:!1,validExample:this.example,errors:[]};if(typeof this.example=="string"){let r=Number(this.example);if(!isNaN(r)&&Number.isInteger(r))return{isValid:!0,coerced:!0,validExample:r,errors:[]}}let t=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return typeof t=="number"&&Number.isInteger(t)?{isValid:!0,coerced:!1,validExample:t,errors:[]}:{isValid:!1,coerced:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_INTEGER,errors:[{message:`Example is not an integer: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertArray({resolvedSchema:t}){if(t.type!="array")return{isValid:!1,coerced:!1,validExample:null,errors:[]};t.items==null&&(t.items={type:"string"});let r=this.example==null,i=this.example??t.example,a=(Array.isArray(i)?i:[i]).map(l=>new e({breadcrumbs:[...this.breadcrumbs,"items"],context:this.context,schema:t.items,example:l,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy}).convert()),u=a.every(l=>l?.isValid??!1)&&!r;return{isValid:u,coerced:!1,validExample:a.map(l=>l.validExample),errors:u?[]:a.flatMap(l=>l.errors)}}convertObject({resolvedSchema:t}){if(t.type=="object"&&t.properties==null&&t.allOf==null)return{isValid:!0,coerced:!1,validExample:this.example??{},errors:[]};let r=typeof this.example!="object"||this.example==null?{}:this.example,i=Object.entries(t.properties??{}).map(([l,d])=>{if(typeof d!="object")return{key:l,result:{isValid:!0,coerced:!1,validExample:void 0,errors:[]}};if(this.isDeprecatedProperty(d)&&!this.isRequiredProperty({key:l,resolvedSchema:t}))return{key:l,result:{isValid:!0,coerced:!1,validExample:void 0,errors:[]}};if("readOnly"in d&&d.readOnly===!0&&"writeOnly"in d&&d.writeOnly===!0)return{key:l,result:{isValid:!0,coerced:!1,validExample:void 0,errors:[]}};if("readOnly"in d&&d.readOnly===!0&&this.exampleGenerationStrategy==="request")return{key:l,result:{isValid:!0,coerced:!1,validExample:void 0,errors:[]}};if("writeOnly"in d&&d.writeOnly===!0&&this.exampleGenerationStrategy==="response")return{key:l,result:{isValid:!0,coerced:!1,validExample:void 0,errors:[]}};let s=!(l in r)||!("nullable"in d)&&r[l]==null||"nullable"in d&&d.nullable===!0&&r[l]===void 0,o=!t.required?.includes(l);if(s&&o){if(this.example===void 0&&this.generateOptionalProperties){let c=new e({breadcrumbs:[...this.breadcrumbs,l],context:this.context,schema:d,example:void 0,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy});return{key:l,result:c.convert()}}return{key:l,result:{isValid:!0,coerced:!1,validExample:void 0,errors:[]}}}else{let b=new e({breadcrumbs:[...this.breadcrumbs,l],context:this.context,schema:d,example:r[l],depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy}).convert();return{key:l,result:b}}}),n=(t.allOf??[]).map((l,d)=>new e({breadcrumbs:[...this.breadcrumbs,`allOf[${d}]`],context:this.context,schema:{...t,...l,allOf:void 0},example:this.example,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy}).convert()),a=i.every(l=>l.result.isValid)&&n.every(l=>l.isValid),u=Object.fromEntries(i.map(({key:l,result:d})=>[l,d.validExample]).filter(([l,d])=>d!==void 0));for(let l of n)if(typeof l.validExample=="object"&&l.validExample!==null){let d=l.validExample;u={...u,...Object.fromEntries(Object.entries(d).filter(([s,o])=>o!==void 0))}}if(Object.keys(u).length===0){let l=n.find(d=>d.validExample!==void 0&&(typeof d.validExample!="object"||d.validExample===null));l&&(u=l.validExample)}return{isValid:a,coerced:!1,validExample:u,errors:[...i.flatMap(({result:l})=>l.errors),...n.flatMap(l=>l.errors)]}}convertSchemaTypeArray({resolvedSchema:t}){if(!Array.isArray(t.type))return{isValid:!1,coerced:!1,validExample:null,errors:[]};if(t.type.length===1)return new e({breadcrumbs:this.breadcrumbs,context:this.context,schema:{...t,type:t.type[0]},example:this.example,depth:this.depth,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy}).convert();let r=t.type.map((u,l)=>new e({breadcrumbs:[...this.breadcrumbs,`type[${l}]`],context:this.context,schema:{...t,type:u},example:this.example,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy}).convert()),i=r.some(u=>u?.isValid??!1),a=r.find(u=>u.isValid)?.validExample??r[0]?.validExample??null;return{isValid:i,coerced:!1,validExample:a,errors:i?[]:r.flatMap(u=>u?.errors??[])}}convertOneOf({resolvedSchema:t}){if(!("oneOf"in t)||t.oneOf==null)return{isValid:!1,coerced:!1,validExample:null,errors:[]};let r=t.oneOf.map((u,l)=>new e({breadcrumbs:[...this.breadcrumbs,`oneOf[${l}]`],context:this.context,schema:{...t,...u,oneOf:void 0},example:this.example,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy}).convert()),i=r.filter(u=>u.isValid),n=i.length>0,a;return n?a=i.find(l=>!l.coerced)?.validExample??i[0]?.validExample:a=r[0]?.validExample,{isValid:n,coerced:!1,validExample:a,errors:n?[]:r.flatMap(u=>u.errors)}}convertAnyOf({resolvedSchema:t}){if(!("anyOf"in t)||t.anyOf==null)return{isValid:!1,coerced:!1,validExample:null,errors:[]};let r=t.anyOf.map((u,l)=>new e({breadcrumbs:[...this.breadcrumbs,`anyOf[${l}]`],context:this.context,schema:u,example:this.example,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy}).convert()),i=r.filter(u=>u.isValid),n=i.length>0,a;return n?a=i.find(l=>!l.coerced)?.validExample??i[0]?.validExample:a=r[0]?.validExample,{isValid:n,coerced:!1,validExample:a,errors:n?[]:r.flatMap(u=>u.errors)}}maybeResolveSchemaExample(t){let r=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(r!=null){if("example"in r)return r.example;if("examples"in r)return Object.values(r.examples??{})[0]}}isDeprecatedProperty(t){return t!=null&&"availability"in t&&t.availability==="deprecated"}isRequiredProperty({key:t,resolvedSchema:r}){return r.required?.includes(t)??!1}};var XPc={};jo(XPc,{ArraySchemaConverter:()=>H9n,EnumSchemaConverter:()=>L9n,ObjectSchemaConverter:()=>U9n,OneOfSchemaConverter:()=>V9n,PrimitiveSchemaConverter:()=>W9n,SchemaConverter:()=>WAi,SchemaOrReferenceConverter:()=>Ok});function BB_(e){return G2({type:e,_default:void 0,validation:void 0,visitor:{primitive:t=>{switch(t.v1){case"BASE_64":return gf.primitive({v1:"BASE_64",v2:Lp.base64({})});case"BOOLEAN":return gf.primitive({v1:"BOOLEAN",v2:Lp.boolean({default:void 0})});case"DATE":return gf.primitive({v1:"DATE",v2:Lp.date({})});case"DATE_TIME":return gf.primitive({v1:"DATE_TIME",v2:Lp.dateTime({})});case"FLOAT":return gf.primitive({v1:"FLOAT",v2:Lp.float({})});case"DOUBLE":return gf.primitive({v1:"DOUBLE",v2:Lp.double({default:void 0,validation:void 0})});case"UINT":return gf.primitive({v1:"UINT",v2:Lp.uint({})});case"UINT_64":return gf.primitive({v1:"UINT_64",v2:Lp.uint64({})});case"INTEGER":return gf.primitive({v1:"INTEGER",v2:Lp.integer({default:void 0,validation:void 0})});case"LONG":return gf.primitive({v1:"LONG",v2:Lp.long({default:void 0})});case"STRING":return gf.primitive({v1:"STRING",v2:Lp.string({default:void 0,validation:void 0})});case"UUID":return gf.primitive({v1:"UUID",v2:Lp.uuid({})});case"BIG_INTEGER":return gf.primitive({v1:"BIG_INTEGER",v2:Lp.bigInteger({default:void 0})});default:return}},unknown:()=>gf.unknown(),map:({keyType:t,valueType:r})=>{if(!(t==null||r==null))return gf.container(_b.map({keyType:t,valueType:r}))},list:t=>{if(t!=null)return gf.container(_b.list(t))},optional:t=>{if(t!=null)return gf.container(_b.optional(t))},nullable:t=>{if(t!=null)return gf.container(_b.nullable(t))},set:t=>{if(t!=null)return gf.container(_b.set(t))},literal:t=>gf.container(_b.literal(t._visit({string:r=>x9.string(r),boolean:r=>x9.boolean(r),_other:()=>{throw new Error("Unexpected literal type")}}))),named:()=>{}}})}var L9n=class extends w0{schema;maybeFernEnum;constructor({context:t,breadcrumbs:r,schema:i,maybeFernEnum:n}){super({context:t,breadcrumbs:r}),this.schema=i,this.maybeFernEnum=n}convert(){if(!this.schema.enum)return;let r=this.schema.enum.filter(n=>typeof n=="string"||typeof n=="number").map(n=>{let a=n.toString(),u=this.maybeFernEnum?.[a],l=u?.name??a;return{name:this.context.casingsGenerator.generateNameAndWireValue({name:l,wireValue:a}),docs:u?.description,availability:void 0,casing:u?.casing}});if(r.length===0){this.context.errorCollector.collect({message:`Received enum schema with no valid values: ${JSON.stringify(this.schema)}`,path:this.breadcrumbs});return}let i=this.context.getAsString(this.schema.default);return{type:lO.enum({default:i!=null?r.find(n=>n.name.wireValue===i):void 0,values:r})}}};var vko=class extends w0{schemaOrReferenceOrBoolean;constructor({context:t,breadcrumbs:r,schemaOrReferenceOrBoolean:i}){super({context:t,breadcrumbs:r}),this.schemaOrReferenceOrBoolean=i}convert(){let t=this.tryConvertUnknownMap();if(t!=null)return t;let r=this.tryConvertTypedMap();if(r!=null)return r}tryConvertUnknownMap(){if(typeof this.schemaOrReferenceOrBoolean=="boolean"){let t=gf.container(_b.map({keyType:w0.STRING,valueType:gf.unknown()}));return{type:lO.alias({aliasOf:t,resolvedType:t}),referencedTypes:new Set,inlinedTypes:{}}}}tryConvertTypedMap(){if(typeof this.schemaOrReferenceOrBoolean=="boolean")return;let r=new Ok({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReference:this.schemaOrReferenceOrBoolean}).convert();if(r!=null){let i=gf.container(_b.map({keyType:w0.STRING,valueType:r.type})),n=new Set;for(let a of r.schema?.typeDeclaration.referencedTypes??[])n.add(a);for(let a of Object.keys(r.inlinedTypes))n.add(a);return{type:lO.alias({aliasOf:i,resolvedType:i}),referencedTypes:n,inlinedTypes:r.inlinedTypes}}}};function CRa({properties:e,required:t,breadcrumbs:r,context:i,errorCollector:n}){let a=[],u={},l={},d=new Set;for(let[s,o]of Object.entries(e??{})){let c=[...r,"properties",s];if(typeof o!="object"){n.collect({message:`Schema property ${s} should be an object`,path:c});continue}let b=yJE(r,o,i)??i.convertBreadcrumbsToName(c),g="nullable"in o?o.nullable:!1,m=new Ok({context:i,breadcrumbs:c,schemaOrReference:o,schemaIdOverride:b,wrapAsOptional:!t.includes(s),wrapAsNullable:g}).convert();if(m!=null){a.push({name:i.casingsGenerator.generateNameAndWireValue({name:s,wireValue:s}),valueType:m.type,docs:o.description,availability:m.availability,propertyAccess:i.getPropertyAccess(o),v2Examples:m.schema?.typeDeclaration?.v2Examples??{userSpecifiedExamples:{},autogeneratedExamples:{}}}),u={...u,...m.inlinedTypes},m.schema?.typeDeclaration.referencedTypes!=null&&m.schema.typeDeclaration.referencedTypes.forEach(P=>{d.add(P)});for(let P of m.schema?.audiences??[])l[P]==null&&(l[P]=new Set),l[P].add(s)}}for(let s of Object.keys(u))d.add(s);return{convertedProperties:a,propertiesByAudience:l,inlinedTypesFromProperties:u,referencedTypes:d}}function yJE(e,t,r){return r.isReferenceObject(t)?void 0:new pH.FernTypeNameExtension({breadcrumbs:e,schema:t,context:r}).convert()}var U9n=class extends w0{schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){let t=typeof this.schema.additionalProperties=="boolean"&&this.schema.additionalProperties;if(!this.schema.properties&&!this.schema.allOf)return{type:lO.object({properties:[],extends:[],extendedProperties:[],extraProperties:t}),propertiesByAudience:{},inlinedTypes:{},referencedTypes:new Set};let{convertedProperties:r,inlinedTypesFromProperties:i,referencedTypes:n,propertiesByAudience:a}=CRa({properties:this.schema.properties??{},required:this.schema.required??[],breadcrumbs:this.breadcrumbs,context:this.context,errorCollector:this.context.errorCollector}),u=[],l=n,d=i,s=a;for(let[o,c]of(this.schema.allOf??[]).entries()){let b=[...this.breadcrumbs,"allOf",o.toString()];if(this.context.isReferenceObject(c)){let E=this.context.convertReferenceToTypeReference({reference:c,breadcrumbs:b});E.ok&&u.push(E.reference);let q=this.context.getTypeIdFromSchemaReference(c);q!=null&&l.add(q);continue}let{convertedProperties:g,inlinedTypesFromProperties:O,referencedTypes:m,propertiesByAudience:P}=CRa({properties:c.properties??{},required:[...this.schema.required??[],...c.required??[]],breadcrumbs:b,context:this.context,errorCollector:this.context.errorCollector});r.push(...g),d={...d,...O},s={...s,...P},m.forEach(E=>{l.add(E)})}for(let o of Object.keys(d))l.add(o);return{type:lO.object({properties:r,extends:u.map(o=>this.context.typeReferenceToDeclaredTypeName(o)).filter(V0),extendedProperties:[],extraProperties:t}),propertiesByAudience:s,referencedTypes:l,inlinedTypes:d}}};var V9n=class extends w0{schema;id;constructor({context:t,breadcrumbs:r,schema:i,id:n,inlinedTypes:a}){super({context:t,breadcrumbs:r}),this.schema=i,this.id=n}convert(){return this.shouldConvertAsNullableSchemaOrReference()?this.convertAsNullableSchemaOrReference():this.schema.discriminator!=null&&!this.unionVariantsContainLiteral({discriminantProperty:this.schema.discriminator.propertyName})?this.convertAsDiscriminatedUnion():this.convertAsUndiscriminatedUnion()}unionVariantsContainLiteral({discriminantProperty:t}){for(let[r,i]of Object.entries(this.schema.discriminator?.mapping??{})){let n=this.context.resolveReference({reference:{$ref:i},breadcrumbs:this.breadcrumbs});if(n.resolved&&!Object.keys(n.value.properties??{}).includes(t))return!1}return!0}convertAsDiscriminatedUnion(){if(this.schema.discriminator==null)return;let t=[],r=new Set,i={};for(let[l,d]of Object.entries(this.schema.discriminator.mapping??{})){let s=new Ok({context:this.context,schemaOrReference:{$ref:d},breadcrumbs:[...this.breadcrumbs,"discriminator","mapping",l]}),o=this.context.getTypeIdFromSchemaReference({$ref:d});o!=null&&r.add(o);let c=s.convert();if(c?.type!=null&&o!=null){for(let g of Object.keys(c?.inlinedTypes??{}))r.add(g);for(let g of c.schema?.typeDeclaration.referencedTypes??[])r.add(g);let b=this.context.casingsGenerator.generateNameAndWireValue({name:l,wireValue:l});t.push({docs:void 0,discriminantValue:b,availability:c.availability,displayName:l,shape:xQ.samePropertiesAsObject({typeId:o,name:this.context.casingsGenerator.generateName(o),fernFilepath:{allParts:[],packagePath:[],file:void 0},displayName:l})}),i={...i,...c.inlinedTypes}}}let{convertedProperties:n,referencedTypes:a,inlinedTypesFromProperties:u}=CRa({properties:this.schema.properties??{},required:this.schema.required??[],breadcrumbs:this.breadcrumbs,context:this.context,errorCollector:this.context.errorCollector});r=new Set([...r,...a]);for(let l of Object.keys({...i,...u}))r.add(l);return{type:lO.union({baseProperties:n,discriminant:this.context.casingsGenerator.generateNameAndWireValue({name:this.schema.discriminator.propertyName,wireValue:this.schema.discriminator.propertyName}),extends:[],types:t}),referencedTypes:r,inlinedTypes:{...i,...u}}}convertAsUndiscriminatedUnion(){if(!this.schema.oneOf&&!this.schema.anyOf||this.schema.anyOf?.length===0&&this.schema.oneOf?.length===0)return;let t=[],r=new Set,i={};for(let[n,a]of[...(this.schema.oneOf??[]).entries(),...(this.schema.anyOf??[]).entries()]){if(this.context.isReferenceObject(a)){let c;if(this.context.isReferenceObjectWithIdentifier(a))c=this.context.convertReferenceToTypeReference({reference:a,displayNameOverride:a.title??a.name??a.messageId,displayNameOverrideSource:"reference_identifier"});else if(this.getDiscriminatorKeyForRef(a)!=null){let g=this.getDiscriminatorKeyForRef(a);c=this.context.convertReferenceToTypeReference({reference:a,displayNameOverride:g,displayNameOverrideSource:"discriminator_key"})}else c=this.context.convertReferenceToTypeReference({reference:a,displayNameOverrideSource:"schema_identifier"});c.ok&&t.push({type:c.reference,docs:a.description});let b=this.context.getTypeIdFromSchemaReference(a);b!=null&&r.add(b);continue}let u=this.extendSubSchema(a),l=this.context.convertBreadcrumbsToName([`${this.id}_${n}`]),d=a.title,o=new WAi({context:this.context,id:l,nameOverride:d,breadcrumbs:[...this.breadcrumbs,`oneOf[${n}]`],schema:u??a}).convert();if(o!=null){let c=o.convertedSchema.typeDeclaration.shape;c.type==="alias"&&this.typeReferenceIsWrappedPrimitive(c.aliasOf)?t.push({type:c.aliasOf,docs:a.description}):c.type==="object"&&c.properties.length===0?t.push({type:gf.container(_b.map({keyType:w0.STRING,valueType:gf.unknown()})),docs:a.description}):(t.push({type:this.context.createNamedTypeReference(l,d),docs:a.description}),i={...i,...o.inlinedTypes,[l]:o.convertedSchema}),o.convertedSchema.typeDeclaration.referencedTypes.forEach(b=>{r.add(b)})}}return{type:lO.undiscriminatedUnion({members:t}),referencedTypes:r,inlinedTypes:i}}shouldConvertAsNullableSchemaOrReference(){return this.schema.oneOf!=null?this.schema.oneOf.some(t=>t&&typeof t=="object"&&"type"in t&&t.type==="null"):this.schema.anyOf!=null?this.schema.anyOf.some(t=>t&&typeof t=="object"&&"type"in t&&t.type==="null"):!1}removeNullFromOneOfOrAnyOf(){let t=this.schema.oneOf??this.schema.anyOf,r=this.schema.oneOf!=null?"oneOf":"anyOf";if(t==null)return;let i=t.filter(n=>!("type"in n&&n.type==="null"));if(i.length===0){this.context.errorCollector.collect({message:`Received ${r} schema with no valid non-null types`,path:this.breadcrumbs});return}return i.length===1?{...this.schema,[r]:void 0,...i[0]}:{...this.schema,[r]:i}}convertAsNullableSchemaOrReference(){let t=this.removeNullFromOneOfOrAnyOf();if(t==null)return;let i=new Ok({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReference:t}).convert();if(i==null)return;let n=this.wrapInNullable(i.type);return{type:lO.alias({aliasOf:n,resolvedType:n}),referencedTypes:i.schema?.typeDeclaration.referencedTypes??new Set,inlinedTypes:i.inlinedTypes}}typeReferenceIsWrappedPrimitive(t){switch(t.type){case"container":return this.containerTypeIsWrappedPrimitive(t.container);case"named":return!1;case"primitive":return!0;case"unknown":return!0;default:return!1}}containerTypeIsWrappedPrimitive(t){switch(t.type){case"list":return this.typeReferenceIsWrappedPrimitive(t.list);case"map":return this.typeReferenceIsWrappedPrimitive(t.keyType)&&this.typeReferenceIsWrappedPrimitive(t.valueType);case"nullable":return this.typeReferenceIsWrappedPrimitive(t.nullable);case"optional":return this.typeReferenceIsWrappedPrimitive(t.optional);case"set":return this.typeReferenceIsWrappedPrimitive(t.set);case"literal":return!0;default:return!1}}wrapInNullable(t){return gf.container(_b.nullable(t))}mergeIntoObjectSchema(t,r){return{...t,properties:{...r,...t.properties??{}}}}extendSubSchema(t){if(Object.entries(this.schema.properties??{}).length===0)return t;if(t.type==="object")return this.mergeIntoObjectSchema(t,this.schema.properties??{});this.context.isObjectSchemaType(t)||this.context.errorCollector.collect({message:"Received additional object properties for oneOf/anyOf that are not objects",path:this.breadcrumbs})}getDiscriminatorKeyForRef(t){return Object.entries(this.schema.discriminator?.mapping??{}).find(([r,i])=>i===t.$ref)?.[0]}};var W9n=class extends w0{schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){switch(this.schema.type){case"string":{let t=this.context.getAsString(this.schema.const);return t!=null?gf.container(_b.literal(x9.string(t))):gf.primitive({v1:"STRING",v2:Lp.string({default:this.context.getAsString(this.schema.default),validation:this.getStringValidation(this.schema)})})}case"number":switch(this.schema.format){case"double":return gf.primitive({v1:"DOUBLE",v2:Lp.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return gf.primitive({v1:"FLOAT",v2:Lp.float({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return gf.primitive({v1:"INTEGER",v2:Lp.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return gf.primitive({v1:"LONG",v2:Lp.long({default:this.context.getAsNumber(this.schema.default)})});case"uint32":return gf.primitive({v1:"UINT",v2:Lp.uint({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return gf.primitive({v1:"UINT_64",v2:Lp.uint64({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return gf.primitive({v1:"DOUBLE",v2:Lp.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"integer":switch(this.schema.format){case"double":return gf.primitive({v1:"DOUBLE",v2:Lp.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return gf.primitive({v1:"FLOAT",v2:Lp.float({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return gf.primitive({v1:"INTEGER",v2:Lp.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return gf.primitive({v1:"LONG",v2:Lp.long({default:this.context.getAsNumber(this.schema.default)})});case"uint32":return gf.primitive({v1:"UINT",v2:Lp.uint({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return gf.primitive({v1:"UINT_64",v2:Lp.uint64({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return gf.primitive({v1:"INTEGER",v2:Lp.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"boolean":{let t=this.context.getAsBoolean(this.schema.const);return t!=null?gf.container(_b.literal(x9.boolean(t))):gf.primitive({v1:"BOOLEAN",v2:Lp.boolean({default:this.schema.default})})}default:return}}getNumberValidation(t){return{max:t.maximum,min:t.minimum,exclusiveMax:typeof t.exclusiveMaximum=="boolean"?t.exclusiveMaximum:void 0,exclusiveMin:typeof t.exclusiveMinimum=="boolean"?t.exclusiveMinimum:void 0,multipleOf:t.multipleOf}}getStringValidation(t){return{minLength:t.minLength,maxLength:t.maxLength,pattern:t.pattern,format:t.format}}};var vJE=["description","example","title","default","deprecated","readOnly","writeOnly","xml","externalDocs","extensions"],WAi=class e extends w0{schema;id;inlined;audiences;nameOverride;constructor({context:t,breadcrumbs:r,schema:i,id:n,inlined:a=!1,nameOverride:u}){super({context:t,breadcrumbs:r}),this.schema=i,this.id=n,this.inlined=a,this.nameOverride=u,this.audiences=this.context.getAudiences({operation:this.schema,breadcrumbs:this.breadcrumbs})??[]}convert(){let t=this.tryConvertFernTypeDeclaration();if(t!=null)return t;let r=this.tryConvertEnumSchema();if(r!=null)return r;let i=this.tryConvertSingularAllOfSchema();if(i!=null)return i;let n=this.tryConvertPrimitiveSchema();if(n!=null)return n;let a=this.tryConvertArraySchema();if(a!=null)return a;let u=this.tryConvertTypeArraySchema();if(u!=null)return u;let l=this.tryConvertOneOfAnyOfSchema();if(l!=null)return l;let d=this.tryConvertMapSchema();if(d!=null)return d;let s=this.tryConvertObjectAllOfSchema();if(s!=null)return s;let o=this.tryConvertUntypedSchema();if(o!=null)return o;this.context.errorCollector.collect({message:`Failed to convert schema object: ${JSON.stringify(this.schema,null,2)}`,path:this.breadcrumbs})}tryConvertEnumSchema(){if(!this.schema.enum?.length)return;let r=new pH.FernEnumExtension({breadcrumbs:this.breadcrumbs,schema:this.schema,context:this.context}).convert(),n=new L9n({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema,maybeFernEnum:r}).convert();if(n!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:n.type,referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertSingularAllOfSchema(){if(this.schemaOnlyHasAllowedKeys(["allOf"])&&this.schema.allOf?.length===1&&this.schema.allOf[0]!=null){let t=this.context.resolveMaybeReference({schemaOrReference:this.schema.allOf[0],breadcrumbs:this.breadcrumbs});if(t!=null){let i=new e({context:this.context,breadcrumbs:[...this.breadcrumbs,"allOf","0"],schema:t,id:this.id,inlined:!0}).convert();if(i?.convertedSchema.typeDeclaration?.shape.type!=="object")return i}}}tryConvertPrimitiveSchema(){let r=new W9n({context:this.context,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:lO.alias({aliasOf:r,resolvedType:r}),referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertArraySchema(){if(this.schema.type==="array"){let r=new H9n({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:lO.alias({aliasOf:r.typeReference,resolvedType:r.typeReference}),referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertTypeArraySchema(){if(Array.isArray(this.schema.type)&&this.schema.type.length>0)return this.schema.type.length===1?this.schema.type=this.schema.type[0]:(this.schema.oneOf=this.schema.type.map(t=>({type:t})),this.schema.type=void 0),this.convert()}tryConvertOneOfAnyOfSchema(){if(this.schema.oneOf!=null||this.schema.anyOf!=null){let r=new V9n({id:this.id,context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertMapSchema(){if((typeof this.schema.additionalProperties=="object"||typeof this.schema.additionalProperties=="boolean")&&this.schema.additionalProperties!=null&&!this.schema.properties&&!this.schema.allOf){let r=new vko({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReferenceOrBoolean:this.schema.additionalProperties}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertObjectAllOfSchema(){if(this.schema.type==="object"||this.schema.properties!=null||this.schema.allOf!=null){let r=new U9n({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:r.propertiesByAudience},inlinedTypes:r.inlinedTypes}}}tryConvertUntypedSchema(){if(this.isUntypedSchema())return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:lO.alias({aliasOf:gf.unknown(),resolvedType:gf.unknown()}),referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertFernTypeDeclaration(){let r=new pH.FernTypeExtension({breadcrumbs:this.breadcrumbs,schema:this.schema,context:this.context}).convert();if(r==null)return;let i=BB_(r);if(i!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:lO.alias({aliasOf:i,resolvedType:i}),referencedTypes:new Set,omitV2Examples:!0}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}createTypeDeclaration({shape:t,referencedTypes:r,omitV2Examples:i}){return{name:this.convertDeclaredTypeName(),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:this.context.getAvailability({node:this.schema,breadcrumbs:this.breadcrumbs}),docs:this.schema.description,referencedTypes:r,source:void 0,inline:this.inlined,v2Examples:i?void 0:this.convertSchemaExamples()}}convertDeclaredTypeName(){return{typeId:this.id,fernFilepath:this.context.createFernFilepath(),name:this.context.casingsGenerator.generateName(this.id),displayName:this.nameOverride}}schemaOnlyHasAllowedKeys(t){let r=[...vJE,...t];return Object.keys(this.schema).every(n=>r.includes(n))}isUntypedSchema(){return!!(this.schema&&typeof this.schema=="object"&&!("type"in this.schema)&&!("oneOf"in this.schema)&&!("anyOf"in this.schema)&&!("allOf"in this.schema)&&!("items"in this.schema)&&!("properties"in this.schema))}convertSchemaExamples(){let t={userSpecifiedExamples:{},autogeneratedExamples:{}},r=this.context.getExamplesFromSchema({schema:this.schema,breadcrumbs:this.breadcrumbs});if(r.length===0){let i=this.generateOrValidateExample({example:void 0,ignoreErrors:!0});return t.autogeneratedExamples={[`${this.id}_example_autogenerated`]:i},t}return t.userSpecifiedExamples=this.convertUserSpecifiedExamples(r),t}convertUserSpecifiedExamples(t){let r={};for(let[i,n]of t.entries()){let a=this.context.resolveExample(n),u=this.generateOrValidateExample({example:a});r[`${this.id}_example_${i}`]=u}return r}generateOrValidateExample({example:t,ignoreErrors:r}){let i=new Wir({breadcrumbs:this.breadcrumbs,context:this.context,schema:this.schema,example:t}),{validExample:n,errors:a}=i.convert();return r||a.forEach(u=>{this.context.errorCollector.collect({message:u.message,path:u.path})}),n}};var Ok=class extends w0{schemaOrReference;schemaIdOverride;wrapAsOptional;wrapAsNullable;constructor({context:t,breadcrumbs:r,schemaOrReference:i,schemaIdOverride:n,wrapAsOptional:a=!1,wrapAsNullable:u=!1}){super({context:t,breadcrumbs:r}),this.schemaOrReference=i,this.schemaIdOverride=n,this.wrapAsOptional=a,this.wrapAsNullable=u}convert(){let t=this.maybeConvertReferenceObject({schemaOrReference:this.schemaOrReference});if(t!=null)return t;let r=this.maybeConvertSingularAllOfReferenceObject();return r??this.convertSchemaObject({schema:this.schemaOrReference})}maybeConvertReferenceObject({schemaOrReference:t}){if(this.context.isReferenceObject(t)){let r=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:this.breadcrumbs});if(r.ok)return{type:this.wrapTypeReference(r.reference),inlinedTypes:{}}}}maybeConvertSingularAllOfReferenceObject(){if(this.context.isReferenceObject(this.schemaOrReference)||this.schemaOrReference.allOf==null||this.schemaOrReference.allOf.length!==1)return;let t=this.schemaOrReference.allOf[0];if(this.context.isReferenceObject(t)){let r=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:this.breadcrumbs});if(r.ok)return{type:this.wrapTypeReference(r.reference),inlinedTypes:{}}}}convertSchemaObject({schema:t}){let r=this.schemaIdOverride??this.context.convertBreadcrumbsToName(this.breadcrumbs),i=new WAi({context:this.context,breadcrumbs:this.breadcrumbs,schema:t,id:r}),n=this.context.getAvailability({node:t,breadcrumbs:this.breadcrumbs}),a=i.convert();if(a!=null){let u=a.convertedSchema.typeDeclaration.shape;return u.type==="alias"?{type:this.wrapTypeReference(u.aliasOf),schema:a.convertedSchema,inlinedTypes:a.inlinedTypes,availability:n}:{type:this.wrapTypeReference(this.context.createNamedTypeReference(r)),schema:a.convertedSchema,inlinedTypes:{...a.inlinedTypes,[r]:a.convertedSchema},availability:n}}}wrapTypeReference(t){return this.wrapAsOptional&&this.wrapAsNullable?this.wrapInOptional(this.wrapInNullable(t)):this.wrapAsOptional?this.wrapInOptional(t):this.wrapAsNullable?this.wrapInNullable(t):t}wrapInOptional(t){return gf.container(_b.optional(t))}wrapInNullable(t){return gf.container(_b.nullable(t))}};var H9n=class e extends w0{static LIST_UNKNOWN=gf.container(_b.list(gf.unknown()));schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){if(this.schema.items!=null){Array.isArray(this.schema.items)&&(this.schema.items={oneOf:this.schema.items});let r=new Ok({context:this.context,breadcrumbs:[...this.breadcrumbs,"items"],schemaOrReference:this.schema.items}).convert();if(r!=null){let i=new Set;for(let n of r.schema?.typeDeclaration.referencedTypes??[])i.add(n);return r.inlinedTypes!=null&&Object.values(r.inlinedTypes).forEach(n=>{n.typeDeclaration.referencedTypes.forEach(a=>{i.add(a)})}),{typeReference:gf.container(_b.list(r.type)),referencedTypes:i,inlinedTypes:r.inlinedTypes}}}return{typeReference:e.LIST_UNKNOWN,referencedTypes:new Set,inlinedTypes:{}}}};var bko=class extends w0{group;method;constructor({context:t,breadcrumbs:r,group:i,method:n}){super({context:t,breadcrumbs:r}),this.group=i,this.method=n}parseMediaTypeObject({mediaTypeObject:t,resolveSchema:r,contentType:i,schemaId:n}){if(t.schema==null)return;if(r){let d=this.context.resolveMaybeReference({schemaOrReference:t.schema,breadcrumbs:[...this.breadcrumbs,"content",i]});if(d==null)return;t.schema=d}let u=new Ok({context:this.context,breadcrumbs:[...this.breadcrumbs,"content",i,"schema"],schemaOrReference:t.schema,schemaIdOverride:n}).convert();if(u==null)return;let l=t.examples!=null?Object.fromEntries(Object.entries(t.examples).map(([d,s])=>{if(this.context.isReferenceObject(s)){let o=this.context.resolveReference({reference:s,breadcrumbs:[...this.breadcrumbs,"content",i,"examples"],skipErrorCollector:!0});return o.resolved?[d,o.value]:null}return[d,s]}).filter(d=>d!=null)):void 0;return{...u,examples:l}}convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:r,exampleGenerationStrategy:i}){let n={userSpecifiedExamples:{},autogeneratedExamples:{}},a=t?.schema,u=this.context.getNamedExamplesFromMediaTypeObject({mediaTypeObject:t,breadcrumbs:this.breadcrumbs,defaultExampleName:`${[...this.group,this.method].join("_")}_example`});for(let[l,d]of u){let s=this.context.resolveExampleWithValue(d),o=this.context.isExampleWithSummary(d)?d.summary:l;s!=null&&(a!=null?n.userSpecifiedExamples[o]=this.generateOrValidateExample({schema:a,example:s,exampleGenerationStrategy:i}):n.userSpecifiedExamples[o]=s)}if(Object.keys(n.userSpecifiedExamples).length===0&&a!=null){let l=T_(`${[...this.group,this.method].join("_")}_example`);n.autogeneratedExamples[l]=this.generateOrValidateExample({schema:a,example:void 0,ignoreErrors:!0,generateOptionalProperties:r,exampleGenerationStrategy:i})}return n}generateOrValidateExample({schema:t,example:r,ignoreErrors:i,generateOptionalProperties:n,exampleGenerationStrategy:a}){let u=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(u==null)return;let l=this.context.getExamplesFromSchema({schema:u,breadcrumbs:this.breadcrumbs}),d=new Wir({breadcrumbs:this.breadcrumbs,context:this.context,schema:u,example:r??l[0],generateOptionalProperties:n??!1,exampleGenerationStrategy:a}),{validExample:s,errors:o}=d.convert();return i||o.forEach(c=>{this.context.errorCollector.collect({message:c.message,path:c.path})}),s}};var gko=class extends w0{parameter;constructor({context:t,breadcrumbs:r,parameter:i}){super({context:t,breadcrumbs:r}),this.parameter=i}convertToOutput({schema:t,typeReference:r,inlinedTypes:i}){let n=this.context.getAvailability({node:this.parameter,breadcrumbs:this.breadcrumbs}),a=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs}),u=this.getParameterSchemaWithExampleOverride({schema:a});switch(this.parameter.in){case"query":return{type:"query",parameter:{name:this.context.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:r??w0.OPTIONAL_STRING,allowMultiple:this.parameter.explode??!1,v2Examples:this.convertParameterExamples({schema:u??t}),availability:n},inlinedTypes:i};case"header":return{type:"header",parameter:{name:this.context.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:r??w0.OPTIONAL_STRING,env:void 0,v2Examples:this.convertParameterExamples({schema:u??t}),availability:n},inlinedTypes:i};case"path":return{type:"path",parameter:{name:this.context.casingsGenerator.generateName(this.parameter.name),docs:this.parameter.description,valueType:r??w0.STRING,location:"ENDPOINT",variable:void 0,v2Examples:this.convertParameterExamples({schema:u??t})},inlinedTypes:i};default:return}}getParameterSchemaWithExampleOverride({schema:t}){if(t!=null)return t.type==="string"&&t.example==null?{...t,example:this.parameter.name}:t}convertParameterExamples({schema:t}){let r={userSpecifiedExamples:{},autogeneratedExamples:{}},i=this.parameter.example,n=this.parameter.examples;for(let[a,u]of Object.entries(n??{})){let l=this.context.resolveExampleWithValue(u);l!=null&&(r.userSpecifiedExamples[a]=this.generateOrValidateExample({schema:t,example:l}))}if(i!=null){let a=this.context.generateUniqueName({prefix:`${this.parameter.name}_example`,existingNames:Object.keys(r.userSpecifiedExamples)});r.userSpecifiedExamples[a]=this.generateOrValidateExample({schema:t,example:i})}if(Object.keys(r.userSpecifiedExamples).length===0){let a=`${this.parameter.name}_example`;r.autogeneratedExamples[a]=this.generateOrValidateExample({schema:t,example:void 0,ignoreErrors:!0})}return r}generateOrValidateExample({schema:t,ignoreErrors:r,example:i}){let n=new Wir({breadcrumbs:this.breadcrumbs,context:this.context,schema:t,example:i}),{validExample:a,errors:u}=n.convert();return r||u.forEach(l=>{this.context.errorCollector.collect({message:l.message,path:l.path})}),a}};var Oko=class extends Aj{server;key="x-fern-server-name";constructor({breadcrumbs:t,server:r,context:i}){super({breadcrumbs:t,context:i}),this.server=r}convert(){let t=this.getExtensionValue(this.server,"x-name");if(!(t==null||typeof t!="string"))return t}};var IB_="Base",EHt=class e extends w0{servers;endpointLevelServers;constructor({breadcrumbs:t,context:r,servers:i,endpointLevelServers:n}){super({breadcrumbs:t,context:r}),this.servers=i,this.endpointLevelServers=n}convert(){if(this.servers==null||this.servers.length===0||this.servers[0]==null)return;if(this.endpointLevelServers!=null&&this.endpointLevelServers.length>0){let r=this.getDefaultBaseUrlName(),i={id:r,name:this.context.casingsGenerator.generateName(r)},n=this.endpointLevelServers.map(l=>{let d=e.getServerName({server:l,context:this.context});return{id:d,name:this.context.casingsGenerator.generateName(d)}}).filter((l,d,s)=>s.findIndex(o=>o.id===l.id)===d),a=[i,...n],u=this.servers.map(l=>{let d=e.getServerName({server:l,context:this.context}),s=this.endpointLevelServers?.map(o=>[e.getServerName({server:o,context:this.context}),this.getServerUrl(o)]);return{id:d,name:this.context.casingsGenerator.generateName(d),urls:{[r]:this.getServerUrl(l),...Object.fromEntries(s??[])},docs:l.description}});return{value:{defaultEnvironment:u[0]?.id,environments:cx.multipleBaseUrls({baseUrls:a,environments:u})},defaultUrl:i.id}}let t=this.withExplodedServers(this.servers).map(r=>{let i=e.getServerName({server:r,context:this.context});return{id:i,name:this.context.casingsGenerator.generateName(i),url:this.getServerUrl(r),docs:r.description}}).filter(V0);return{value:{defaultEnvironment:t[0]?.id,environments:cx.singleBaseUrl({environments:t})},defaultUrl:t[0]?.id}}static getServerExtensionName({server:t,context:r}){return new Oko({breadcrumbs:[],server:t,context:r}).convert()}static getServerName({server:t,context:r}){return e.getServerExtensionName({server:t,context:r})??t.description??t.url}getServerUrl(t){if(t.variables==null)return t.url;let r=t.url;for(let[i,n]of Object.entries(t.variables))n.default!=null&&(r=r.replace(`{${i}}`,n.default));return r}withExplodedServers(t){return t.flatMap(r=>{if(r.variables==null)return[r];let i=Object.entries(r.variables).filter(([l,d])=>d.enum!=null&&d.enum.length>0);if(i.length===0)return[r];let n=i[0];if(n==null)return[r];let[a,u]=n;return u.enum==null?[r]:u.enum.map(l=>{let d=r.url.replace(`{${a}}`,l),s={};for(let[c,b]of Object.entries(r.variables??{}))c!==a&&(s[c]=b);let o={...r,url:d,variables:Object.keys(s).length>0?s:void 0,"x-fern-server-name":r.description?`${r.description}_${l}`:`${l}`,description:r.description};return this.withExplodedServers([o])[0]})}).filter(V0)}getDefaultBaseUrlName(){return this.servers==null||this.servers.length===0||this.servers[0]==null?IB_:e.getServerExtensionName({server:this.servers[0],context:this.context})??IB_}};var BRa={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",498:"InvalidTokenError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},bJE=new Set(Object.values(BRa));var gJE=hu.object({type:hu.string(),channelId:hu.string().optional(),messageId:hu.string(),value:hu.any()}),OJE=hu.object({summary:hu.string().optional(),description:hu.string().optional(),"query-parameters":hu.record(hu.string()).optional(),headers:hu.record(hu.string()).optional(),messages:hu.array(gJE)}),zB_=hu.array(OJE);var mko=class extends Aj{channel;key="x-fern-examples";constructor({breadcrumbs:t,channel:r,context:i}){super({breadcrumbs:t??[],context:i}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(t==null)return;let r=zB_.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-examples extension: ${r.error.message}`,path:this.breadcrumbs});return}return r.data.map(i=>({summary:i.summary,description:i.description,queryParameters:i["query-parameters"],headers:i.headers,messages:i.messages.map(n=>({type:n.type,channelId:n.channelId,messageId:n.messageId,value:n.value}))}))}};var $9n=class extends w0{channel;channelPath;inlinedTypes={};websocketGroup;constructor({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a}){super({context:t,breadcrumbs:r}),this.websocketGroup=i,this.channel=n,this.channelPath=a}convertExamples({fullPath:t,baseUrl:r,asyncApiVersion:i}){let a=new mko({context:this.context,breadcrumbs:this.breadcrumbs,channel:this.channel}).convert();return a==null?{}:Object.fromEntries(a.map((u,l)=>[l.toString(),{channel:{method:"GET",path:t},baseUrl:t,environment:r,auth:void 0,pathParameters:{},queryParameters:u.queryParameters,headers:u.headers,messages:u.messages.map(d=>({type:i==="v2"?d.type:d.messageId,body:d.value}))}]))}transformToValidPath(t){return t.startsWith("/")?t:"/"+t}};var HAi=class extends QA.AbstractConverters.AbstractParameterConverter{parameterNamePrefix;constructor({context:t,breadcrumbs:r,parameter:i,parameterNamePrefix:n}){super({context:t,breadcrumbs:r,parameter:i}),this.parameterNamePrefix=n}convert(){let t,r={},n=new pH.FernOptionalExtension({breadcrumbs:this.breadcrumbs,parameter:this.parameter,context:this.context}).convert()??this.parameter.required===!1,a=this.parameter.schema??{...this.parameter,type:"string",enum:this.parameter.enum,default:this.parameter.default,example:this.parameter.example??this.parameter.name,examples:Object.values(this.parameter.examples??{}),deprecated:this.parameter.deprecated,required:void 0},l=new QA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,"schema"],schemaIdOverride:this.parameterNamePrefix?`${this.parameterNamePrefix}_${this.parameter.name}`:this.parameter.name,schemaOrReference:a,wrapAsOptional:n}).convert();return l!=null&&(t=l.type,r=l.inlinedTypes??{}),this.convertToOutput({schema:a,typeReference:t,inlinedTypes:r})}};var Pko=class extends Aj{channel;key="x-fern-address";constructor({breadcrumbs:t,channel:r,context:i}){super({breadcrumbs:t,context:i}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(!(t==null||typeof t!="string"))return t}};var G9n=class extends Aj{channel;key="x-fern-display-name";constructor({breadcrumbs:t,channel:r,context:i}){super({breadcrumbs:t,context:i}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(!(t==null||typeof t!="string"))return t}};var jko=class extends $9n{inlinedTypes={};constructor({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a}){super({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a})}convert(){let t=[],r=[],i=[],a=new G9n({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert()??this.websocketGroup?.join(".");this.channel.parameters&&this.convertPathParameters({context:this.context,pathParameters:t}),this.channel.bindings?.ws!=null&&(this.convertHeaders({context:this.context,headers:i}),this.convertBindingQueryParameters({context:this.context,queryParameters:r}));let u;this.channel.subscribe!=null&&(u=this.convertMessage({context:this.context,operation:this.channel.subscribe,origin:"server"}));let l;this.channel.publish!=null&&(l=this.convertMessage({context:this.context,operation:this.channel.publish,origin:"client"}));let d=[];u!=null&&d.push(u),l!=null&&d.push(l);let o=new Pko({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert(),c=this.transformToValidPath(o??this.channelPath),b=this.channel.servers?.[0]??Object.keys(this.context.spec.servers??{})[0],g=lF(c),O=T_(this.channelPath),m=this.context.getAudiences({operation:this.channel,breadcrumbs:this.breadcrumbs})??[];return{channel:{name:this.context.casingsGenerator.generateName(O),displayName:a,baseUrl:b,path:g,auth:!1,headers:i,queryParameters:r,pathParameters:t,messages:d,availability:this.context.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs}),docs:this.channel.description,examples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples({fullPath:c,baseUrl:b,asyncApiVersion:"v2"})}},audiences:m,inlinedTypes:this.inlinedTypes}}convertMessage({context:t,operation:r,origin:i}){let n,a=i==="server"?"subscribe":"publish",u=[...this.breadcrumbs,a],l=t.resolveMaybeReference({schemaOrReference:r.message,breadcrumbs:u});l!=null&&(r.message=l);let d=qVi(T_(`${this.channelPath}_${a}`)).replace(/ /g,"");if("oneOf"in r.message){let o=new QA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:u,schemaOrReference:r.message,schemaIdOverride:d}).convert();o!=null&&o.schema!=null&&(n=o.schema,this.inlinedTypes={...this.inlinedTypes,...o.inlinedTypes})}else if(t.isMessageWithPayload(r.message)){let s=t.resolveMaybeReference({schemaOrReference:r.message.payload,breadcrumbs:u});if(s!=null){let c=new QA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:u,schemaOrReference:s,schemaIdOverride:d}).convert();c!=null&&c.schema!=null&&(n=c.schema,this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes})}}if(n!=null){let s=n,o=gf.named({fernFilepath:t.createFernFilepath(),name:s.typeDeclaration.name.name,typeId:s.typeDeclaration.name.typeId,displayName:void 0,default:void 0,inline:!1}),c=R9.reference({bodyType:o,docs:r.description}),b=i==="server"?"subscribe":"publish";return{type:b,displayName:b,origin:i,body:c,availability:t.getAvailability({node:r,breadcrumbs:this.breadcrumbs}),docs:r.description}}}convertPathParameters({context:t,pathParameters:r}){for(let[i,n]of Object.entries(this.channel.parameters??{})){let a=t.resolveMaybeReference({schemaOrReference:n,breadcrumbs:this.breadcrumbs});if(a==null)continue;let l=new HAi({context:this.context,breadcrumbs:this.breadcrumbs,parameter:{...a,name:i,in:"path",description:n.description,required:n.required??!0}}).convert();l!=null&&(this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes},l.type==="path"&&r.push(l.parameter))}}convertHeaders({context:t,headers:r}){if(this.channel.bindings?.ws?.headers!=null){let i=this.channel.bindings.ws.headers.required??[];for(let[n,a]of Object.entries(this.channel.bindings.ws.headers.properties??{})){let u=t.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,n]});if(u==null)continue;let d=new HAi({context:this.context,breadcrumbs:[...this.breadcrumbs,n],parameter:{name:n,in:"header",required:i.includes(n),schema:u,description:"description"in u?u.description:void 0}}).convert();d!=null&&d.type==="header"&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},r.push(d.parameter))}}}convertBindingQueryParameters({context:t,queryParameters:r}){if(this.channel.bindings?.ws?.query!=null){let i=this.channel.bindings.ws.query.required??[];for(let[n,a]of Object.entries(this.channel.bindings.ws.query.properties??{})){let u=t.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,n]});if(u==null)continue;let d=new HAi({context:this.context,breadcrumbs:[...this.breadcrumbs,n],parameter:{name:n,in:"query",required:i.includes(n),schema:u,description:"description"in u?u.description:void 0,deprecated:u.deprecated??!1}}).convert();d!=null&&d.type==="query"&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},r.push(d.parameter))}}}};var Q9n=class extends w0{servers;constructor({context:t,breadcrumbs:r,servers:i}){super({context:t,breadcrumbs:r}),this.servers=i}convert(){if(this.servers==null||Object.keys(this.servers).length===0)return;let t=[],r;for(let[i,n]of Object.entries(this.servers)){let a=this.buildSingleBaseUrlEnvironment(this.context,i,n);t.push(a),r==null&&(r=a.id)}return{defaultEnvironment:r,environments:cx.singleBaseUrl({environments:t})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var wko=class extends Q9n{constructor({context:t,breadcrumbs:r,servers:i}){super({context:t,breadcrumbs:r,servers:i})}buildSingleBaseUrlEnvironment(t,r,i){return{id:r,name:t.casingsGenerator.generateName(r),url:this.constructServerUrl(i.protocol,i.url),docs:void 0}}};var kPc="$message.",xB_="#/channels/",RB_="#/servers/",Sko=class extends $9n{operations;inlinedTypes={};constructor({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a,operations:u}){super({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a}),this.operations=u}convert(){let t=[],r=[],i=[],a=new G9n({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert()??this.websocketGroup?.join(".")??this.channelPath;this.channel.parameters&&this.convertChannelParameters({pathParameters:t,queryParameters:r,headers:i,channelPath:this.channelPath});let u=Object.entries(this.operations).reduce((b,[g,O])=>{try{this.getChannelPathFromOperation(O)===this.channelPath&&(b[g]=O)}catch{}return b},{}),l=[];for(let[b,g]of Object.entries(u))for(let O of g.messages){let m=this.context.convertReferenceToTypeReference({reference:O});if(m.ok){let P=R9.reference({bodyType:m.reference,docs:g.description});l.push({type:b,displayName:b,origin:g.action==="send"?"client":"server",body:P,availability:this.context.getAvailability({node:g,breadcrumbs:this.breadcrumbs}),docs:g.description})}}let d=this.resolveChannelServersFromReference(this.channel.servers??[])??Object.keys(this.context.spec.servers??{})[0],s=this.transformToValidPath(this.channel.address??this.channelPath),o=lF(s),c=this.context.getAudiences({operation:this.channel,breadcrumbs:this.breadcrumbs})??[];return{channel:{name:this.context.casingsGenerator.generateName(a),displayName:a,baseUrl:d,path:o,auth:!1,headers:i,queryParameters:r,pathParameters:t,messages:l,availability:this.context.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs}),docs:this.channel.description,examples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples({fullPath:s,baseUrl:d,asyncApiVersion:"v3"})}},audiences:c,inlinedTypes:this.inlinedTypes}}convertChannelParameters({pathParameters:t,queryParameters:r,headers:i,channelPath:n}){for(let a of Object.values(this.channel.parameters??{})){let u=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,"parameters"]});if(u==null)continue;let l=this.convertChannelParameterLocation(a.location);if(l==null)continue;let{type:d,parameterKey:s}=l,c=new HAi({context:this.context,breadcrumbs:this.breadcrumbs,parameter:{...u,name:s,in:d},parameterNamePrefix:this.channelPath}).convert();if(c!=null)switch(this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes},c.type){case"path":t.push(c.parameter);break;case"query":r.push(c.parameter);break;case"header":i.push(c.parameter);break}}}convertChannelParameterLocation(t){try{let[r,i]=t.split("#/");if(r==null||i==null){this.context.errorCollector.collect({message:`Invalid location format: ${t}; unable to parse message type and parameter key`,path:this.breadcrumbs});return}if(!r.startsWith(kPc)){this.context.errorCollector.collect({message:`Invalid location format: ${t}; expected ${kPc} prefix`,path:this.breadcrumbs});return}let n=r.substring(kPc.length);if(n!=="header"&&n!=="path"&&n!=="payload"){this.context.errorCollector.collect({message:`Invalid message type: ${n}. Must be one of: header, path, payload`,path:this.breadcrumbs});return}return n==="payload"?{type:"query",parameterKey:i}:{type:n,parameterKey:i}}catch{this.context.errorCollector.collect({message:`Invalid location format: ${t}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`,path:this.breadcrumbs});return}}resolveChannelServersFromReference(t){if(t==null||t.length===0||t[0]==null)return;let r=t[0];if(!r.$ref.startsWith(RB_)){this.context.errorCollector.collect({message:`Failed to resolve server name from server ref ${r.$ref}`,path:this.breadcrumbs});return}let i=r.$ref.substring(RB_.length);if(i==null){this.context.errorCollector.collect({message:`Failed to find server with name ${i}`,path:this.breadcrumbs});return}return i}getChannelPathFromOperation(t){if(!t.channel.$ref.startsWith(xB_))throw new Error(`Failed to resolve channel path from operation ${t.channel.$ref}`);return t.channel.$ref.substring(xB_.length)}};var Dko=class extends Q9n{constructor({context:t,breadcrumbs:r,servers:i}){super({context:t,breadcrumbs:r,servers:i})}buildSingleBaseUrlEnvironment(t,r,i){return{id:r,name:t.casingsGenerator.generateName(r),url:this.constructServerUrl(i.protocol,i.host),docs:void 0}}};var IRa=class extends Mpi{constructor({context:t,breadcrumbs:r,audiences:i}){super({context:t,breadcrumbs:r,audiences:i})}async convert(){return this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.context.spec=await this.resolveAllExternalRefs({spec:this.context.spec}),this.isAsyncAPIV3(this.context)?this.convertChannelMessages():this.convertComponentMessages(),this.convertSchemas(),this.convertServers(),this.convertChannels(),this.finalizeIr()}isAsyncAPIV3(t){return parseFloat(t.spec.asyncapi)>=3}convertChannelMessages(){let t=this.context.spec;for(let[r,i]of Object.entries(t.channels??{}))for(let[n,a]of Object.entries(i.messages??{})){if(!this.context.isMessageWithPayload(a)&&!this.context.isReferenceObject(a))continue;let u=["channels",r,"messages",n],l=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:u});if(!this.context.isMessageWithPayload(l))continue;let d=this.context.resolveMaybeReference({schemaOrReference:l.payload,breadcrumbs:u});if(d==null)continue;let s=`${r}_${n}`;this.convertSchema({id:s,breadcrumbs:u,schema:d})}}convertComponentMessages(){for(let[t,r]of Object.entries(this.context.spec.components?.messages??{})){if(r.payload==null)continue;let i=["components","messages",t],n=this.context.resolveMaybeReference({schemaOrReference:r.payload,breadcrumbs:i});n!=null&&this.convertSchema({id:t,breadcrumbs:i,schema:n})}}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{}))this.convertSchema({id:t,breadcrumbs:["components","schemas",t],schema:r})}convertSchema({id:t,breadcrumbs:r,schema:i}){let a=new QA.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:r,schema:i}).convert();a!=null&&(this.addTypeToRootPackage(t),this.addTypesToIr({...a.inlinedTypes,[t]:a.convertedSchema}))}convertServers(){let t;if(this.isAsyncAPIV3(this.context)){let r=this.context.spec.servers;t=new Dko({context:this.context,breadcrumbs:["servers"],servers:r}).convert()}else{let r=this.context.spec.servers;t=new wko({context:this.context,breadcrumbs:["servers"],servers:r}).convert()}this.addEnvironmentsToIr({environmentConfig:t})}convertChannels(){for(let[t,r]of Object.entries(this.context.spec.channels??{})){let n=new pH.SdkGroupNameExtension({breadcrumbs:["channels",t],operation:r,context:this.context}).convert()?.groups,a;if(this.isAsyncAPIV3(this.context)){let l=this.context.spec.operations??{};a=new Sko({context:this.context,breadcrumbs:["channels",t],websocketGroup:n,channel:r,channelPath:t,operations:l}).convert()}else a=new jko({context:this.context,breadcrumbs:["channels",t],websocketGroup:n,channel:r,channelPath:t}).convert();a!=null&&(this.addWebsocketChannelToIr({websocketChannel:a.channel,channelPath:t,audiences:a.audiences,websocketGroup:n}),this.addTypesToIr(a.inlinedTypes))}}};var zRa=class extends f8{isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}getTypeIdFromMessageReference(t){let r=t.$ref.match(/\/messages\/(.+)$/);if(!(!r||!r[1]))return r[1]}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n}){let a,u=t.$ref.match(/^.*\/schemas\/(.+)$/),l=t.$ref.match(/^.*\/channels\/([^/]+)\/messages\/(.+)$/),d=t.$ref.match(/^.*\/messages\/(.+)$/);if(u&&u[1])return a=u[1],this.convertSchemaReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a});if(l&&l[2]){let s=l[1],o=l[2];return a=`${s}_${o}`,this.convertV3MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a})}else return d&&d[1]?(a=d[1],this.convertV2MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a})):{ok:!1}}convertSchemaReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a}){let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let l;return n==="reference_identifier"?l=i??u.value.title:(n==="discriminator_key"||n==="schema_identifier")&&(l=u.value.title??i),{ok:!0,reference:gf.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:l,default:void 0,inline:!1})}}convertV3MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a}){let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let l;return n==="reference_identifier"?l=i??u.value.name:(n==="discriminator_key"||n==="schema_identifier")&&(l=u.value.name??i),{ok:!0,reference:gf.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:l,default:void 0,inline:!1})}}convertV2MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a}){let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let l;return n==="reference_identifier"?l=i??u.value.messageId??u.value.name:(n==="discriminator_key"||n==="schema_identifier")&&(l=u.value.messageId??u.value.name??i),{ok:!0,reference:gf.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:l,default:void 0,inline:!1})}}};var UB_=ci(ejc(),1);var ijc=ci(ejc(),1);var NB_=["get","post","put","delete","patch","head"];var Eko=class extends Aj{operation;key="x-fern-idempotent";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-idempotent",path:this.breadcrumbs});return}return t}}};var jJE=hu.object({cursor:hu.string(),next_cursor:hu.string(),results:hu.string()}),wJE=hu.object({offset:hu.string(),results:hu.string(),step:hu.string().optional(),"has-next-page":hu.string().optional()}),tjc=hu.union([hu.boolean(),jJE,wJE]);var rjc="$request.",Mko="$response.",Ako=class extends Aj{operation;document;key="x-fern-pagination";constructor({breadcrumbs:t,operation:r,document:i,context:n}){super({breadcrumbs:t,context:n}),this.operation=r,this.document=i}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=tjc.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-pagination extension: ${r.error.message}`,path:this.breadcrumbs});return}if(typeof r.data=="boolean"){let i=this.getExtensionValue(this.document);if(i==null)return;if(typeof i=="boolean"){this.context.errorCollector.collect({message:"Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.",path:this.breadcrumbs});return}let n=tjc.safeParse(i);if(!n.success){this.context.errorCollector.collect({message:`Invalid x-fern-pagination extension: ${n.error.message}`,path:this.breadcrumbs});return}if(typeof n.data=="boolean"){this.context.errorCollector.collect({message:"Global pagination extension is a boolean, expected an object.",path:this.breadcrumbs});return}return this.convertPaginationConfig({config:n.data})}if(typeof r.data=="boolean"){this.context.errorCollector.collect({message:"Pagination extension is a boolean with no global configuration.",path:this.breadcrumbs});return}return this.convertPaginationConfig({config:r.data})}convertPaginationConfig({config:t}){let r=t;if("cursor"in r)return{type:"cursor",cursor:f8.maybeTrimPrefix(r.cursor,rjc),nextCursor:f8.maybeTrimPrefix(r.next_cursor,Mko),results:f8.maybeTrimPrefix(r.results,Mko)};let i=t;return{type:"offset",offset:f8.maybeTrimPrefix(i.offset,rjc),results:f8.maybeTrimPrefix(i.results,Mko),step:i.step!=null?f8.maybeTrimPrefix(i.step,rjc):void 0,hasNextPage:i["has-next-page"]!=null?f8.maybeTrimPrefix(i["has-next-page"],Mko):void 0}}};var SJE="$request.",DJE=hu.object({"stream-condition":hu.string().optional(),format:hu.enum(["sse","json"]).optional(),"stream-description":hu.string().optional(),"response-stream":hu.any(),response:hu.any()}),EJE=hu.union([hu.boolean(),DJE]),qko=class extends Aj{operation;key="x-fern-streaming";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=EJE.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-streaming extension: ${r.error.message}`,path:this.breadcrumbs});return}if(typeof r.data=="boolean")return r.data?{type:"stream",format:"json"}:void 0;if(r.data["stream-condition"]==null&&r.data.format!=null)return{type:"stream",format:r.data.format};if(r.data["stream-condition"]==null){this.context.errorCollector.collect({message:"Missing stream-condition property without specified format.",path:this.breadcrumbs});return}return{type:"streamCondition",format:r.data.format??"json",streamDescription:r.data["stream-description"],streamConditionProperty:f8.maybeTrimPrefix(r.data["stream-condition"],SJE),responseStream:r.data["response-stream"],response:r.data.response}}};var Tko=class extends Aj{operation;key="x-fern-webhook";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-webhook",path:this.breadcrumbs});return}return t}}};var Cko=class extends Aj{operation;key="x-fern-examples";constructor({context:t,breadcrumbs:r,operation:i}){super({breadcrumbs:r,context:t}),this.operation=i}convert(){let t=this.getExtensionValue(this.operation);return t==null?void 0:(Array.isArray(t)?t:[]).filter(n=>{let a=JN.serialization.ExampleEndpointCallSchema.parse(n);return a.ok||this.context.errorCollector.collect({message:`Failed to parse x-fern-example in ${this.breadcrumbs.join(".")}`,path:this.breadcrumbs}),a.ok})}};var Bko=class extends QA.AbstractConverters.AbstractMediaTypeObjectConverter{responseBody;statusCode;streamingExtension;constructor({context:t,breadcrumbs:r,responseBody:i,group:n,method:a,statusCode:u,streamingExtension:l}){super({context:t,breadcrumbs:r,group:n,method:a}),this.responseBody=i,this.statusCode=u,this.streamingExtension=l}convert(){return this.shouldConvertAsStreaming()?this.convertStreaming():this.convertNonStreaming()}convertStreaming(){if(this.streamingExtension==null)return;let t=[...this.group,this.method,"Response",this.statusCode].join("_"),r=Object.keys(this.responseBody.content??{});for(let i of r){let n=this.responseBody.content?.[i];if(n==null)continue;let a=this.parseMediaTypeObject({mediaTypeObject:n,schemaId:t,contentType:this.streamingExtension.format});if(a!=null)return this.convertStreamingResponse({mediaTypeObject:n,convertedSchema:a})}}convertNonStreaming(){let t=[...this.group,this.method,"Response",this.statusCode].join("_"),r=Object.keys(this.responseBody.content??{}).filter(n=>n.includes("json"));for(let n of r){let a=this.responseBody.content?.[n];if(a==null)continue;let u=this.parseMediaTypeObject({mediaTypeObject:a,schemaId:t,contentType:n});if(u!=null&&this.shouldReturnJsonResponse(n))return this.returnJsonResponse({mediaTypeObject:a,convertedSchema:u})}let i=Object.keys(this.responseBody.content??{}).filter(n=>!n.includes("json"));for(let n of i){let a=this.responseBody.content?.[n];if(a==null)continue;let u=this.parseMediaTypeObject({mediaTypeObject:a,schemaId:t,contentType:n});if(u!=null){if(this.isBinarySchema(u))return this.shouldReturnBytesResponse()?this.returnBytesResponse({mediaTypeObject:a}):this.returnFileDownloadResponse({mediaTypeObject:a});if(this.shouldReturnTextResponse(n))return this.returnTextResponse({mediaTypeObject:a})}}}convertStreamingResponse({mediaTypeObject:t,convertedSchema:r}){if(this.streamingExtension==null)return;switch(this.streamingExtension.format){case"json":return{responseBody:gE.streaming(SW.json({docs:this.responseBody.description,payload:r.type,terminator:void 0,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples};case"sse":return{responseBody:gE.streaming(SW.sse({docs:this.responseBody.description,payload:r.type,terminator:void 0,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples};default:return}}returnJsonResponse({mediaTypeObject:t,convertedSchema:r}){return{responseBody:gE.json(AZ.response({responseBodyType:r.type,docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples}}returnBytesResponse({mediaTypeObject:t}){return{responseBody:gE.bytes({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}returnFileDownloadResponse({mediaTypeObject:t}){return{responseBody:gE.fileDownload({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}returnTextResponse({mediaTypeObject:t}){return{responseBody:gE.text({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}isBinarySchema(t){let r=t.type;switch(r.type){case"container":case"named":case"unknown":return!1;case"primitive":return r.primitive.v2==null?!1:r.primitive.v2.type==="string"&&r.primitive.v2.validation?.format==="binary";default:return!1}}shouldConvertAsStreaming(){return this.streamingExtension!=null}shouldReturnJsonResponse(t){return t.includes("json")}shouldReturnBytesResponse(){return(this.context.settings?.useBytesForBinaryResponse??!1)&&this.streamingExtension==null}shouldReturnTextResponse(t){return mM.parse(t)?.isText()??!1}};var Iko=class extends QA.AbstractConverters.AbstractMediaTypeObjectConverter{responseError;statusCode;methodName;constructor({context:t,breadcrumbs:r,responseError:i,group:n,method:a,methodName:u,statusCode:l}){super({context:t,breadcrumbs:r,group:n,method:a}),this.responseError=i,this.statusCode=l,this.methodName=u}convert(){if(!this.responseError.content){let i=BRa[this.statusCode];if(i==null){this.context.logger.warn(`No error name found for status code ${this.statusCode}`);return}let n=this.getErrorIdFromErrorName(i);return{error:{error:{name:this.context.casingsGenerator.generateName(n),fernFilepath:{allParts:[],packagePath:[],file:void 0},errorId:n},docs:this.responseError.description},errorType:gf.unknown(),displayName:i,statusCode:this.statusCode,inlinedTypes:{},examples:{}}}let t=Object.keys(this.responseError.content).filter(i=>i.includes("json")),r=BRa[this.statusCode];if(r==null){this.context.logger.warn(`No error name found for status code ${this.statusCode}`);return}for(let i of[...t]){let n=this.responseError.content?.[i];if(n==null)continue;let a=this.parseMediaTypeObject({mediaTypeObject:n,schemaId:FB_(`${this.methodName}Request${r}`),contentType:i});if(a==null)continue;let u=this.getErrorIdFromErrorName(r);if(a.schema!=null)return this.constructErrorConverterOutput({errorName:r,errorId:u,fernFilepath:a.schema.typeDeclaration.name.fernFilepath,convertedSchema:a});if(a.type.type==="named")return this.constructErrorConverterOutput({errorName:r,errorId:u,fernFilepath:a.type.fernFilepath,convertedSchema:a})}}constructErrorConverterOutput({errorName:t,errorId:r,fernFilepath:i,convertedSchema:n}){return{error:{error:{name:this.context.casingsGenerator.generateName(r),fernFilepath:i,errorId:r},docs:this.responseError.description},errorType:n.type,displayName:t,statusCode:this.statusCode,inlinedTypes:n.inlinedTypes,examples:n.examples}}getErrorIdFromErrorName(t){return this.context.enableUniqueErrorsPerEndpoint?FB_(`${this.methodName}Request${t}`):t}};function FB_(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}var zko=class extends QA.AbstractConverters.AbstractParameterConverter{constructor({context:t,breadcrumbs:r,parameter:i}){super({context:t,breadcrumbs:r,parameter:i})}convert(){let t,r={};if(this.parameter.schema!=null){let n=new QA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required}).convert();n!=null&&(t=n.type,r=n.inlinedTypes??{})}return this.convertToOutput({schema:this.parameter.schema??{type:"string"},typeReference:t,inlinedTypes:r})}};var xko=class extends QA.AbstractConverters.AbstractMediaTypeObjectConverter{requestBody;schemaId;streamingExtension;constructor({context:t,breadcrumbs:r,requestBody:i,group:n,method:a,streamingExtension:u}){super({context:t,breadcrumbs:r,group:n,method:a}),this.requestBody=i,this.schemaId=[...this.group,this.method,"Request"].join("_"),this.streamingExtension=u}convert(){if(!this.requestBody.content)return;let t=Object.keys(this.requestBody.content).filter(u=>mM.parse(u)?.isJSON());for(let u of t){let l=this.handleJsonOrFormContent({contentType:u});if(l!=null)return l}let r=Object.keys(this.requestBody.content).filter(u=>mM.parse(u)?.isURLEncoded());for(let u of r){let l=this.handleJsonOrFormContent({contentType:u});if(l!=null)return l}let i=Object.keys(this.requestBody.content).filter(u=>mM.parse(u)?.isPlainText());for(let u of i){let l=this.handleJsonOrFormContent({contentType:u});if(l!=null)return l}let n=Object.keys(this.requestBody.content).filter(u=>mM.parse(u)?.isMultipart());for(let u of n){let l=this.handleMultipartContent({contentType:u});if(l!=null)return l}let a=Object.keys(this.requestBody.content).filter(u=>mM.parse(u)?.isOctetStream());for(let u of a){let l=this.handleOctetStreamContent({contentType:u});if(l!=null)return l}}handleJsonOrFormContent({contentType:t}){let r=this.requestBody.content[t];if(r==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,contentType:t});if(i!=null)return i.schema?.typeDeclaration.shape.type==="object"?{requestBody:ZC.inlinedRequestBody({contentType:t,docs:this.requestBody.description,name:this.context.casingsGenerator.generateName(this.schemaId),extendedProperties:i.schema?.typeDeclaration.shape.extendedProperties,extends:i.schema?.typeDeclaration.shape.extends,properties:i.schema?.typeDeclaration.shape.properties,extraProperties:i.schema?.typeDeclaration.shape.extraProperties,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:i.inlinedTypes})}:{requestBody:ZC.reference({contentType:t,docs:this.requestBody.description,requestBodyType:i.type,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:i.inlinedTypes??{}}}handleMultipartContent({contentType:t}){let r=this.requestBody.content[t];if(r==null||r.schema==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,resolveSchema:!0,contentType:t});if(i!=null&&i.schema?.typeDeclaration.shape.type==="object")return{requestBody:ZC.fileUpload({contentType:t,docs:this.requestBody.description,name:this.context.casingsGenerator.generateName(this.schemaId),properties:i.schema?.typeDeclaration.shape.properties.map(n=>this.convertRequestBodyProperty({property:n,contentType:t})),v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:i.inlinedTypes}),examples:i.examples}}handleOctetStreamContent({contentType:t}){let r=this.requestBody.content[t];if(r==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,contentType:t});return{requestBody:ZC.bytes({contentType:t,isOptional:this.requestBody.required===!1,docs:this.requestBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:i?.inlinedTypes??{}}}convertRequestBodyProperty({property:t,contentType:r}){let{isFile:i,isOptional:n,isArray:a}=this.recursivelyCheckTypeReferenceIsFile({typeReference:t.valueType});return i?a?z9.file(Qne.fileArray({key:t.name,isOptional:n,contentType:r,docs:t.docs})):z9.file(Qne.file({key:t.name,isOptional:n,contentType:r,docs:t.docs})):z9.bodyProperty({...t,contentType:r,style:void 0,name:t.name})}recursivelyCheckTypeReferenceIsFile({typeReference:t,isOptional:r,isArray:i}){return this.context.isList(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.list,isOptional:r,isArray:!0}):this.context.isOptional(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.optional,isOptional:!0,isArray:i}):this.context.isNullable(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.nullable,isOptional:r,isArray:i}):{isFile:this.context.isFile(t),isOptional:r??!1,isArray:i??!1}}};var MJE=/{([^}]+)}/g,AJE=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]),J9n=class extends w0{operation;method;path;inlinedTypes={};constructor({context:t,breadcrumbs:r,operation:i,method:n,path:a}){super({context:t,breadcrumbs:r}),this.operation=i,this.method=n,this.path=a}convertHttpMethod(){switch(this.method){case"get":return lR.Get;case"post":return lR.Post;case"put":return lR.Put;case"delete":return lR.Delete;case"patch":return lR.Patch;case"head":return lR.Head;default:return}}convertParameters({breadcrumbs:t}){let r=[],i=[],n=[];if(!this.operation.parameters)return this.checkMissingPathParameters(r),{pathParameters:r,queryParameters:i,headers:n};for(let a of this.operation.parameters){let u=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:t});if(u==null)continue;let d=new zko({context:this.context,breadcrumbs:t,parameter:u}).convert();if(d!=null)switch(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},d.type){case"path":r.push(d.parameter);break;case"query":i.push(d.parameter);break;case"header":{let s=d.parameter.name.name.originalName,o=d.parameter.name.wireValue,c=!1,b=this.context.authOverrides?.["auth-schemes"];if(b!=null){for(let g of Object.values(b))if(BJE(g)&&g.header.toLowerCase()===o.toLowerCase()){c=!0;break}}!AJE.has(s.toLowerCase())&&!c&&n.push(d.parameter);break}}}return this.checkMissingPathParameters(r),{pathParameters:r,queryParameters:i,headers:n}}checkMissingPathParameters(t){let i=[...this.path.matchAll(MJE)].map(n=>n[1]).filter(n=>!t.some(a=>a.name.originalName===n));for(let n of i){if(n==null)continue;let a=`${n}_example`;t.push({name:this.context.casingsGenerator.generateName(n),valueType:w0.STRING,docs:void 0,location:"ENDPOINT",variable:void 0,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{[a]:this.generateStringParameterExample({example:n})}}})}}convertRequestBody({breadcrumbs:t,group:r,method:i,streamingExtension:n}){if(this.operation.requestBody==null)return;let a=this.context.resolveMaybeReference({schemaOrReference:this.operation.requestBody,breadcrumbs:t});if(a==null)return null;let l=new xko({context:this.context,breadcrumbs:t,requestBody:a,group:r??[],method:i,streamingExtension:n}).convert();if(l!=null)return this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes},{value:l.requestBody,examples:l.examples}}computeGroupNameAndLocationFromExtensions(){let r=new pH.SdkMethodNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert()?.methodName,n=new pH.SdkGroupNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert()?.groups??[];if(r!=null)return{group:n,method:r}}evaluateMethodNameFromOperation(){let t=this.operation.operationId;return t??(this.operation.summary!=null?T_(this.operation.summary):T_(`${this.method}_${this.path.split("/").join("_")}`))}computeGroupNameFromTagAndOperationId(){let t=this.operation.tags?.[0],r=this.evaluateMethodNameFromOperation();if(t==null)return{method:r};let i=LB_(t),n=LB_(r);return OEe(i,n)?{method:t}:this.computeGroupAndMethodFromTokens({tag:t,tagTokens:i,methodName:r,methodNameTokens:n})}computeGroupAndMethodFromTokens({tag:t,tagTokens:r,methodName:i,methodNameTokens:n}){if(r.some((l,d)=>l!==n[d]))return{group:[t],method:i};let u=n.slice(r.length);return{group:[t],method:T_(u.join("_"))}}generateStringParameterExample({example:t}){let r=new QA.ExampleConverter({breadcrumbs:this.breadcrumbs,context:this.context,schema:{type:"string"},example:t}),{validExample:i}=r.convert();return i}};function LB_(e){let t=qJE(e)?TJE(e):CJE(e);return t=t.map(r=>r.toLowerCase()),t=Sxe(t),t}function qJE(e){return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)}function TJE(e){return e.split(/(?=[A-Z])/)}function CJE(e){return e.split(/[^a-zA-Z0-9]+/)}function BJE(e){return e?.header!=null}var Rko=class e extends J9n{idempotent;idToAuthScheme;topLevelServers;streamingExtension;static AUTHORIZATION_HEADER="Authorization";constructor({context:t,breadcrumbs:r,operation:i,method:n,path:a,idempotent:u,idToAuthScheme:l,topLevelServers:d,streamingExtension:s}){super({context:t,breadcrumbs:r,operation:i,method:n,path:a}),this.idempotent=u,this.idToAuthScheme=l,this.topLevelServers=d,this.streamingExtension=s}convert(){let t=this.convertHttpMethod();if(t==null)return;let{group:r,method:i}=this.computeGroupNameAndLocationFromExtensions()??this.computeGroupNameFromTagAndOperationId(),{headers:n,pathParameters:a,queryParameters:u}=this.convertParameters({breadcrumbs:[...this.breadcrumbs,"parameters"]}),l=this.convertRequestBody({breadcrumbs:[...this.breadcrumbs,"requestBody"],group:r,method:i,streamingExtension:this.streamingExtension}),d=l?.value,s=this.convertResponseBody({breadcrumbs:[...this.breadcrumbs,"responses"],group:r,method:i,streamingExtension:this.streamingExtension}),o=s?.response,c=s?.streamResponse,b=s!=null?s.errors:[],g={},O=b.map(I=>I.error),m=lF(this.path),P=this.getEndpointBaseUrl(),E=this.getEndpointBaseUrls(),q=this.convertExamples({httpPath:m,httpMethod:t,baseUrl:P}),M=new Set(this.operation.security?.flatMap(I=>Object.keys(I))??[]),D=this.authSchemeToHeaders(Array.from(M));D.length>0&&n.push(...D);for(let I of b){let L=I.error,V=I.errorType,X=L.error.errorId;g[X]={name:L.error,displayName:I.displayName,discriminantValue:{name:L.error.name,wireValue:X},type:V,statusCode:I.statusCode,docs:L.docs,examples:[],v2Examples:void 0}}let C={displayName:this.operation.summary,method:t,name:this.context.casingsGenerator.generateName(i),baseUrl:P,v2BaseUrls:E,path:m,pathParameters:a,queryParameters:u,headers:n.filter((I,L,V)=>L===V.findIndex(X=>X.name.wireValue===I.name.wireValue)),requestBody:d,sdkRequest:void 0,errors:O,auth:this.operation.security!=null||this.context.spec.security!=null,availability:this.context.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs}),docs:this.operation.description,userSpecifiedExamples:[],autogeneratedExamples:[],idempotent:this.idempotent??!1,basePath:void 0,fullPath:m,allPathParameters:a,pagination:void 0,transport:void 0,v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:q},source:Gne.openapi()},x=this.context.namespace!=null?[this.context.namespace]:[],$=r?.map(I=>T_(I));return x.push(...$??[]),{audiences:this.context.getAudiences({operation:this.operation,breadcrumbs:this.breadcrumbs})??[],group:r,errors:g,endpoint:{id:`endpoint_${x.join("/")}.${i}`,...C,response:o},streamEndpoint:c!=null&&c.body!=null?{id:`endpoint_${x.join("/")}.${i}_stream`,...C,response:c}:void 0,inlinedTypes:this.inlinedTypes,servers:this.filterOutTopLevelServers(this.operation.servers??[])}}convertResponseBody({breadcrumbs:t,group:r,method:i,streamingExtension:n}){if(this.operation.responses==null)return;let a,u=!1;for(let[l,d]of Object.entries(this.operation.responses)){let s=parseInt(l);if(!(isNaN(s)||s<200||s>=300&&s<400)){if(a==null&&(a={response:void 0,streamResponse:void 0,errors:[],examples:{}}),s>=200&&s<300&&!u){let o=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:[...t,l]});if(o==null)continue;let b=new Bko({context:this.context,breadcrumbs:[...t,l],responseBody:o,group:r??[],method:i,statusCode:l,streamingExtension:n}).convert();b!=null&&(u=!0,this.inlinedTypes={...this.inlinedTypes,...b.inlinedTypes},a.response={statusCode:s,body:b.responseBody},a.streamResponse={statusCode:s,body:b.streamResponseBody})}if(s>=400&&s<600){let o=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:[...t,l]});if(o==null)continue;let b=new Iko({context:this.context,breadcrumbs:[...t,l],responseError:o,group:r??[],method:i,methodName:this.evaluateMethodNameFromOperation(),statusCode:s}).convert();b!=null&&(this.inlinedTypes={...this.inlinedTypes,...b.inlinedTypes},a.errors.push(b))}}}return a}authSchemeToHeaders(t){let r=[];for(let i of t){let n=this.idToAuthScheme?.[i];if(n==null)continue;let a={valueType:w0.STRING,availability:void 0,docs:void 0,env:void 0,v2Examples:void 0};switch(n.type){case"bearer":r.push({name:{name:this.context.casingsGenerator.generateName(e.AUTHORIZATION_HEADER),wireValue:e.AUTHORIZATION_HEADER},...a});break;case"basic":r.push({name:{name:this.context.casingsGenerator.generateName(e.AUTHORIZATION_HEADER),wireValue:e.AUTHORIZATION_HEADER},...a});break;case"header":r.push({name:n.name,...a});break}}return r}convertExamples({httpPath:t,httpMethod:r,baseUrl:i}){let a=new Cko({context:this.context,breadcrumbs:this.breadcrumbs,operation:this.operation}).convert();return a==null?{}:Object.fromEntries(a.map((u,l)=>[u.name??`Example_${l}`,{request:u.request!=null?{docs:void 0,endpoint:{method:r,path:this.buildExamplePath(t,u["path-parameters"]??{})},baseUrl:void 0,environment:i,auth:void 0,pathParameters:u["path-parameters"]??{},queryParameters:u["query-parameters"]??{},headers:u.headers??{},requestBody:u.request}:void 0,response:u.response!=null?{docs:void 0,statusCode:void 0,body:Ws.V2HttpEndpointResponseBody.json(u.response)}:void 0,codeSamples:u["code-samples"]?.map(d=>({docs:void 0,language:("language"in d?d.language:d.sdk)??void 0,code:d.code}))}]))}getEndpointBaseUrl(){let t=this.operation.servers?.[0];if(t==null)return;let i=this.topLevelServers?.find(n=>n.url===t.url)??t;return EHt.getServerName({server:i,context:this.context})}getEndpointBaseUrls(){let t=this.operation.servers;return t?.map(i=>{let a=this.topLevelServers?.find(u=>u.url===i.url)??i;return EHt.getServerName({server:a,context:this.context})})}buildExamplePath(t,r){return t.head+t.parts.map(i=>`${r[i.pathParameter]??i.pathParameter}${i.tail}`).join("")}filterOutTopLevelServers(t){return t.filter(r=>!this.topLevelServers?.some(i=>i.url===r.url))}};var K9n=class extends J9n{constructor({context:t,breadcrumbs:r,operation:i,method:n,path:a}){super({context:t,breadcrumbs:r,operation:i,method:n,path:a})}convert(){if(this.operation.requestBody==null){this.context.errorCollector.collect({message:"Skipping webhook because no request body present",path:this.breadcrumbs});return}let t=this.convertHttpMethod();if(t==null)return;if(t!=="POST"&&t!=="GET"){this.context.errorCollector.collect({message:"Skipping webhook because non-POST or GET method",path:this.breadcrumbs});return}let{group:r,method:i}=this.computeGroupNameAndLocationFromExtensions()??this.computeGroupNameFromTagAndOperationId(),n=[...this.breadcrumbs,"Payload"],{headers:a}=this.convertParameters({breadcrumbs:n}),u=this.convertRequestBody({breadcrumbs:n,group:r,method:i,streamingExtension:void 0}),l;if(u?.value.type==="inlinedRequestBody")l=EW.inlinedPayload({name:u.value.name,extends:u.value.extends,properties:u.value.properties});else if(u?.value.type==="reference")l=EW.reference({payloadType:u.value.requestBodyType,docs:u.value.docs});else return;return{audiences:this.context.getAudiences({operation:this.operation,breadcrumbs:this.breadcrumbs})??[],group:r,webhook:{id:`${r?.join(".")??""}.${i}`,name:this.context.casingsGenerator.generateName(i),displayName:this.operation.summary,method:t,headers:a,payload:l,examples:[],availability:this.context.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs}),docs:this.operation.description,v2Examples:void 0},inlinedTypes:this.inlinedTypes}}};var Nko=class extends w0{pathItem;path;idToAuthScheme;topLevelServers;constructor({context:t,breadcrumbs:r,pathItem:i,path:n,idToAuthScheme:a,topLevelServers:u}){super({context:t,breadcrumbs:r}),this.pathItem=i,this.path=n,this.idToAuthScheme=a,this.topLevelServers=u}convert(){let t=[],r=[],i={};for(let n of NB_){let a=this.pathItem[n];if(a==null)continue;let u=[...this.breadcrumbs,n],l=this.tryParseAsWebhook({operationBreadcrumbs:u,operation:a,method:n,context:this.context});if(l!=null){r.push(l),Object.assign(i,l.inlinedTypes);continue}let s=new qko({breadcrumbs:u,operation:a,context:this.context}).convert(),o=this.tryParseAsHttpEndpoint({operationBreadcrumbs:u,operation:a,method:n,streamingExtension:s});o!=null&&(t.push(o),Object.assign(i,o.inlinedTypes))}return{endpoints:t,webhooks:r,inlinedTypes:i}}tryParseAsWebhook({operation:t,method:r,operationBreadcrumbs:i,context:n}){return new Tko({breadcrumbs:i,operation:t,context:n}).convert()?new K9n({context:this.context,breadcrumbs:i,operation:t,method:ijc.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path}).convert():void 0}tryParseAsHttpEndpoint({operation:t,method:r,operationBreadcrumbs:i,streamingExtension:n}){new Ako({breadcrumbs:i,operation:t,document:this.context.spec,context:this.context}).convert()!=null;let d=new Eko({breadcrumbs:i,operation:t,context:this.context}).convert();return new Rko({context:this.context,breadcrumbs:i,operation:t,method:ijc.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path,idempotent:d,idToAuthScheme:this.idToAuthScheme,topLevelServers:this.topLevelServers,streamingExtension:n}).convert()}};var Fko=class extends w0{securityScheme;constructor({context:t,breadcrumbs:r,securityScheme:i}){super({context:t,breadcrumbs:r}),this.securityScheme=i}convert(){switch(this.securityScheme.type){case"http":{if(this.securityScheme.scheme==="bearer")return CB.bearer({token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description});if(this.securityScheme.scheme==="basic")return CB.basic({username:this.context.casingsGenerator.generateName("username"),password:this.context.casingsGenerator.generateName("password"),usernameEnvVar:void 0,passwordEnvVar:void 0,docs:this.securityScheme.description});break}case"apiKey":{if(this.securityScheme.in==="header")return CB.header({name:{name:this.context.casingsGenerator.generateName(this.securityScheme.name),wireValue:this.securityScheme.name},valueType:w0.OPTIONAL_STRING,prefix:void 0,headerEnvVar:void 0,docs:this.securityScheme.description});break}case"oauth2":return CB.bearer({token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description})}}};var xRa=class extends Mpi{constructor({breadcrumbs:t,context:r,audiences:i}){super({breadcrumbs:t,context:r,audiences:i})}async convert(){this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.context.spec=await this.resolveAllExternalRefs({spec:this.context.spec});let t=this.convertSecuritySchemes();this.convertSchemas(),this.convertWebhooks();let{endpointLevelServers:r,errors:i}=this.convertPaths({idToAuthScheme:t});this.addErrorsToIr(i);let{defaultUrl:n}=this.convertServers({endpointLevelServers:r});return this.updateEndpointsWithDefaultUrl(n),this.finalizeIr()}convertSecuritySchemes(){if(this.context.authOverrides)return this.addAuthToIR(GPc({rawApiFileSchema:this.context.authOverrides,casingsGenerator:this.context.casingsGenerator})),{};let t={},r=[];for(let[i,n]of Object.entries(this.context.spec.components?.securitySchemes??{})){let a=this.context.resolveMaybeReference({schemaOrReference:n,breadcrumbs:["components","securitySchemes",i]});if(a==null)continue;let l=new Fko({context:this.context,breadcrumbs:["components","securitySchemes",i],securityScheme:a}).convert();l!=null&&(this.shouldAddAuthSchemeToIr({authScheme:l,schemeId:i,currentSecuritySchemes:r})?r.push(l):t[i]=l)}return r.length>0&&this.addAuthToIR({requirement:r.length===1?"ALL":"ANY",schemes:r,docs:void 0}),t}convertServers({endpointLevelServers:t}){if(this.context.environmentOverrides){let n=qRa({rawApiFileSchema:this.context.environmentOverrides,casingsGenerator:this.context.casingsGenerator});return n!=null&&this.addEnvironmentsToIr({environmentConfig:n.environmentsConfig,audiences:n.audiences}),{defaultUrl:this.context.environmentOverrides["default-url"]}}let i=new EHt({context:this.context,breadcrumbs:["servers"],servers:this.context.spec.servers,endpointLevelServers:t}).convert();return this.addEnvironmentsToIr({environmentConfig:i?.value}),{defaultUrl:i?.defaultUrl}}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{})){let n=new QA.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:["components","schemas",t],schema:r}).convert();n!=null&&(this.addTypeToPackage(t),this.addTypesToIr({...n.inlinedTypes,[t]:n.convertedSchema}))}}convertWebhooks(){for(let[,t]of Object.entries(this.context.spec.webhooks??{})){if(t==null){this.context.errorCollector.collect({message:"Skipping empty webhook",path:this.breadcrumbs});continue}if(!("post"in t)){this.context.errorCollector.collect({message:"Skipping webhook as it is not a POST method",path:this.breadcrumbs});continue}if(t.post?.operationId==null){this.context.errorCollector.collect({message:"Skipping webhook as no operationId is present",path:this.breadcrumbs});continue}let r=t.post.operationId,n=new K9n({context:this.context,breadcrumbs:["webhooks",r],operation:t.post,method:UB_.OpenAPIV3.HttpMethods.POST,path:r}).convert();n!=null&&(this.addWebhookToIr({webhook:n.webhook,operationId:r,audiences:n.audiences,group:n.group}),this.addTypesToIr(n.inlinedTypes))}}convertPaths({idToAuthScheme:t}){let r=[],i={};for(let[n,a]of Object.entries(this.context.spec.paths??{})){if(a==null)continue;let l=new Nko({context:this.context,breadcrumbs:["paths",n],topLevelServers:this.context.spec.servers,pathItem:a,path:n}).convert();if(l!=null){for(let d of l.endpoints){if(this.addEndpointToIr({endpoint:d.endpoint,audiences:d.audiences,endpointGroup:d.group}),d.streamEndpoint!=null&&this.addEndpointToIr({endpoint:d.streamEndpoint,audiences:d.audiences,endpointGroup:d.group}),d.servers)for(let s of d.servers)this.shouldAddServerToCollectedServers({server:s,currentServers:r})&&r.push(s);if(d.errors)for(let[s,o]of Object.entries(d.errors))i[s]=o}for(let d of l.webhooks){let s=this.context.getGroup({groupParts:d.group,namespace:this.context.namespace});this.addWebhookToIr({webhook:d.webhook,operationId:s.join("."),group:s,audiences:d.audiences})}this.addTypesToIr(l.inlinedTypes)}}return{endpointLevelServers:r,errors:i}}shouldAddAuthSchemeToIr({authScheme:t,schemeId:r,currentSecuritySchemes:i}){let n=i.some(u=>u.type===t.type&&u.type==="bearer"&&t.type==="bearer"?u.token===t.token:!1),a=new Set(this.context.spec.security?.flatMap(u=>Object.keys(u))??[]);return(a.size===0||a.has(r))&&!n}};var RRa=class extends f8{isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n}){let a=this.getTypeIdFromSchemaReference(t);if(a==null)return{ok:!1};let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let l;return n==="reference_identifier"?l=i??u.value.title:(n==="discriminator_key"||n==="schema_identifier")&&(l=u.value.title??i),{ok:!0,reference:gf.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,default:void 0,inline:!1,displayName:l})}}};var Lko=class extends QA.AbstractConverters.AbstractParameterConverter{constructor({context:t,breadcrumbs:r,parameter:i}){super({context:t,breadcrumbs:r,parameter:i})}convert(){let t,r={};if(this.parameter.schema!=null){let n=new QA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required}).convert();n!=null&&(t=n.type,r=n.inlinedTypes??{})}return this.convertToOutput({schema:this.parameter.schema??{type:"string"},typeReference:t,inlinedTypes:r})}};var IJE=hu.object({description:hu.string().optional(),required:hu.boolean().optional(),deprecated:hu.boolean().optional(),allowEmptyValue:hu.boolean().optional(),style:hu.string().optional(),explode:hu.boolean().optional(),allowReserved:hu.boolean().optional(),schema:hu.any().optional(),example:hu.any().optional(),examples:hu.record(hu.string(),hu.any()).optional(),content:hu.record(hu.string(),hu.any()).optional()}),zJE=IJE.extend({name:hu.string(),in:hu.string()}),xJE=hu.array(zJE),Uko=class extends Aj{operation;key="x-fern-parameters";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null)try{return xJE.parse(t)}catch(r){this.context.errorCollector.collect({message:`Failed to parse x-fern-parameters extension: ${r instanceof Error?r.message:String(r)}`,path:this.breadcrumbs});return}}};var Vko=class extends w0{method;pathParameters;queryParameters;headers;constructor({context:t,breadcrumbs:r,method:i,pathParameters:n=[],queryParameters:a=[],headers:u=[]}){super({context:t,breadcrumbs:r}),this.method=i,this.pathParameters=n,this.queryParameters=a,this.headers=u}convert(){let t={},r="";for(let d of this.pathParameters)r+=`/{${d.name.originalName}}`;let i=lF(r),n=[];for(let[d,s]of this.method.params.entries()){let o;if(this.context.isReferenceObject(s)){let O=this.context.resolveReference({reference:s});if(O.resolved)o=O.value;else continue}else o=s;let c=[this.method.name,"Param",o.name].join("_"),g=new QA.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[this.method.name,"Param",o.name],schemaIdOverride:c,context:this.context,schemaOrReference:o.schema,wrapAsOptional:!o.required}).convert();g!=null&&(n.push({docs:o.description,availability:this.context.getAvailability({node:s,breadcrumbs:[...this.breadcrumbs,"parameters"]}),name:this.context.casingsGenerator.generateNameAndWireValue({name:o.name,wireValue:o.name}),valueType:g.type,v2Examples:g.schema?.typeDeclaration.v2Examples}),t={...g.inlinedTypes,...t,...g.schema!=null?{[c]:g.schema}:{}})}let a;if(this.method.result!=null){let d=this.context.resolveMaybeReference({schemaOrReference:this.method.result,breadcrumbs:[...this.breadcrumbs,"result"]});if(d!=null){let s=new QA.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[this.method.name,"result"],context:this.context,schemaOrReference:d.schema}),o=[this.method.name,"Result"].join("_"),c=s.convert();c!=null&&(a={docs:d.description,v2Examples:c.schema?.typeDeclaration.v2Examples,responseBodyType:c.type},t={...c.inlinedTypes,...t,...c.schema!=null?{[o]:c.schema}:{}})}}let u=this.context.getAudiences({operation:this.method,breadcrumbs:this.breadcrumbs})??[];return{endpoint:{baseUrl:void 0,v2BaseUrls:void 0,basePath:void 0,auth:!1,method:"POST",id:this.method.name,docs:this.method.description,name:this.context.casingsGenerator.generateName(this.method.name),headers:this.headers,displayName:this.method.name,pathParameters:this.pathParameters,queryParameters:this.queryParameters,allPathParameters:this.pathParameters,path:i,fullPath:i,requestBody:n.length>0?ZC.inlinedRequestBody({name:this.context.casingsGenerator.generateName([this.method.name,"Request"].join("_")),docs:void 0,properties:n,extends:[],extendedProperties:[],contentType:"application/json",extraProperties:!1,v2Examples:void 0}):void 0,sdkRequest:void 0,response:a!=null?{body:gE.json(AZ.response(a)),statusCode:void 0}:void 0,errors:[],idempotent:!1,pagination:void 0,userSpecifiedExamples:[],autogeneratedExamples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples()},transport:void 0,availability:void 0,source:Gne.openrpc()},audiences:u,inlinedTypes:t}}convertExamples(){let t={},r=0;if(this.method.examples&&this.method.examples.length>0){for(let i of this.method.examples??[]){let n;if(this.context.isReferenceObject(i)){let d=this.context.resolveReference({reference:i});if(d.resolved)n=d.value;else continue}else n=i;let a;if(n.result)if(this.context.isReferenceObject(n.result)){let d=this.context.resolveReference({reference:n.result});d.resolved&&(a=d.value)}else a=n.result;let u=n.name??`Example ${r+1}`,l=[];if(n.params&&Array.isArray(n.params)){l=[];for(let d of n.params)if(this.context.isReferenceObject(d)){let s=this.context.resolveReference({reference:d});if(s.resolved)l.push(s.value);else continue}else l.push(d)}t[u]={request:{docs:void 0,endpoint:{method:"POST",path:"/{apiKey}"},baseUrl:void 0,environment:void 0,auth:void 0,pathParameters:{},queryParameters:{},headers:{},requestBody:l.map(d=>d.value)??void 0},response:{docs:void 0,statusCode:void 0,body:a?.value?Ws.V2HttpEndpointResponseBody.json({jsonrpc:"2.0",id:n.examplePairedRequest?.id||"1",result:a.value}):void 0},codeSamples:[]}}++r}return t}};var NRa=class extends Mpi{constructor({context:t,breadcrumbs:r,audiences:i}){super({context:t,breadcrumbs:r,audiences:i})}async convert(){return this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.convertServers({}),this.convertSchemas(),this.convertMethods(),this.finalizeIr()}convertServers({endpointLevelServers:t}){let i=new EHt({context:this.context,breadcrumbs:["servers"],servers:this.context.spec.servers,endpointLevelServers:t}).convert();this.addEnvironmentsToIr({environmentConfig:i?.value})}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{})){let n=new QA.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:["components","schemas",t],schema:r}).convert();n!=null&&(this.addTypeToPackage(t),this.addTypesToIr({...n.inlinedTypes,[t]:n.convertedSchema}))}}convertMethods(){let r=new Uko({context:this.context,breadcrumbs:["methods"],operation:this.context.spec}).convert(),i=[],n=[],a=[];if(r&&r.length>0)for(let[l,d]of r.entries()){let o=new Lko({context:this.context,breadcrumbs:[...this.breadcrumbs,`x-fern-parameters[${l}]`],parameter:d}).convert();if(o!=null)switch(o.type){case"path":{i.push(o.parameter);break}case"query":{n.push(o.parameter);break}case"header":{a.push(o.parameter);break}}}let u=this.context.getGroup({groupParts:[],namespace:this.context.namespace});for(let l of this.context.spec.methods??[]){let d=this.context.resolveMaybeReference({schemaOrReference:l,breadcrumbs:["methods"]});if(d==null)continue;let o=new Vko({context:this.context,breadcrumbs:["methods"],method:d,pathParameters:i,queryParameters:n,headers:a}).convert();o!=null&&(this.addEndpointToIr({endpoint:o.endpoint,audiences:o.audiences,endpointGroup:u,serviceName:"service_root"}),this.addTypesToIr(o.inlinedTypes))}}};var FRa=class extends f8{isReferenceObject(t){return t!=null&&"$ref"in t}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n}){let a=this.getTypeIdFromSchemaReference(t);if(a==null)return{ok:!1};let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let l;return n==="reference_identifier"?l=i??u.value.title:(n==="discriminator_key"||n==="schema_identifier")&&(l=u.value.title??i),{ok:!0,reference:gf.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,displayName:l,default:void 0,inline:!1})}}};var VB_={[hy.GenerationLanguage.PHP]:new Set(["abstract","and","as","break","callable","case","catch","class","clone","const","continue","declare","default","do","echo","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","extends","final","finally","fn","for","foreach","function","global","goto","list","if","implements","include","include_once","instanceof","insteadof","interface","match","namespace","new","or","parent","Parent","print","private","protected","public","readonly","require","require_once","return","static","switch","throw","trait","try","use","var","while","xor","yield"].flatMap(e=>[e,iz(e)])),[hy.GenerationLanguage.TYPESCRIPT]:new Set(["any","as","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","module","new","null","number","of","package","private","protected","public","require","return","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","var","void","while","with","yield","Date","Error","File","Object","Record"]),[hy.GenerationLanguage.JAVA]:new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","try","void","volatile","while"]),[hy.GenerationLanguage.PYTHON]:new Set(["False","None","True","and","as","assert","async","","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","float","int","complex","bool","uuid","list","set","map","long","self","all"]),[hy.GenerationLanguage.GO]:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[hy.GenerationLanguage.RUBY]:new Set(["__ENCODING__","__LINE__","__FILE__","alias","and","begin","break","case","class","def","defined","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","Object","JSON","Date","DateTime"]),[hy.GenerationLanguage.CSHARP]:new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while","add","and","alias","ascending","args","async","","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","managed","nameof","nint","not","notnull","nuint","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value","var","when","where","with","yield"]),[hy.GenerationLanguage.SWIFT]:new Set([])};var RJE=["go","ruby"];function njc({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let u=c=>({unsafeName:c,safeName:NJE({name:c,keywords:FJE({generationLanguage:e,keywords:t})})}),l=T_(n),d=iz(l),s=AVi(n),o=SVi(l);return r&&(!VJE(o)&&(e==null||RJE.includes(e))&&(l=o.map((c,b)=>{if(b>0){let g=Wko(c);if(g!=null)return g;if(Hko(c))return c.toUpperCase()}return c}).join(""),d=o.map((c,b)=>{let g=Wko(c);return g??(Hko(c)?c.toUpperCase():b===0?iz(c):c)}).join("")),s=n.split(" ").map(c=>c.split(/(\d+)/).map(AVi).join("")).join("_")),{originalName:n,camelCase:u(a?.casingOverrides?.camel??l),snakeCase:u(a?.casingOverrides?.snake??s),screamingSnakeCase:u(a?.casingOverrides?.["screaming-snake"]??s.toUpperCase()),pascalCase:u(a?.casingOverrides?.pascal??d)}},generateNameAndWireValue:({name:n,wireValue:a,opts:u})=>({name:i.generateName(n,u),wireValue:a})};return i}function NJE({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":UJE(e)?"_"+e:e}function FJE({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return VB_[e]}var LJE=/^[0-9]/;function UJE(e){return LJE.test(e)}function VJE(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=Wko(i)!=null||Hko(i),a=Wko(t)!=null||Hko(t);return n&&a})}function Wko(e){return HJE.get(e.toUpperCase())}function Hko(e){return WJE.has(e.toUpperCase())}var WJE=new Set(["ACL","API","ASCII","CPU","CSS","DNS","EOF","GUID","HTML","HTTP","HTTPS","ID","IP","JSON","LHS","QPS","RAM","RHS","RPC","SAML","SCIM","SLA","SMTP","SQL","SSH","SSO","TCP","TLS","TTL","UDP","UI","UID","UUID","URI","URL","UTF8","VM","XML","XMPP","XSRF","XSS"]),HJE=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]);var WB_=require("fs/promises");async function ajc({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,WB_.readFile)(t)).toString(),n;try{n=JSON.parse(i)}catch{n=qd.load(i)}return r!=null?await i9n({absoluteFilePathToOverrides:r,context:e,data:n}):n}var SR=class extends YIa{type="oss";allSpecs;specs;sources;loader;constructor({allSpecs:t,specs:r,...i}){super({...i,respectReadonlySchemas:r.every(n=>n.settings?.respectReadonlySchemas),respectNullableSchemas:r.every(n=>n.settings?.respectNullableSchemas),onlyIncludeReferencedSchemas:r.every(n=>n.settings?.onlyIncludeReferencedSchemas),inlinePathParameters:r.every(n=>n.settings?.inlinePathParameters),objectQueryParameters:r.every(n=>n.settings?.objectQueryParameters),useBytesForBinaryResponse:r.filter(n=>n.type==="openapi"&&n.source.type==="openapi").some(n=>n.settings?.useBytesForBinaryResponse),respectForwardCompatibleEnums:r.filter(n=>n.type==="openapi"&&n.source.type==="openapi").some(n=>n.settings?.respectForwardCompatibleEnums),exampleGeneration:r[0]?.settings?.exampleGeneration}),this.specs=r,this.allSpecs=t,this.sources=this.convertSpecsToIdentifiableSources(r),this.loader=new wHt(this.absoluteFilePath)}async getOpenAPIIr({context:t,relativePathToDependency:r},i){let n=await CFe({context:t,specs:this.specs,relativePathToDependency:r});return XJi({context:t,documents:await this.loader.loadDocuments({context:t,specs:n}),options:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.objectQueryParameters,exampleGeneration:i?.exampleGeneration??this.exampleGeneration,useBytesForBinaryResponse:i?.useBytesForBinaryResponse??this.useBytesForBinaryResponse}})}async getIntermediateRepresentation({context:t,audiences:r,enableUniqueErrorsPerEndpoint:i}){let n=await CFe({context:t,specs:this.specs}),a=await this.loader.loadDocuments({context:t,specs:n}),u=this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0;u&&t.logger.trace("Using auth overrides from generators configuration");let l=this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0;l&&t.logger.trace("Using environment overrides from generators configuration");let d=this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0;d&&t.logger.trace("Using global header overrides from generators configuration");let s,o=[];for(let c of a){let b=Vu(this.absoluteFilePath,Qa.of(c.source?.file??"")),g=cne(aR(),b),O=new z9n({logger:t.logger,relativeFilepathToSpec:g});o.push(O);let m;switch(c.type){case"openapi":{let E=new RRa({namespace:c.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:c.value,exampleGenerationArgs:{disabled:!1},errorCollector:O,authOverrides:u,environmentOverrides:l,globalHeaderOverrides:d,enableUniqueErrorsPerEndpoint:i});m=await new xRa({context:E,audiences:r}).convert();break}case"asyncapi":{let E=new zRa({namespace:c.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:c.value,exampleGenerationArgs:{disabled:!1},errorCollector:O,enableUniqueErrorsPerEndpoint:i});m=await new IRa({context:E,audiences:r}).convert();break}default:O.collect({message:`Unsupported document type: ${c}`,path:[]});break}let P=njc({generationLanguage:"typescript",keywords:void 0,smartCasing:!1});m!=null&&(s=s===void 0?m:oko(s,m,P))}for(let c of this.allSpecs)if(c.type==="openrpc"){let b=c.absoluteFilepath,g=cne(aR(),b),O=new z9n({logger:t.logger,relativeFilepathToSpec:g});o.push(O);let m=new FRa({namespace:c.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:await ajc({context:t,absoluteFilePath:c.absoluteFilepath,absoluteFilePathToOverrides:c.absoluteFilepathToOverrides}),exampleGenerationArgs:{disabled:!1},errorCollector:O,enableUniqueErrorsPerEndpoint:i}),E=await new NRa({context:m,audiences:r}).convert(),q=njc({generationLanguage:"typescript",keywords:void 0,smartCasing:!1});E!=null&&(s=s===void 0?E:oko(s,E,q))}for(let c of o)if(c.hasErrors()){let b=c.getErrorStats(),g=c.relativeFilepathToSpec?` for ${c.relativeFilepathToSpec}`:"";b.numErrors>0?t.logger.log("error",`API validation${g} completed with ${b.numErrors} errors and ${b.numWarnings} warnings.`):b.numWarnings>0?t.logger.log("warn",`API validation${g} completed with ${b.numWarnings} warnings.`):t.logger.log("info",`All checks passed when parsing OpenAPI${g}.`),t.logger.log("info",""),await c.logErrors({logWarnings:!1})}if(s===void 0)throw new Error("Failed to generate intermediate representation");return s}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new DMe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion,sources:this.sources})}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.specs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(V0)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,i=[];return t.reduce((n,a)=>{let u=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(u)||(r.add(u),n.push({type:a.type,id:Iae(),absoluteFilePath:u})),n},i)}};var HB_={None:"none",Header:"header"};var peu={};jo(peu,{ConjureAliasDeclaration:()=>Xko,ConjureArgument:()=>leu,ConjureArgumentWithParamType:()=>ceu,ConjureAuthDefinition:()=>k9n,ConjureAuthDefinitionType:()=>ueu,ConjureDefinitions:()=>aeu,ConjureEndpointDefinition:()=>feu,ConjureEnumDeclaration:()=>ieu,ConjureEnumVariant:()=>reu,ConjureEnumWithDocs:()=>teu,ConjureObjectDeclaration:()=>eeu,ConjureParamType:()=>seu,ConjurePrimitive:()=>Yko,ConjureService:()=>deu,ConjureServiceName:()=>Kko,ConjureType:()=>JAi,ConjureTypeDeclaration:()=>neu,ConjureTypeReference:()=>KAi,ConjureTypeWithDocs:()=>Zko,ConjureTypes:()=>oeu,ConjureUnionDeclaration:()=>kko,DefinitionFile:()=>bI_,WithDocs:()=>Hir,commons:()=>ljc,conjure:()=>fjc,services:()=>djc,types:()=>pjc});var ljc={};jo(ljc,{WithDocs:()=>Hir});var ip={};jo(ip,{JsonError:()=>Y9n,ParseError:()=>X9n,any:()=>aI_,bigint:()=>GB_,boolean:()=>oI_,booleanLiteral:()=>nI_,date:()=>QB_,discriminant:()=>hI_,enum_:()=>Gko,getObjectLikeUtils:()=>MHt,getObjectUtils:()=>DKi,getSchemaUtils:()=>Qq,isProperty:()=>QAi,lazy:()=>JB_,lazyObject:()=>tI_,list:()=>Jko,number:()=>uI_,object:()=>Qko,objectWithoutOptionalProperties:()=>eI_,optional:()=>ojc,property:()=>YB_,record:()=>fI_,set:()=>dI_,string:()=>sI_,stringLiteral:()=>iI_,transform:()=>ujc,undiscriminatedUnion:()=>_I_,union:()=>vI_,unknown:()=>cI_,withParsedProperties:()=>cjc});var qj={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function yA(e,t){return`Expected ${t}. Received ${$JE(e)}.`}function $JE(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function pL(e){return{...e,json:$B_(e.json),parse:$B_(e.parse)}}function $B_(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1960
|
+
`}async function CFe({context:e,specs:t,relativePathToDependency:r}){let i=new QXo({context:e}),n=t.filter(l=>l.type==="openapi").map(l=>({...l,relativePathToDependency:r})),a=t.filter(l=>l.type==="protobuf"),u=await Promise.all(a.map(async l=>AHE({generator:i,protobufSpec:l,relativePathToDependency:r})));return[...n,...u]}async function AHE({generator:e,protobufSpec:t,relativePathToDependency:r}){return{type:"openapi",absoluteFilepath:await e.generate({absoluteFilepathToProtobufRoot:t.absoluteFilepathToProtobufRoot,absoluteFilepathToProtobufTarget:t.absoluteFilepathToProtobufTarget,relativeFilepathToProtobufRoot:t.relativeFilepathToProtobufRoot,local:t.generateLocally}),absoluteFilepathToOverrides:t.absoluteFilepathToOverrides,settings:t.settings,source:{type:"protobuf",relativePathToDependency:r,root:t.absoluteFilepathToProtobufRoot,file:t.absoluteFilepathToProtobufTarget}}}var GC_=require("fs"),C9n=require("fs/promises");var QC_=require("os"),JC_=ci(require("path"),1),KC_=require("stream/promises"),YC_=ci(tko(),1),XC_=ci(fne(),1);var BPc=ci(e$i(),1);var zP;(function(e){e.FILE_READ="FILE_READ",e.FILE_PARSE="FILE_PARSE",e.FILE_MISSING="FILE_MISSING",e.STRUCTURE_VALIDATION="STRUCTURE_VALIDATION",e.JSONSCHEMA_VALIDATION="JSONSCHEMA_VALIDATION",e.DEPENDENCY_NOT_LISTED="DEPENDENCY_NOT_LISTED",e.FAILED_TO_LOAD_DEPENDENCY="FAILED_TO_LOAD_DEPENDENCY",e.EXPORTING_PACKAGE_MARKER_OTHER_KEYS="EXPORTING_PACKAGE_MARKER_OTHER_KEYS",e.EXPORT_PACKAGE_HAS_DEFINITIONS="EXPORT_PACKAGE_HAS_DEFINITIONS",e.MISCONFIGURED_DIRECTORY="MISCONFIGURED_DIRECTORY"})(zP||(zP={}));var aQE=Efi();async function ZC_({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:i,cliVersion:n,settings:a,loadAPIWorkspace:u}){let l,d={type:zP.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},s=t.dependencies[e];return s==null?d={type:zP.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${dQE(s)}`},async o=>{switch(s.type){case"version":l=await lQE({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;case"local":l=await cQE({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;default:mo(s)}}),l!=null?{didSucceed:!0,definition:l}:{didSucceed:!1,failure:d}}var kC_="dependencies";var oQE="metadata.json",uQE=".fern";function sQE(e){return Vu($l.of((0,QC_.homedir)()),Qa.of(uQE),Qa.of(kC_),Qa.of(e.organization),Qa.of(e.apiName),Qa.of(e.version))}async function cQE({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){if(n==null){t.failWithoutThrowing("Failed to load api definition");return}t.logger.info("Parsing...");let a=await n({absolutePathToWorkspace:e.absoluteFilepath,context:t,cliVersion:r,workspaceName:void 0});if(!a.didSucceed){t.failWithoutThrowing("Failed to load api definition",a.failures);return}t.logger.info("Modifying source filepath ...");let u=await a.workspace.getDefinition({context:t,relativePathToDependency:Qa.of(e.path)},i);return t.logger.info("Loaded..."),u}async function lQE({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){let a=sQE(e),u=Vu(a,Qa.of(kC_)),l=Vu(a,Qa.of(oQE)),d;if(!await Cf(u)||!await Cf(l)){t.logger.info("Downloading manifest...");let c=await aQE.definitionRegistry.get(BPc.FernFiddle.OrganizationId(e.organization),BPc.FernFiddle.ApiId(e.apiName),e.version);if(!c.ok){c.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:m=>{t.failWithoutThrowing("Failed to download API manifest",m)}});return}let b=c.body.yamlSchemaVersion!=null?parseInt(c.body.yamlSchemaVersion):void 0,g=sJi(r),O=sJi(c.body.cliVersion);if(b!=null){if(b>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${c.body.cliVersion}`);return}else if(b<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(g.major!==O.major||g.minor!==O.minor){t.failWithoutThrowing(`CLI version is ${c.body.cliVersion}. Expected ${g.major}.${g.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+c.body.definitionS3DownloadUrl),await(0,C9n.mkdir)(u,{recursive:!0});try{await fQE({s3PreSignedReadUrl:c.body.definitionS3DownloadUrl,absolutePathToLocalOutput:u})}catch(m){t.failWithoutThrowing("Failed to download API",m);return}d=c.body,await(0,C9n.writeFile)(l,JSON.stringify(d))}else d=JSON.parse((await(0,C9n.readFile)(l)).toString());if(t.logger.info("Parsing..."),n==null){t.failWithoutThrowing("Failed to load API");return}let s=await n({absolutePathToWorkspace:u,context:t,cliVersion:d.cliVersion,workspaceName:void 0});if(!s.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",s.failures);return}if(s.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await s.workspace.getDefinition({context:t},i)}async function fQE({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await rF.get(e,{responseType:"stream"}),i=await XC_.default.dir(),n=JC_.default.join(i.path,"api.tgz");await(0,KC_.pipeline)(r.data,(0,GC_.createWriteStream)(n)),await(0,YC_.extract)({file:n,cwd:t})}function dQE(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:mo(e)}}var dB_=ci(aB_(),1);function rko(e,t){for(let[r,i]of t3(e))_QE({relativeFilepath:r,failure:i,logger:t})}function _QE({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case zP.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 zP.FILE_READ:r.error("Failed to open file: "+e);break;case zP.FILE_MISSING:r.error("Missing file: "+e);break;case zP.FILE_PARSE:t.error instanceof vSa?r.error(vFe({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case zP.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of hQE(i))r.error(vFe({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case zP.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case zP.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${VOo}: `+t.dependencyName);break;case zP.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case zP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case zP.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(vFe({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(i=>i!=="")]}));for(let i of t.error.allErrors)i!==t.error.error&&r.debug(vFe({title:i.message??"Unknown error",breadcrumbs:[e,...i.instancePath.split("/").filter(n=>n!=="")]}));break;default:mo(t)}}function hQE(e){switch(e.code){case Jl.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${Gs.underline(e.expected)} but received ${Gs.underline(e.received)}`}];case Jl.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${Gs.underline(t)}`}));case Jl.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>Gs.underline(t)).join(", ")}`}];case Jl.invalid_union:case Jl.invalid_arguments:case Jl.invalid_return_type:case Jl.invalid_date:case Jl.invalid_string:case Jl.too_small:case Jl.too_big:case Jl.invalid_intersection_types:case Jl.not_multiple_of:case Jl.custom:default:return[{title:e.message}]}}var oB_=require("fs/promises");async function uB_(e,t){let r=[];for(let i of await Fxe(e,t))r.push(await yQE({relativeFilepath:xq(e,i),absoluteFilepath:i}));return r}async function yQE({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,oB_.readFile)(t)).toString()}}async function sB_(e){let t={},r={};function i(n){try{t[n.relativeFilepath]={defaultUrl:void 0,contents:qd.load(n.fileContents,{schema:qd.CORE_SCHEMA}),rawContents:n.fileContents}}catch(a){r[n.relativeFilepath]={type:zP.FILE_PARSE,error:a}}}return await Promise.all(e.map(i)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}async function cB_({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:i,settings:n,loadAPIWorkspace:a}){let u={},l={},d={};return await Promise.all(t3(t.packageMarkers).map(async([s,o])=>{if(o.contents.export==null)u[s]=o;else{let{export:c,...b}=o.contents;if(fZ(b)>0)d[s]={type:zP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:s};else{let g=Xd(s);if(uVt(t.namedDefinitionFiles).some(m=>m!==s&&m.startsWith(g)))d[s]={type:zP.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:g};else{let m=await ZC_({dependencyName:typeof o.contents.export=="string"?o.contents.export:o.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:i,settings:n,loadAPIWorkspace:a});m.didSucceed?l[Xd(s)]={definition:m.definition,url:typeof o.contents.export=="object"?o.contents.export.url:void 0}:d[s]=m.failure}}}})),fZ(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:u,importedDefinitions:l}}var lB_=ci(require("path"),1);var xPc={};jo(xPc,{additionalProperties:()=>OQE,default:()=>PQE,definitions:()=>mQE,properties:()=>bQE,required:()=>gQE,type:()=>vQE});var vQE="object",bQE={docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},"default-url":{oneOf:[{type:"string"},{type:"null"}]},"default-environment":{oneOf:[{type:"string"},{type:"null"}]},environments:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/environments.EnvironmentSchema"}},{type:"null"}]},auth:{oneOf:[{$ref:"#/definitions/auth.ApiAuthSchema"},{type:"null"}]},"auth-schemes":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/auth.AuthSchemeDeclarationSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},name:{type:"string"},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},"error-discrimination":{oneOf:[{$ref:"#/definitions/file.ErrorDiscriminationSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},errors:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"idempotency-headers":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},variables:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/variables.VariableDeclarationSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"null"}]},product:{oneOf:[{$ref:"#/definitions/products.ProductDeclarationSchema"},{type:"null"}]},version:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},gQE=["name"],OQE=!1,mQE={"environments.SingleBaseUrlEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},url:{type:"string"}},required:["url"],additionalProperties:!1},"environments.MultipleBaseUrlsEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},urls:{type:"object",additionalProperties:{type:"string"}}},required:["urls"],additionalProperties:!1},"environments.EnvironmentSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/environments.SingleBaseUrlEnvironmentSchema"},{$ref:"#/definitions/environments.MultipleBaseUrlsEnvironmentSchema"}]},"auth.AuthSchemeReferenceSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{type:"string"}},required:["scheme"],additionalProperties:!1},"auth.AnyAuthItem":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"}]},"auth.AnyAuthSchemesSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},any:{type:"array",items:{$ref:"#/definitions/auth.AnyAuthItem"}}},required:["any"],additionalProperties:!1},"auth.ApiAuthSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"},{$ref:"#/definitions/auth.AnyAuthSchemesSchema"}]},"auth.OAuthAccessTokenRequestPropertiesSchema":{type:"object",properties:{"client-id":{oneOf:[{type:"string"},{type:"null"}]},"client-secret":{oneOf:[{type:"string"},{type:"null"}]},scopes:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthAccessTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthGetTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthRefreshTokenRequestPropertiesSchema":{type:"object",properties:{"refresh-token":{type:"string"}},required:["refresh-token"],additionalProperties:!1},"auth.OAuthRefreshTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthRefreshTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"oauth"},type:{const:"client-credentials"},scopes:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"client-id-env":{oneOf:[{type:"string"},{type:"null"}]},"client-secret-env":{oneOf:[{type:"string"},{type:"null"}]},"token-prefix":{oneOf:[{type:"string"},{type:"null"}]},"token-header":{oneOf:[{type:"string"},{type:"null"}]},"get-token":{$ref:"#/definitions/auth.OAuthGetTokenEndpointSchema"},"refresh-token":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenEndpointSchema"},{type:"null"}]}},required:["scheme","type","get-token"],additionalProperties:!1},"auth.HeaderAuthSchemeSchema":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},header:{type:"string"},type:{oneOf:[{type:"string"},{type:"null"}]},prefix:{oneOf:[{type:"string"},{type:"null"}]}},required:["header"],additionalProperties:!1},"auth.AuthVariable":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.BasicAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"basic"},username:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]},password:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.BearerAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},token:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.AuthSchemeDeclarationSchema":{anyOf:[{$ref:"#/definitions/auth.OAuthSchemeSchema"},{$ref:"#/definitions/auth.HeaderAuthSchemeSchema"},{$ref:"#/definitions/auth.BasicAuthSchemeSchema"},{$ref:"#/definitions/auth.BearerAuthSchemeSchema"}]},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"file.PropertyBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"property"},"property-name":{type:"string"}},required:["strategy","property-name"],additionalProperties:!1},"file.StatusCodeBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"status-code"}},required:["strategy"],additionalProperties:!1},"file.ErrorDiscriminationSchema":{anyOf:[{$ref:"#/definitions/file.PropertyBasedErrorDiscrimination"},{$ref:"#/definitions/file.StatusCodeBasedErrorDiscrimination"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"variables.VariableDeclarationDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"variables.VariableDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/variables.VariableDeclarationDetailed"}]},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"versioning.VersionValueDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionValue":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionValueDetailed"}]},"versioning.VersionDeclarationHeaderObjectSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionDeclarationHeaderSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionDeclarationHeaderObjectSchema"}]},"versioning.VersionDeclarationSchema":{type:"object",properties:{default:{oneOf:[{type:"string"},{type:"null"}]},values:{type:"array",items:{$ref:"#/definitions/versioning.VersionValue"}},header:{$ref:"#/definitions/versioning.VersionDeclarationHeaderSchema"}},required:["values","header"],additionalProperties:!1},"products.ProductValueDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},versions:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"products.ProductValue":{anyOf:[{type:"string"},{$ref:"#/definitions/products.ProductValueDetailed"}]},"products.ProductDeclarationHeaderObjectSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"products.ProductDeclarationHeaderSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/products.ProductDeclarationHeaderObjectSchema"}]},"products.ProductDeclarationSchema":{type:"object",properties:{default:{oneOf:[{type:"string"},{type:"null"}]},values:{type:"array",items:{$ref:"#/definitions/products.ProductValue"}},header:{$ref:"#/definitions/products.ProductDeclarationHeaderSchema"}},required:["values","header"],additionalProperties:!1}},PQE={type:vQE,properties:bQE,required:gQE,additionalProperties:OQE,definitions:mQE};var RPc={};jo(RPc,{additionalProperties:()=>SQE,default:()=>EQE,definitions:()=>DQE,properties:()=>wQE,type:()=>jQE});var jQE="object",wQE={docs:{oneOf:[{type:"string"},{type:"null"}]},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]}},SQE=!1,DQE={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE","HEAD"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{type:"boolean"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1}},EQE={type:jQE,properties:wQE,additionalProperties:SQE,definitions:DQE};var NPc={};jo(NPc,{additionalProperties:()=>qQE,default:()=>CQE,definitions:()=>TQE,properties:()=>AQE,type:()=>MQE});var MQE="object",AQE={imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},navigation:{oneOf:[{$ref:"#/definitions/file.Navigation"},{type:"null"}]},export:{oneOf:[{$ref:"#/definitions/file.Export"},{type:"null"}]}},qQE=!1,TQE={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE","HEAD"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{type:"boolean"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1},"file.Navigation":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"file.ExportDetailed":{type:"object",properties:{dependency:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]}},required:["dependency"],additionalProperties:!1},"file.Export":{anyOf:[{type:"string"},{$ref:"#/definitions/file.ExportDetailed"}]}},CQE={type:MQE,properties:AQE,additionalProperties:qQE,definitions:TQE};function fB_({files:e,absolutePathToDefinition:t}){let r,i={},n={},a={};for(let[u,l]of t3(e)){let d=l.contents,s=o=>{a[u]={type:zP.JSONSCHEMA_VALIDATION,error:o}};if(u===i3){let o=pVt(d,xPc);if(o.success){let c=JN.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:c["default-url"],contents:c,rawContents:l.rawContents}}else s(o)}else if(lB_.default.basename(u)===zS){let o=pVt(d,NPc);if(o.success){let c=JN.serialization.PackageMarkerFileSchema.parseOrThrow(d);n[u]={defaultUrl:typeof c.export=="object"?c.export.url:void 0,contents:c,rawContents:l.rawContents}}else s(o)}else{let o=pVt(d,RPc);if(o.success){let c=JN.serialization.DefinitionFileSchema.parseOrThrow(d);i[u]={defaultUrl:void 0,contents:c,rawContents:l.rawContents,absoluteFilePath:Vu(t,u)}}else s(o)}}return r==null?{didSucceed:!1,failures:{[Qa.of(i3)]:{type:zP.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:i,rootApiFile:r,packageMarkers:n}}var Fir=class extends sHt{type="fern";context;fernWorkspaces={};loadAPIWorkspace;constructor({context:t,loadAPIWorkspace:r,...i}){super(i),this.context=t,this.loadAPIWorkspace=r}async getDefinition({context:t},r){return(await this.toFernWorkspace({context:t},r)).definition}async toFernWorkspace({context:t},r){let i=(0,dB_.default)(r??{}),n=this.fernWorkspaces[i];if(n==null){let a=t||this.context,u=Vu(this.absoluteFilePath,Qa.of(v9)),l=await x2s({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await uB_(u,"{yml,yaml}"),s=await sB_(d);if(!s.didSucceed)return rko(s.failures,a.logger),a.failAndThrow();let o=fB_({files:s.files,absolutePathToDefinition:u});if(!o.didSucceed)return rko(o.failures,a.logger),a.failAndThrow();let c=await cB_({dependenciesConfiguration:l,structuralValidationResult:o,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!c.didSucceed)return rko(c.failures,a.logger),a.failAndThrow();let b={absoluteFilePath:u,rootApiFile:o.rootApiFile,namedDefinitionFiles:o.namedDefinitionFiles,packageMarkers:c.packageMarkers,importedDefinitions:c.importedDefinitions};r?.auth!=null&&(b={...b,rootApiFile:{...b.rootApiFile,contents:{...b.rootApiFile.contents,auth:r?.auth}}}),n=new DMe({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:l,workspaceName:this.workspaceName,definition:b,cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[i]=n}return n}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var w0=class e{breadcrumbs=[];context;static STRING=Ws.TypeReference.primitive({v1:"STRING",v2:Ws.PrimitiveTypeV2.string({default:void 0,validation:void 0})});static OPTIONAL_STRING=Ws.TypeReference.container(Ws.ContainerType.optional(e.STRING));constructor({breadcrumbs:t=[],context:r}){this.breadcrumbs=t,this.context=r}};var pB_={[hy.GenerationLanguage.PHP]:new Set(["abstract","and","as","break","callable","case","catch","class","clone","const","continue","declare","default","do","echo","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","extends","final","finally","fn","for","foreach","function","global","goto","list","if","implements","include","include_once","instanceof","insteadof","interface","match","namespace","new","or","parent","Parent","print","private","protected","public","readonly","require","require_once","return","static","switch","throw","trait","try","use","var","while","xor","yield"].flatMap(e=>[e,iz(e)])),[hy.GenerationLanguage.TYPESCRIPT]:new Set(["any","as","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","module","new","null","number","of","package","private","protected","public","require","return","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","var","void","while","with","yield","Date","Error","File","Object","Record"]),[hy.GenerationLanguage.JAVA]:new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","try","void","volatile","while"]),[hy.GenerationLanguage.PYTHON]:new Set(["False","None","True","and","as","assert","async","","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","float","int","complex","bool","uuid","list","set","map","long","self","all"]),[hy.GenerationLanguage.GO]:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[hy.GenerationLanguage.RUBY]:new Set(["__ENCODING__","__LINE__","__FILE__","alias","and","begin","break","case","class","def","defined","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","Object","JSON","Date","DateTime"]),[hy.GenerationLanguage.CSHARP]:new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while","add","and","alias","ascending","args","async","","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","managed","nameof","nint","not","notnull","nuint","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value","var","when","where","with","yield"]),[hy.GenerationLanguage.SWIFT]:new Set([])};var BQE=["go","ruby"];function RMe({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let u=c=>({unsafeName:c,safeName:IQE({name:c,keywords:zQE({generationLanguage:e,keywords:t})})}),l=T_(n),d=iz(l),s=AVi(n),o=SVi(l);return r&&(!NQE(o)&&(e==null||BQE.includes(e))&&(l=o.map((c,b)=>{if(b>0){let g=iko(c);if(g!=null)return g;if(nko(c))return c.toUpperCase()}return c}).join(""),d=o.map((c,b)=>{let g=iko(c);return g??(nko(c)?c.toUpperCase():b===0?iz(c):c)}).join("")),s=n.split(" ").map(c=>c.split(/(\d+)/).map(AVi).join("")).join("_")),{originalName:n,camelCase:u(a?.casingOverrides?.camel??l),snakeCase:u(a?.casingOverrides?.snake??s),screamingSnakeCase:u(a?.casingOverrides?.["screaming-snake"]??s.toUpperCase()),pascalCase:u(a?.casingOverrides?.pascal??d)}},generateNameAndWireValue:({name:n,wireValue:a,opts:u})=>({name:i.generateName(n,u),wireValue:a})};return i}function IQE({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":RQE(e)?"_"+e:e}function zQE({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return pB_[e]}var xQE=/^[0-9]/;function RQE(e){return xQE.test(e)}function NQE(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=iko(i)!=null||nko(i),a=iko(t)!=null||nko(t);return n&&a})}function iko(e){return LQE.get(e.toUpperCase())}function nko(e){return FQE.has(e.toUpperCase())}var FQE=new Set(["ACL","API","ASCII","CPU","CSS","DNS","EOF","GUID","HTML","HTTP","HTTPS","ID","IP","JSON","LHS","QPS","RAM","RHS","RPC","SAML","SCIM","SLA","SMTP","SQL","SSH","SSO","TCP","TLS","TTL","UDP","UI","UID","UUID","URI","URL","UTF8","VM","XML","XMPP","XSRF","XSS"]),LQE=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]);var hB_=require("fs/promises");var FPc=class{_map;_path;_lastScalar;_fragments;_count;constructor(){this._map={},this._path=[],this._lastScalar="",this._fragments=[],this._count=0}get map(){return this._map}resolveNode(t,r){if(t.path==="."&&(r="."),!this._map[r]){let{line:i,position:n,lineStart:a}=t;this._map[r]={line:i,position:n,lineStart:a}}t.children&&t.children.length>0&&t.children.forEach(i=>{this.resolveNode(i,(r==="."?"":r)+"."+i.path)})}iterFragments(t,r){for(let i=this._fragments.length-1;i>=0;i--){if(!this._fragments[i].path.startsWith(t)||this._fragments[i].path===t)continue;let n=this._fragments.pop();r(n)}}handleState(t,r){if(t==="close"){let i=r.result,n=r.kind,a=this._path.join(".");if(n==="scalar"){this._path.pop(),this._lastScalar=`${i}`;let{line:u,position:l,lineStart:d}=r;this._path.length===0?this._map["."+i]={line:u,position:l,lineStart:d}:this._fragments.push({path:this._path.join(".")+"."+i,line:u,position:l,lineStart:d})}else if(n==="mapping"){let u={path:a,children:[],line:0,position:0,lineStart:0},l=0;this.iterFragments(a,d=>{l++,!((!d.children||d.children.length===0)&&l%2===1)&&(this._path.length===1?this.resolveNode(d,d.path):(u.children.push({...d,path:d.path.slice(a.length+1)}),u.line=d.line,u.position=d.position,u.lineStart=d.lineStart))}),u.children&&u.children.length>0&&this._fragments.push(u),this._path.pop()}else if(n==="sequence"){let u={path:a,children:[],line:0,position:0,lineStart:0},l=new Set,d=i.length;this.iterFragments(a,s=>{l.has(s.position)||(d--,l.add(s.position),this._path.length===1?this.resolveNode(s,`${a}.${d}`):(u.children.push({...s,path:d.toString()}),u.line=s.line,u.position=s.position,u.lineStart=s.lineStart))}),u.children&&u.children.length>0&&this._fragments.push(u),this._path.pop()}else this._path.pop()}if(t==="open"){if(this._count===0){let{line:i,position:n,lineStart:a}=r;this._map["."]={line:i,position:n,lineStart:a}}this._path.push(this._lastScalar),this._count++}}listen(){return this.handleState.bind(this)}lookup(t){let r=t instanceof Array?t.map(n=>`${n}`).join("."):`${t}`;r.startsWith(".")||(r="."+r),r.startsWith("..")&&(r=r.slice(1)),r=r.replace(/\[/g,".").replace(/\]/g,"");let i=this._map[r];if(i)return{line:i.line+1,column:i.position-i.lineStart+1,position:i.position}}},_B_=FPc;var Lir;(function(e){e.WARNING="warning",e.ERROR="error"})(Lir||(Lir={}));var z9n=class{errors=[];logger;breadcrumbToLineNumberMapper;relativeFilepathToSpec;constructor({logger:t,relativeFilepathToSpec:r}){this.logger=t,this.relativeFilepathToSpec=r,r&&(this.breadcrumbToLineNumberMapper=new LPc({logger:t,relativePathToFile:Qa.of(r)}))}collect(t){this.errors.push(t)}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}dedupe(){let t=[],r=new Set,i=0;for(let n of this.errors){let a=n.path?n.path.join("->"):"",u=`${n.message}|${n.level||Lir.WARNING}|${a}`;r.has(u)?i++:(r.add(u),t.push(n))}return this.errors=t,i}getErrorStats(){this.dedupe();let t=0,r=0;for(let i of this.errors)i.level===Lir.ERROR?t++:r++;return{numErrors:t,numWarnings:r}}async logErrors({logWarnings:t}){this.dedupe();for(let r of this.errors)if(!(r.level===Lir.WARNING&&!t)){switch(r.level){case Lir.ERROR:if(this.logger.log(Pb.Error,r.message),r.path&&r.path.length>0){let i=await this.breadcrumbToLineNumberMapper?.getSourceLocation(r.path),n=i?`${this.relativeFilepathToSpec}:${i.line}:${i.column}`:r.path.join(" -> ");this.logger.log(Pb.Error,` - at location (${n})`)}break;case Lir.WARNING:default:if(this.logger.log(Pb.Warn,r.message),r.path&&r.path.length>0){let i=await this.breadcrumbToLineNumberMapper?.getSourceLocation(r.path),n=i?`${this.relativeFilepathToSpec}:${i.line}:${i.column}`:r.path.join(" -> ");this.logger.log(Pb.Warn,` - at location (${n})`)}}this.logger.log(Pb.Info,"")}}},LPc=class{logger;relativePathToFile;map=new _B_;initialized=!1;constructor({relativePathToFile:t,logger:r}){this.relativePathToFile=t,this.logger=r}async initialize(){if(!this.initialized)try{let t=await(0,hB_.readFile)(this.relativePathToFile,"utf-8");qd.load(t,{listener:this.map.listen()}),this.initialized=!0}catch(t){this.logger.log(Pb.Warn,`Failed to initialize line number mapping for ${this.relativePathToFile}: ${JSON.stringify(t)}`)}}async getSourceLocation(t){return this.initialized||await this.initialize(),this.map.lookup(t)}};var f8=class e{args;spec;settings;errorCollector;logger;generationLanguage;smartCasing;casingsGenerator;namespace;exampleGenerationArgs;authOverrides;environmentOverrides;globalHeaderOverrides;enableUniqueErrorsPerEndpoint;constructor(t){this.args=t,this.spec=t.spec,this.settings=t.settings,this.errorCollector=t.errorCollector,this.logger=t.logger,this.generationLanguage=t.generationLanguage,this.smartCasing=t.smartCasing,this.namespace=t.namespace,this.casingsGenerator=RMe({generationLanguage:t.generationLanguage,keywords:void 0,smartCasing:t.smartCasing}),this.exampleGenerationArgs=t.exampleGenerationArgs,this.authOverrides=t.authOverrides,this.environmentOverrides=t.environmentOverrides,this.globalHeaderOverrides=t.globalHeaderOverrides,this.enableUniqueErrorsPerEndpoint=t.enableUniqueErrorsPerEndpoint}static BREADCRUMBS_TO_IGNORE=["properties","allOf","anyOf"];convertBreadcrumbsToName(t){let r=t.filter((n,a)=>!(/^\d+$/.test(n)||e.BREADCRUMBS_TO_IGNORE.includes(n)||a===0&&n==="components"||a===1&&n==="schemas"||t[0]==="paths"&&(a===0||a===1&&["get","post","put","delete","patch"].includes(n)||a===2&&t[1]!=null&&["get","post","put","delete","patch"].includes(t[1])&&n==="parameters"))),i=T_(r.join("_"));return i.charAt(0).toUpperCase()+i.slice(1)}createFernFilepath(t={}){let r=this.namespace!=null?[this.casingsGenerator.generateName(this.namespace)]:[],i=t.name!=null?this.casingsGenerator.generateName(t.name):void 0;return{allParts:i?[...r,i]:r,packagePath:r,file:i}}resolveReference({reference:t,breadcrumbs:r,skipErrorCollector:i}){let n=this.spec,a=t.$ref.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(u=>u.replace(/~1/g,"/"));for(let u of a){if(typeof n!="object"||n==null)return i||this.errorCollector.collect({level:Lir.ERROR,message:this.getErrorMessageForMissingRef({reference:t}),path:r}),{resolved:!1};n=n[u]}return n==null?(i||this.errorCollector.collect({level:Lir.ERROR,message:this.getErrorMessageForMissingRef({reference:t}),path:r}),{resolved:!1}):{resolved:!0,value:n}}getErrorMessageForMissingRef({reference:t}){let r=t.$ref.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/");return r.length>=3&&r[0]==="components"&&r[1]==="schemas"?`Schema ${r[2]} does not exist`:`${t.$ref} does not exist`}async resolveMaybeExternalReference(t){let r=this.spec,i,n=!1,a=null,u;if(this.isExternalReference(t.$ref)){n=!0;let d=t.$ref.split("#"),s=d[0];if(i=d[1],!s)return{resolved:!1};u=s;let o=await fetch(s);if(!o.ok)return{resolved:!1};try{let c=await o.text();try{a=JSON.parse(c),r=a}catch{a=qd.load(c),r=a}if(r==null)return{resolved:!1}}catch{return{resolved:!1}}if(!i)return{resolved:!0,value:r}}let l=(i??t.$ref).replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(d=>d.replace(/~1/g,"/"));for(let d of l){if(typeof r!="object"||r==null)return{resolved:!1};r=r[d]}if(r==null)return{resolved:!1};if(n&&typeof r=="object"&&r!==null){let d=new Set;d.add(t.$ref),r=await this.resolveNestedExternalReferences(r,a,d,u)}return{resolved:!0,value:r}}async resolveNestedExternalReferences(t,r,i,n){if(t===null||typeof t!="object")return t;if(Array.isArray(t)){let u=[];for(let l of t)u.push(await this.resolveNestedExternalReferences(l,r,i,n));return u}if(this.isReferenceObject(t)){let u=t.$ref;if(this.isExternalReference(u)){if(i.has(u))return t;i.add(u);let l=await this.resolveMaybeExternalReference({$ref:u});if(i.delete(u),l.resolved)return l.value}else{let l=`${n}${u}`;if(i.has(l))return t;i.add(l);let d=r,s=u.substring(2).split("/").map(o=>o.replace(/~1/g,"/").replace(/~0/g,"~"));for(let o of s){if(typeof d!="object"||d===null)return t;d=d[o]}if(d!=null){let o=await this.resolveNestedExternalReferences(d,r,i,n);return i.delete(u),o}i.delete(u)}return t}let a={};for(let[u,l]of Object.entries(t))typeof l=="object"&&l!==null?a[u]=await this.resolveNestedExternalReferences(l,r,i,n):a[u]=l;return a}getExamplesFromSchema({schema:t,breadcrumbs:r}){if(t==null)return[];let i=t.example!=null?[t.example]:[];return t.examples!=null&&(Array.isArray(t.examples)?i.push(...t.examples):this.errorCollector.collect({message:"Received non-array schema examples",path:r})),i}getNamedExamplesFromMediaTypeObject({mediaTypeObject:t,breadcrumbs:r,defaultExampleName:i}){if(t==null)return[];let n=[];if(t.example!=null){let a=this.generateUniqueName({prefix:i??`${r.join("_")}_example`,existingNames:[]});n.push([a,t.example])}return t.examples!=null&&n.push(...Object.entries(t.examples)),n}resolveMaybeReference({schemaOrReference:t,breadcrumbs:r,skipErrorCollector:i}){if(this.isReferenceObject(t)){let n=this.resolveReference({reference:t,breadcrumbs:r,skipErrorCollector:i});return n.resolved?n.value:void 0}return t}resolveExample(t){if(!this.isReferenceObject(t))return t;let r=this.resolveReference({reference:t});return r.resolved?this.returnExampleValue(r.value):void 0}resolveExampleWithValue(t){if(!this.isReferenceObject(t))return this.returnExampleValue(t);let r=this.resolveReference({reference:t});return r.resolved?this.returnExampleValue(r.value):void 0}returnExampleValue(t){return this.isExampleWithValue(t)?t.value:t}getPropertyAccess(t){let r=t;for(;this.isReferenceObject(r);){let i=this.resolveReference({reference:r});if(!i.resolved)return;r=i.value}if(!(r.readOnly&&r.writeOnly)){if(r.readOnly)return Rkt.ReadOnly;if(r.writeOnly)return Rkt.WriteOnly}}getAudiences({operation:t,breadcrumbs:r}){let n=new pH.AudienceExtension({operation:t,breadcrumbs:r,context:this}).convert();if(n!=null)return n.audiences}getAvailability({node:t,breadcrumbs:r}){for(;this.isReferenceObject(t);){let a=this.resolveReference({reference:t});if(!a.resolved)return;t=a.value}let n=new pH.FernAvailabilityExtension({node:t,breadcrumbs:r,context:this}).convert();if(n!=null)return{status:n,message:void 0};if(t.deprecated===!0)return{status:B9.Deprecated,message:void 0}}getTypeIdFromSchemaReference(t){let r=t.$ref.match(/\/schemas\/(.+)$/);if(!(!r||!r[1]))return r[1]}createNamedTypeReference(t,r){return gf.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(t),typeId:t,displayName:r,default:void 0,inline:!1})}typeReferenceToDeclaredTypeName(t){if(t.type!=="named")return;let r=t.typeId;return{typeId:r,fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r),displayName:t.displayName}}removeSchemaFromInlinedTypes({id:t,inlinedTypes:r}){return Object.fromEntries(Object.entries(r).filter(([i])=>i!==t))}static maybeTrimPrefix(t,r){return t.startsWith(r)?t.slice(r.length):t}generateUniqueName({prefix:t,existingNames:r}){if(!r.includes(t))return t;let i=0;for(;r.includes(`${t}_${i}`);)i++;return`${t}_${i}`}isReferenceObject(t){return typeof t=="object"&&t!==null&&"$ref"in t}isExternalReference(t){return t.startsWith("http://")||t.startsWith("https://")}isReferenceObjectWithIdentifier(t){return this.isReferenceObject(t)&&("title"in t||"name"in t||"messageId"in t)}isExampleWithSummary(t){return typeof t=="object"&&t!=null&&"summary"in t}isExampleWithValue(t){return typeof t=="object"&&t!=null&&"value"in t}isOptional(t){return t.type==="container"&&t.container.type==="optional"}isNullable(t){return t.type==="container"&&t.container.type==="nullable"}isList(t){return t.type==="container"&&t.container.type==="list"}isFile(t){return t.type==="primitive"&&t.primitive.v2?.type==="string"&&t.primitive.v2.validation?.format==="binary"}getAsString(t){if(typeof t=="string")return t}getAsInteger(t){if(typeof t=="number"&&Number.isInteger(t))return t}getAsNumber(t){if(typeof t=="number")return t}getAsBoolean(t){if(typeof t=="boolean")return t}getAsArray(t){if(Array.isArray(t))return t}getAsObject(t){if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t}getGroup({groupParts:t,namespace:r}){let i=[];return r!=null&&i.push(r),i.push(...t??[]),i}isObjectSchemaType(t){return t.type==="object"||t.properties!=null}};var Aj=class{breadcrumbs;context;constructor(t){this.breadcrumbs=t.breadcrumbs,this.context=t.context}getExtensionValue(t,r){if(typeof t!="object"||t==null)return;let i=t[this.key];if(i!=null)return i;if(r!=null)return t[r]}};function lF(e){let t=VQE(e),{value:r,done:i}=UPc(t,"{");return i?{head:r,parts:[]}:{head:r,parts:[...UQE(t)]}}function*UQE(e){let t;do{let{value:r}=UPc(e,"}"),i=UPc(e,"{");t=i.done,yield{pathParameter:r,tail:i.value}}while(!t)}function*VQE(e){for(let t of e)yield t}function UPc(e,t){let r="",i=e.next();for(;i.done!==!0&&i.value!==t;)r+=i.value,i=e.next();return{value:r,done:i.done??!1}}function DRa(e){let t=2166136261;function r(n,a){if(typeof n=="object"&&n!=null){if(a>64){i("[MaxDepthExceeded]");return}if(Array.isArray(n)){i("[");for(let u=0;u<n.length;u++)u>0&&i(","),r(n[u],a+1);i("]")}else i("{"),Object.keys(n).sort().forEach((l,d)=>{d>0&&i(","),i(l),i(":"),r(n[l],a+1)}),i("}")}else i(String(n))}function i(n){for(let a=0;a<n.length;a++){let u=n.charCodeAt(a);t^=u,t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24),t>>>=0}}return r(e,0),t.toString(16)}function Uir({typeReference:e,typeDeclarations:t}){if(e.type==="container"&&e.container.type==="optional")return!0;if(e.type==="named"){let r=t?.[e.typeId];if(r?.shape.type==="alias"&&r?.shape.resolvedType.type==="container"&&r?.shape.resolvedType.container.type==="optional")return!0}return!1}function yB_({fieldName:e,containerType:t,maxDepth:r,currentDepth:i,typeDeclarations:n,skipOptionalProperties:a}){if(i>=r)return Vir({containerType:t});switch(t.type){case"list":{let u=Gq({fieldName:e,typeReference:t.list,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?Vir({containerType:t}):{type:"success",example:bm.list({list:[u.example,u.example],itemType:t.list}),jsonExample:[u.jsonExample,u.jsonExample]}}case"literal":return{type:"success",example:bm.literal({literal:t.literal._visit({boolean:u=>Rd.boolean(u),string:u=>Rd.string({original:u}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:t.literal._visit({boolean:u=>u,string:u=>u,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":{if(a)return Vir({containerType:t});let u=Gq({fieldName:e,typeReference:t.optional,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?Vir({containerType:t}):{type:"success",example:bm.optional({optional:u.example,valueType:t.optional}),jsonExample:u.jsonExample}}case"nullable":{if(a)return Vir({containerType:t});let u=Gq({fieldName:e,typeReference:t.nullable,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?Vir({containerType:t}):{type:"success",example:bm.nullable({nullable:u.example,valueType:t.nullable}),jsonExample:u.jsonExample}}case"set":{let u=Gq({fieldName:e,typeReference:t.set,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"?Vir({containerType:t}):{type:"success",example:bm.set({set:[u.example],itemType:t.set}),jsonExample:[u.jsonExample]}}case"map":{let u=Gq({fieldName:e,typeReference:t.keyType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a}),l=Gq({fieldName:e,typeReference:t.valueType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return u.type==="failure"||l.type==="failure"?Vir({containerType:t}):{type:"success",example:bm.map({map:[{key:u.example,value:l.example}],keyType:t.keyType,valueType:t.valueType}),jsonExample:{[u.jsonExample]:l.jsonExample}}}default:mo(t)}}function Vir({containerType:e}){switch(e.type){case"list":return{type:"success",example:bm.list({list:[],itemType:e.list}),jsonExample:[]};case"literal":return{type:"success",example:bm.literal({literal:e.literal._visit({boolean:t=>Rd.boolean(t),string:t=>Rd.string({original:t}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:e.literal._visit({boolean:t=>t,string:t=>t,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":return{type:"success",example:bm.optional({optional:void 0,valueType:e.optional}),jsonExample:void 0};case"nullable":return{type:"success",example:bm.nullable({nullable:void 0,valueType:e.nullable}),jsonExample:void 0};case"set":return{type:"success",example:bm.set({set:[],itemType:e.set}),jsonExample:[]};case"map":return{type:"success",example:bm.map({map:[],keyType:e.keyType,valueType:e.valueType}),jsonExample:{}};default:mo(e)}}function bB_({fieldName:e,primitiveType:t}){switch(t.v1){case"STRING":return QQE({fieldName:e,default_:WQE(t.v2),validation:HQE(t.v2)});case"BASE_64":return{type:"success",example:Rd.base64(Gy.BASE64),jsonExample:Gy.BASE64};case"BOOLEAN":return{type:"success",example:Rd.boolean(Gy.BOOLEAN),jsonExample:Gy.BOOLEAN};case"DATE":return{type:"success",example:Rd.date(Gy.DATE),jsonExample:Gy.DATE};case"DATE_TIME":return{type:"success",example:Rd.datetime({datetime:new Date(Gy.DATE_TIME),raw:Gy.DATE_TIME}),jsonExample:Gy.DATE_TIME};case"DOUBLE":return JQE({fieldName:e,validation:$QE(t.v2)});case"FLOAT":return{type:"success",example:Rd.float(Gy.FLOAT),jsonExample:Gy.FLOAT};case"INTEGER":return KQE({fieldName:e,validation:GQE(t.v2)});case"UINT_64":return{type:"success",example:Rd.uint64(Gy.INT64),jsonExample:Gy.INT64};case"UINT":return{type:"success",example:Rd.uint(Gy.UINT),jsonExample:Gy.UINT};case"BIG_INTEGER":return{type:"success",example:Rd.bigInteger(Gy.INT64.toString()),jsonExample:`${Gy.INT64}`};case"LONG":return{type:"success",example:Rd.long(Gy.INT64),jsonExample:Gy.INT64};case"UUID":return{type:"success",example:Rd.uuid(Gy.UUID),jsonExample:Gy.UUID};default:mo(t.v1)}}function WQE(e){if(e?.type==="string")return e.default}function HQE(e){if(e?.type==="string")return e.validation}function $QE(e){if(e?.type==="double")return e.validation}function GQE(e){if(e?.type==="integer")return e.validation}function vB_(e){if(e<=Gy.SAMPLE_STRINGS.length){let t=Gy.SAMPLE_STRINGS[e-1];if(t)return t;throw new Error(`Unexpected undefined value in SAMPLE_STRINGS at index ${e-1}`)}return Gy.SAMPLE_STRINGS[Gy.SAMPLE_STRINGS.length-1]+".".repeat(e-Gy.SAMPLE_STRINGS.length)}function QQE({fieldName:e,default_:t,validation:r}){if(t!=null)return{type:"success",example:Rd.string({original:t}),jsonExample:t};if(r){let n=r.minLength,a=r.maxLength;if(n){let u=vB_(n);return{type:"success",example:Rd.string({original:u}),jsonExample:u}}else if(a){let u=vB_(a);return{type:"success",example:Rd.string({original:u}),jsonExample:u}}}let i=e??Gy.STRING;return{type:"success",example:Rd.string({original:i}),jsonExample:i}}function JQE({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Rd.double(r),jsonExample:r};if(i)return{type:"success",example:Rd.double(i),jsonExample:i}}return{type:"success",example:Rd.double(Gy.DOUBLE),jsonExample:Gy.DOUBLE}}function KQE({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Rd.integer(r),jsonExample:r};if(i)return{type:"success",example:Rd.integer(i),jsonExample:i}}return{type:"success",example:Rd.integer(Gy.INT),jsonExample:Gy.INT}}function x9n({fieldName:e,typeDeclarations:t,typeDeclaration:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){switch(r.shape.type){case"alias":{let u=Gq({fieldName:e,typeDeclarations:t,typeReference:r.shape.aliasOf,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(u.type==="failure")return u;let{example:l,jsonExample:d}=u;return{type:"success",example:Iw.alias({value:l}),jsonExample:d}}case"enum":{let u=r.shape.values[0];return u==null?{type:"failure",message:"No enum values present"}:{type:"success",example:Iw.enum({value:u.name}),jsonExample:u.name.wireValue}}case"object":{let u={},l=[];if(r.shape.extends!=null)for(let c of r.shape.extends){let b=t[c.typeId];if(b==null)continue;let g=x9n({fieldName:e,typeDeclaration:b,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});g!=null&&g.type==="success"&&g.example.type==="object"&&(Object.assign(u,g.jsonExample),l.push(...g.example.properties))}let d=YQE({fieldName:e,typeDeclaration:r,objectTypeDeclaration:r.shape,typeDeclarations:t,currentDepth:n,maxDepth:i,skipOptionalProperties:a});if(d.type==="failure")return d;let{example:s,jsonExample:o}=d;return{type:"success",example:Iw.object({...s,properties:[...l,...s.properties]}),jsonExample:Object.assign({},u,o)}}case"undiscriminatedUnion":{let u=0;for(let l of r.shape.members){let d=Gq({fieldName:e,typeReference:l.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(d.type==="failure"){++u;continue}let{example:s,jsonExample:o}=d;return{type:"success",example:Iw.undiscriminatedUnion({index:u,singleUnionType:s}),jsonExample:o}}break}case"union":{let u=r.shape.discriminant,l={};if(r.shape.baseProperties!=null)for(let d of r.shape.baseProperties){let s=Gq({fieldName:d.name.wireValue,typeReference:d.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});s.type==="success"&&(l[d.name.wireValue]=s.jsonExample)}for(let d of r.shape.types){let s=d.shape._visit({noProperties:()=>({type:"success",example:Iw.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:h3.noProperties()}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,...l}}),samePropertiesAsObject:o=>{let c=t[o.typeId];if(c==null)return{type:"failure",message:`Failed to find type declaration with id ${o.typeId}`};let b=x9n({currentDepth:n,maxDepth:i,fieldName:e,typeDeclaration:c,typeDeclarations:t,skipOptionalProperties:a});if(b==null)return{type:"failure",message:"Failed to generate example for type reference"};if(b.type==="failure")return b;let{example:g,jsonExample:O}=b;return{type:"success",example:Iw.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:h3.samePropertiesAsObject({typeId:c.name.typeId,object:g.type==="object"?g:{properties:[]}})}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,...typeof O=="object"?O:{},...l}}},singleProperty:o=>{let c=Gq({currentDepth:n+1,maxDepth:i,fieldName:e,typeReference:o.type,typeDeclarations:t,skipOptionalProperties:a});if(c.type==="failure")return c;let{example:b,jsonExample:g}=c;return{type:"success",example:Iw.union({discriminant:u,singleUnionType:{wireDiscriminantValue:d.discriminantValue,shape:h3.singleProperty(b)}}),jsonExample:{[u.wireValue]:d.discriminantValue.wireValue,[o.name.wireValue]:g,...l}}},_other:()=>{throw new Error("Encountered unknown union type")}});if(s.type!=="failure")return s}}}return{type:"failure",message:"Failed to generate example for type reference"}}function YQE({fieldName:e,typeDeclaration:t,objectTypeDeclaration:r,typeDeclarations:i,maxDepth:n,currentDepth:a,skipOptionalProperties:u}){let l={},d=[];for(let s of[...r.properties??[],...r.extendedProperties??[]]){let o=Gq({fieldName:s.name.wireValue,typeReference:s.valueType,typeDeclarations:i,currentDepth:a+1,maxDepth:n,skipOptionalProperties:u});if(o.type==="failure"&&!Uir({typeDeclarations:i,typeReference:s.valueType}))return{type:"failure",message:`Failed to generate required property ${s.name.wireValue} b/c ${o.message}`};if(o.type==="failure")continue;let{example:c,jsonExample:b}=o;d.push({name:s.name,originalTypeDeclaration:t.name,value:c}),l[s.name.wireValue]=b}return{type:"success",example:Iw.object({properties:d}),jsonExample:l}}function Gq({fieldName:e,typeReference:t,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){if(n>i)return{type:"failure",message:"Exceeded max depth"};switch(t.type){case"named":{let u=r[t.typeId];if(u==null)return{type:"failure",message:`Failed to find type declaration with id ${t.typeId}`};let l=x9n({fieldName:e,typeDeclaration:u,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(l==null)return{type:"failure",message:"Failed to generate example for type declaration"};if(l.type==="failure")return l;let{example:d,jsonExample:s}=l;return{type:"success",example:{jsonExample:s,shape:Nh.named({shape:d,typeName:u.name})},jsonExample:s}}case"container":{let u=yB_({fieldName:e,containerType:t.container,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(u.type==="failure"){let{example:s,jsonExample:o}=Vir({containerType:t.container});return{type:"success",example:{jsonExample:o,shape:Nh.container(s)},jsonExample:o}}let{example:l,jsonExample:d}=u;return{type:"success",example:{jsonExample:d,shape:Nh.container(l)},jsonExample:d}}case"primitive":{let{jsonExample:u,example:l}=bB_({fieldName:e,primitiveType:t.primitive});return{type:"success",example:{jsonExample:u,shape:Nh.primitive(l)},jsonExample:u}}case"unknown":{let u={key:"value"};return{type:"success",example:{jsonExample:u,shape:Nh.unknown(u)},jsonExample:u}}}}function PKi(e,t){let r=[];for(let i of e){let n=Gq({fieldName:i.name.originalName,currentDepth:0,maxDepth:t.maxDepth??1,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,value:n.example})}return{type:"success",example:r,jsonExample:void 0}}function R9n(e,t){let r=[];for(let i of e){if(t.skipOptionalRequestProperties&&Uir({typeDeclarations:t.typeDeclarations,typeReference:i.valueType}))continue;let n=Gq({fieldName:i.name.name.originalName,currentDepth:0,maxDepth:t.maxDepth??1,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,value:n.example})}return{type:"success",example:r,jsonExample:void 0}}function ako(e,t){let r=[];for(let i of e){if(t.skipOptionalRequestProperties&&Uir({typeDeclarations:t.typeDeclarations,typeReference:i.valueType}))continue;let n=Gq({fieldName:i.name.name.originalName,currentDepth:0,maxDepth:t.maxDepth??10,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,shape:i.allowMultiple?$2.exploded():$2.single(),value:n.example})}return{type:"success",example:r,jsonExample:void 0}}var VPc=gf.primitive({v1:O0.String,v2:Lp.string({default:void 0,validation:void 0})});function ERa({ir:e,endpoint:t,service:r,typeDeclarations:i,skipOptionalRequestProperties:n,generationResponse:a}){let u={name:void 0,endpointHeaders:[],endpointPathParameters:[],queryParameters:[],servicePathParameters:[],serviceHeaders:[],rootPathParameters:[],request:void 0,response:RT.ok(kC.body(void 0)),docs:void 0},l=PKi(t.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(l.type==="failure")return l;u.endpointPathParameters=l.example;let d=PKi(r.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(d.type==="failure")return d;u.servicePathParameters=d.example;let s=PKi(e.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(s.type==="failure")return s;u.rootPathParameters=s.example;let o=ako(t.queryParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:10});if(o.type==="failure")return o;u.queryParameters=o.example;let c=R9n(t.headers,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(c.type==="failure")return c;u.endpointHeaders=c.example;let b=R9n(r.headers,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(b.type==="failure")return b;if(u.serviceHeaders=b.example,t.requestBody!=null)switch(t.requestBody.type){case"bytes":return{type:"failure",message:"Bytes request unsupported"};case"fileUpload":return{type:"failure",message:"File upload unsupported"};case"inlinedRequestBody":{let g={},O=[];if(t.requestBody.extends!=null)for(let m of t.requestBody.extends){let P=i[m.typeId];if(P==null)throw new Error(`Failed to find extended type declaration with id ${m.typeId}`);let E=x9n({typeDeclaration:P,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});E!=null&&E.type==="success"&&Object.assign(g,E.jsonExample)}for(let m of[...t.requestBody.properties??[],...t.requestBody.extendedProperties??[]]){let P=Gq({fieldName:m.name.wireValue,typeReference:m.valueType,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});if(P.type==="failure"&&!Uir({typeDeclarations:i,typeReference:m.valueType}))return{type:"failure",message:`Failed to generate required property ${m.name.wireValue} b/c ${P.message}`};if(P.type==="failure")continue;let{example:E,jsonExample:q}=P;O.push({name:m.name,originalTypeDeclaration:void 0,value:E}),g[m.name.wireValue]=q}u.request=zQ.inlinedRequestBody({jsonExample:g,properties:O});break}case"reference":{let g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.requestBody.requestBodyType,skipOptionalProperties:n});if(g.type==="failure")return g;let{example:O}=g;u.request=zQ.reference(O);break}default:mo(t.requestBody)}if(a.type==="success"&&t.response?.body!=null)switch(t.response.body.type){case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":{let g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.responseBodyType,skipOptionalProperties:!1});if(g.type==="failure")return g;let{example:O,jsonExample:m}=g;u.response=RT.ok(kC.body({...O,jsonExample:m}));break}case"streamParameter":{let g;switch(t.response.body.nonStreamResponse.type){case"bytes":return{type:"failure",message:"Bytes unsupported"};case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.nonStreamResponse.value.responseBodyType,skipOptionalProperties:!1});break;case"text":g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:VPc,skipOptionalProperties:!1});break;default:mo(t.response.body.nonStreamResponse)}if(g.type==="failure")return g;let{example:O,jsonExample:m}=g;u.response=RT.ok(kC.body({...O,jsonExample:m}));break}case"streaming":{let g;switch(t.response.body.value.type){case"sse":{if(g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),g.type==="failure")return g;let{example:O,jsonExample:m}=g;u.response=RT.ok(kC.sse([{data:{...O,jsonExample:m},event:""}]));break}case"json":{if(g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),g.type==="failure")return g;let{example:O,jsonExample:m}=g;u.response=RT.ok(kC.stream([{...O,jsonExample:m}]));break}case"text":{if(g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:VPc,skipOptionalProperties:!1}),g.type==="failure")return g;let{example:O,jsonExample:m}=g;u.response=RT.ok(kC.stream([{...O,jsonExample:m}]));break}default:mo(t.response.body.value)}break}case"text":{let g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:VPc,skipOptionalProperties:!1});if(g.type==="failure")return g;let{example:O,jsonExample:m}=g;u.response=RT.ok(kC.body({...O,jsonExample:m}));break}case"bytes":return{type:"failure",message:"Bytes unsupported"};default:mo(t.response.body)}else if(a.type==="error")if(a.declaration.type==null)u.response=RT.error({body:void 0,error:a.declaration.name});else{let g=Gq({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:a.declaration.type,skipOptionalProperties:n});if(g.type==="failure")return g;let{example:O}=g;u.response=RT.error({body:O,error:a.declaration.name})}try{return{type:"success",example:{id:DRa(u),url:XQE(t,u),...u},jsonExample:void 0}}catch(g){return{type:"failure",message:`Parse failure with exceptions ${g}`}}}function XQE(e,t){let r={};[...t.rootPathParameters,...t.servicePathParameters,...t.endpointPathParameters].forEach(n=>{let a=n.value.jsonExample,u=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=u});let i=e.fullPath.head+e.fullPath.parts.map(n=>r[n.pathParameter]+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function OB_({ir:e,channel:t,typeDeclarations:r,skipOptionalRequestProperties:i}){let n={name:void 0,pathParameters:[],headers:[],queryParameters:[],messages:[],docs:void 0},a=PKi(t.pathParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(a.type==="failure")return a;n.pathParameters.push(...a.example);let u=PKi(e.pathParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(u.type==="failure")return u;n.pathParameters.push(...u.example);let l=ako(t.queryParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:10});if(l.type==="failure")return l;n.queryParameters=l.example;let d=R9n(t.headers,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(d.type==="failure")return d;n.headers.push(...d.example);let s=R9n(e.headers,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(s.type==="failure")return s;n.headers.push(...s.example);let c=t.messages.filter(O=>O.origin==="client")[0];if(c!=null){let O=gB_({message:c,typeDeclarations:r,skipOptionalRequestProperties:i});O!=null&&n.messages.push({type:c.type,body:O})}let g=t.messages.filter(O=>O.origin==="server")[0];if(g!=null){let O=gB_({message:g,typeDeclarations:r,skipOptionalRequestProperties:i});O!=null&&n.messages.push({type:g.type,body:O})}return{type:"success",example:{...n,url:ZQE(t,n)},jsonExample:void 0}}function gB_({message:e,typeDeclarations:t,skipOptionalRequestProperties:r}){if(e.body.type==="inlinedBody")return;let i=Gq({currentDepth:0,maxDepth:10,typeDeclarations:t,typeReference:e.body.bodyType,skipOptionalProperties:r});if(i.type==="success")return JEe.reference(i.example)}function ZQE(e,t){let r={};[...t.pathParameters].forEach(n=>{let a=n.value.jsonExample,u=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=u});let i=e.path.head+e.path.parts.map(n=>r[n.pathParameter]+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function N9n(e){let t=e?.userSpecifiedExamples??{},r=e?.autogeneratedExamples??{},i=Object.values(t)[0],n=Object.values(r)[0];return{userExample:i,autoExample:n}}function VAi(e){let t=e?.userSpecifiedExamples??{},r=e?.autogeneratedExamples??{};return{userExamples:t,autoExamples:r}}function mB_({service:e,endpoint:t,typeDeclarations:r,skipOptionalRequestProperties:i}){let n={pathParameters:{},queryParameters:{},headers:{}};for(let a of t.pathParameters){let{userExample:u,autoExample:l}=N9n(a.v2Examples);u!==void 0?n.pathParameters[a.name.originalName]=u:l!==void 0&&(n.pathParameters[a.name.originalName]=l)}for(let a of t.queryParameters){let{userExample:u,autoExample:l}=N9n(a.v2Examples);if(u!==void 0)n.queryParameters[a.name.name.originalName]=u;else if(l!==void 0){if(i&&Uir({typeReference:a.valueType,typeDeclarations:r}))continue;n.queryParameters[a.name.name.originalName]=l}}for(let a of t.headers){let{userExample:u,autoExample:l}=N9n(a.v2Examples);if(u!==void 0)n.headers[a.name.name.originalName]=u;else if(l!==void 0){if(i&&Uir({typeReference:a.valueType,typeDeclarations:r}))continue;n.headers[a.name.name.originalName]=l}}return n}function PB_({endpoint:e,service:t,typeDeclarations:r,skipOptionalRequestProperties:i}){let{pathParameters:n,queryParameters:a,headers:u}=mB_({service:t,endpoint:e,typeDeclarations:r,skipOptionalRequestProperties:i}),l={},d={},s={endpoint:{method:e.method,path:kQE(e)},baseUrl:void 0,environment:e.baseUrl,auth:void 0,pathParameters:n,queryParameters:a,headers:u,requestBody:void 0,docs:void 0};if(e.requestBody!=null)switch(e.requestBody.type){case"bytes":break;case"fileUpload":{let{userExamples:o,autoExamples:c}=VAi(e.requestBody.v2Examples);for(let[b,g]of Object.entries(o))l[b]={...s,requestBody:g};for(let[b,g]of Object.entries(c))d[b]={...s,requestBody:g};break}case"inlinedRequestBody":{let{userExamples:o,autoExamples:c}=VAi(e.requestBody.v2Examples);for(let[b,g]of Object.entries(o))l[b]={...s,requestBody:g};for(let[b,g]of Object.entries(c))d[b]={...s,requestBody:g};break}case"reference":{let{userExamples:o,autoExamples:c}=VAi(e.requestBody.v2Examples);for(let[b,g]of Object.entries(o))l[b]={...s,requestBody:g};for(let[b,g]of Object.entries(c))d[b]={...s,requestBody:g};break}default:mo(e.requestBody)}return{userRequestExamples:l,autoRequestExamples:d,baseExample:s}}function kQE(e){let t={};[...e.pathParameters,...e.allPathParameters].forEach(i=>{let{userExample:n,autoExample:a}=N9n(i.v2Examples),u=n??a,l;u==null?l=i.name.originalName:l=typeof u=="string"?u:JSON.stringify(u),t[i.name.originalName]=l});let r=e.fullPath.head+e.fullPath.parts.map(i=>t[i.pathParameter]+i.tail).join("");return r.startsWith("/")||r===""?r:`/${r}`}function jB_({endpoint:e}){let t={},r={},i={statusCode:e.response?.statusCode,body:void 0,docs:void 0};if(e.response==null)return{userResponseExamples:{},autoResponseExamples:{},baseExample:i};if(e.response.body==null)return e.source?.type==="openrpc"?{userResponseExamples:{},autoResponseExamples:{},baseExample:{...i,body:I9.json(MRa(null))}}:{userResponseExamples:{},autoResponseExamples:{},baseExample:i};switch(e.response.body.type){case"bytes":break;case"fileDownload":break;case"text":{let n=e.response.body,{userExamples:a,autoExamples:u}=VAi(n.v2Examples);for(let[l,d]of Object.entries(a)){let s=e.source?.type==="openrpc"?MRa(d):d;t[l]={...i,body:I9.json(s)}}for(let[l,d]of Object.entries(u)){let s=e.source?.type==="openrpc"?MRa(d):d;r[l]={...i,body:I9.json(s)}}break}case"json":{let n=e.response.body.value;if(n.type==="response"){let{userExamples:a,autoExamples:u}=VAi(n.v2Examples);for(let[l,d]of Object.entries(a)){let s=e.source?.type==="openrpc"?MRa(d):d;t[l]={...i,body:I9.json(s)}}for(let[l,d]of Object.entries(u)){let s=e.source?.type==="openrpc"?MRa(d):d;r[l]={...i,body:I9.json(s)}}}break}case"streaming":{let n=e.response.body.value;if(n.type==="json"){let{userExamples:a,autoExamples:u}=VAi(n.v2Examples);for(let[l,d]of Object.entries(a))t[l]={...i,body:I9.stream([d])};for(let[l,d]of Object.entries(u))r[l]={...i,body:I9.stream([d])}}break}case"streamParameter":break;default:mo(e.response.body)}return{userResponseExamples:t,autoResponseExamples:r,baseExample:i}}function MRa(e,t=1){return{id:t,jsonrpc:"2.0",result:e}}function wB_({endpoint:e,service:t,typeDeclarations:r,skipOptionalRequestProperties:i}){let n={},a={},{userRequestExamples:u,autoRequestExamples:l,baseExample:d}=PB_({endpoint:e,service:t,typeDeclarations:r,skipOptionalRequestProperties:i}),{userResponseExamples:s,autoResponseExamples:o,baseExample:c}=jB_({endpoint:e}),b=Object.keys(l)[0],g=Object.values(l)[0],O=Object.values(o)[0];for(let[m,P]of Object.entries(u))n[m]={request:P,response:s[m]??O??c,codeSamples:void 0};for(let[m,P]of Object.entries(s))n[m]={request:u[m]??g??d,response:P,codeSamples:void 0};return Object.keys(n).length===0&&(a[b??T_(`${e.name.originalName}_example`)]={request:g??d,response:O??c,codeSamples:void 0}),{userFullExamples:n,autoFullExamples:a}}function ARa({ir:e,exampleGeneration:t}){for(let[r,i]of Object.entries(e.services))for(let n of i.endpoints){if(n.userSpecifiedExamples.length>0&&t?.skipAutogenerationIfManualExamplesExist===!0)continue;let a=ERa({ir:e,service:i,endpoint:n,typeDeclarations:e.types,skipOptionalRequestProperties:!t?.includeOptionalRequestPropertyExamples,generationResponse:{type:"success"}});if(a.type==="failure")continue;let{example:u}=a;n.autogeneratedExamples=[{example:u}]}for(let[r,i]of Object.entries(e.websocketChannels??{})){if(i.examples.length>0&&t?.skipAutogenerationIfManualExamplesExist===!0)continue;let n=OB_({ir:e,channel:i,typeDeclarations:e.types,skipOptionalRequestProperties:!t?.includeOptionalRequestPropertyExamples});if(n.type==="failure")continue;let{example:a}=n;i.examples=[...i.examples,a]}return e}function WPc({ir:e,exampleGeneration:t}){for(let[r,i]of Object.entries(e.services))for(let n of i.endpoints){n.v2Examples==null&&(n.v2Examples={userSpecifiedExamples:{},autogeneratedExamples:{}});let{userFullExamples:a,autoFullExamples:u}=wB_({service:i,endpoint:n,typeDeclarations:e.types,skipOptionalRequestProperties:!t?.includeOptionalRequestPropertyExamples});if(Object.keys(n.v2Examples.userSpecifiedExamples).length>0){if(Object.values(n.v2Examples.userSpecifiedExamples).some(d=>d.request!=null||d.response!=null))continue;let l=Object.values(n.v2Examples.userSpecifiedExamples)[0]?.codeSamples;for(let[d,s]of Object.entries(u))u[d]={...s,codeSamples:l};for(let[d,s]of Object.entries(a))a[d]={...s,codeSamples:l}}n.v2Examples.autogeneratedExamples=u,n.v2Examples.userSpecifiedExamples=a}return e}function oko(e,t,r){let{environments:i,changedBaseUrlIds1:n,changedBaseUrlIds2:a}=tJE(e.environments,t.environments,r),{services:u,websocketChannels:l}=rJE(e,t,n,a);return{apiName:e.apiName,basePath:e.basePath,selfHosted:e.selfHosted&&t.selfHosted,apiDisplayName:e.apiDisplayName??t.apiDisplayName,apiDocs:e.apiDocs??t.apiDocs,auth:e.auth??t.auth,headers:[...e.headers??[],...t.headers??[]],environments:i,types:{...e.types??{},...t.types??{}},constants:{...e.constants??{},...t.constants??{}},errors:{...e.errors??{},...t.errors??{}},services:u,webhookGroups:{...e.webhookGroups??{},...t.webhookGroups??{}},subpackages:eJE(e.subpackages,t.subpackages),websocketChannels:l,rootPackage:{service:e.rootPackage.service??t.rootPackage.service,types:[...e.rootPackage.types??[],...t.rootPackage.types??[]],errors:[...e.rootPackage.errors??[],...t.rootPackage.errors??[]],subpackages:[...e.rootPackage.subpackages??[],...(t.rootPackage.subpackages??[]).filter(d=>!e.rootPackage.subpackages?.includes(d))],fernFilepath:e.rootPackage.fernFilepath??t.rootPackage.fernFilepath,webhooks:e.rootPackage.webhooks??t.rootPackage.webhooks,websocket:e.rootPackage.websocket??t.rootPackage.websocket,hasEndpointsInTree:e.rootPackage.hasEndpointsInTree||t.rootPackage.hasEndpointsInTree,navigationConfig:e.rootPackage.navigationConfig??t.rootPackage.navigationConfig,docs:e.rootPackage.docs??t.rootPackage.docs},fdrApiDefinitionId:e.fdrApiDefinitionId??t.fdrApiDefinitionId,apiVersion:e.apiVersion??t.apiVersion,idempotencyHeaders:[...e.idempotencyHeaders??[],...t.idempotencyHeaders??[]],pathParameters:[...e.pathParameters??[],...t.pathParameters??[]],errorDiscriminationStrategy:e.errorDiscriminationStrategy??t.errorDiscriminationStrategy,variables:[...e.variables??[],...t.variables??[]],serviceTypeReferenceInfo:e.serviceTypeReferenceInfo??t.serviceTypeReferenceInfo,readmeConfig:e.readmeConfig??t.readmeConfig,sourceConfig:e.sourceConfig??t.sourceConfig,publishConfig:e.publishConfig??t.publishConfig,dynamic:e.dynamic??t.dynamic,sdkConfig:e.sdkConfig??t.sdkConfig}}function eJE(e,t){let r=e;for(let[i,n]of Object.entries(t))r[i]==null?r[i]=n:r[i]={name:n.name,fernFilepath:n.fernFilepath,hasEndpointsInTree:r[i].hasEndpointsInTree||n.hasEndpointsInTree,navigationConfig:r[i].navigationConfig??n.navigationConfig,docs:r[i].docs??n.docs,service:r[i].service??n.service,subpackages:[...r[i].subpackages??[],...(n.subpackages??[]).filter(a=>!r[i]?.subpackages?.includes(a))],webhooks:r[i].webhooks??n.webhooks,websocket:r[i].websocket??n.websocket,errors:[...r[i].errors??[],...n.errors??[]],types:[...r[i].types??[],...n.types??[]]};return r}function tJE(e,t,r){if(e==null&&t==null)return{environments:void 0,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(t==null)return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(e==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(JSON.stringify(e)===JSON.stringify(t))return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let i=SB_(e),n=SB_(t);if(i&&n&&e.environments.type==="singleBaseUrl"&&t.environments.type==="singleBaseUrl")return{environments:{defaultEnvironment:e.defaultEnvironment??t.defaultEnvironment,environments:cx.singleBaseUrl({environments:[...e.environments.environments,...t.environments.environments]})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let a=i?t.defaultEnvironment:e.defaultEnvironment,u=e.environments,l=t.environments;if(u.type==="singleBaseUrl"&&l.type==="singleBaseUrl"){let d=i?l:u,s=i?u:l,o={},{deconflictedEnvironments2:c,changedBaseUrlIds2:b}=iJE(d,s,r);if(d.environments[0]==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let g="Base",O=r.generateName("Base");return d.environments.forEach(m=>{o[m.id]=g}),{environments:{defaultEnvironment:a,environments:cx.multipleBaseUrls({baseUrls:[{id:g,name:O},...c.environments.map(m=>({id:m.id,name:m.name}))],environments:d.environments.map(m=>({id:m.id,name:m.name,urls:{[g]:m.url,...Object.fromEntries(c.environments.map(P=>[P.id,P.url]))},docs:void 0}))})},changedBaseUrlIds1:i?b:o,changedBaseUrlIds2:i?o:b}}if(u.type==="multipleBaseUrls"&&l.type==="singleBaseUrl"||u.type==="singleBaseUrl"&&l.type==="multipleBaseUrls"){let d=u.type==="singleBaseUrl"?u:l,s=u.type==="multipleBaseUrls"?u:l,{deconflictedEnvironments1:o,changedBaseUrlIds1:c}=nJE(d,s,r);return{environments:{defaultEnvironment:a,environments:cx.multipleBaseUrls({baseUrls:[...s.baseUrls,...o.environments.map(b=>({id:b.id,name:b.name}))],environments:s.environments.map(b=>({...b,urls:{...b.urls,...Object.fromEntries(o.environments.map(g=>[g.id,g.url]))}}))})},changedBaseUrlIds1:u.type==="singleBaseUrl"?c:void 0,changedBaseUrlIds2:u.type==="singleBaseUrl"?void 0:c}}if(u.type==="multipleBaseUrls"&&l.type==="multipleBaseUrls"){let{deconflictedEnvironments:d,changedBaseUrlIds:s}=aJE(u,l,r);return{environments:{defaultEnvironment:a,environments:cx.multipleBaseUrls({baseUrls:[...u.baseUrls,...d.baseUrls],environments:u.environments.flatMap(o=>d.environments.map(c=>({...o,urls:{...o.urls,...c.urls}})))})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:s}}return{environments:e??t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0}}function rJE(e,t,r,i){if(r!=null)for(let[u,l]of Object.entries(r)){for(let d of Object.values(e.services))for(let s of Object.values(d.endpoints))s.baseUrl==u&&(s.baseUrl=l),s.v2BaseUrls?.includes(u)&&(s.v2BaseUrls=s.v2BaseUrls.map(o=>o===u?l:o));for(let d of Object.values(e.websocketChannels??{}))d.baseUrl==u&&(d.baseUrl=l)}if(i!=null)for(let[u,l]of Object.entries(i)){for(let d of Object.values(t.services))for(let s of Object.values(d.endpoints))s.baseUrl==u&&(s.baseUrl=l),s.v2BaseUrls?.includes(u)&&(s.v2BaseUrls=s.v2BaseUrls.map(o=>o===u?l:o));for(let d of Object.values(t.websocketChannels??{}))d.baseUrl==u&&(d.baseUrl=l)}let n=e.services;for(let[u,l]of Object.entries(t.services))n[u]==null?n[u]=l:n[u]={availability:l.availability,name:l.name,displayName:l.displayName,basePath:l.basePath,endpoints:[...n[u].endpoints??[],...l.endpoints],pathParameters:[...n[u].pathParameters??[],...l.pathParameters??[]],headers:[...n[u].headers??[],...l.headers??[]],encoding:l.encoding,transport:l.transport};let a={...e.websocketChannels??{},...t.websocketChannels??{}};return{services:n,websocketChannels:a}}function iJE(e,t,r){let i={},n=new Set(e.environments.map(s=>s.id)),a=new Set(e.environments.map(s=>s.name)),u=new Map(e.environments.map(s=>[s.url,s.id])),l=t.environments.filter(s=>{let o=u.get(s.url);return o!=null?(i[s.id]=o,!1):!0}).map(s=>{if(n.has(s.id)||a.has(s.name)){let o=HPc(s.id,n);return i[s.id]=o,{...s,id:o,name:r.generateName(o)}}return s});return{deconflictedEnvironments2:cx.singleBaseUrl({environments:l}),changedBaseUrlIds2:i}}function nJE(e,t,r){let i={},n=new Set(t.baseUrls.map(d=>d.id)),a=new Set(t.baseUrls.map(d=>d.name)),u=e.environments.map(d=>{if(n.has(d.id)||a.has(d.name)){let s=HPc(d.id,n);return i[d.id]=s,{...d,id:s,name:r.generateName(s)}}return d});return{deconflictedEnvironments1:cx.singleBaseUrl({environments:u}),changedBaseUrlIds1:i}}function aJE(e,t,r){let i={},n=new Set(e.baseUrls.map(s=>s.id)),a=new Set(e.baseUrls.map(s=>s.name)),u=t.baseUrls.map(s=>{if(n.has(s.id)||a.has(s.name)){let o=HPc(s.id,n);return i[s.id]=o,{...s,id:o,name:r.generateName(o)}}return s}),l=t.environments.map(s=>({...s,urls:Object.fromEntries(Object.entries(s.urls).map(([o,c])=>[i[o]??o,c]))}));return{deconflictedEnvironments:cx.multipleBaseUrls({baseUrls:u,environments:l}),changedBaseUrlIds:i}}function SB_(e){return e.environments.type==="singleBaseUrl"?e.environments.environments.some(t=>t.url&&(t.url.startsWith("ws://")||t.url.startsWith("wss://"))):e.environments.type==="multipleBaseUrls"?e.environments.environments.some(t=>Object.values(t.urls).some(r=>r&&(r.startsWith("ws://")||r.startsWith("wss://")))):!1}function HPc(e,t){let r=e,i=1;for(;t.has(r);)r=`${e}-${i}`,i++;return r}function GPc({rawApiFileSchema:e,casingsGenerator:t}){if(e.auth==null)return{docs:void 0,requirement:pRe.All,schemes:[]};let r=typeof e.auth!="string"?e.auth.docs:void 0;return BHi(e.auth,{single:i=>{let n=DB_({reference:i,authSchemeDeclarations:e["auth-schemes"],casingsGenerator:t});return{docs:r,requirement:pRe.All,schemes:[n]}},any:({any:i})=>({docs:r,requirement:pRe.Any,schemes:i.map(n=>DB_({reference:n,authSchemeDeclarations:e["auth-schemes"],casingsGenerator:t}))})})}function DB_({reference:e,authSchemeDeclarations:t,casingsGenerator:r}){let i=(a,u)=>{let l=t?.[a];if(l==null)throw new Error("Unknown auth scheme: "+a);return BDa(l,{header:d=>CB.header({docs:u,name:r.generateNameAndWireValue({name:d.name??a,wireValue:d.header}),valueType:gf.primitive({v1:O0.String,v2:Lp.string({default:void 0,validation:void 0})}),prefix:d.prefix,headerEnvVar:d.env}),basic:d=>EB_({casingsGenerator:r,docs:u,rawScheme:d}),bearer:d=>$Pc({casingsGenerator:r,docs:u,rawScheme:d}),oauth:d=>$Pc({casingsGenerator:r,docs:u,rawScheme:void 0})})},n=typeof e=="string"?e:e.scheme;switch(n){case"bearer":case"oauth":return $Pc({casingsGenerator:r,docs:void 0,rawScheme:void 0});case"basic":return EB_({casingsGenerator:r,docs:void 0,rawScheme:void 0});default:return i(n,typeof e!="string"?e.docs:void 0)}}function $Pc({casingsGenerator:e,docs:t,rawScheme:r}){return CB.bearer({docs:t,token:e.generateName(r?.token?.name??"token"),tokenEnvVar:r?.token?.env})}function EB_({casingsGenerator:e,docs:t,rawScheme:r}){return CB.basic({docs:t,username:e.generateName(r?.username?.name??"username"),usernameEnvVar:r?.username?.env,password:e.generateName(r?.password?.name??"password"),passwordEnvVar:r?.password?.env})}function qRa({rawApiFileSchema:{"default-environment":e,environments:t},casingsGenerator:r}){if(t==null)return;let i=Object.values(t)[0];if(i!=null)return{environmentsConfig:{defaultEnvironment:e??void 0,environments:$kt(i,{singleBaseUrl:()=>cx.singleBaseUrl(oJE({environments:t,casingsGenerator:r})),multipleBaseUrls:n=>cx.multipleBaseUrls(uJE({baseUrls:Object.keys(n.urls),environments:t,casingsGenerator:r}))})},audiences:{...Object.fromEntries(Object.entries(t).map(([n,a])=>[n,$kt(a,{singleBaseUrl:u=>[...typeof u=="string"?[]:u.audiences??[]],multipleBaseUrls:u=>[...u.audiences??[]]})]))}}}function oJE({environments:e,casingsGenerator:t}){return{environments:Object.entries(e).map(([r,i])=>$kt(i,{singleBaseUrl:n=>({docs:typeof n=="string"?void 0:n.docs,id:r,name:t.generateName(r),url:MB_(typeof n=="string"?n:n.url)}),multipleBaseUrls:()=>{throw new Error(`Environment ${r} has multiple base URLs`)}}))}}function uJE({baseUrls:e,environments:t,casingsGenerator:r}){return{baseUrls:e.map(i=>({id:i,name:r.generateName(i)})),environments:Object.entries(t).map(([i,n])=>$kt(n,{multipleBaseUrls:a=>({docs:a.docs,id:i,name:r.generateName(i),urls:dd(a.urls,u=>MB_(u))}),singleBaseUrl:()=>{throw new Error(`Environment ${i} does not have multiple base URLs`)}}))}}function MB_(e){return e.endsWith("/")?e.slice(0,-1):e}function NMe(e){return e.allParts.map(t=>t.originalName).join("/")}var Pm={generateTypeId:e=>`type_${NMe(e.fernFilepath)}:${e.name.originalName}`,generateErrorId:e=>`error_${NMe(e.fernFilepath)}:${e.name.originalName}`,generateServiceId:e=>`service_${NMe(e.fernFilepath)}`,generateServiceIdFromFernFilepath:e=>`service_${NMe(e)}`,generateSubpackageId:e=>`subpackage_${NMe(e)}`,generateEndpointId:(e,t)=>{let r=NMe(e.fernFilepath),i=t.name.originalName;return`endpoint_${r}.${i}`},generateWebhookGroupId:e=>`webhooks_${NMe(e)}`,generateWebhookId:(e,t)=>`webhooks_${NMe(e)}.${t}`,generateWebSocketChannelId:e=>`channel_${NMe(e)}`};function F9n(e){return e.type!=null}var uko=class{environments=new Set;types=new Set;properties;errors=new Set;services=new Set;endpoints=new Set;requestProperties;queryParameters;webhooks=new Set;webhookPayloadProperties;channels=new Set;subpackages=new Set;constructor({types:t,properties:r,errors:i,environments:n,services:a,endpoints:u,webhooks:l,subpackages:d,queryParameters:s,requestProperties:o,webhookPayloadProperties:c,channels:b}){this.environments=n,this.types=t,this.properties=r,this.errors=i,this.services=a,this.endpoints=u,this.webhooks=l,this.webhookPayloadProperties=c,this.subpackages=d,this.requestProperties=o,this.queryParameters=s,this.channels=b}hasTypeId(t){return this.types.has(t)}hasErrorId(t){return this.errors.has(t)}hasServiceId(t){return this.services.has(t)}hasSubpackageId(t){return this.subpackages.has(t)}hasType(t){let r=Pm.generateTypeId(t.name);return this.types.has(r)}hasProperty(t,r){let i=this.properties[t];return i==null?!0:i.has(r)}hasError(t){let r=Pm.generateErrorId(t.name);return this.errors.has(r)}hasService(t){let r=Pm.generateServiceId(t.name);return this.services.has(r)}hasEnvironmentId(t){return this.environments.has(t)}hasEndpoint(t){return this.endpoints.has(t.id)}hasRequestProperty(t,r){let i=this.requestProperties[t];return i==null?!0:i.has(r)}hasQueryParameter(t,r){let i=this.queryParameters[t];return i==null?!0:i.has(r)}hasSubpackage(t){return this.subpackages.has(t)}hasWebhook(t){return t.id?this.webhooks.has(t.id):!0}hasChannel(t){return t.name.originalName?this.channels.has(t.name.originalName):!0}hasWebhookPayloadProperty(t,r){let i=this.webhookPayloadProperties[t];return i==null?!0:i.has(r)}};function jKi(e){let t={};for(let[r,i]of Object.entries(e))if(typeof i!="string")for(let n of i.audiences??[])t[n]==null&&(t[n]=new Set),t[n]?.add(r);return t}var wKi=class{types={};properties={};queryParameters={};requestProperties={};webhookProperties={};errors={};endpoints={};webhooks={};channels={};audiences;typesReferencedByService={};environmentsNeededForAudience=new Set;typesNeededForAudience=new Set;servicesNeededForAudience=new Set;endpointsNeededForAudience=new Set;webhooksNeededForAudience=new Set;channelsNeededForAudience=new Set;subpackagesNeededForAudience=new Set;constructor(t){this.audiences=sJE(t)}addType({declaredTypeName:t,descendantTypeIds:r,descendantFilepaths:i,descendantTypeIdsByAudience:n,propertiesByAudience:a}){let u=Pm.generateTypeId(t),l={typeId:u,allDescendants:r,descendantsByAudience:n,referencedSubpackages:i};this.types[u]=l,this.typesReferencedByService[u]==null&&(this.typesReferencedByService[u]=new Set),this.properties[u]={typeId:u,propertiesByAudience:a}}markTypeForAudiences(t,r){let i=Pm.generateTypeId(t);this.hasAudience(r)&&(this.typesNeededForAudience.add(i),this.addSubpackages(t.fernFilepath),this.types[i]?.referencedSubpackages.forEach(n=>{this.addSubpackages(n)}))}markEnvironmentForAudiences(t,r,i){t&&(this.hasAudience(r)||i)&&this.environmentsNeededForAudience.add(t.id)}getTypesReferencedByService(){for(let t of Object.values(this.endpoints))for(let r of t.referencedTypes)this.markTypeForService(r,t.serviceId);return this.typesReferencedByService}addError(t){let r=Pm.generateErrorId(t.name),i=new Set,n=new Set;t.type!=null&&jR(t.type,i,n);let a={errorId:r,referencedTypes:i,referencedSubpackages:n};this.errors[r]=a}addEndpoint(t,r,i){let n=Pm.generateServiceId(t.name),a=r.id,u=new Set,l=new Set,d=new Set;for(let s of[...t.headers,...r.headers])jR(s.valueType,u,d);for(let s of[...t.pathParameters,...r.pathParameters])jR(s.valueType,u,d);for(let s of r.queryParameters)jR(s.valueType,u,d);if(i!=null&&i.request!=null&&typeof i.request!="string"){let s=jKi(i.request["query-parameters"]??{});this.queryParameters[a]={endpointId:a,parametersByAudience:s}}r.requestBody!=null&&ZC._visit(r.requestBody,{inlinedRequestBody:s=>{for(let o of s.extends)sko(o,u,d);for(let o of s.properties)jR(o.valueType,u,d);if(i!=null&&typeof i.request=="object"&&typeof i.request.body=="object"&&XC(i.request.body)){let o=jKi(i.request.body.properties??{});this.requestProperties[a]={endpointId:a,propertiesByAudience:o}}},reference:({requestBodyType:s})=>{jR(s,u,d)},fileUpload:({properties:s})=>{for(let o of s)z9._visit(o,{file:Go,bodyProperty:({valueType:c})=>{jR(c,u,d)},_other:()=>{throw new Error("Unknown FileUploadRequestProperty: "+o.type)}})},bytes:()=>{},_other:()=>{throw new Error("Unknown HttpRequestBody: "+r.requestBody?.type)}}),r.response?.body!=null&&gE._visit(r.response.body,{fileDownload:Go,json:s=>{jR(s.responseBodyType,u,d)},streaming:s=>{s._visit({sse:o=>jR(o.payload,u,d),json:o=>jR(o.payload,u,d),text:Go,_other:()=>{throw new Error("Unknown streamingResponse type: "+s.type)}})},streamParameter:s=>{s.streamResponse._visit({sse:o=>jR(o.payload,u,d),json:o=>jR(o.payload,u,d),text:Go,_other:()=>{throw new Error("Unknown streamingResponse type: "+s.streamResponse.type)}}),s.nonStreamResponse.type==="json"&&jR(s.nonStreamResponse.value.responseBodyType,u,d)},text:Go,bytes:Go,_other:()=>{throw new Error("Unknown HttpResponse: "+r.response?.body?.type)}}),r.errors.forEach(s=>{l.add(Pm.generateErrorId(s.error)),d.add(s.error.fernFilepath)}),this.endpoints[a]={endpointId:a,serviceId:n,referencedTypes:u,referencedErrors:l,referencedSubpackages:d}}markEndpointForAudience(t,r,i){if(this.hasAudience(i)){let n=Pm.generateServiceId(t);this.servicesNeededForAudience.add(n),r.forEach(a=>{let u=a.id;this.endpointsNeededForAudience.add(u),this.endpoints[u]?.referencedSubpackages.forEach(l=>{this.addSubpackages(l)})}),this.servicesNeededForAudience.add(n),this.addSubpackages(t.fernFilepath)}}getFilteredSubpackages(){return this.subpackagesNeededForAudience}getFilteredServices(){return this.servicesNeededForAudience}getFilteredEndpoints(){return this.endpointsNeededForAudience}getFilteredChannels(){return this.channelsNeededForAudience}getFilteredWebhooks(){return this.webhooksNeededForAudience}addWebhook(t,r,i){let n=r.id;if(n==null)return;let a=new Set,u=new Set;r.payload!=null&&EW._visit(r.payload,{inlinedPayload:l=>{for(let d of l.extends)sko(d,a,u);for(let d of l.properties)jR(d.valueType,a,u);if(i?.payload!=null&&typeof i.payload=="object"&&!F9n(i.payload)){let d=jKi(i.payload.properties??{});this.webhookProperties[n]={webhookId:n,propertiesByAudience:d}}},reference:({payloadType:l})=>{jR(l,a,u)},_other:()=>{throw new Error("Unknown WebhookPayload: "+r.payload?.type)}}),u.add(t),this.webhooks[n]={webhookId:n,referencedTypes:a,referencedSubpackages:u}}markWebhookForAudiences(t,r,i){let n=r.id;n!=null&&this.hasAudience(i)&&(this.webhooksNeededForAudience.add(n),this.addSubpackages(t))}addChannel(t,r,i,n){if(r==null)return;let a=new Set,u=new Set;for(let l of i.messages)R9._visit(l.body,{reference:({bodyType:d})=>{jR(d,a,u)},inlinedBody:d=>{for(let s of d.extends)sko(s,a,u);for(let s of d.properties)jR(s.valueType,a,u)},_other:()=>{}});u.add(t),this.channels[r]={channelId:r,referencedTypes:a,referencedSubpackages:u}}markChannelForAudiences(t,r,i){r!=null&&this.hasAudience(i)&&(this.channelsNeededForAudience.add(r),this.addSubpackages(t))}build(){let t=new Set,r=new Set;for(let l of this.endpointsNeededForAudience.keys()){let d=this.getEndpointNode(l);for(let s of d.referencedErrors){if(r.has(s))continue;r.add(s);let o=this.getErrorNode(s);this.addReferencedTypes(t,o.referencedTypes)}this.addReferencedTypes(t,d.referencedTypes)}this.addReferencedTypes(t,this.typesNeededForAudience);for(let l of this.webhooksNeededForAudience.keys()){let d=this.getWebhookNode(l);this.addReferencedTypes(t,d.referencedTypes)}for(let l of this.channelsNeededForAudience.keys()){let d=this.getChannelNode(l);this.addReferencedTypes(t,d.referencedTypes)}let i={},n={},a={},u={};if(this.audiences.type==="filtered"){for(let[l,d]of Object.entries(this.properties)){if(!t.has(l))continue;let s=new Set;for(let o of this.audiences.audiences){let c=d.propertiesByAudience[o];c?.forEach(b=>{s.add(b)})}s.size>0&&(i[l]=s),i[l]=s.size>0?s:void 0}for(let[l,d]of Object.entries(this.requestProperties)){if(!this.endpointsNeededForAudience.has(l))continue;let s=new Set;for(let o of this.audiences.audiences){let c=d.propertiesByAudience[o];c?.forEach(b=>{s.add(b)})}n[l]=s.size>0?s:void 0}for(let[l,d]of Object.entries(this.queryParameters)){if(!this.endpointsNeededForAudience.has(l))continue;let s=new Set;for(let o of this.audiences.audiences){let c=d.parametersByAudience[o];c?.forEach(b=>{s.add(b)})}a[l]=s.size>0?s:void 0}for(let[l,d]of Object.entries(this.webhookProperties)){if(!this.webhooksNeededForAudience.has(l))continue;let s=new Set;for(let o of this.audiences.audiences){let c=d.propertiesByAudience[o];c?.forEach(b=>{s.add(b)})}u[l]=s.size>0?s:void 0}}return new uko({types:t,properties:i,errors:r,requestProperties:n,queryParameters:a,environments:this.environmentsNeededForAudience,services:this.servicesNeededForAudience,endpoints:this.endpointsNeededForAudience,webhooks:this.webhooksNeededForAudience,webhookPayloadProperties:u,subpackages:this.subpackagesNeededForAudience,channels:this.channelsNeededForAudience})}markTypeForService(t,r){let i=this.typesReferencedByService[t]??=new Set;if(i.has(r))return;i.add(r);let n=this.getTypeNode(t);for(let a of n.allDescendants)this.markTypeForService(a,r)}addReferencedTypes(t,r){for(let i of r){if(t.has(i))continue;t.add(i);let n=this.getTypeNode(i);if(this.audiences.type==="filtered")for(let a of this.audiences.audiences){let u=n.descendantsByAudience[a];if(u!=null)u.forEach(l=>{t.add(l)});else{n.allDescendants.forEach(l=>{t.add(l)});break}}else n.allDescendants.forEach(a=>{t.add(a)})}}getTypeNode(t){let r=this.types[t];if(r==null)throw new Error(`Failed to find type node with id ${t}`);return r}getErrorNode(t){let r=this.errors[t];if(r==null)throw new Error(`Failed to find error node with id ${t}`);return r}getEndpointNode(t){let r=this.endpoints[t];if(r==null)throw new Error(`Failed to find endpoint node with id ${t}`);return r}getWebhookNode(t){let r=this.webhooks[t];if(r==null)throw new Error(`Failed to find webhook node with id ${t}`);return r}getChannelNode(t){let r=this.channels[t];if(r==null)throw new Error(`Failed to find channel node with id ${t}`);return r}hasNoAudiences(){return this.audiences.type==="none"}hasAudience(t){let r=this.audiences;switch(r.type){case"none":return!0;case"filtered":return t.some(i=>r.audiences.has(i));default:mo(r)}}addSubpackages(t){for(let r=1;r<=t.allParts.length;++r){let i={...t,allParts:t.allParts.slice(0,r)};this.subpackagesNeededForAudience.add(Pm.generateSubpackageId(i))}}};function sJE(e){switch(e.type){case"all":return{type:"none"};case"select":return{type:"filtered",audiences:new Set(e.audiences)};default:mo(e)}}function jR(e,t,r){gf._visit(e,{container:i=>{cJE(i,t,r)},named:i=>{sko(i,t,r)},primitive:Go,unknown:Go,_other:Go})}function sko(e,t,r){t.add(Pm.generateTypeId(e)),r.add(e.fernFilepath)}function cJE(e,t,r){_b._visit(e,{list:i=>{jR(i,t,r)},map:i=>{jR(i.keyType,t,r),jR(i.valueType,t,r)},optional:i=>{jR(i,t,r)},nullable:i=>{jR(i,t,r)},set:i=>{jR(i,t,r)},literal:Go,_other:Go})}var QPc=class{errors;constructor(){this.errors=[]}add(t){this.errors.push({message:t})}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}},TRa=class{errors;constructor(){this.errors=new QPc}async check({from:t,to:r}){let i=this.checkBreaking({from:t,to:r});return{bump:i.isBreaking?"major":"minor",isBreaking:i.isBreaking,errors:i.errors}}checkBreaking({from:t,to:r}){this.checkTypeBreakingChanges({from:t.types,to:r.types}),this.checkErrorsBreakingChanges({from:t.errors,to:r.errors}),this.checkServicesBreakingChanges({from:t.services,to:r.services});let i=this.errors.hasErrors();return{bump:i?"major":"minor",isBreaking:i,errors:this.errors.getErrors()}}checkTypeBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){let a=r[i];if(!a){this.errors.add(`Type "${i}" was removed.`);continue}this.areTypeDeclarationsCompatible({from:n,to:a})||this.errors.add(`Type "${i}" has an incompatible change.`)}}checkErrorsBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){let a=Object.values(r).find(u=>u.name.errorId===n.name.errorId);if(!a){this.errors.add(`Error "${n.name.errorId}" with status code "${n.statusCode}" was removed.`);continue}this.checkErrorBreakingChanges({from:n,to:a})}}checkErrorBreakingChanges({from:t,to:r}){if(t.type!=null){if(r.type==null){this.errors.add(`Error "${t.name.errorId}" with status code "${t.statusCode}" had its type removed.`);return}this.areTypeReferencesCompatible({from:t.type,to:r.type})||this.errors.add(`Error "${t.name.errorId}" type reference changed.`)}this.areDeclaredErrorNamesCompatible({from:t.name,to:r.name})||this.errors.add(`Error "${t.name.errorId}" name changed.`),this.areNameAndWireValuesCompatible({from:t.discriminantValue,to:r.discriminantValue})||this.errors.add(`Error "${t.name.errorId}" discriminant value changed.`)}checkServicesBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){let a=r[i];if(!a){this.errors.add(`Service "${i}" was removed.`);continue}this.checkServiceBreakingChanges({id:i,from:n,to:a})}}checkServiceBreakingChanges({id:t,from:r,to:i}){this.checkHeadersBreakingChanges({id:t,from:r.headers,to:i.headers}),this.checkEndpointsBreakingChanges({id:t,from:r,to:i})}checkEndpointsBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.endpoints.map(u=>[u.id,u])),a=Object.fromEntries(i.endpoints.map(u=>[u.id,u]));for(let[u,l]of Object.entries(n)){let d=a[u];if(!d){this.errors.add(`Endpoint "${u}" was removed.`);continue}this.checkEndpointBreakingChanges({id:u,from:l,to:d})}}checkEndpointBreakingChanges({id:t,from:r,to:i}){this.checkHttpMethodsBreakingChanges({id:t,from:r.method,to:i.method}),this.checkHttpPathsBreakingChanges({id:t,from:r.fullPath,to:i.fullPath}),this.checkPathParametersBreakingChanges({id:t,from:r.pathParameters,to:i.pathParameters}),this.checkQueryParametersBreakingChanges({id:t,from:r.queryParameters,to:i.queryParameters}),this.checkHeadersBreakingChanges({id:t,from:r.headers,to:i.headers}),r.requestBody!=null&&(i.requestBody!=null?this.checkHttpRequestBodiesCompatible({id:t,from:r.requestBody,to:i.requestBody}):this.errors.add(`Request body was removed from endpoint "${r.id}".`)),r.response!=null&&(i.response!=null?this.checkHttpResponseBreakingChanges({id:t,from:r.response,to:i.response}):this.errors.add(`Response was removed from endpoint "${r.id}".`)),(r.pagination!=null&&i.pagination==null||r.pagination==null&&i.pagination!=null)&&this.errors.add(`Pagination was ${r.pagination!=null?"added":"removed"} from endpoint "${r.id}".`)}checkPathParametersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(u=>[u.name.originalName,u])),a=Object.fromEntries(i.map(u=>[u.name.originalName,u]));for(let[u,l]of Object.entries(n)){let d=a[u];if(!d){this.errors.add(`Path parameter "${u}" was removed from endpoint "${t}".`);continue}this.areTypeReferencesCompatible({from:l.valueType,to:d.valueType})||this.errors.add(`Path parameter "${u}" type changed in endpoint "${t}".`)}}checkQueryParametersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(u=>[u.name.wireValue,u])),a=Object.fromEntries(i.map(u=>[u.name.wireValue,u]));this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(n).map(([u,l])=>[u,l.valueType])),to:Object.fromEntries(Object.entries(a).map(([u,l])=>[u,l.valueType]))});for(let[u,l]of Object.entries(n)){let d=a[u];if(!d){this.errors.add(`Query parameter "${u}" was removed from endpoint "${t}".`);continue}this.areTypeReferencesCompatible({from:l.valueType,to:d.valueType})||this.errors.add(`Query parameter "${u}" type changed in endpoint "${t}".`),l.allowMultiple!==d.allowMultiple&&this.errors.add(`Query parameter "${u}" allow-multiple values changed in endpoint "${t}".`)}}checkHeadersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(u=>[u.name.wireValue,u])),a=Object.fromEntries(i.map(u=>[u.name.wireValue,u]));this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(n).map(([u,l])=>[u,l.valueType])),to:Object.fromEntries(Object.entries(a).map(([u,l])=>[u,l.valueType]))});for(let[u,l]of Object.entries(n)){let d=a[u];if(!d){this.errors.add(`Header "${u}" was removed from ${t}.`);continue}this.areTypeReferencesCompatible({from:l.valueType,to:d.valueType})||this.errors.add(`Header "${u}" type changed in ${t}.`)}}checkHttpMethodsBreakingChanges({id:t,from:r,to:i}){r!==i&&this.errors.add(`HTTP method changed in ${t}.`)}checkHttpPathsBreakingChanges({id:t,from:r,to:i}){this.areHttpPathsCompatible({from:r,to:i})||this.errors.add(`HTTP path changed in ${t}.`)}areHttpPathsCompatible({from:t,to:r}){if(t.head!==r.head||t.parts.length!==r.parts.length)return!1;for(let i=0;i<t.parts.length;i++){let n=t.parts[i];if(n==null)return!1;let a=r.parts[i];if(a==null||n.pathParameter!==a.pathParameter||n.tail!==a.tail)return!1}return!0}checkHttpRequestBodiesCompatible({id:t,from:r,to:i}){switch(r.type){case"inlinedRequestBody":if(i.type==="inlinedRequestBody"&&this.areInlinedRequestBodiesCompatible({from:r,to:i}))return;break;case"reference":if(i.type==="reference"&&this.areReferenceRequestBodiesCompatible({from:r,to:i}))return;break;case"fileUpload":if(i.type==="fileUpload"&&this.areFileUploadRequestBodiesCompatible({from:r,to:i}))return;break;case"bytes":if(i.type==="bytes")return;break;default:mo(r)}this.errors.add(`Request body type changed from "${r.type}" to "${i.type}" in endpoint "${t}".`)}areInlinedRequestBodiesCompatible({from:t,to:r}){let i=this.getInlinedRequestBody(t),n=this.getInlinedRequestBody(r);return this.checkForNewInlinedRequestBodyProperties({from:i,to:n}),Object.entries(i).every(([a,u])=>{let l=n[a];return l?this.areTypeReferencesCompatible({from:u,to:l}):(this.errors.add(`Request body property "${a}" was removed.`),!1)})}areReferenceRequestBodiesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.requestBodyType,to:r.requestBodyType})}areFileUploadRequestBodiesCompatible({from:t,to:r}){let i=this.getFileUploadRequest(t.properties),n=this.getFileUploadRequest(r.properties);this.checkForNewFileUploadRequestProperties({from:i,to:n});for(let[a,u]of Object.entries(i)){let l=n[a];if(!l)return this.errors.add(`File upload property "${a}" was removed.`),!1;if(u==="file"&&l!=="file")return this.errors.add(`File upload property "${a}" type changed.`),!1;if(u==="fileArray"&&l!=="fileArray")return this.errors.add(`File upload property "${a}" type changed.`),!1;if(u!=="file"&&u!=="fileArray"&&l!=="file"&&l!=="fileArray"&&!this.areTypeReferencesCompatible({from:u,to:l}))return this.errors.add(`File upload property "${a}" type changed.`),!1}return!0}checkHttpResponseBreakingChanges({id:t,from:r,to:i}){if(r.statusCode!==i.statusCode&&this.errors.add(`Response status code changed from "${r.statusCode}" to "${i.statusCode}".`),!(r.body==null&&i.body==null)){if(r.body==null||i.body==null){this.errors.add(`Response body was ${r.body==null?"added":"removed"}.`);return}switch(r.body.type){case"json":if(i.body.type==="json"){this.areJsonResponsesCompatible({from:r.body.value,to:i.body.value});return}break;case"fileDownload":if(i.body.type==="fileDownload")return;break;case"text":if(i.body.type==="text")return;break;case"bytes":if(i.body.type==="bytes")return;break;case"streaming":if(i.body.type==="streaming"){this.areStreamingResponsesCompatible({from:r.body.value,to:i.body.value});return}break;case"streamParameter":if(i.body.type==="streamParameter"){this.areStreamingResponsesCompatible({from:r.body.streamResponse,to:i.body.streamResponse});return}break;default:mo(r.body)}this.errors.add(`HTTP response type "${r.body.type}" defined for endpoint "${t}" is not compatible with type "${i.body.type}".`)}}areJsonResponsesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.responseBodyType,to:r.responseBodyType})}areStreamingResponsesCompatible({from:t,to:r}){switch(t.type){case"json":if(r.type==="json")return this.areTypeReferencesCompatible({from:t.payload,to:r.payload});break;case"sse":if(r.type==="sse")return this.areTypeReferencesCompatible({from:t.payload,to:r.payload});break;case"text":if(r.type==="text")return!0;break;default:mo(t)}return this.errors.add(`Streaming response type "${t.type}" is not compatible with type "${r.type}".`),!1}areTypeDeclarationsCompatible({from:t,to:r}){return this.areDeclaredTypeNamesCompatible({from:t.name,to:r.name})&&this.areTypeShapesCompatible({from:t.shape,to:r.shape})}areTypeShapesCompatible({from:t,to:r}){switch(t.type){case"alias":if(r.type==="alias")return this.areAliasTypesCompatible({from:t,to:r});break;case"enum":if(r.type==="enum")return this.areEnumTypesCompatible({from:t,to:r});break;case"object":if(r.type==="object")return this.areObjectTypesCompatible({from:t,to:r});break;case"union":if(r.type==="union")return this.areUnionTypesCompatible({from:t,to:r});break;case"undiscriminatedUnion":if(r.type==="undiscriminatedUnion")return this.areUndiscriminatedUnionTypesCompatible({from:t,to:r});break;default:mo(t)}return this.errors.add(`Type "${t.type}" is not compatible with type "${r.type}".`),!1}areAliasTypesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.aliasOf,to:r.aliasOf})}areEnumTypesCompatible({from:t,to:r}){let i=Object.fromEntries(t.values.map(a=>[a.name.wireValue,a])),n=Object.fromEntries(r.values.map(a=>[a.name.wireValue,a]));return Object.keys(i).length!==Object.keys(n).length?!1:Object.values(i).every(a=>{let u=n[a.name.wireValue];return u?this.areNameAndWireValuesCompatible({from:a.name,to:u.name}):(this.errors.add(`Enum value "${a.name.wireValue}" was removed.`),!1)})}areObjectTypesCompatible({from:t,to:r}){let i=Object.fromEntries([...t.properties.map(a=>[a.name.wireValue,a]),...t.extendedProperties?.map(a=>[a.name.wireValue,a])??[]]),n=Object.fromEntries([...r.properties.map(a=>[a.name.wireValue,a]),...r.extendedProperties?.map(a=>[a.name.wireValue,a])??[]]);return this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(i).map(([a,u])=>[a,u.valueType])),to:Object.fromEntries(Object.entries(n).map(([a,u])=>[a,u.valueType]))}),Object.values(i).every(a=>{let u=n[a.name.wireValue];return u?this.areObjectPropertiesCompatible({from:a,to:u}):(this.errors.add(`Object property "${a.name.wireValue}" was removed.`),!1)})}areObjectPropertiesCompatible({from:t,to:r}){return this.areNameAndWireValuesCompatible({from:t.name,to:r.name})&&this.areTypeReferencesCompatible({from:t.valueType,to:r.valueType})}areUnionTypesCompatible({from:t,to:r}){if(!this.areNameAndWireValuesCompatible({from:t.discriminant,to:r.discriminant}))return this.errors.add(`Union type with discriminant value "${t.discriminant.wireValue}" changed.`),!1;let i=new Set(t.extends.map(s=>this.getKeyForDeclaration(s))),n=new Set(r.extends.map(s=>this.getKeyForDeclaration(s)));for(let s of i)if(!n.has(s))return this.errors.add(`Extended type "${s}" was removed.`),!1;let a=Object.fromEntries(t.baseProperties.map(s=>[s.name.wireValue,s])),u=Object.fromEntries(r.baseProperties.map(s=>[s.name.wireValue,s]));for(let s of Object.values(a)){let o=u[s.name.wireValue];if(!o)return this.errors.add(`Union type with discriminant value "${s.name.wireValue}" no longer has a property named "${s.name.wireValue}".`),!1;if(!this.areObjectPropertiesCompatible({from:s,to:o}))return!1}this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(a).map(([s,o])=>[s,o.valueType])),to:Object.fromEntries(Object.entries(u).map(([s,o])=>[s,o.valueType]))});let l=Object.fromEntries(t.types.map(s=>[s.discriminantValue.wireValue,s])),d=Object.fromEntries(r.types.map(s=>[s.discriminantValue.wireValue,s]));return Object.values(l).every(s=>{let o=d[s.discriminantValue.wireValue];return o?this.areSingleUnionTypesCompatible({from:s.shape,to:o.shape}):(this.errors.add(`Union type for discriminant value "${s.discriminantValue.wireValue}" was removed.`),!1)})}areSingleUnionTypesCompatible({from:t,to:r}){switch(t.propertiesType){case"samePropertiesAsObject":if(r.propertiesType==="samePropertiesAsObject")return this.areDeclaredTypeNamesCompatible({from:t,to:r});break;case"singleProperty":if(r.propertiesType==="singleProperty")return this.areNameAndWireValuesCompatible({from:t.name,to:r.name})&&this.areTypeReferencesCompatible({from:t.type,to:r.type});break;case"noProperties":if(r.propertiesType==="noProperties")return!0;break;default:mo(t)}return this.errors.add(`Single union type of style "${t.propertiesType}" is not compatible with style "${r.propertiesType}".`),!1}areUndiscriminatedUnionTypesCompatible({from:t,to:r}){return t.members.every((i,n)=>{let a=r.members[n];return a?this.areTypeReferencesCompatible({from:i.type,to:a.type}):(this.errors.add(`Undiscriminated union member at index ${n} was removed.`),!1)})}checkForNewRequiredTypeReferences({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}checkForNewFileUploadRequestProperties({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||n==="file"||n==="fileArray"||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}checkForNewInlinedRequestBodyProperties({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}areTypeReferencesCompatible({from:t,to:r}){switch(t.type){case"primitive":if(r.type==="primitive")return this.arePrimitiveTypesCompatible({from:t,to:r});break;case"container":if(r.type==="container")return this.areContainerTypesCompatible({from:t.container,to:r.container});break;case"named":if(r.type==="named")return this.areNamedTypesCompatible({from:t,to:r});break;case"unknown":if(r.type==="unknown")return!0;break;default:mo(t)}return this.errors.add(`TypeReference "${t.type}" is not compatible with type "${r.type}".`),!1}arePrimitiveTypesCompatible({from:t,to:r}){return t.primitive.v1===r.primitive.v1}areContainerTypesCompatible({from:t,to:r}){switch(t.type){case"list":if(r.type==="list")return this.areTypeReferencesCompatible({from:t.list,to:r.list});break;case"set":if(r.type==="set")return this.areTypeReferencesCompatible({from:t.set,to:r.set});break;case"map":if(r.type==="map")return this.areTypeReferencesCompatible({from:t.keyType,to:r.keyType})&&this.areTypeReferencesCompatible({from:t.valueType,to:r.valueType});break;case"optional":if(r.type==="optional")return this.areTypeReferencesCompatible({from:t.optional,to:r.optional});break;case"nullable":if(r.type==="nullable")return this.areTypeReferencesCompatible({from:t.nullable,to:r.nullable});break;case"literal":if(r.type==="literal")return this.areLiteralsCompatible({from:t.literal,to:r.literal});break;default:mo(t)}return this.errors.add(`Container type "${t.type}" is not compatible with type "${r.type}".`),!1}areNamedTypesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areDeclaredTypeNamesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areDeclaredErrorNamesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areNameAndWireValuesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&t.wireValue===r.wireValue}areLiteralsCompatible({from:t,to:r}){switch(t.type){case"boolean":if(r.type==="boolean")return t.boolean===r.boolean;break;case"string":if(r.type==="string")return t.string===r.string;break;default:mo(t)}return!1}areFernFilepathsCompatible({from:t,to:r}){return t.allParts.length!==r.allParts.length?!1:t.allParts.every((i,n)=>{let a=r.allParts[n];return a==null?!1:this.areNamesCompatible({from:i,to:a})})}areNamesCompatible({from:t,to:r}){return t.originalName===r.originalName}getInlinedRequestBody(t){let r={};for(let i of[...t.extendedProperties??[],...t.properties])r[i.name.wireValue]=i.valueType;return r}getFileUploadRequest(t){let r={};for(let i of t)switch(i.type){case"file":r[i.value.key.wireValue]="file";break;case"bodyProperty":r[i.name.wireValue]=i.valueType;break;default:mo(i)}return r}getKeyForDeclaration({name:t,fernFilepath:r}){return`${r.allParts.map(n=>n.camelCase.unsafeName).join(".")}.${t.pascalCase.unsafeName}`}};function qB_({filteredIr:e,singleUnionTypeProperties:t}){return t._visit({samePropertiesAsObject:r=>{let i=e.hasTypeId(r.typeId)?{...r,object:{properties:r.object.properties.filter(n=>e.hasProperty(n.originalTypeDeclaration.typeId,n.name.wireValue)).map(n=>({...n,value:wR({filteredIr:e,exampleTypeReference:n.value})})).filter(n=>n.value!==void 0)}}:void 0;return i!==void 0?h3.samePropertiesAsObject(i):void 0},singleProperty:r=>{let i=wR({filteredIr:e,exampleTypeReference:r});return i!==void 0?h3.singleProperty(i):void 0},noProperties:()=>t,_other:()=>{throw new Error("Received unknown type for example.")}})}function wR({filteredIr:e,exampleTypeReference:t}){return t.shape._visit({primitive:()=>t,container:r=>r._visit({list:i=>({...t,shape:Nh.container(bm.list({...i,list:i.list.map(n=>wR({filteredIr:e,exampleTypeReference:n})).filter(n=>n!==void 0)}))}),set:i=>({...t,shape:Nh.container(bm.set({...i,set:i.set.map(n=>wR({filteredIr:e,exampleTypeReference:n})).filter(n=>n!==void 0)}))}),optional:i=>{let n=i.optional!=null?wR({filteredIr:e,exampleTypeReference:i.optional}):void 0;return n!=null?{...t,shape:Nh.container(bm.optional({optional:n,valueType:i.valueType}))}:void 0},nullable:i=>{let n=i.nullable!=null?wR({filteredIr:e,exampleTypeReference:i.nullable}):void 0;return n!=null?{...t,shape:Nh.container(bm.nullable({nullable:n,valueType:i.valueType}))}:void 0},map:i=>({...t,shape:Nh.container(bm.map({...i,map:i.map.map(n=>{let a=wR({filteredIr:e,exampleTypeReference:n.key}),u=wR({filteredIr:e,exampleTypeReference:n.value});return a!==void 0&&u!==void 0?{key:a,value:u}:void 0}).filter(n=>n!==void 0)}))}),literal:()=>t,_other:()=>{throw new Error("Received unknown type for example.")}}),named:r=>e.hasTypeId(r.typeName.typeId)?r.shape._visit({alias:i=>{let n=wR({filteredIr:e,exampleTypeReference:i.value});return n!==void 0?{...t,shape:Nh.named({...r,shape:Iw.alias({...i,value:n})})}:void 0},enum:i=>({...t,shape:Nh.named({...r,shape:Iw.enum(i)})}),object:i=>({...t,shape:Nh.named({...r,shape:Iw.object({...i,properties:i.properties.filter(n=>e.hasProperty(n.originalTypeDeclaration.typeId,n.name.wireValue)).map(n=>({...n,value:wR({filteredIr:e,exampleTypeReference:n.value})})).filter(n=>n.value!==void 0)})})}),union:i=>{let n=qB_({filteredIr:e,singleUnionTypeProperties:i.singleUnionType.shape});return n!==void 0?{...t,shape:Nh.named({...r,shape:Iw.union({...i,singleUnionType:{...i.singleUnionType,shape:n}})})}:void 0},undiscriminatedUnion:i=>{let n=wR({filteredIr:e,exampleTypeReference:i.singleUnionType});return n!==void 0?{...t,shape:Nh.named({...r,shape:Iw.undiscriminatedUnion({...i,singleUnionType:n})})}:void 0},_other:()=>{throw new Error("Received unknown type for example.")}}):void 0,unknown:()=>t,_other:()=>t})}function JPc({filteredIr:e,pathParameters:t}){return t.map(r=>{let i=wR({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function lJE({filteredIr:e,queryParameters:t}){return t.map(r=>{let i=wR({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function AB_({filteredIr:e,headers:t}){return t.map(r=>{let i=wR({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function fJE({filteredIr:e,requestBody:t}){return t._visit({inlinedRequestBody:r=>({...t,properties:r.properties.filter(i=>i.originalTypeDeclaration?e.hasProperty(i.originalTypeDeclaration.typeId,i.name.wireValue):!0).map(i=>{let n=wR({filteredIr:e,exampleTypeReference:i.value});return n!==void 0?{...i,value:n}:void 0}).filter(i=>i!==void 0)}),reference:r=>{let i=wR({filteredIr:e,exampleTypeReference:r});return i!==void 0?zQ.reference(i):void 0},_other:()=>{throw new Error("Received unknown type for example.")}})}function dJE({filteredIr:e,response:t}){return t._visit({ok:r=>r._visit({body:i=>RT.ok(kC.body(i!=null?wR({filteredIr:e,exampleTypeReference:i}):void 0)),stream:i=>RT.ok(kC.stream(i.map(n=>wR({filteredIr:e,exampleTypeReference:n})).filter(V0))),sse:i=>RT.ok(kC.sse(i.map(({event:n,data:a})=>{let u=wR({filteredIr:e,exampleTypeReference:a});return u!==void 0?{event:n,data:u}:void 0}).filter(V0))),_other:({type:i})=>{throw new Error(`Received unknown type for OK example: ${i}`)}}),error:({error:r,body:i})=>RT.error({error:r,body:i!=null?wR({filteredIr:e,exampleTypeReference:i}):void 0}),_other:({type:r})=>{throw new Error(`Received unknown type for example: ${r}`)}})}function KPc({filteredIr:e,example:t}){return{...t,rootPathParameters:JPc({filteredIr:e,pathParameters:t.rootPathParameters}),servicePathParameters:JPc({filteredIr:e,pathParameters:t.servicePathParameters}),endpointPathParameters:JPc({filteredIr:e,pathParameters:t.endpointPathParameters}),serviceHeaders:AB_({filteredIr:e,headers:t.serviceHeaders}),endpointHeaders:AB_({filteredIr:e,headers:t.endpointHeaders}),queryParameters:lJE({filteredIr:e,queryParameters:t.queryParameters}),request:t.request!==void 0?fJE({filteredIr:e,requestBody:t.request}):void 0,response:dJE({filteredIr:e,response:t.response})}}function TB_({filteredIr:e,exampleType:t}){return t.shape._visit({alias:r=>{let i=wR({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...t,shape:Iw.alias({...r,value:i})}:void 0},enum:()=>t,object:r=>({...t,shape:Iw.object({...r,properties:r.properties.filter(i=>e.hasProperty(i.originalTypeDeclaration.typeId,i.name.wireValue)).map(i=>({...i,value:wR({filteredIr:e,exampleTypeReference:i.value})})).filter(i=>i.value!==void 0)})}),union:r=>{let i=qB_({filteredIr:e,singleUnionTypeProperties:r.singleUnionType.shape});return i!==void 0?{...t,shape:Iw.union({...r,singleUnionType:{...r.singleUnionType,shape:i}})}:void 0},undiscriminatedUnion:r=>{let i=wR({filteredIr:e,exampleTypeReference:r.singleUnionType});return i!==void 0?{...t,shape:Iw.undiscriminatedUnion({...r,singleUnionType:i})}:void 0},_other:()=>{throw new Error("Received unknown type for example.")}})}function YPc(e,t){if(t==null)return e;let r=MVi(e.types,u=>t.hasType(u)),i=Object.fromEntries(Object.entries(r).map(([u,l])=>{let d=[];if(l.userProvidedExamples=l.userProvidedExamples.map(s=>TB_({filteredIr:t,exampleType:s})).filter(s=>s!==void 0),l.shape.type==="object"){for(let s of l.shape.properties)t.hasProperty(u,s.name.wireValue)&&d.push(s);return[u,{...l,shape:lO.object({...l.shape,properties:d})}]}return[u,l]})),n=Object.fromEntries(Object.entries(e.webhookGroups).map(([u,l])=>{let d=l.filter(s=>t.hasWebhook(s)).map(s=>{let o=s.id;return s.payload.type==="inlinedPayload"&&o!=null&&(s.payload={...s.payload,properties:s.payload.properties.filter(c=>t.hasWebhookPayloadProperty(o,c.name.wireValue))}),s});return[u,d]})),a=e.environments;if(a){switch(a.environments.type){case"singleBaseUrl":{a.environments.environments=a.environments.environments.filter(u=>t.hasEnvironmentId(u.id));break}case"multipleBaseUrls":{a.environments.environments=a.environments.environments.filter(u=>t.hasEnvironmentId(u.id));break}}a.defaultEnvironment&&(t.hasEnvironmentId(a.defaultEnvironment)||(a.defaultEnvironment=void 0))}return{...e,environments:a,types:i,errors:MVi(e.errors,u=>t.hasError(u)),services:dd(MVi(e.services,u=>t.hasService(u)),u=>({...u,endpoints:u.endpoints.filter(l=>t.hasEndpoint(l)).map(l=>(l.autogeneratedExamples=l.autogeneratedExamples.map(d=>({...d,example:KPc({filteredIr:t,example:d.example})})),l.userSpecifiedExamples=l.userSpecifiedExamples.map(d=>({...d,example:d.example!=null?KPc({filteredIr:t,example:d.example}):void 0})),l.queryParameters.length>0&&(l.queryParameters=l.queryParameters.filter(d=>t.hasQueryParameter(l.id,d.name.wireValue))),l.requestBody?.type==="inlinedRequestBody"?{...l,requestBody:{...l.requestBody,properties:l.requestBody.properties.filter(d=>t.hasRequestProperty(l.id,d.name.wireValue))}}:l))})),webhookGroups:n,serviceTypeReferenceInfo:pJE(e.serviceTypeReferenceInfo,t)}}function pJE(e,t){if(t==null)return e;let r={};return Object.entries(e.typesReferencedOnlyByService).forEach(([i,n])=>{t.hasServiceId(i)&&(r[i]=n.filter(a=>t.hasTypeId(a)))}),{sharedTypes:e.sharedTypes.filter(i=>t.hasTypeId(i)),typesReferencedOnlyByService:r}}var pH={};jo(pH,{AudienceExtension:()=>cko,FernAvailabilityExtension:()=>lko,FernEnumExtension:()=>fko,FernIgnoreExtension:()=>SKi,FernOptionalExtension:()=>dko,FernTypeExtension:()=>hko,FernTypeNameExtension:()=>yko,SdkGroupNameExtension:()=>pko,SdkMethodNameExtension:()=>_ko});var cko=class extends Aj{operation;key="x-fern-audiences";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=Array.isArray(t)?t.filter(i=>typeof i=="string"):typeof t=="string"?[t]:[];if(r.length!==0)return{audiences:r}}};var lko=class extends Aj{node;key="x-fern-availability";constructor({breadcrumbs:t,node:r,context:i}){super({breadcrumbs:t,context:i}),this.node=r}convert(){let t=this.getExtensionValue(this.node);if(t==null||typeof t!="string")return;switch(t.toUpperCase().replace(/[-_\s]/g,"_")){case"IN_DEVELOPMENT":return B9.InDevelopment;case"PRE_RELEASE":return B9.PreRelease;case"GENERAL_AVAILABILITY":return B9.GeneralAvailability;case"DEPRECATED":return B9.Deprecated;default:return}}};var _JE=hu.object({snake:hu.string().optional(),camel:hu.string().optional(),screamingSnake:hu.string().optional(),pascal:hu.string().optional()}),hJE=hu.object({description:hu.string().optional(),name:hu.string().optional(),casing:_JE.optional()}),CB_=hu.record(hJE);var fko=class extends Aj{schema;key="x-fern-enum";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(t==null)return;let r=CB_.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-enum extension: ${r.error.message}`,path:this.breadcrumbs});return}return r.data}};var SKi=class extends Aj{operation;key="x-fern-ignore";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-ignore",path:this.breadcrumbs});return}return t}}};var dko=class extends Aj{parameter;key="x-fern-optional";constructor({breadcrumbs:t,parameter:r,context:i}){super({breadcrumbs:t,context:i}),this.parameter=r}convert(){let t=this.getExtensionValue(this.parameter);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-optional",path:this.breadcrumbs});return}return t}}};var pko=class extends Aj{operation;key="x-fern-sdk-group-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=Array.isArray(t)?t.filter(i=>typeof i=="string"):typeof t=="string"?[t]:[];if(r.length!==0)return{groups:r}}};var _ko=class extends Aj{operation;key="x-fern-sdk-method-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null&&typeof t=="string")return{methodName:t}}};var hko=class extends Aj{schema;key="x-fern-type";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(t!=null&&typeof t=="string")return t}};var yko=class extends Aj{schema;key="x-fern-type-name";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(typeof t=="string")return t}};var Mpi=class extends w0{ir;audiences;irGraph;constructor({breadcrumbs:t=[],context:r,audiences:i}){super({breadcrumbs:t,context:r}),this.audiences=i,this.irGraph=new wKi(i),this.ir={auth:{docs:void 0,requirement:Ws.AuthSchemesRequirement.All,schemes:[]},selfHosted:!1,types:{},services:{},errors:{},webhookGroups:{},websocketChannels:void 0,headers:[],idempotencyHeaders:[],apiVersion:void 0,apiDisplayName:void 0,apiDocs:void 0,basePath:void 0,pathParameters:[],errorDiscriminationStrategy:Ws.ErrorDiscriminationStrategy.statusCode(),variables:[],serviceTypeReferenceInfo:{sharedTypes:[],typesReferencedOnlyByService:{}},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,environments:void 0,fdrApiDefinitionId:void 0,rootPackage:this.createPackage(),subpackages:{},sdkConfig:{hasFileDownloadEndpoints:!1,hasPaginatedEndpoints:!1,hasStreamingEndpoints:!1,isAuthMandatory:!0,platformHeaders:{language:"",sdkName:"",sdkVersion:"",userAgent:void 0}}}}removeXFernIgnores({document:t,breadcrumbs:r=[]}){return Array.isArray(t)?t.filter((i,n)=>!new SKi({breadcrumbs:[...r,String(n)],operation:i,context:this.context}).convert()).map((i,n)=>this.removeXFernIgnores({document:i,breadcrumbs:[...r,String(n)]})):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([i,n])=>!new SKi({breadcrumbs:[...r,i],operation:n,context:this.context}).convert()).map(([i,n])=>[i,this.removeXFernIgnores({document:n,breadcrumbs:[...r,i]})])):t}finalizeIr(){let t={...this.ir,apiName:this.context.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:this.context.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}};return t=this.irGraph.hasNoAudiences()?t:this.filterIrForAudiences(t),{...t,...ARa({ir:t,exampleGeneration:this.context.exampleGenerationArgs}),...WPc({ir:t,exampleGeneration:this.context.exampleGenerationArgs})}}filterIrForAudiences(t){let r=this.irGraph.getFilteredEndpoints(),i=this.irGraph.getFilteredChannels(),n=this.irGraph.getFilteredWebhooks();for(let a of Object.values(t.services)){let u=[];for(let l of a.endpoints)r.has(l.id)&&u.push(l);a.endpoints=u}return t.websocketChannels=Object.fromEntries(Object.entries(t.websocketChannels??{}).filter(([a])=>i.has(a))),t.webhookGroups=Object.fromEntries(Object.entries(t.webhookGroups).filter(([a])=>n.has(a))),t}async resolveAllExternalRefs({spec:t}){let r=[t];for(;r.length>0;){let i=r.shift();i!=null&&(Array.isArray(i)?await this.resolveExternalRefsInArray(i,r):typeof i=="object"&&await this.resolveExternalRefsInObject(i,r))}return t}async resolveExternalRefsInArray(t,r){for(let i=0;i<t.length;i++)t[i]=await this.resolveReferenceChain(t[i],r)}async resolveExternalRefsInObject(t,r){for(let[i,n]of Object.entries(t))t[i]=await this.resolveReferenceChain(n,r)}async resolveReferenceChain(t,r){let i=t;if(!this.context.isReferenceObject(i))return r.push(i),t;for(;this.context.isReferenceObject(i);){let n=this.context.isExternalReference(i.$ref),a=await this.context.resolveMaybeExternalReference({$ref:i.$ref});if(a.resolved){if(i=a.value,n)return i}else return t}return t}shouldAddServerToCollectedServers({server:t,currentServers:r}){return!r.some(i=>i.url===t.url&&"x-fern-server-name"in i&&"x-fern-server-name"in t&&i["x-fern-server-name"]===t["x-fern-server-name"])}addEndpointToIr({endpoint:t,audiences:r,endpointGroup:i,serviceName:n}){let a=this.context.getGroup({groupParts:i,namespace:this.context.namespace}),u=this.getOrCreatePackage({group:i}),l=[...a].map(o=>this.context.casingsGenerator.generateName(o)),d=l[l.length-1];u.service==null&&(u.service=n??`service_${a.map(o=>T_(o)).join("/")}`),this.ir.services[u.service]==null&&(this.ir.services[u.service]=this.createNewService({allParts:l,finalpart:d})),this.ir.services[u.service]?.endpoints.push(t);let s=this.ir.services[u.service];s!=null&&(this.irGraph.addEndpoint(s,t),this.irGraph.markEndpointForAudience(s.name,[t],r))}addWebhookToIr({webhook:t,operationId:r,audiences:i,group:n}){let a=n?.join(".")??r,u=this.getOrCreatePackage({group:n});this.ir.webhookGroups[a]==null&&(this.ir.webhookGroups[a]=[]),this.ir.webhookGroups[a].push(t),u.webhooks=a;let l=this.context.createFernFilepath();this.irGraph.addWebhook(l,t),i!=null&&this.irGraph.markWebhookForAudiences(l,t,i)}addWebsocketChannelToIr({websocketChannel:t,channelPath:r,audiences:i,websocketGroup:n}){let a=T_(n?.join(".")),u=T_(r),l=this.context.namespace?`${T_(this.context.namespace)}/`:"",d=a?`channel_${l}${a}`:`channel_${l}${u}`,s=n?this.getOrCreatePackage({group:n}):this.getOrCreatePackage({group:[u]});this.ir.websocketChannels={...this.ir.websocketChannels,[d]:t},d!==""?s.websocket==null&&(s.websocket=d):this.ir.rootPackage.websocket="";let o=this.context.createFernFilepath();this.irGraph.addChannel(o,d,t),i!=null&&this.irGraph.markChannelForAudiences(o,d,i)}addAuthToIR(t){this.ir.auth=t}addErrorsToIr(t){this.ir.errors=t;for(let r of Object.values(t))this.irGraph.addError(r)}addEnvironmentsToIr({environmentConfig:t,audiences:r}){if(this.ir.environments=t,r!=null)for(let[i,n]of Object.entries(t??{}))r[i]!=null&&this.irGraph.markEnvironmentForAudiences(n,r[i])}addTypeToRootPackage(t){this.ir.rootPackage.types.push(t)}addTypeToPackage(t){let r=this.context.getGroup({groupParts:[],namespace:this.context.namespace});this.getOrCreatePackage({group:r}).types.push(t)}addTypesToIr(t){Object.assign(this.ir.types,Object.fromEntries(Object.entries(t).map(([r,i])=>[r,i.typeDeclaration])));for(let r of Object.values(t))this.irGraph.addType({declaredTypeName:r.typeDeclaration.name,descendantTypeIds:r.typeDeclaration.referencedTypes,descendantTypeIdsByAudience:{},propertiesByAudience:r.propertiesByAudience,descendantFilepaths:new Set}),this.irGraph.markTypeForAudiences(r.typeDeclaration.name,r.audiences)}updateEndpointsWithDefaultUrl(t){if(t!=null)for(let r of Object.values(this.ir.services))for(let i of r.endpoints)i.baseUrl==null&&(i.baseUrl=t)}createNewService({allParts:t,finalpart:r}){return{name:{fernFilepath:{allParts:t,packagePath:t.slice(0,-1),file:r}},displayName:void 0,basePath:lF(""),headers:[],pathParameters:[],availability:void 0,endpoints:[],transport:void 0,encoding:void 0}}createPackage(t={}){return{fernFilepath:this.context.createFernFilepath(t),service:void 0,types:[],errors:[],subpackages:[],docs:void 0,webhooks:void 0,websocket:void 0,hasEndpointsInTree:!1,navigationConfig:void 0}}getOrCreatePackage({group:t}){let r=[];if(this.context.namespace!=null&&r.push(this.context.namespace),r.push(...(t??[]).map(n=>T_(n))),r.length==0)return this.ir.rootPackage;let i=this.ir.rootPackage;for(let n=0;n<r.length;n++){let a=r[n]??"",l=`subpackage_${r.slice(0,n+1).join("/")}`;this.ir.subpackages[l]==null&&(this.ir.subpackages[l]={name:this.context.casingsGenerator.generateName(a),...this.createPackage({name:a})});let d=this.ir.subpackages[l];i.subpackages.includes(l)||i.subpackages.push(l),i=d}return i}};var QA={};jo(QA,{AbstractConverters:()=>ZPc,ExampleConverter:()=>Wir,SchemaConverters:()=>XPc,ServersConverter:()=>EHt});var ZPc={};jo(ZPc,{AbstractMediaTypeObjectConverter:()=>bko,AbstractParameterConverter:()=>gko});var Wir=class e extends w0{MAX_DEPTH=12;EXAMPLE_STRING="foo";EXAMPLE_NUMBER=42;EXAMPLE_BOOLEAN=!0;EXAMPLE_INTEGER=42;schema;example;depth;exampleGenerationStrategy;generateOptionalProperties;constructor({breadcrumbs:t,context:r,schema:i,example:n,depth:a=0,exampleGenerationStrategy:u,generateOptionalProperties:l=!1}){super({breadcrumbs:t,context:r}),this.example=n,this.schema=i,this.depth=a,this.exampleGenerationStrategy=u,this.generateOptionalProperties=l}convert(){if(this.depth>this.MAX_DEPTH)return{isValid:!0,coerced:!1,validExample:this.example,errors:[]};let t=this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});return t==null?{isValid:!1,coerced:!1,validExample:null,errors:[{message:"Schema is not resolvable",path:this.breadcrumbs}]}:typeof t!="object"?{isValid:!1,coerced:!1,validExample:null,errors:[{message:`Schema should be an object: ${JSON.stringify(t,null,2)}`,path:this.breadcrumbs}]}:"nullable"in t&&t.nullable===!0&&this.example===null?{isValid:!0,coerced:!1,validExample:this.example,errors:[]}:Array.isArray(t.type)?this.convertSchemaTypeArray({resolvedSchema:t}):t.type=="null"?this.convertNull():t.type=="boolean"?this.convertBoolean():t.enum!=null?this.convertEnum(t):t.type=="number"?this.convertNumber():t.type=="string"?this.convertString():t.type=="integer"?this.convertInteger():t.type=="array"?this.convertArray({resolvedSchema:t}):"oneOf"in t&&t.oneOf!=null?this.convertOneOf({resolvedSchema:t}):"anyOf"in t&&t.anyOf!=null?this.convertAnyOf({resolvedSchema:t}):t.type=="object"||t.properties!=null||t.allOf!=null?this.convertObject({resolvedSchema:t}):typeof t=="object"&&Object.keys(t).length===0?{isValid:!0,coerced:!1,validExample:this.example,errors:[]}:{isValid:!1,coerced:!1,validExample:null,errors:[{message:`Unsupported schema type: ${JSON.stringify(t,null,2)}`,path:this.breadcrumbs}]}}convertNull(){let t=this.example===null;return t?{isValid:t,coerced:!1,validExample:this.example,errors:[]}:{isValid:!1,coerced:!1,validExample:null,errors:[{message:`Example is not null: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertBoolean(){let t=typeof this.example=="boolean";if(t)return{isValid:t,coerced:!1,validExample:this.example,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return typeof r=="boolean"?{isValid:!0,coerced:!1,validExample:r,errors:[]}:{isValid:!1,coerced:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_BOOLEAN,errors:[{message:`Example is not a boolean: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertEnum(t){let r=t.enum?.includes(this.example)??!1;if(r)return{isValid:r,coerced:!1,validExample:this.example,errors:[]};let i=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return i!==void 0&&t.enum?.includes(i)?{isValid:!0,coerced:!1,validExample:i,errors:[]}:{isValid:r,coerced:!1,validExample:t.enum?.[0],errors:[{message:`Example is not one of the allowed enum values: ${JSON.stringify(t.enum,null,2)}`,path:this.breadcrumbs}]}}convertNumber(){if(typeof this.example=="number")return{isValid:!0,coerced:!1,validExample:this.example,errors:[]};let t=Number(this.example);if(!isNaN(t))return{isValid:!0,coerced:!0,validExample:t,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return typeof r=="number"?{isValid:!0,coerced:!1,validExample:r,errors:[]}:{isValid:!1,coerced:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_NUMBER,errors:[{message:`Example is not a number: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertString(){if(typeof this.example=="string")return{isValid:!0,coerced:!1,validExample:this.example,errors:[]};if(typeof this.example!="object"&&!Array.isArray(this.example)&&this.example!=null)return{isValid:!0,coerced:!0,validExample:String(this.example),errors:[]};let t=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return typeof t=="string"?{isValid:!0,coerced:!1,validExample:t,errors:[]}:{isValid:!1,coerced:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_STRING,errors:[{message:`Example cannot be converted to string: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertInteger(){if(typeof this.example=="number"&&Number.isInteger(this.example))return{isValid:!0,coerced:!1,validExample:this.example,errors:[]};if(typeof this.example=="string"){let r=Number(this.example);if(!isNaN(r)&&Number.isInteger(r))return{isValid:!0,coerced:!0,validExample:r,errors:[]}}let t=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return typeof t=="number"&&Number.isInteger(t)?{isValid:!0,coerced:!1,validExample:t,errors:[]}:{isValid:!1,coerced:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_INTEGER,errors:[{message:`Example is not an integer: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertArray({resolvedSchema:t}){if(t.type!="array")return{isValid:!1,coerced:!1,validExample:null,errors:[]};t.items==null&&(t.items={type:"string"});let r=this.example==null,i=this.example??t.example,a=(Array.isArray(i)?i:[i]).map(l=>new e({breadcrumbs:[...this.breadcrumbs,"items"],context:this.context,schema:t.items,example:l,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy}).convert()),u=a.every(l=>l?.isValid??!1)&&!r;return{isValid:u,coerced:!1,validExample:a.map(l=>l.validExample),errors:u?[]:a.flatMap(l=>l.errors)}}convertObject({resolvedSchema:t}){if(t.type=="object"&&t.properties==null&&t.allOf==null)return{isValid:!0,coerced:!1,validExample:this.example??{},errors:[]};let r=typeof this.example!="object"||this.example==null?{}:this.example,i=Object.entries(t.properties??{}).map(([l,d])=>{if(typeof d!="object")return{key:l,result:{isValid:!0,coerced:!1,validExample:void 0,errors:[]}};if(this.isDeprecatedProperty(d)&&!this.isRequiredProperty({key:l,resolvedSchema:t}))return{key:l,result:{isValid:!0,coerced:!1,validExample:void 0,errors:[]}};if("readOnly"in d&&d.readOnly===!0&&"writeOnly"in d&&d.writeOnly===!0)return{key:l,result:{isValid:!0,coerced:!1,validExample:void 0,errors:[]}};if("readOnly"in d&&d.readOnly===!0&&this.exampleGenerationStrategy==="request")return{key:l,result:{isValid:!0,coerced:!1,validExample:void 0,errors:[]}};if("writeOnly"in d&&d.writeOnly===!0&&this.exampleGenerationStrategy==="response")return{key:l,result:{isValid:!0,coerced:!1,validExample:void 0,errors:[]}};let s=!(l in r)||!("nullable"in d)&&r[l]==null||"nullable"in d&&d.nullable===!0&&r[l]===void 0,o=!t.required?.includes(l);if(s&&o){if(this.example===void 0&&this.generateOptionalProperties){let c=new e({breadcrumbs:[...this.breadcrumbs,l],context:this.context,schema:d,example:void 0,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy});return{key:l,result:c.convert()}}return{key:l,result:{isValid:!0,coerced:!1,validExample:void 0,errors:[]}}}else{let b=new e({breadcrumbs:[...this.breadcrumbs,l],context:this.context,schema:d,example:r[l],depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy}).convert();return{key:l,result:b}}}),n=(t.allOf??[]).map((l,d)=>new e({breadcrumbs:[...this.breadcrumbs,`allOf[${d}]`],context:this.context,schema:{...t,...l,allOf:void 0},example:this.example,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy}).convert()),a=i.every(l=>l.result.isValid)&&n.every(l=>l.isValid),u=Object.fromEntries(i.map(({key:l,result:d})=>[l,d.validExample]).filter(([l,d])=>d!==void 0));for(let l of n)if(typeof l.validExample=="object"&&l.validExample!==null){let d=l.validExample;u={...u,...Object.fromEntries(Object.entries(d).filter(([s,o])=>o!==void 0))}}if(Object.keys(u).length===0){let l=n.find(d=>d.validExample!==void 0&&(typeof d.validExample!="object"||d.validExample===null));l&&(u=l.validExample)}return{isValid:a,coerced:!1,validExample:u,errors:[...i.flatMap(({result:l})=>l.errors),...n.flatMap(l=>l.errors)]}}convertSchemaTypeArray({resolvedSchema:t}){if(!Array.isArray(t.type))return{isValid:!1,coerced:!1,validExample:null,errors:[]};if(t.type.length===1)return new e({breadcrumbs:this.breadcrumbs,context:this.context,schema:{...t,type:t.type[0]},example:this.example,depth:this.depth,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy}).convert();let r=t.type.map((u,l)=>new e({breadcrumbs:[...this.breadcrumbs,`type[${l}]`],context:this.context,schema:{...t,type:u},example:this.example,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy}).convert()),i=r.some(u=>u?.isValid??!1),a=r.find(u=>u.isValid)?.validExample??r[0]?.validExample??null;return{isValid:i,coerced:!1,validExample:a,errors:i?[]:r.flatMap(u=>u?.errors??[])}}convertOneOf({resolvedSchema:t}){if(!("oneOf"in t)||t.oneOf==null)return{isValid:!1,coerced:!1,validExample:null,errors:[]};let r=t.oneOf.map((u,l)=>new e({breadcrumbs:[...this.breadcrumbs,`oneOf[${l}]`],context:this.context,schema:{...t,...u,oneOf:void 0},example:this.example,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy}).convert()),i=r.filter(u=>u.isValid),n=i.length>0,a;return n?a=i.find(l=>!l.coerced)?.validExample??i[0]?.validExample:a=r[0]?.validExample,{isValid:n,coerced:!1,validExample:a,errors:n?[]:r.flatMap(u=>u.errors)}}convertAnyOf({resolvedSchema:t}){if(!("anyOf"in t)||t.anyOf==null)return{isValid:!1,coerced:!1,validExample:null,errors:[]};let r=t.anyOf.map((u,l)=>new e({breadcrumbs:[...this.breadcrumbs,`anyOf[${l}]`],context:this.context,schema:u,example:this.example,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy}).convert()),i=r.filter(u=>u.isValid),n=i.length>0,a;return n?a=i.find(l=>!l.coerced)?.validExample??i[0]?.validExample:a=r[0]?.validExample,{isValid:n,coerced:!1,validExample:a,errors:n?[]:r.flatMap(u=>u.errors)}}maybeResolveSchemaExample(t){let r=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(r!=null){if("example"in r)return r.example;if("examples"in r)return Object.values(r.examples??{})[0]}}isDeprecatedProperty(t){return t!=null&&"availability"in t&&t.availability==="deprecated"}isRequiredProperty({key:t,resolvedSchema:r}){return r.required?.includes(t)??!1}};var XPc={};jo(XPc,{ArraySchemaConverter:()=>H9n,EnumSchemaConverter:()=>L9n,ObjectSchemaConverter:()=>U9n,OneOfSchemaConverter:()=>V9n,PrimitiveSchemaConverter:()=>W9n,SchemaConverter:()=>WAi,SchemaOrReferenceConverter:()=>Ok});function BB_(e){return G2({type:e,_default:void 0,validation:void 0,visitor:{primitive:t=>{switch(t.v1){case"BASE_64":return gf.primitive({v1:"BASE_64",v2:Lp.base64({})});case"BOOLEAN":return gf.primitive({v1:"BOOLEAN",v2:Lp.boolean({default:void 0})});case"DATE":return gf.primitive({v1:"DATE",v2:Lp.date({})});case"DATE_TIME":return gf.primitive({v1:"DATE_TIME",v2:Lp.dateTime({})});case"FLOAT":return gf.primitive({v1:"FLOAT",v2:Lp.float({})});case"DOUBLE":return gf.primitive({v1:"DOUBLE",v2:Lp.double({default:void 0,validation:void 0})});case"UINT":return gf.primitive({v1:"UINT",v2:Lp.uint({})});case"UINT_64":return gf.primitive({v1:"UINT_64",v2:Lp.uint64({})});case"INTEGER":return gf.primitive({v1:"INTEGER",v2:Lp.integer({default:void 0,validation:void 0})});case"LONG":return gf.primitive({v1:"LONG",v2:Lp.long({default:void 0})});case"STRING":return gf.primitive({v1:"STRING",v2:Lp.string({default:void 0,validation:void 0})});case"UUID":return gf.primitive({v1:"UUID",v2:Lp.uuid({})});case"BIG_INTEGER":return gf.primitive({v1:"BIG_INTEGER",v2:Lp.bigInteger({default:void 0})});default:return}},unknown:()=>gf.unknown(),map:({keyType:t,valueType:r})=>{if(!(t==null||r==null))return gf.container(_b.map({keyType:t,valueType:r}))},list:t=>{if(t!=null)return gf.container(_b.list(t))},optional:t=>{if(t!=null)return gf.container(_b.optional(t))},nullable:t=>{if(t!=null)return gf.container(_b.nullable(t))},set:t=>{if(t!=null)return gf.container(_b.set(t))},literal:t=>gf.container(_b.literal(t._visit({string:r=>x9.string(r),boolean:r=>x9.boolean(r),_other:()=>{throw new Error("Unexpected literal type")}}))),named:()=>{}}})}var L9n=class extends w0{schema;maybeFernEnum;constructor({context:t,breadcrumbs:r,schema:i,maybeFernEnum:n}){super({context:t,breadcrumbs:r}),this.schema=i,this.maybeFernEnum=n}convert(){if(!this.schema.enum)return;let r=this.schema.enum.filter(n=>typeof n=="string"||typeof n=="number").map(n=>{let a=n.toString(),u=this.maybeFernEnum?.[a],l=u?.name??a;return{name:this.context.casingsGenerator.generateNameAndWireValue({name:l,wireValue:a}),docs:u?.description,availability:void 0,casing:u?.casing}});if(r.length===0){this.context.errorCollector.collect({message:`Received enum schema with no valid values: ${JSON.stringify(this.schema)}`,path:this.breadcrumbs});return}let i=this.context.getAsString(this.schema.default);return{type:lO.enum({default:i!=null?r.find(n=>n.name.wireValue===i):void 0,values:r})}}};var vko=class extends w0{schemaOrReferenceOrBoolean;constructor({context:t,breadcrumbs:r,schemaOrReferenceOrBoolean:i}){super({context:t,breadcrumbs:r}),this.schemaOrReferenceOrBoolean=i}convert(){let t=this.tryConvertUnknownMap();if(t!=null)return t;let r=this.tryConvertTypedMap();if(r!=null)return r}tryConvertUnknownMap(){if(typeof this.schemaOrReferenceOrBoolean=="boolean"){let t=gf.container(_b.map({keyType:w0.STRING,valueType:gf.unknown()}));return{type:lO.alias({aliasOf:t,resolvedType:t}),referencedTypes:new Set,inlinedTypes:{}}}}tryConvertTypedMap(){if(typeof this.schemaOrReferenceOrBoolean=="boolean")return;let r=new Ok({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReference:this.schemaOrReferenceOrBoolean}).convert();if(r!=null){let i=gf.container(_b.map({keyType:w0.STRING,valueType:r.type})),n=new Set;for(let a of r.schema?.typeDeclaration.referencedTypes??[])n.add(a);for(let a of Object.keys(r.inlinedTypes))n.add(a);return{type:lO.alias({aliasOf:i,resolvedType:i}),referencedTypes:n,inlinedTypes:r.inlinedTypes}}}};function CRa({properties:e,required:t,breadcrumbs:r,context:i,errorCollector:n}){let a=[],u={},l={},d=new Set;for(let[s,o]of Object.entries(e??{})){let c=[...r,"properties",s];if(typeof o!="object"){n.collect({message:`Schema property ${s} should be an object`,path:c});continue}let b=yJE(r,o,i)??i.convertBreadcrumbsToName(c),g="nullable"in o?o.nullable:!1,m=new Ok({context:i,breadcrumbs:c,schemaOrReference:o,schemaIdOverride:b,wrapAsOptional:!t.includes(s),wrapAsNullable:g}).convert();if(m!=null){a.push({name:i.casingsGenerator.generateNameAndWireValue({name:s,wireValue:s}),valueType:m.type,docs:o.description,availability:m.availability,propertyAccess:i.getPropertyAccess(o),v2Examples:m.schema?.typeDeclaration?.v2Examples??{userSpecifiedExamples:{},autogeneratedExamples:{}}}),u={...u,...m.inlinedTypes},m.schema?.typeDeclaration.referencedTypes!=null&&m.schema.typeDeclaration.referencedTypes.forEach(P=>{d.add(P)});for(let P of m.schema?.audiences??[])l[P]==null&&(l[P]=new Set),l[P].add(s)}}for(let s of Object.keys(u))d.add(s);return{convertedProperties:a,propertiesByAudience:l,inlinedTypesFromProperties:u,referencedTypes:d}}function yJE(e,t,r){return r.isReferenceObject(t)?void 0:new pH.FernTypeNameExtension({breadcrumbs:e,schema:t,context:r}).convert()}var U9n=class extends w0{schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){let t=typeof this.schema.additionalProperties=="boolean"&&this.schema.additionalProperties;if(!this.schema.properties&&!this.schema.allOf)return{type:lO.object({properties:[],extends:[],extendedProperties:[],extraProperties:t}),propertiesByAudience:{},inlinedTypes:{},referencedTypes:new Set};let{convertedProperties:r,inlinedTypesFromProperties:i,referencedTypes:n,propertiesByAudience:a}=CRa({properties:this.schema.properties??{},required:this.schema.required??[],breadcrumbs:this.breadcrumbs,context:this.context,errorCollector:this.context.errorCollector}),u=[],l=n,d=i,s=a;for(let[o,c]of(this.schema.allOf??[]).entries()){let b=[...this.breadcrumbs,"allOf",o.toString()];if(this.context.isReferenceObject(c)){let E=this.context.convertReferenceToTypeReference({reference:c,breadcrumbs:b});E.ok&&u.push(E.reference);let q=this.context.getTypeIdFromSchemaReference(c);q!=null&&l.add(q);continue}let{convertedProperties:g,inlinedTypesFromProperties:O,referencedTypes:m,propertiesByAudience:P}=CRa({properties:c.properties??{},required:[...this.schema.required??[],...c.required??[]],breadcrumbs:b,context:this.context,errorCollector:this.context.errorCollector});r.push(...g),d={...d,...O},s={...s,...P},m.forEach(E=>{l.add(E)})}for(let o of Object.keys(d))l.add(o);return{type:lO.object({properties:r,extends:u.map(o=>this.context.typeReferenceToDeclaredTypeName(o)).filter(V0),extendedProperties:[],extraProperties:t}),propertiesByAudience:s,referencedTypes:l,inlinedTypes:d}}};var V9n=class extends w0{schema;id;constructor({context:t,breadcrumbs:r,schema:i,id:n,inlinedTypes:a}){super({context:t,breadcrumbs:r}),this.schema=i,this.id=n}convert(){return this.shouldConvertAsNullableSchemaOrReference()?this.convertAsNullableSchemaOrReference():this.schema.discriminator!=null&&!this.unionVariantsContainLiteral({discriminantProperty:this.schema.discriminator.propertyName})?this.convertAsDiscriminatedUnion():this.convertAsUndiscriminatedUnion()}unionVariantsContainLiteral({discriminantProperty:t}){for(let[r,i]of Object.entries(this.schema.discriminator?.mapping??{})){let n=this.context.resolveReference({reference:{$ref:i},breadcrumbs:this.breadcrumbs});if(n.resolved&&!Object.keys(n.value.properties??{}).includes(t))return!1}return!0}convertAsDiscriminatedUnion(){if(this.schema.discriminator==null)return;let t=[],r=new Set,i={};for(let[l,d]of Object.entries(this.schema.discriminator.mapping??{})){let s=new Ok({context:this.context,schemaOrReference:{$ref:d},breadcrumbs:[...this.breadcrumbs,"discriminator","mapping",l]}),o=this.context.getTypeIdFromSchemaReference({$ref:d});o!=null&&r.add(o);let c=s.convert();if(c?.type!=null&&o!=null){for(let g of Object.keys(c?.inlinedTypes??{}))r.add(g);for(let g of c.schema?.typeDeclaration.referencedTypes??[])r.add(g);let b=this.context.casingsGenerator.generateNameAndWireValue({name:l,wireValue:l});t.push({docs:void 0,discriminantValue:b,availability:c.availability,displayName:l,shape:xQ.samePropertiesAsObject({typeId:o,name:this.context.casingsGenerator.generateName(o),fernFilepath:{allParts:[],packagePath:[],file:void 0},displayName:l})}),i={...i,...c.inlinedTypes}}}let{convertedProperties:n,referencedTypes:a,inlinedTypesFromProperties:u}=CRa({properties:this.schema.properties??{},required:this.schema.required??[],breadcrumbs:this.breadcrumbs,context:this.context,errorCollector:this.context.errorCollector});r=new Set([...r,...a]);for(let l of Object.keys({...i,...u}))r.add(l);return{type:lO.union({baseProperties:n,discriminant:this.context.casingsGenerator.generateNameAndWireValue({name:this.schema.discriminator.propertyName,wireValue:this.schema.discriminator.propertyName}),extends:[],types:t}),referencedTypes:r,inlinedTypes:{...i,...u}}}convertAsUndiscriminatedUnion(){if(!this.schema.oneOf&&!this.schema.anyOf||this.schema.anyOf?.length===0&&this.schema.oneOf?.length===0)return;let t=[],r=new Set,i={};for(let[n,a]of[...(this.schema.oneOf??[]).entries(),...(this.schema.anyOf??[]).entries()]){if(this.context.isReferenceObject(a)){let c;if(this.context.isReferenceObjectWithIdentifier(a))c=this.context.convertReferenceToTypeReference({reference:a,displayNameOverride:a.title??a.name??a.messageId,displayNameOverrideSource:"reference_identifier"});else if(this.getDiscriminatorKeyForRef(a)!=null){let g=this.getDiscriminatorKeyForRef(a);c=this.context.convertReferenceToTypeReference({reference:a,displayNameOverride:g,displayNameOverrideSource:"discriminator_key"})}else c=this.context.convertReferenceToTypeReference({reference:a,displayNameOverrideSource:"schema_identifier"});c.ok&&t.push({type:c.reference,docs:a.description});let b=this.context.getTypeIdFromSchemaReference(a);b!=null&&r.add(b);continue}let u=this.extendSubSchema(a),l=this.context.convertBreadcrumbsToName([`${this.id}_${n}`]),d=a.title,o=new WAi({context:this.context,id:l,nameOverride:d,breadcrumbs:[...this.breadcrumbs,`oneOf[${n}]`],schema:u??a}).convert();if(o!=null){let c=o.convertedSchema.typeDeclaration.shape;c.type==="alias"&&this.typeReferenceIsWrappedPrimitive(c.aliasOf)?t.push({type:c.aliasOf,docs:a.description}):c.type==="object"&&c.properties.length===0?t.push({type:gf.container(_b.map({keyType:w0.STRING,valueType:gf.unknown()})),docs:a.description}):(t.push({type:this.context.createNamedTypeReference(l,d),docs:a.description}),i={...i,...o.inlinedTypes,[l]:o.convertedSchema}),o.convertedSchema.typeDeclaration.referencedTypes.forEach(b=>{r.add(b)})}}return{type:lO.undiscriminatedUnion({members:t}),referencedTypes:r,inlinedTypes:i}}shouldConvertAsNullableSchemaOrReference(){return this.schema.oneOf!=null?this.schema.oneOf.some(t=>t&&typeof t=="object"&&"type"in t&&t.type==="null"):this.schema.anyOf!=null?this.schema.anyOf.some(t=>t&&typeof t=="object"&&"type"in t&&t.type==="null"):!1}removeNullFromOneOfOrAnyOf(){let t=this.schema.oneOf??this.schema.anyOf,r=this.schema.oneOf!=null?"oneOf":"anyOf";if(t==null)return;let i=t.filter(n=>!("type"in n&&n.type==="null"));if(i.length===0){this.context.errorCollector.collect({message:`Received ${r} schema with no valid non-null types`,path:this.breadcrumbs});return}return i.length===1?{...this.schema,[r]:void 0,...i[0]}:{...this.schema,[r]:i}}convertAsNullableSchemaOrReference(){let t=this.removeNullFromOneOfOrAnyOf();if(t==null)return;let i=new Ok({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReference:t}).convert();if(i==null)return;let n=this.wrapInNullable(i.type);return{type:lO.alias({aliasOf:n,resolvedType:n}),referencedTypes:i.schema?.typeDeclaration.referencedTypes??new Set,inlinedTypes:i.inlinedTypes}}typeReferenceIsWrappedPrimitive(t){switch(t.type){case"container":return this.containerTypeIsWrappedPrimitive(t.container);case"named":return!1;case"primitive":return!0;case"unknown":return!0;default:return!1}}containerTypeIsWrappedPrimitive(t){switch(t.type){case"list":return this.typeReferenceIsWrappedPrimitive(t.list);case"map":return this.typeReferenceIsWrappedPrimitive(t.keyType)&&this.typeReferenceIsWrappedPrimitive(t.valueType);case"nullable":return this.typeReferenceIsWrappedPrimitive(t.nullable);case"optional":return this.typeReferenceIsWrappedPrimitive(t.optional);case"set":return this.typeReferenceIsWrappedPrimitive(t.set);case"literal":return!0;default:return!1}}wrapInNullable(t){return gf.container(_b.nullable(t))}mergeIntoObjectSchema(t,r){return{...t,properties:{...r,...t.properties??{}}}}extendSubSchema(t){if(Object.entries(this.schema.properties??{}).length===0)return t;if(t.type==="object")return this.mergeIntoObjectSchema(t,this.schema.properties??{});this.context.isObjectSchemaType(t)||this.context.errorCollector.collect({message:"Received additional object properties for oneOf/anyOf that are not objects",path:this.breadcrumbs})}getDiscriminatorKeyForRef(t){return Object.entries(this.schema.discriminator?.mapping??{}).find(([r,i])=>i===t.$ref)?.[0]}};var W9n=class extends w0{schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){switch(this.schema.type){case"string":{let t=this.context.getAsString(this.schema.const);return t!=null?gf.container(_b.literal(x9.string(t))):gf.primitive({v1:"STRING",v2:Lp.string({default:this.context.getAsString(this.schema.default),validation:this.getStringValidation(this.schema)})})}case"number":switch(this.schema.format){case"double":return gf.primitive({v1:"DOUBLE",v2:Lp.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return gf.primitive({v1:"FLOAT",v2:Lp.float({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return gf.primitive({v1:"INTEGER",v2:Lp.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return gf.primitive({v1:"LONG",v2:Lp.long({default:this.context.getAsNumber(this.schema.default)})});case"uint32":return gf.primitive({v1:"UINT",v2:Lp.uint({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return gf.primitive({v1:"UINT_64",v2:Lp.uint64({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return gf.primitive({v1:"DOUBLE",v2:Lp.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"integer":switch(this.schema.format){case"double":return gf.primitive({v1:"DOUBLE",v2:Lp.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return gf.primitive({v1:"FLOAT",v2:Lp.float({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return gf.primitive({v1:"INTEGER",v2:Lp.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return gf.primitive({v1:"LONG",v2:Lp.long({default:this.context.getAsNumber(this.schema.default)})});case"uint32":return gf.primitive({v1:"UINT",v2:Lp.uint({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return gf.primitive({v1:"UINT_64",v2:Lp.uint64({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return gf.primitive({v1:"INTEGER",v2:Lp.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"boolean":{let t=this.context.getAsBoolean(this.schema.const);return t!=null?gf.container(_b.literal(x9.boolean(t))):gf.primitive({v1:"BOOLEAN",v2:Lp.boolean({default:this.schema.default})})}default:return}}getNumberValidation(t){return{max:t.maximum,min:t.minimum,exclusiveMax:typeof t.exclusiveMaximum=="boolean"?t.exclusiveMaximum:void 0,exclusiveMin:typeof t.exclusiveMinimum=="boolean"?t.exclusiveMinimum:void 0,multipleOf:t.multipleOf}}getStringValidation(t){return{minLength:t.minLength,maxLength:t.maxLength,pattern:t.pattern,format:t.format}}};var vJE=["description","example","title","default","deprecated","readOnly","writeOnly","xml","externalDocs","extensions"],WAi=class e extends w0{schema;id;inlined;audiences;nameOverride;constructor({context:t,breadcrumbs:r,schema:i,id:n,inlined:a=!1,nameOverride:u}){super({context:t,breadcrumbs:r}),this.schema=i,this.id=n,this.inlined=a,this.nameOverride=u,this.audiences=this.context.getAudiences({operation:this.schema,breadcrumbs:this.breadcrumbs})??[]}convert(){let t=this.tryConvertFernTypeDeclaration();if(t!=null)return t;let r=this.tryConvertEnumSchema();if(r!=null)return r;let i=this.tryConvertSingularAllOfSchema();if(i!=null)return i;let n=this.tryConvertPrimitiveSchema();if(n!=null)return n;let a=this.tryConvertArraySchema();if(a!=null)return a;let u=this.tryConvertTypeArraySchema();if(u!=null)return u;let l=this.tryConvertOneOfAnyOfSchema();if(l!=null)return l;let d=this.tryConvertMapSchema();if(d!=null)return d;let s=this.tryConvertObjectAllOfSchema();if(s!=null)return s;let o=this.tryConvertUntypedSchema();if(o!=null)return o;this.context.errorCollector.collect({message:`Failed to convert schema object: ${JSON.stringify(this.schema,null,2)}`,path:this.breadcrumbs})}tryConvertEnumSchema(){if(!this.schema.enum?.length)return;let r=new pH.FernEnumExtension({breadcrumbs:this.breadcrumbs,schema:this.schema,context:this.context}).convert(),n=new L9n({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema,maybeFernEnum:r}).convert();if(n!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:n.type,referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertSingularAllOfSchema(){if(this.schemaOnlyHasAllowedKeys(["allOf"])&&this.schema.allOf?.length===1&&this.schema.allOf[0]!=null){let t=this.context.resolveMaybeReference({schemaOrReference:this.schema.allOf[0],breadcrumbs:this.breadcrumbs});if(t!=null){let i=new e({context:this.context,breadcrumbs:[...this.breadcrumbs,"allOf","0"],schema:t,id:this.id,inlined:!0}).convert();if(i?.convertedSchema.typeDeclaration?.shape.type!=="object")return i}}}tryConvertPrimitiveSchema(){let r=new W9n({context:this.context,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:lO.alias({aliasOf:r,resolvedType:r}),referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertArraySchema(){if(this.schema.type==="array"){let r=new H9n({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:lO.alias({aliasOf:r.typeReference,resolvedType:r.typeReference}),referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertTypeArraySchema(){if(Array.isArray(this.schema.type)&&this.schema.type.length>0)return this.schema.type.length===1?this.schema.type=this.schema.type[0]:(this.schema.oneOf=this.schema.type.map(t=>({type:t})),this.schema.type=void 0),this.convert()}tryConvertOneOfAnyOfSchema(){if(this.schema.oneOf!=null||this.schema.anyOf!=null){let r=new V9n({id:this.id,context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertMapSchema(){if((typeof this.schema.additionalProperties=="object"||typeof this.schema.additionalProperties=="boolean")&&this.schema.additionalProperties!=null&&!this.schema.properties&&!this.schema.allOf){if(typeof this.schema.additionalProperties=="boolean"&&this.schema.additionalProperties===!1)return;let r=new vko({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReferenceOrBoolean:this.schema.additionalProperties}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertObjectAllOfSchema(){if(this.schema.type==="object"||this.schema.properties!=null||this.schema.allOf!=null){let r=new U9n({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:r.propertiesByAudience},inlinedTypes:r.inlinedTypes}}}tryConvertUntypedSchema(){if(this.isUntypedSchema())return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:lO.alias({aliasOf:gf.unknown(),resolvedType:gf.unknown()}),referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertFernTypeDeclaration(){let r=new pH.FernTypeExtension({breadcrumbs:this.breadcrumbs,schema:this.schema,context:this.context}).convert();if(r==null)return;let i=BB_(r);if(i!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:lO.alias({aliasOf:i,resolvedType:i}),referencedTypes:new Set,omitV2Examples:!0}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}createTypeDeclaration({shape:t,referencedTypes:r,omitV2Examples:i}){return{name:this.convertDeclaredTypeName(),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:this.context.getAvailability({node:this.schema,breadcrumbs:this.breadcrumbs}),docs:this.schema.description,referencedTypes:r,source:void 0,inline:this.inlined,v2Examples:i?void 0:this.convertSchemaExamples()}}convertDeclaredTypeName(){return{typeId:this.id,fernFilepath:this.context.createFernFilepath(),name:this.context.casingsGenerator.generateName(this.id),displayName:this.nameOverride}}schemaOnlyHasAllowedKeys(t){let r=[...vJE,...t];return Object.keys(this.schema).every(n=>r.includes(n))}isUntypedSchema(){return!!(this.schema&&typeof this.schema=="object"&&!("type"in this.schema)&&!("oneOf"in this.schema)&&!("anyOf"in this.schema)&&!("allOf"in this.schema)&&!("items"in this.schema)&&!("properties"in this.schema))}convertSchemaExamples(){let t={userSpecifiedExamples:{},autogeneratedExamples:{}},r=this.context.getExamplesFromSchema({schema:this.schema,breadcrumbs:this.breadcrumbs});if(r.length===0){let i=this.generateOrValidateExample({example:void 0,ignoreErrors:!0});return t.autogeneratedExamples={[`${this.id}_example_autogenerated`]:i},t}return t.userSpecifiedExamples=this.convertUserSpecifiedExamples(r),t}convertUserSpecifiedExamples(t){let r={};for(let[i,n]of t.entries()){let a=this.context.resolveExample(n),u=this.generateOrValidateExample({example:a});r[`${this.id}_example_${i}`]=u}return r}generateOrValidateExample({example:t,ignoreErrors:r}){let i=new Wir({breadcrumbs:this.breadcrumbs,context:this.context,schema:this.schema,example:t}),{validExample:n,errors:a}=i.convert();return r||a.forEach(u=>{this.context.errorCollector.collect({message:u.message,path:u.path})}),n}};var Ok=class extends w0{schemaOrReference;schemaIdOverride;wrapAsOptional;wrapAsNullable;constructor({context:t,breadcrumbs:r,schemaOrReference:i,schemaIdOverride:n,wrapAsOptional:a=!1,wrapAsNullable:u=!1}){super({context:t,breadcrumbs:r}),this.schemaOrReference=i,this.schemaIdOverride=n,this.wrapAsOptional=a,this.wrapAsNullable=u}convert(){let t=this.maybeConvertReferenceObject({schemaOrReference:this.schemaOrReference});if(t!=null)return t;let r=this.maybeConvertSingularAllOfReferenceObject();return r??this.convertSchemaObject({schema:this.schemaOrReference})}maybeConvertReferenceObject({schemaOrReference:t}){if(this.context.isReferenceObject(t)){let r=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:this.breadcrumbs});if(r.ok)return{type:this.wrapTypeReference(r.reference),inlinedTypes:{}}}}maybeConvertSingularAllOfReferenceObject(){if(this.context.isReferenceObject(this.schemaOrReference)||this.schemaOrReference.allOf==null||this.schemaOrReference.allOf.length!==1)return;let t=this.schemaOrReference.allOf[0];if(this.context.isReferenceObject(t)){let r=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:this.breadcrumbs});if(r.ok)return{type:this.wrapTypeReference(r.reference),inlinedTypes:{}}}}convertSchemaObject({schema:t}){let r=this.schemaIdOverride??this.context.convertBreadcrumbsToName(this.breadcrumbs),i=new WAi({context:this.context,breadcrumbs:this.breadcrumbs,schema:t,id:r}),n=this.context.getAvailability({node:t,breadcrumbs:this.breadcrumbs}),a=i.convert();if(a!=null){let u=a.convertedSchema.typeDeclaration.shape;return u.type==="alias"?{type:this.wrapTypeReference(u.aliasOf),schema:a.convertedSchema,inlinedTypes:a.inlinedTypes,availability:n}:{type:this.wrapTypeReference(this.context.createNamedTypeReference(r)),schema:a.convertedSchema,inlinedTypes:{...a.inlinedTypes,[r]:a.convertedSchema},availability:n}}}wrapTypeReference(t){return this.wrapAsOptional&&this.wrapAsNullable?this.wrapInOptional(this.wrapInNullable(t)):this.wrapAsOptional?this.wrapInOptional(t):this.wrapAsNullable?this.wrapInNullable(t):t}wrapInOptional(t){return gf.container(_b.optional(t))}wrapInNullable(t){return gf.container(_b.nullable(t))}};var H9n=class e extends w0{static LIST_UNKNOWN=gf.container(_b.list(gf.unknown()));schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){if(this.schema.items!=null){Array.isArray(this.schema.items)&&(this.schema.items={oneOf:this.schema.items});let r=new Ok({context:this.context,breadcrumbs:[...this.breadcrumbs,"items"],schemaOrReference:this.schema.items}).convert();if(r!=null){let i=new Set;for(let n of r.schema?.typeDeclaration.referencedTypes??[])i.add(n);return r.inlinedTypes!=null&&Object.values(r.inlinedTypes).forEach(n=>{n.typeDeclaration.referencedTypes.forEach(a=>{i.add(a)})}),{typeReference:gf.container(_b.list(r.type)),referencedTypes:i,inlinedTypes:r.inlinedTypes}}}return{typeReference:e.LIST_UNKNOWN,referencedTypes:new Set,inlinedTypes:{}}}};var bko=class extends w0{group;method;constructor({context:t,breadcrumbs:r,group:i,method:n}){super({context:t,breadcrumbs:r}),this.group=i,this.method=n}parseMediaTypeObject({mediaTypeObject:t,resolveSchema:r,contentType:i,schemaId:n}){if(t.schema==null)return;if(r){let d=this.context.resolveMaybeReference({schemaOrReference:t.schema,breadcrumbs:[...this.breadcrumbs,"content",i]});if(d==null)return;t.schema=d}let u=new Ok({context:this.context,breadcrumbs:[...this.breadcrumbs,"content",i,"schema"],schemaOrReference:t.schema,schemaIdOverride:n}).convert();if(u==null)return;let l=t.examples!=null?Object.fromEntries(Object.entries(t.examples).map(([d,s])=>{if(this.context.isReferenceObject(s)){let o=this.context.resolveReference({reference:s,breadcrumbs:[...this.breadcrumbs,"content",i,"examples"],skipErrorCollector:!0});return o.resolved?[d,o.value]:null}return[d,s]}).filter(d=>d!=null)):void 0;return{...u,examples:l}}convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:r,exampleGenerationStrategy:i}){let n={userSpecifiedExamples:{},autogeneratedExamples:{}},a=t?.schema,u=this.context.getNamedExamplesFromMediaTypeObject({mediaTypeObject:t,breadcrumbs:this.breadcrumbs,defaultExampleName:`${[...this.group,this.method].join("_")}_example`});for(let[l,d]of u){let s=this.context.resolveExampleWithValue(d),o=this.context.isExampleWithSummary(d)?d.summary:l;s!=null&&(a!=null?n.userSpecifiedExamples[o]=this.generateOrValidateExample({schema:a,example:s,exampleGenerationStrategy:i}):n.userSpecifiedExamples[o]=s)}if(Object.keys(n.userSpecifiedExamples).length===0&&a!=null){let l=T_(`${[...this.group,this.method].join("_")}_example`);n.autogeneratedExamples[l]=this.generateOrValidateExample({schema:a,example:void 0,ignoreErrors:!0,generateOptionalProperties:r,exampleGenerationStrategy:i})}return n}generateOrValidateExample({schema:t,example:r,ignoreErrors:i,generateOptionalProperties:n,exampleGenerationStrategy:a}){let u=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(u==null)return;let l=this.context.getExamplesFromSchema({schema:u,breadcrumbs:this.breadcrumbs}),d=new Wir({breadcrumbs:this.breadcrumbs,context:this.context,schema:u,example:r??l[0],generateOptionalProperties:n??!1,exampleGenerationStrategy:a}),{validExample:s,errors:o}=d.convert();return i||o.forEach(c=>{this.context.errorCollector.collect({message:c.message,path:c.path})}),s}};var gko=class extends w0{parameter;constructor({context:t,breadcrumbs:r,parameter:i}){super({context:t,breadcrumbs:r}),this.parameter=i}convertToOutput({schema:t,typeReference:r,inlinedTypes:i}){let n=this.context.getAvailability({node:this.parameter,breadcrumbs:this.breadcrumbs}),a=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs}),u=this.getParameterSchemaWithExampleOverride({schema:a});switch(this.parameter.in){case"query":return{type:"query",parameter:{name:this.context.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:r??w0.OPTIONAL_STRING,allowMultiple:this.parameter.explode??!1,v2Examples:this.convertParameterExamples({schema:u??t}),availability:n},inlinedTypes:i};case"header":return{type:"header",parameter:{name:this.context.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:r??w0.OPTIONAL_STRING,env:void 0,v2Examples:this.convertParameterExamples({schema:u??t}),availability:n},inlinedTypes:i};case"path":return{type:"path",parameter:{name:this.context.casingsGenerator.generateName(this.parameter.name),docs:this.parameter.description,valueType:r??w0.STRING,location:"ENDPOINT",variable:void 0,v2Examples:this.convertParameterExamples({schema:u??t})},inlinedTypes:i};default:return}}getParameterSchemaWithExampleOverride({schema:t}){if(t!=null)return t.type==="string"&&t.example==null?{...t,example:this.parameter.name}:t}convertParameterExamples({schema:t}){let r={userSpecifiedExamples:{},autogeneratedExamples:{}},i=this.parameter.example,n=this.parameter.examples;for(let[a,u]of Object.entries(n??{})){let l=this.context.resolveExampleWithValue(u);l!=null&&(r.userSpecifiedExamples[a]=this.generateOrValidateExample({schema:t,example:l}))}if(i!=null){let a=this.context.generateUniqueName({prefix:`${this.parameter.name}_example`,existingNames:Object.keys(r.userSpecifiedExamples)});r.userSpecifiedExamples[a]=this.generateOrValidateExample({schema:t,example:i})}if(Object.keys(r.userSpecifiedExamples).length===0){let a=`${this.parameter.name}_example`;r.autogeneratedExamples[a]=this.generateOrValidateExample({schema:t,example:void 0,ignoreErrors:!0})}return r}generateOrValidateExample({schema:t,ignoreErrors:r,example:i}){let n=new Wir({breadcrumbs:this.breadcrumbs,context:this.context,schema:t,example:i}),{validExample:a,errors:u}=n.convert();return r||u.forEach(l=>{this.context.errorCollector.collect({message:l.message,path:l.path})}),a}};var Oko=class extends Aj{server;key="x-fern-server-name";constructor({breadcrumbs:t,server:r,context:i}){super({breadcrumbs:t,context:i}),this.server=r}convert(){let t=this.getExtensionValue(this.server,"x-name");if(!(t==null||typeof t!="string"))return t}};var IB_="Base",EHt=class e extends w0{servers;endpointLevelServers;constructor({breadcrumbs:t,context:r,servers:i,endpointLevelServers:n}){super({breadcrumbs:t,context:r}),this.servers=i,this.endpointLevelServers=n}convert(){if(this.servers==null||this.servers.length===0||this.servers[0]==null)return;if(this.endpointLevelServers!=null&&this.endpointLevelServers.length>0){let r=this.getDefaultBaseUrlName(),i={id:r,name:this.context.casingsGenerator.generateName(r)},n=this.endpointLevelServers.map(l=>{let d=e.getServerName({server:l,context:this.context});return{id:d,name:this.context.casingsGenerator.generateName(d)}}).filter((l,d,s)=>s.findIndex(o=>o.id===l.id)===d),a=[i,...n],u=this.servers.map(l=>{let d=e.getServerName({server:l,context:this.context}),s=this.endpointLevelServers?.map(o=>[e.getServerName({server:o,context:this.context}),this.getServerUrl(o)]);return{id:d,name:this.context.casingsGenerator.generateName(d),urls:{[r]:this.getServerUrl(l),...Object.fromEntries(s??[])},docs:l.description}});return{value:{defaultEnvironment:u[0]?.id,environments:cx.multipleBaseUrls({baseUrls:a,environments:u})},defaultUrl:i.id}}let t=this.withExplodedServers(this.servers).map(r=>{let i=e.getServerName({server:r,context:this.context});return{id:i,name:this.context.casingsGenerator.generateName(i),url:this.getServerUrl(r),docs:r.description}}).filter(V0);return{value:{defaultEnvironment:t[0]?.id,environments:cx.singleBaseUrl({environments:t})},defaultUrl:t[0]?.id}}static getServerExtensionName({server:t,context:r}){return new Oko({breadcrumbs:[],server:t,context:r}).convert()}static getServerName({server:t,context:r}){return e.getServerExtensionName({server:t,context:r})??t.description??t.url}getServerUrl(t){if(t.variables==null)return t.url;let r=t.url;for(let[i,n]of Object.entries(t.variables))n.default!=null&&(r=r.replace(`{${i}}`,n.default));return r}withExplodedServers(t){return t.flatMap(r=>{if(r.variables==null)return[r];let i=Object.entries(r.variables).filter(([l,d])=>d.enum!=null&&d.enum.length>0);if(i.length===0)return[r];let n=i[0];if(n==null)return[r];let[a,u]=n;return u.enum==null?[r]:u.enum.map(l=>{let d=r.url.replace(`{${a}}`,l),s={};for(let[c,b]of Object.entries(r.variables??{}))c!==a&&(s[c]=b);let o={...r,url:d,variables:Object.keys(s).length>0?s:void 0,"x-fern-server-name":r.description?`${r.description}_${l}`:`${l}`,description:r.description};return this.withExplodedServers([o])[0]})}).filter(V0)}getDefaultBaseUrlName(){return this.servers==null||this.servers.length===0||this.servers[0]==null?IB_:e.getServerExtensionName({server:this.servers[0],context:this.context})??IB_}};var BRa={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",498:"InvalidTokenError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},bJE=new Set(Object.values(BRa));var gJE=hu.object({type:hu.string(),channelId:hu.string().optional(),messageId:hu.string(),value:hu.any()}),OJE=hu.object({summary:hu.string().optional(),description:hu.string().optional(),"query-parameters":hu.record(hu.string()).optional(),headers:hu.record(hu.string()).optional(),messages:hu.array(gJE)}),zB_=hu.array(OJE);var mko=class extends Aj{channel;key="x-fern-examples";constructor({breadcrumbs:t,channel:r,context:i}){super({breadcrumbs:t??[],context:i}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(t==null)return;let r=zB_.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-examples extension: ${r.error.message}`,path:this.breadcrumbs});return}return r.data.map(i=>({summary:i.summary,description:i.description,queryParameters:i["query-parameters"],headers:i.headers,messages:i.messages.map(n=>({type:n.type,channelId:n.channelId,messageId:n.messageId,value:n.value}))}))}};var $9n=class extends w0{channel;channelPath;inlinedTypes={};websocketGroup;constructor({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a}){super({context:t,breadcrumbs:r}),this.websocketGroup=i,this.channel=n,this.channelPath=a}convertExamples({fullPath:t,baseUrl:r,asyncApiVersion:i}){let a=new mko({context:this.context,breadcrumbs:this.breadcrumbs,channel:this.channel}).convert();return a==null?{}:Object.fromEntries(a.map((u,l)=>[l.toString(),{channel:{method:"GET",path:t},baseUrl:t,environment:r,auth:void 0,pathParameters:{},queryParameters:u.queryParameters,headers:u.headers,messages:u.messages.map(d=>({type:i==="v2"?d.type:d.messageId,body:d.value}))}]))}transformToValidPath(t){return t.startsWith("/")?t:"/"+t}};var HAi=class extends QA.AbstractConverters.AbstractParameterConverter{parameterNamePrefix;constructor({context:t,breadcrumbs:r,parameter:i,parameterNamePrefix:n}){super({context:t,breadcrumbs:r,parameter:i}),this.parameterNamePrefix=n}convert(){let t,r={},n=new pH.FernOptionalExtension({breadcrumbs:this.breadcrumbs,parameter:this.parameter,context:this.context}).convert()??this.parameter.required===!1,a=this.parameter.schema??{...this.parameter,type:"string",enum:this.parameter.enum,default:this.parameter.default,example:this.parameter.example??this.parameter.name,examples:Object.values(this.parameter.examples??{}),deprecated:this.parameter.deprecated,required:void 0},l=new QA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,"schema"],schemaIdOverride:this.parameterNamePrefix?`${this.parameterNamePrefix}_${this.parameter.name}`:this.parameter.name,schemaOrReference:a,wrapAsOptional:n}).convert();return l!=null&&(t=l.type,r=l.inlinedTypes??{}),this.convertToOutput({schema:a,typeReference:t,inlinedTypes:r})}};var Pko=class extends Aj{channel;key="x-fern-address";constructor({breadcrumbs:t,channel:r,context:i}){super({breadcrumbs:t,context:i}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(!(t==null||typeof t!="string"))return t}};var G9n=class extends Aj{channel;key="x-fern-display-name";constructor({breadcrumbs:t,channel:r,context:i}){super({breadcrumbs:t,context:i}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(!(t==null||typeof t!="string"))return t}};var jko=class extends $9n{inlinedTypes={};constructor({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a}){super({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a})}convert(){let t=[],r=[],i=[],a=new G9n({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert()??this.websocketGroup?.join(".");this.channel.parameters&&this.convertPathParameters({context:this.context,pathParameters:t}),this.channel.bindings?.ws!=null&&(this.convertHeaders({context:this.context,headers:i}),this.convertBindingQueryParameters({context:this.context,queryParameters:r}));let u;this.channel.subscribe!=null&&(u=this.convertMessage({context:this.context,operation:this.channel.subscribe,origin:"server"}));let l;this.channel.publish!=null&&(l=this.convertMessage({context:this.context,operation:this.channel.publish,origin:"client"}));let d=[];u!=null&&d.push(u),l!=null&&d.push(l);let o=new Pko({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert(),c=this.transformToValidPath(o??this.channelPath),b=this.channel.servers?.[0]??Object.keys(this.context.spec.servers??{})[0],g=lF(c),O=T_(this.channelPath),m=this.context.getAudiences({operation:this.channel,breadcrumbs:this.breadcrumbs})??[];return{channel:{name:this.context.casingsGenerator.generateName(O),displayName:a,baseUrl:b,path:g,auth:!1,headers:i,queryParameters:r,pathParameters:t,messages:d,availability:this.context.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs}),docs:this.channel.description,examples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples({fullPath:c,baseUrl:b,asyncApiVersion:"v2"})}},audiences:m,inlinedTypes:this.inlinedTypes}}convertMessage({context:t,operation:r,origin:i}){let n,a=i==="server"?"subscribe":"publish",u=[...this.breadcrumbs,a],l=t.resolveMaybeReference({schemaOrReference:r.message,breadcrumbs:u});l!=null&&(r.message=l);let d=qVi(T_(`${this.channelPath}_${a}`)).replace(/ /g,"");if("oneOf"in r.message){let o=new QA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:u,schemaOrReference:r.message,schemaIdOverride:d}).convert();o!=null&&o.schema!=null&&(n=o.schema,this.inlinedTypes={...this.inlinedTypes,...o.inlinedTypes})}else if(t.isMessageWithPayload(r.message)){let s=t.resolveMaybeReference({schemaOrReference:r.message.payload,breadcrumbs:u});if(s!=null){let c=new QA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:u,schemaOrReference:s,schemaIdOverride:d}).convert();c!=null&&c.schema!=null&&(n=c.schema,this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes})}}if(n!=null){let s=n,o=gf.named({fernFilepath:t.createFernFilepath(),name:s.typeDeclaration.name.name,typeId:s.typeDeclaration.name.typeId,displayName:void 0,default:void 0,inline:!1}),c=R9.reference({bodyType:o,docs:r.description}),b=i==="server"?"subscribe":"publish";return{type:b,displayName:b,origin:i,body:c,availability:t.getAvailability({node:r,breadcrumbs:this.breadcrumbs}),docs:r.description}}}convertPathParameters({context:t,pathParameters:r}){for(let[i,n]of Object.entries(this.channel.parameters??{})){let a=t.resolveMaybeReference({schemaOrReference:n,breadcrumbs:this.breadcrumbs});if(a==null)continue;let l=new HAi({context:this.context,breadcrumbs:this.breadcrumbs,parameter:{...a,name:i,in:"path",description:n.description,required:n.required??!0}}).convert();l!=null&&(this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes},l.type==="path"&&r.push(l.parameter))}}convertHeaders({context:t,headers:r}){if(this.channel.bindings?.ws?.headers!=null){let i=this.channel.bindings.ws.headers.required??[];for(let[n,a]of Object.entries(this.channel.bindings.ws.headers.properties??{})){let u=t.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,n]});if(u==null)continue;let d=new HAi({context:this.context,breadcrumbs:[...this.breadcrumbs,n],parameter:{name:n,in:"header",required:i.includes(n),schema:u,description:"description"in u?u.description:void 0}}).convert();d!=null&&d.type==="header"&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},r.push(d.parameter))}}}convertBindingQueryParameters({context:t,queryParameters:r}){if(this.channel.bindings?.ws?.query!=null){let i=this.channel.bindings.ws.query.required??[];for(let[n,a]of Object.entries(this.channel.bindings.ws.query.properties??{})){let u=t.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,n]});if(u==null)continue;let d=new HAi({context:this.context,breadcrumbs:[...this.breadcrumbs,n],parameter:{name:n,in:"query",required:i.includes(n),schema:u,description:"description"in u?u.description:void 0,deprecated:u.deprecated??!1}}).convert();d!=null&&d.type==="query"&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},r.push(d.parameter))}}}};var Q9n=class extends w0{servers;constructor({context:t,breadcrumbs:r,servers:i}){super({context:t,breadcrumbs:r}),this.servers=i}convert(){if(this.servers==null||Object.keys(this.servers).length===0)return;let t=[],r;for(let[i,n]of Object.entries(this.servers)){let a=this.buildSingleBaseUrlEnvironment(this.context,i,n);t.push(a),r==null&&(r=a.id)}return{defaultEnvironment:r,environments:cx.singleBaseUrl({environments:t})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var wko=class extends Q9n{constructor({context:t,breadcrumbs:r,servers:i}){super({context:t,breadcrumbs:r,servers:i})}buildSingleBaseUrlEnvironment(t,r,i){return{id:r,name:t.casingsGenerator.generateName(r),url:this.constructServerUrl(i.protocol,i.url),docs:void 0}}};var kPc="$message.",xB_="#/channels/",RB_="#/servers/",Sko=class extends $9n{operations;inlinedTypes={};constructor({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a,operations:u}){super({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a}),this.operations=u}convert(){let t=[],r=[],i=[],a=new G9n({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert()??this.websocketGroup?.join(".")??this.channelPath;this.channel.parameters&&this.convertChannelParameters({pathParameters:t,queryParameters:r,headers:i,channelPath:this.channelPath});let u=Object.entries(this.operations).reduce((b,[g,O])=>{try{this.getChannelPathFromOperation(O)===this.channelPath&&(b[g]=O)}catch{}return b},{}),l=[];for(let[b,g]of Object.entries(u))for(let O of g.messages){let m=this.context.convertReferenceToTypeReference({reference:O});if(m.ok){let P=R9.reference({bodyType:m.reference,docs:g.description});l.push({type:b,displayName:b,origin:g.action==="send"?"client":"server",body:P,availability:this.context.getAvailability({node:g,breadcrumbs:this.breadcrumbs}),docs:g.description})}}let d=this.resolveChannelServersFromReference(this.channel.servers??[])??Object.keys(this.context.spec.servers??{})[0],s=this.transformToValidPath(this.channel.address??this.channelPath),o=lF(s),c=this.context.getAudiences({operation:this.channel,breadcrumbs:this.breadcrumbs})??[];return{channel:{name:this.context.casingsGenerator.generateName(a),displayName:a,baseUrl:d,path:o,auth:!1,headers:i,queryParameters:r,pathParameters:t,messages:l,availability:this.context.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs}),docs:this.channel.description,examples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples({fullPath:s,baseUrl:d,asyncApiVersion:"v3"})}},audiences:c,inlinedTypes:this.inlinedTypes}}convertChannelParameters({pathParameters:t,queryParameters:r,headers:i,channelPath:n}){for(let a of Object.values(this.channel.parameters??{})){let u=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,"parameters"]});if(u==null)continue;let l=this.convertChannelParameterLocation(a.location);if(l==null)continue;let{type:d,parameterKey:s}=l,c=new HAi({context:this.context,breadcrumbs:this.breadcrumbs,parameter:{...u,name:s,in:d},parameterNamePrefix:this.channelPath}).convert();if(c!=null)switch(this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes},c.type){case"path":t.push(c.parameter);break;case"query":r.push(c.parameter);break;case"header":i.push(c.parameter);break}}}convertChannelParameterLocation(t){try{let[r,i]=t.split("#/");if(r==null||i==null){this.context.errorCollector.collect({message:`Invalid location format: ${t}; unable to parse message type and parameter key`,path:this.breadcrumbs});return}if(!r.startsWith(kPc)){this.context.errorCollector.collect({message:`Invalid location format: ${t}; expected ${kPc} prefix`,path:this.breadcrumbs});return}let n=r.substring(kPc.length);if(n!=="header"&&n!=="path"&&n!=="payload"){this.context.errorCollector.collect({message:`Invalid message type: ${n}. Must be one of: header, path, payload`,path:this.breadcrumbs});return}return n==="payload"?{type:"query",parameterKey:i}:{type:n,parameterKey:i}}catch{this.context.errorCollector.collect({message:`Invalid location format: ${t}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`,path:this.breadcrumbs});return}}resolveChannelServersFromReference(t){if(t==null||t.length===0||t[0]==null)return;let r=t[0];if(!r.$ref.startsWith(RB_)){this.context.errorCollector.collect({message:`Failed to resolve server name from server ref ${r.$ref}`,path:this.breadcrumbs});return}let i=r.$ref.substring(RB_.length);if(i==null){this.context.errorCollector.collect({message:`Failed to find server with name ${i}`,path:this.breadcrumbs});return}return i}getChannelPathFromOperation(t){if(!t.channel.$ref.startsWith(xB_))throw new Error(`Failed to resolve channel path from operation ${t.channel.$ref}`);return t.channel.$ref.substring(xB_.length)}};var Dko=class extends Q9n{constructor({context:t,breadcrumbs:r,servers:i}){super({context:t,breadcrumbs:r,servers:i})}buildSingleBaseUrlEnvironment(t,r,i){return{id:r,name:t.casingsGenerator.generateName(r),url:this.constructServerUrl(i.protocol,i.host),docs:void 0}}};var IRa=class extends Mpi{constructor({context:t,breadcrumbs:r,audiences:i}){super({context:t,breadcrumbs:r,audiences:i})}async convert(){return this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.context.spec=await this.resolveAllExternalRefs({spec:this.context.spec}),this.isAsyncAPIV3(this.context)?this.convertChannelMessages():this.convertComponentMessages(),this.convertSchemas(),this.convertServers(),this.convertChannels(),this.finalizeIr()}isAsyncAPIV3(t){return parseFloat(t.spec.asyncapi)>=3}convertChannelMessages(){let t=this.context.spec;for(let[r,i]of Object.entries(t.channels??{}))for(let[n,a]of Object.entries(i.messages??{})){if(!this.context.isMessageWithPayload(a)&&!this.context.isReferenceObject(a))continue;let u=["channels",r,"messages",n],l=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:u});if(!this.context.isMessageWithPayload(l))continue;let d=this.context.resolveMaybeReference({schemaOrReference:l.payload,breadcrumbs:u});if(d==null)continue;let s=`${r}_${n}`;this.convertSchema({id:s,breadcrumbs:u,schema:d})}}convertComponentMessages(){for(let[t,r]of Object.entries(this.context.spec.components?.messages??{})){if(r.payload==null)continue;let i=["components","messages",t],n=this.context.resolveMaybeReference({schemaOrReference:r.payload,breadcrumbs:i});n!=null&&this.convertSchema({id:t,breadcrumbs:i,schema:n})}}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{}))this.convertSchema({id:t,breadcrumbs:["components","schemas",t],schema:r})}convertSchema({id:t,breadcrumbs:r,schema:i}){let a=new QA.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:r,schema:i}).convert();a!=null&&(this.addTypeToRootPackage(t),this.addTypesToIr({...a.inlinedTypes,[t]:a.convertedSchema}))}convertServers(){let t;if(this.isAsyncAPIV3(this.context)){let r=this.context.spec.servers;t=new Dko({context:this.context,breadcrumbs:["servers"],servers:r}).convert()}else{let r=this.context.spec.servers;t=new wko({context:this.context,breadcrumbs:["servers"],servers:r}).convert()}this.addEnvironmentsToIr({environmentConfig:t})}convertChannels(){for(let[t,r]of Object.entries(this.context.spec.channels??{})){let n=new pH.SdkGroupNameExtension({breadcrumbs:["channels",t],operation:r,context:this.context}).convert()?.groups,a;if(this.isAsyncAPIV3(this.context)){let l=this.context.spec.operations??{};a=new Sko({context:this.context,breadcrumbs:["channels",t],websocketGroup:n,channel:r,channelPath:t,operations:l}).convert()}else a=new jko({context:this.context,breadcrumbs:["channels",t],websocketGroup:n,channel:r,channelPath:t}).convert();a!=null&&(this.addWebsocketChannelToIr({websocketChannel:a.channel,channelPath:t,audiences:a.audiences,websocketGroup:n}),this.addTypesToIr(a.inlinedTypes))}}};var zRa=class extends f8{isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}getTypeIdFromMessageReference(t){let r=t.$ref.match(/\/messages\/(.+)$/);if(!(!r||!r[1]))return r[1]}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n}){let a,u=t.$ref.match(/^.*\/schemas\/(.+)$/),l=t.$ref.match(/^.*\/channels\/([^/]+)\/messages\/(.+)$/),d=t.$ref.match(/^.*\/messages\/(.+)$/);if(u&&u[1])return a=u[1],this.convertSchemaReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a});if(l&&l[2]){let s=l[1],o=l[2];return a=`${s}_${o}`,this.convertV3MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a})}else return d&&d[1]?(a=d[1],this.convertV2MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a})):{ok:!1}}convertSchemaReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a}){let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let l;return n==="reference_identifier"?l=i??u.value.title:(n==="discriminator_key"||n==="schema_identifier")&&(l=u.value.title??i),{ok:!0,reference:gf.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:l,default:void 0,inline:!1})}}convertV3MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a}){let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let l;return n==="reference_identifier"?l=i??u.value.name:(n==="discriminator_key"||n==="schema_identifier")&&(l=u.value.name??i),{ok:!0,reference:gf.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:l,default:void 0,inline:!1})}}convertV2MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a}){let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let l;return n==="reference_identifier"?l=i??u.value.messageId??u.value.name:(n==="discriminator_key"||n==="schema_identifier")&&(l=u.value.messageId??u.value.name??i),{ok:!0,reference:gf.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:l,default:void 0,inline:!1})}}};var UB_=ci(ejc(),1);var ijc=ci(ejc(),1);var NB_=["get","post","put","delete","patch","head"];var Eko=class extends Aj{operation;key="x-fern-idempotent";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-idempotent",path:this.breadcrumbs});return}return t}}};var jJE=hu.object({cursor:hu.string(),next_cursor:hu.string(),results:hu.string()}),wJE=hu.object({offset:hu.string(),results:hu.string(),step:hu.string().optional(),"has-next-page":hu.string().optional()}),tjc=hu.union([hu.boolean(),jJE,wJE]);var rjc="$request.",Mko="$response.",Ako=class extends Aj{operation;document;key="x-fern-pagination";constructor({breadcrumbs:t,operation:r,document:i,context:n}){super({breadcrumbs:t,context:n}),this.operation=r,this.document=i}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=tjc.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-pagination extension: ${r.error.message}`,path:this.breadcrumbs});return}if(typeof r.data=="boolean"){let i=this.getExtensionValue(this.document);if(i==null)return;if(typeof i=="boolean"){this.context.errorCollector.collect({message:"Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.",path:this.breadcrumbs});return}let n=tjc.safeParse(i);if(!n.success){this.context.errorCollector.collect({message:`Invalid x-fern-pagination extension: ${n.error.message}`,path:this.breadcrumbs});return}if(typeof n.data=="boolean"){this.context.errorCollector.collect({message:"Global pagination extension is a boolean, expected an object.",path:this.breadcrumbs});return}return this.convertPaginationConfig({config:n.data})}if(typeof r.data=="boolean"){this.context.errorCollector.collect({message:"Pagination extension is a boolean with no global configuration.",path:this.breadcrumbs});return}return this.convertPaginationConfig({config:r.data})}convertPaginationConfig({config:t}){let r=t;if("cursor"in r)return{type:"cursor",cursor:f8.maybeTrimPrefix(r.cursor,rjc),nextCursor:f8.maybeTrimPrefix(r.next_cursor,Mko),results:f8.maybeTrimPrefix(r.results,Mko)};let i=t;return{type:"offset",offset:f8.maybeTrimPrefix(i.offset,rjc),results:f8.maybeTrimPrefix(i.results,Mko),step:i.step!=null?f8.maybeTrimPrefix(i.step,rjc):void 0,hasNextPage:i["has-next-page"]!=null?f8.maybeTrimPrefix(i["has-next-page"],Mko):void 0}}};var SJE="$request.",DJE=hu.object({"stream-condition":hu.string().optional(),format:hu.enum(["sse","json"]).optional(),"stream-description":hu.string().optional(),"response-stream":hu.any(),response:hu.any()}),EJE=hu.union([hu.boolean(),DJE]),qko=class extends Aj{operation;key="x-fern-streaming";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=EJE.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-streaming extension: ${r.error.message}`,path:this.breadcrumbs});return}if(typeof r.data=="boolean")return r.data?{type:"stream",format:"json"}:void 0;if(r.data["stream-condition"]==null&&r.data.format!=null)return{type:"stream",format:r.data.format};if(r.data["stream-condition"]==null){this.context.errorCollector.collect({message:"Missing stream-condition property without specified format.",path:this.breadcrumbs});return}return{type:"streamCondition",format:r.data.format??"json",streamDescription:r.data["stream-description"],streamConditionProperty:f8.maybeTrimPrefix(r.data["stream-condition"],SJE),responseStream:r.data["response-stream"],response:r.data.response}}};var Tko=class extends Aj{operation;key="x-fern-webhook";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-webhook",path:this.breadcrumbs});return}return t}}};var Cko=class extends Aj{operation;key="x-fern-examples";constructor({context:t,breadcrumbs:r,operation:i}){super({breadcrumbs:r,context:t}),this.operation=i}convert(){let t=this.getExtensionValue(this.operation);return t==null?void 0:(Array.isArray(t)?t:[]).filter(n=>{let a=JN.serialization.ExampleEndpointCallSchema.parse(n);return a.ok||this.context.errorCollector.collect({message:`Failed to parse x-fern-example in ${this.breadcrumbs.join(".")}`,path:this.breadcrumbs}),a.ok})}};var Bko=class extends QA.AbstractConverters.AbstractMediaTypeObjectConverter{responseBody;statusCode;streamingExtension;constructor({context:t,breadcrumbs:r,responseBody:i,group:n,method:a,statusCode:u,streamingExtension:l}){super({context:t,breadcrumbs:r,group:n,method:a}),this.responseBody=i,this.statusCode=u,this.streamingExtension=l}convert(){return this.shouldConvertAsStreaming()?this.convertStreaming():this.convertNonStreaming()}convertStreaming(){if(this.streamingExtension==null)return;let t=[...this.group,this.method,"Response",this.statusCode].join("_"),r=Object.keys(this.responseBody.content??{});for(let i of r){let n=this.responseBody.content?.[i];if(n==null)continue;let a=this.parseMediaTypeObject({mediaTypeObject:n,schemaId:t,contentType:this.streamingExtension.format});if(a!=null)return this.convertStreamingResponse({mediaTypeObject:n,convertedSchema:a})}}convertNonStreaming(){let t=[...this.group,this.method,"Response",this.statusCode].join("_"),r=Object.keys(this.responseBody.content??{}).filter(n=>n.includes("json"));for(let n of r){let a=this.responseBody.content?.[n];if(a==null)continue;let u=this.parseMediaTypeObject({mediaTypeObject:a,schemaId:t,contentType:n});if(u!=null&&this.shouldReturnJsonResponse(n))return this.returnJsonResponse({mediaTypeObject:a,convertedSchema:u})}let i=Object.keys(this.responseBody.content??{}).filter(n=>!n.includes("json"));for(let n of i){let a=this.responseBody.content?.[n];if(a==null)continue;let u=this.parseMediaTypeObject({mediaTypeObject:a,schemaId:t,contentType:n});if(u!=null){if(this.isBinarySchema(u))return this.shouldReturnBytesResponse()?this.returnBytesResponse({mediaTypeObject:a}):this.returnFileDownloadResponse({mediaTypeObject:a});if(this.shouldReturnTextResponse(n))return this.returnTextResponse({mediaTypeObject:a})}}}convertStreamingResponse({mediaTypeObject:t,convertedSchema:r}){if(this.streamingExtension==null)return;switch(this.streamingExtension.format){case"json":return{responseBody:gE.streaming(SW.json({docs:this.responseBody.description,payload:r.type,terminator:void 0,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples};case"sse":return{responseBody:gE.streaming(SW.sse({docs:this.responseBody.description,payload:r.type,terminator:void 0,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples};default:return}}returnJsonResponse({mediaTypeObject:t,convertedSchema:r}){return{responseBody:gE.json(AZ.response({responseBodyType:r.type,docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples}}returnBytesResponse({mediaTypeObject:t}){return{responseBody:gE.bytes({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}returnFileDownloadResponse({mediaTypeObject:t}){return{responseBody:gE.fileDownload({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}returnTextResponse({mediaTypeObject:t}){return{responseBody:gE.text({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}isBinarySchema(t){let r=t.type;switch(r.type){case"container":case"named":case"unknown":return!1;case"primitive":return r.primitive.v2==null?!1:r.primitive.v2.type==="string"&&r.primitive.v2.validation?.format==="binary";default:return!1}}shouldConvertAsStreaming(){return this.streamingExtension!=null}shouldReturnJsonResponse(t){return t.includes("json")}shouldReturnBytesResponse(){return(this.context.settings?.useBytesForBinaryResponse??!1)&&this.streamingExtension==null}shouldReturnTextResponse(t){return mM.parse(t)?.isText()??!1}};var Iko=class extends QA.AbstractConverters.AbstractMediaTypeObjectConverter{responseError;statusCode;methodName;constructor({context:t,breadcrumbs:r,responseError:i,group:n,method:a,methodName:u,statusCode:l}){super({context:t,breadcrumbs:r,group:n,method:a}),this.responseError=i,this.statusCode=l,this.methodName=u}convert(){if(!this.responseError.content){let i=BRa[this.statusCode];if(i==null){this.context.logger.warn(`No error name found for status code ${this.statusCode}`);return}let n=this.getErrorIdFromErrorName(i);return{error:{error:{name:this.context.casingsGenerator.generateName(n),fernFilepath:{allParts:[],packagePath:[],file:void 0},errorId:n},docs:this.responseError.description},errorType:gf.unknown(),displayName:i,statusCode:this.statusCode,inlinedTypes:{},examples:{}}}let t=Object.keys(this.responseError.content).filter(i=>i.includes("json")),r=BRa[this.statusCode];if(r==null){this.context.logger.warn(`No error name found for status code ${this.statusCode}`);return}for(let i of[...t]){let n=this.responseError.content?.[i];if(n==null)continue;let a=this.parseMediaTypeObject({mediaTypeObject:n,schemaId:FB_(`${this.methodName}Request${r}`),contentType:i});if(a==null)continue;let u=this.getErrorIdFromErrorName(r);if(a.schema!=null)return this.constructErrorConverterOutput({errorName:r,errorId:u,fernFilepath:a.schema.typeDeclaration.name.fernFilepath,convertedSchema:a});if(a.type.type==="named")return this.constructErrorConverterOutput({errorName:r,errorId:u,fernFilepath:a.type.fernFilepath,convertedSchema:a})}}constructErrorConverterOutput({errorName:t,errorId:r,fernFilepath:i,convertedSchema:n}){return{error:{error:{name:this.context.casingsGenerator.generateName(r),fernFilepath:i,errorId:r},docs:this.responseError.description},errorType:n.type,displayName:t,statusCode:this.statusCode,inlinedTypes:n.inlinedTypes,examples:n.examples}}getErrorIdFromErrorName(t){return this.context.enableUniqueErrorsPerEndpoint?FB_(`${this.methodName}Request${t}`):t}};function FB_(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}var zko=class extends QA.AbstractConverters.AbstractParameterConverter{constructor({context:t,breadcrumbs:r,parameter:i}){super({context:t,breadcrumbs:r,parameter:i})}convert(){let t,r={};if(this.parameter.schema!=null){let i=this.context.convertBreadcrumbsToName([...this.breadcrumbs,this.parameter.name]),a=new QA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required,schemaIdOverride:i}).convert();a!=null&&(t=a.type,r=a.inlinedTypes??{})}return this.convertToOutput({schema:this.parameter.schema??{type:"string"},typeReference:t,inlinedTypes:r})}};var xko=class extends QA.AbstractConverters.AbstractMediaTypeObjectConverter{requestBody;schemaId;streamingExtension;constructor({context:t,breadcrumbs:r,requestBody:i,group:n,method:a,streamingExtension:u}){super({context:t,breadcrumbs:r,group:n,method:a}),this.requestBody=i,this.schemaId=[...this.group,this.method,"Request"].join("_"),this.streamingExtension=u}convert(){if(!this.requestBody.content)return;let t=Object.keys(this.requestBody.content).filter(u=>mM.parse(u)?.isJSON());for(let u of t){let l=this.handleJsonOrFormContent({contentType:u});if(l!=null)return l}let r=Object.keys(this.requestBody.content).filter(u=>mM.parse(u)?.isURLEncoded());for(let u of r){let l=this.handleJsonOrFormContent({contentType:u});if(l!=null)return l}let i=Object.keys(this.requestBody.content).filter(u=>mM.parse(u)?.isPlainText());for(let u of i){let l=this.handleJsonOrFormContent({contentType:u});if(l!=null)return l}let n=Object.keys(this.requestBody.content).filter(u=>mM.parse(u)?.isMultipart());for(let u of n){let l=this.handleMultipartContent({contentType:u});if(l!=null)return l}let a=Object.keys(this.requestBody.content).filter(u=>mM.parse(u)?.isOctetStream());for(let u of a){let l=this.handleOctetStreamContent({contentType:u});if(l!=null)return l}}handleJsonOrFormContent({contentType:t}){let r=this.requestBody.content[t];if(r==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,contentType:t});if(i!=null)return i.schema?.typeDeclaration.shape.type==="object"?{requestBody:ZC.inlinedRequestBody({contentType:t,docs:this.requestBody.description,name:this.context.casingsGenerator.generateName(this.schemaId),extendedProperties:i.schema?.typeDeclaration.shape.extendedProperties,extends:i.schema?.typeDeclaration.shape.extends,properties:i.schema?.typeDeclaration.shape.properties,extraProperties:i.schema?.typeDeclaration.shape.extraProperties,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:i.inlinedTypes})}:{requestBody:ZC.reference({contentType:t,docs:this.requestBody.description,requestBodyType:i.type,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:i.inlinedTypes??{}}}handleMultipartContent({contentType:t}){let r=this.requestBody.content[t];if(r==null||r.schema==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,resolveSchema:!0,contentType:t});if(i!=null&&i.schema?.typeDeclaration.shape.type==="object")return{requestBody:ZC.fileUpload({contentType:t,docs:this.requestBody.description,name:this.context.casingsGenerator.generateName(this.schemaId),properties:i.schema?.typeDeclaration.shape.properties.map(n=>this.convertRequestBodyProperty({property:n,contentType:t})),v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:i.inlinedTypes}),examples:i.examples}}handleOctetStreamContent({contentType:t}){let r=this.requestBody.content[t];if(r==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,contentType:t});return{requestBody:ZC.bytes({contentType:t,isOptional:this.requestBody.required===!1,docs:this.requestBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:i?.inlinedTypes??{}}}convertRequestBodyProperty({property:t,contentType:r}){let{isFile:i,isOptional:n,isArray:a}=this.recursivelyCheckTypeReferenceIsFile({typeReference:t.valueType});return i?a?z9.file(Qne.fileArray({key:t.name,isOptional:n,contentType:r,docs:t.docs})):z9.file(Qne.file({key:t.name,isOptional:n,contentType:r,docs:t.docs})):z9.bodyProperty({...t,contentType:r,style:void 0,name:t.name})}recursivelyCheckTypeReferenceIsFile({typeReference:t,isOptional:r,isArray:i}){return this.context.isList(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.list,isOptional:r,isArray:!0}):this.context.isOptional(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.optional,isOptional:!0,isArray:i}):this.context.isNullable(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.nullable,isOptional:r,isArray:i}):{isFile:this.context.isFile(t),isOptional:r??!1,isArray:i??!1}}};var MJE=/{([^}]+)}/g,AJE=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]),J9n=class extends w0{operation;method;path;inlinedTypes={};constructor({context:t,breadcrumbs:r,operation:i,method:n,path:a}){super({context:t,breadcrumbs:r}),this.operation=i,this.method=n,this.path=a}convertHttpMethod(){switch(this.method){case"get":return lR.Get;case"post":return lR.Post;case"put":return lR.Put;case"delete":return lR.Delete;case"patch":return lR.Patch;case"head":return lR.Head;default:return}}convertParameters({breadcrumbs:t}){let r=[],i=[],n=[];if(!this.operation.parameters)return this.checkMissingPathParameters(r),{pathParameters:r,queryParameters:i,headers:n};for(let a of this.operation.parameters){let u=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:t});if(u==null)continue;let d=new zko({context:this.context,breadcrumbs:t,parameter:u}).convert();if(d!=null)switch(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},d.type){case"path":r.push(d.parameter);break;case"query":i.push(d.parameter);break;case"header":{let s=d.parameter.name.name.originalName,o=d.parameter.name.wireValue,c=!1,b=this.context.authOverrides?.["auth-schemes"];if(b!=null){for(let g of Object.values(b))if(BJE(g)&&g.header.toLowerCase()===o.toLowerCase()){c=!0;break}}!AJE.has(s.toLowerCase())&&!c&&n.push(d.parameter);break}}}return this.checkMissingPathParameters(r),{pathParameters:r,queryParameters:i,headers:n}}checkMissingPathParameters(t){let i=[...this.path.matchAll(MJE)].map(n=>n[1]).filter(n=>!t.some(a=>a.name.originalName===n));for(let n of i){if(n==null)continue;let a=`${n}_example`;t.push({name:this.context.casingsGenerator.generateName(n),valueType:w0.STRING,docs:void 0,location:"ENDPOINT",variable:void 0,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{[a]:this.generateStringParameterExample({example:n})}}})}}convertRequestBody({breadcrumbs:t,group:r,method:i,streamingExtension:n}){if(this.operation.requestBody==null)return;let a=this.context.resolveMaybeReference({schemaOrReference:this.operation.requestBody,breadcrumbs:t});if(a==null)return null;let l=new xko({context:this.context,breadcrumbs:t,requestBody:a,group:r??[],method:i,streamingExtension:n}).convert();if(l!=null)return this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes},{value:l.requestBody,examples:l.examples}}computeGroupNameAndLocationFromExtensions(){let r=new pH.SdkMethodNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert()?.methodName,n=new pH.SdkGroupNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert()?.groups??[];if(r!=null)return{group:n,method:r}}evaluateMethodNameFromOperation(){let t=this.operation.operationId;return t??(this.operation.summary!=null?T_(this.operation.summary):T_(`${this.method}_${this.path.split("/").join("_")}`))}computeGroupNameFromTagAndOperationId(){let t=this.operation.tags?.[0],r=this.evaluateMethodNameFromOperation();if(t==null)return{method:r};let i=LB_(t),n=LB_(r);return OEe(i,n)?{method:t}:this.computeGroupAndMethodFromTokens({tag:t,tagTokens:i,methodName:r,methodNameTokens:n})}computeGroupAndMethodFromTokens({tag:t,tagTokens:r,methodName:i,methodNameTokens:n}){if(r.some((l,d)=>l!==n[d]))return{group:[t],method:i};let u=n.slice(r.length);return{group:[t],method:T_(u.join("_"))}}generateStringParameterExample({example:t}){let r=new QA.ExampleConverter({breadcrumbs:this.breadcrumbs,context:this.context,schema:{type:"string"},example:t}),{validExample:i}=r.convert();return i}};function LB_(e){let t=qJE(e)?TJE(e):CJE(e);return t=t.map(r=>r.toLowerCase()),t=Sxe(t),t}function qJE(e){return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)}function TJE(e){return e.split(/(?=[A-Z])/)}function CJE(e){return e.split(/[^a-zA-Z0-9]+/)}function BJE(e){return e?.header!=null}var Rko=class e extends J9n{idempotent;idToAuthScheme;topLevelServers;streamingExtension;static AUTHORIZATION_HEADER="Authorization";constructor({context:t,breadcrumbs:r,operation:i,method:n,path:a,idempotent:u,idToAuthScheme:l,topLevelServers:d,streamingExtension:s}){super({context:t,breadcrumbs:r,operation:i,method:n,path:a}),this.idempotent=u,this.idToAuthScheme=l,this.topLevelServers=d,this.streamingExtension=s}convert(){let t=this.convertHttpMethod();if(t==null)return;let{group:r,method:i}=this.computeGroupNameAndLocationFromExtensions()??this.computeGroupNameFromTagAndOperationId(),{headers:n,pathParameters:a,queryParameters:u}=this.convertParameters({breadcrumbs:[...this.breadcrumbs,"parameters"]}),l=this.convertRequestBody({breadcrumbs:[...this.breadcrumbs,"requestBody"],group:r,method:i,streamingExtension:this.streamingExtension}),d=l?.value,s=this.convertResponseBody({breadcrumbs:[...this.breadcrumbs,"responses"],group:r,method:i,streamingExtension:this.streamingExtension}),o=s?.response,c=s?.streamResponse,b=s!=null?s.errors:[],g={},O=b.map(I=>I.error),m=lF(this.path),P=this.getEndpointBaseUrl(),E=this.getEndpointBaseUrls(),q=this.convertExamples({httpPath:m,httpMethod:t,baseUrl:P}),M=new Set(this.operation.security?.flatMap(I=>Object.keys(I))??[]),D=this.authSchemeToHeaders(Array.from(M));D.length>0&&n.push(...D);for(let I of b){let L=I.error,V=I.errorType,X=L.error.errorId;g[X]={name:L.error,displayName:I.displayName,discriminantValue:{name:L.error.name,wireValue:X},type:V,statusCode:I.statusCode,docs:L.docs,examples:[],v2Examples:void 0}}let C={displayName:this.operation.summary,method:t,name:this.context.casingsGenerator.generateName(i),baseUrl:P,v2BaseUrls:E,path:m,pathParameters:a,queryParameters:u,headers:n.filter((I,L,V)=>L===V.findIndex(X=>X.name.wireValue===I.name.wireValue)),requestBody:d,sdkRequest:void 0,errors:O,auth:this.operation.security!=null||this.context.spec.security!=null,availability:this.context.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs}),docs:this.operation.description,userSpecifiedExamples:[],autogeneratedExamples:[],idempotent:this.idempotent??!1,basePath:void 0,fullPath:m,allPathParameters:a,pagination:void 0,transport:void 0,v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:q},source:Gne.openapi()},x=this.context.namespace!=null?[this.context.namespace]:[],$=r?.map(I=>T_(I));return x.push(...$??[]),{audiences:this.context.getAudiences({operation:this.operation,breadcrumbs:this.breadcrumbs})??[],group:r,errors:g,endpoint:{id:`endpoint_${x.join("/")}.${i}`,...C,response:o},streamEndpoint:c!=null&&c.body!=null?{id:`endpoint_${x.join("/")}.${i}_stream`,...C,response:c}:void 0,inlinedTypes:this.inlinedTypes,servers:this.filterOutTopLevelServers(this.operation.servers??[])}}convertResponseBody({breadcrumbs:t,group:r,method:i,streamingExtension:n}){if(this.operation.responses==null)return;let a,u=!1;for(let[l,d]of Object.entries(this.operation.responses)){let s=parseInt(l);if(!(isNaN(s)||s<200||s>=300&&s<400)){if(a==null&&(a={response:void 0,streamResponse:void 0,errors:[],examples:{}}),s>=200&&s<300&&!u){let o=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:[...t,l]});if(o==null)continue;let b=new Bko({context:this.context,breadcrumbs:[...t,l],responseBody:o,group:r??[],method:i,statusCode:l,streamingExtension:n}).convert();b!=null&&(u=!0,this.inlinedTypes={...this.inlinedTypes,...b.inlinedTypes},a.response={statusCode:s,body:b.responseBody},a.streamResponse={statusCode:s,body:b.streamResponseBody})}if(s>=400&&s<600){let o=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:[...t,l]});if(o==null)continue;let b=new Iko({context:this.context,breadcrumbs:[...t,l],responseError:o,group:r??[],method:i,methodName:this.evaluateMethodNameFromOperation(),statusCode:s}).convert();b!=null&&(this.inlinedTypes={...this.inlinedTypes,...b.inlinedTypes},a.errors.push(b))}}}return a}authSchemeToHeaders(t){let r=[];for(let i of t){let n=this.idToAuthScheme?.[i];if(n==null)continue;let a={valueType:w0.STRING,availability:void 0,docs:void 0,env:void 0,v2Examples:void 0};switch(n.type){case"bearer":r.push({name:{name:this.context.casingsGenerator.generateName(e.AUTHORIZATION_HEADER),wireValue:e.AUTHORIZATION_HEADER},...a});break;case"basic":r.push({name:{name:this.context.casingsGenerator.generateName(e.AUTHORIZATION_HEADER),wireValue:e.AUTHORIZATION_HEADER},...a});break;case"header":r.push({name:n.name,...a});break}}return r}convertExamples({httpPath:t,httpMethod:r,baseUrl:i}){let a=new Cko({context:this.context,breadcrumbs:this.breadcrumbs,operation:this.operation}).convert();return a==null?{}:Object.fromEntries(a.map((u,l)=>[u.name??`Example_${l}`,{request:u.request!=null?{docs:void 0,endpoint:{method:r,path:this.buildExamplePath(t,u["path-parameters"]??{})},baseUrl:void 0,environment:i,auth:void 0,pathParameters:u["path-parameters"]??{},queryParameters:u["query-parameters"]??{},headers:u.headers??{},requestBody:u.request}:void 0,response:u.response!=null?{docs:void 0,statusCode:void 0,body:Ws.V2HttpEndpointResponseBody.json(u.response)}:void 0,codeSamples:u["code-samples"]?.map(d=>({docs:void 0,language:("language"in d?d.language:d.sdk)??void 0,code:d.code}))}]))}getEndpointBaseUrl(){let t=this.operation.servers?.[0];if(t==null)return;let i=this.topLevelServers?.find(n=>n.url===t.url)??t;return EHt.getServerName({server:i,context:this.context})}getEndpointBaseUrls(){let t=this.operation.servers;return t?.map(i=>{let a=this.topLevelServers?.find(u=>u.url===i.url)??i;return EHt.getServerName({server:a,context:this.context})})}buildExamplePath(t,r){return t.head+t.parts.map(i=>`${r[i.pathParameter]??i.pathParameter}${i.tail}`).join("")}filterOutTopLevelServers(t){return t.filter(r=>!this.topLevelServers?.some(i=>i.url===r.url))}};var K9n=class extends J9n{constructor({context:t,breadcrumbs:r,operation:i,method:n,path:a}){super({context:t,breadcrumbs:r,operation:i,method:n,path:a})}convert(){if(this.operation.requestBody==null){this.context.errorCollector.collect({message:"Skipping webhook because no request body present",path:this.breadcrumbs});return}let t=this.convertHttpMethod();if(t==null)return;if(t!=="POST"&&t!=="GET"){this.context.errorCollector.collect({message:"Skipping webhook because non-POST or GET method",path:this.breadcrumbs});return}let{group:r,method:i}=this.computeGroupNameAndLocationFromExtensions()??this.computeGroupNameFromTagAndOperationId(),n=[...this.breadcrumbs,"Payload"],{headers:a}=this.convertParameters({breadcrumbs:n}),u=this.convertRequestBody({breadcrumbs:n,group:r,method:i,streamingExtension:void 0}),l;if(u?.value.type==="inlinedRequestBody")l=EW.inlinedPayload({name:u.value.name,extends:u.value.extends,properties:u.value.properties});else if(u?.value.type==="reference")l=EW.reference({payloadType:u.value.requestBodyType,docs:u.value.docs});else return;return{audiences:this.context.getAudiences({operation:this.operation,breadcrumbs:this.breadcrumbs})??[],group:r,webhook:{id:`${r?.join(".")??""}.${i}`,name:this.context.casingsGenerator.generateName(i),displayName:this.operation.summary,method:t,headers:a,payload:l,examples:[],availability:this.context.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs}),docs:this.operation.description,v2Examples:void 0},inlinedTypes:this.inlinedTypes}}};var Nko=class extends w0{pathItem;path;idToAuthScheme;topLevelServers;constructor({context:t,breadcrumbs:r,pathItem:i,path:n,idToAuthScheme:a,topLevelServers:u}){super({context:t,breadcrumbs:r}),this.pathItem=i,this.path=n,this.idToAuthScheme=a,this.topLevelServers=u}convert(){let t=[],r=[],i={};for(let n of NB_){let a=this.pathItem[n];if(a==null)continue;let u=[...this.breadcrumbs,n],l=this.tryParseAsWebhook({operationBreadcrumbs:u,operation:a,method:n,context:this.context});if(l!=null){r.push(l),Object.assign(i,l.inlinedTypes);continue}let s=new qko({breadcrumbs:u,operation:a,context:this.context}).convert(),o=this.tryParseAsHttpEndpoint({operationBreadcrumbs:u,operation:a,method:n,streamingExtension:s});o!=null&&(t.push(o),Object.assign(i,o.inlinedTypes))}return{endpoints:t,webhooks:r,inlinedTypes:i}}tryParseAsWebhook({operation:t,method:r,operationBreadcrumbs:i,context:n}){return new Tko({breadcrumbs:i,operation:t,context:n}).convert()?new K9n({context:this.context,breadcrumbs:i,operation:t,method:ijc.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path}).convert():void 0}tryParseAsHttpEndpoint({operation:t,method:r,operationBreadcrumbs:i,streamingExtension:n}){new Ako({breadcrumbs:i,operation:t,document:this.context.spec,context:this.context}).convert()!=null;let d=new Eko({breadcrumbs:i,operation:t,context:this.context}).convert();return new Rko({context:this.context,breadcrumbs:i,operation:t,method:ijc.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path,idempotent:d,idToAuthScheme:this.idToAuthScheme,topLevelServers:this.topLevelServers,streamingExtension:n}).convert()}};var Fko=class extends w0{securityScheme;constructor({context:t,breadcrumbs:r,securityScheme:i}){super({context:t,breadcrumbs:r}),this.securityScheme=i}convert(){switch(this.securityScheme.type){case"http":{if(this.securityScheme.scheme==="bearer")return CB.bearer({token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description});if(this.securityScheme.scheme==="basic")return CB.basic({username:this.context.casingsGenerator.generateName("username"),password:this.context.casingsGenerator.generateName("password"),usernameEnvVar:void 0,passwordEnvVar:void 0,docs:this.securityScheme.description});break}case"apiKey":{if(this.securityScheme.in==="header")return CB.header({name:{name:this.context.casingsGenerator.generateName(this.securityScheme.name),wireValue:this.securityScheme.name},valueType:w0.OPTIONAL_STRING,prefix:void 0,headerEnvVar:void 0,docs:this.securityScheme.description});break}case"oauth2":return CB.bearer({token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description})}}};var xRa=class extends Mpi{constructor({breadcrumbs:t,context:r,audiences:i}){super({breadcrumbs:t,context:r,audiences:i})}async convert(){this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.context.spec=await this.resolveAllExternalRefs({spec:this.context.spec});let t=this.convertSecuritySchemes();this.convertSchemas(),this.convertWebhooks();let{endpointLevelServers:r,errors:i}=this.convertPaths({idToAuthScheme:t});this.addErrorsToIr(i);let{defaultUrl:n}=this.convertServers({endpointLevelServers:r});return this.updateEndpointsWithDefaultUrl(n),this.finalizeIr()}convertSecuritySchemes(){if(this.context.authOverrides)return this.addAuthToIR(GPc({rawApiFileSchema:this.context.authOverrides,casingsGenerator:this.context.casingsGenerator})),{};let t={},r=[];for(let[i,n]of Object.entries(this.context.spec.components?.securitySchemes??{})){let a=this.context.resolveMaybeReference({schemaOrReference:n,breadcrumbs:["components","securitySchemes",i]});if(a==null)continue;let l=new Fko({context:this.context,breadcrumbs:["components","securitySchemes",i],securityScheme:a}).convert();l!=null&&(this.shouldAddAuthSchemeToIr({authScheme:l,schemeId:i,currentSecuritySchemes:r})?r.push(l):t[i]=l)}return r.length>0&&this.addAuthToIR({requirement:r.length===1?"ALL":"ANY",schemes:r,docs:void 0}),t}convertServers({endpointLevelServers:t}){if(this.context.environmentOverrides){let n=qRa({rawApiFileSchema:this.context.environmentOverrides,casingsGenerator:this.context.casingsGenerator});return n!=null&&this.addEnvironmentsToIr({environmentConfig:n.environmentsConfig,audiences:n.audiences}),{defaultUrl:this.context.environmentOverrides["default-url"]}}let i=new EHt({context:this.context,breadcrumbs:["servers"],servers:this.context.spec.servers,endpointLevelServers:t}).convert();return this.addEnvironmentsToIr({environmentConfig:i?.value}),{defaultUrl:i?.defaultUrl}}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{})){let n=new QA.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:["components","schemas",t],schema:r}).convert();n!=null&&(this.addTypeToPackage(t),this.addTypesToIr({...n.inlinedTypes,[t]:n.convertedSchema}))}}convertWebhooks(){for(let[,t]of Object.entries(this.context.spec.webhooks??{})){if(t==null){this.context.errorCollector.collect({message:"Skipping empty webhook",path:this.breadcrumbs});continue}if(!("post"in t)){this.context.errorCollector.collect({message:"Skipping webhook as it is not a POST method",path:this.breadcrumbs});continue}if(t.post?.operationId==null){this.context.errorCollector.collect({message:"Skipping webhook as no operationId is present",path:this.breadcrumbs});continue}let r=t.post.operationId,n=new K9n({context:this.context,breadcrumbs:["webhooks",r],operation:t.post,method:UB_.OpenAPIV3.HttpMethods.POST,path:r}).convert();n!=null&&(this.addWebhookToIr({webhook:n.webhook,operationId:r,audiences:n.audiences,group:n.group}),this.addTypesToIr(n.inlinedTypes))}}convertPaths({idToAuthScheme:t}){let r=[],i={};for(let[n,a]of Object.entries(this.context.spec.paths??{})){if(a==null)continue;let l=new Nko({context:this.context,breadcrumbs:["paths",n],topLevelServers:this.context.spec.servers,pathItem:a,path:n}).convert();if(l!=null){for(let d of l.endpoints){if(this.addEndpointToIr({endpoint:d.endpoint,audiences:d.audiences,endpointGroup:d.group}),d.streamEndpoint!=null&&this.addEndpointToIr({endpoint:d.streamEndpoint,audiences:d.audiences,endpointGroup:d.group}),d.servers)for(let s of d.servers)this.shouldAddServerToCollectedServers({server:s,currentServers:r})&&r.push(s);if(d.errors)for(let[s,o]of Object.entries(d.errors))i[s]=o}for(let d of l.webhooks){let s=this.context.getGroup({groupParts:d.group,namespace:this.context.namespace});this.addWebhookToIr({webhook:d.webhook,operationId:s.join("."),group:s,audiences:d.audiences})}this.addTypesToIr(l.inlinedTypes)}}return{endpointLevelServers:r,errors:i}}shouldAddAuthSchemeToIr({authScheme:t,schemeId:r,currentSecuritySchemes:i}){let n=i.some(u=>u.type===t.type&&u.type==="bearer"&&t.type==="bearer"?u.token===t.token:!1),a=new Set(this.context.spec.security?.flatMap(u=>Object.keys(u))??[]);return(a.size===0||a.has(r))&&!n}};var RRa=class extends f8{isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n}){let a=this.getTypeIdFromSchemaReference(t);if(a==null)return{ok:!1};let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let l;return n==="reference_identifier"?l=i??u.value.title:(n==="discriminator_key"||n==="schema_identifier")&&(l=u.value.title??i),{ok:!0,reference:gf.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,default:void 0,inline:!1,displayName:l})}}};var Lko=class extends QA.AbstractConverters.AbstractParameterConverter{constructor({context:t,breadcrumbs:r,parameter:i}){super({context:t,breadcrumbs:r,parameter:i})}convert(){let t,r={};if(this.parameter.schema!=null){let n=new QA.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required}).convert();n!=null&&(t=n.type,r=n.inlinedTypes??{})}return this.convertToOutput({schema:this.parameter.schema??{type:"string"},typeReference:t,inlinedTypes:r})}};var IJE=hu.object({description:hu.string().optional(),required:hu.boolean().optional(),deprecated:hu.boolean().optional(),allowEmptyValue:hu.boolean().optional(),style:hu.string().optional(),explode:hu.boolean().optional(),allowReserved:hu.boolean().optional(),schema:hu.any().optional(),example:hu.any().optional(),examples:hu.record(hu.string(),hu.any()).optional(),content:hu.record(hu.string(),hu.any()).optional()}),zJE=IJE.extend({name:hu.string(),in:hu.string()}),xJE=hu.array(zJE),Uko=class extends Aj{operation;key="x-fern-parameters";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null)try{return xJE.parse(t)}catch(r){this.context.errorCollector.collect({message:`Failed to parse x-fern-parameters extension: ${r instanceof Error?r.message:String(r)}`,path:this.breadcrumbs});return}}};var Vko=class extends w0{method;pathParameters;queryParameters;headers;constructor({context:t,breadcrumbs:r,method:i,pathParameters:n=[],queryParameters:a=[],headers:u=[]}){super({context:t,breadcrumbs:r}),this.method=i,this.pathParameters=n,this.queryParameters=a,this.headers=u}convert(){let t={},r="";for(let d of this.pathParameters)r+=`/{${d.name.originalName}}`;let i=lF(r),n=[];for(let[d,s]of this.method.params.entries()){let o;if(this.context.isReferenceObject(s)){let O=this.context.resolveReference({reference:s});if(O.resolved)o=O.value;else continue}else o=s;let c=[this.method.name,"Param",o.name].join("_"),g=new QA.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[this.method.name,"Param",o.name],schemaIdOverride:c,context:this.context,schemaOrReference:o.schema,wrapAsOptional:!o.required}).convert();g!=null&&(n.push({docs:o.description,availability:this.context.getAvailability({node:s,breadcrumbs:[...this.breadcrumbs,"parameters"]}),name:this.context.casingsGenerator.generateNameAndWireValue({name:o.name,wireValue:o.name}),valueType:g.type,v2Examples:g.schema?.typeDeclaration.v2Examples}),t={...g.inlinedTypes,...t,...g.schema!=null?{[c]:g.schema}:{}})}let a;if(this.method.result!=null){let d=this.context.resolveMaybeReference({schemaOrReference:this.method.result,breadcrumbs:[...this.breadcrumbs,"result"]});if(d!=null){let s=new QA.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[this.method.name,"result"],context:this.context,schemaOrReference:d.schema}),o=[this.method.name,"Result"].join("_"),c=s.convert();c!=null&&(a={docs:d.description,v2Examples:c.schema?.typeDeclaration.v2Examples,responseBodyType:c.type},t={...c.inlinedTypes,...t,...c.schema!=null?{[o]:c.schema}:{}})}}let u=this.context.getAudiences({operation:this.method,breadcrumbs:this.breadcrumbs})??[];return{endpoint:{baseUrl:void 0,v2BaseUrls:void 0,basePath:void 0,auth:!1,method:"POST",id:this.method.name,docs:this.method.description,name:this.context.casingsGenerator.generateName(this.method.name),headers:this.headers,displayName:this.method.name,pathParameters:this.pathParameters,queryParameters:this.queryParameters,allPathParameters:this.pathParameters,path:i,fullPath:i,requestBody:n.length>0?ZC.inlinedRequestBody({name:this.context.casingsGenerator.generateName([this.method.name,"Request"].join("_")),docs:void 0,properties:n,extends:[],extendedProperties:[],contentType:"application/json",extraProperties:!1,v2Examples:void 0}):void 0,sdkRequest:void 0,response:a!=null?{body:gE.json(AZ.response(a)),statusCode:void 0}:void 0,errors:[],idempotent:!1,pagination:void 0,userSpecifiedExamples:[],autogeneratedExamples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples()},transport:void 0,availability:void 0,source:Gne.openrpc()},audiences:u,inlinedTypes:t}}convertExamples(){let t={},r=0;if(this.method.examples&&this.method.examples.length>0){for(let i of this.method.examples??[]){let n;if(this.context.isReferenceObject(i)){let d=this.context.resolveReference({reference:i});if(d.resolved)n=d.value;else continue}else n=i;let a;if(n.result)if(this.context.isReferenceObject(n.result)){let d=this.context.resolveReference({reference:n.result});d.resolved&&(a=d.value)}else a=n.result;let u=n.name??`Example ${r+1}`,l=[];if(n.params&&Array.isArray(n.params)){l=[];for(let d of n.params)if(this.context.isReferenceObject(d)){let s=this.context.resolveReference({reference:d});if(s.resolved)l.push(s.value);else continue}else l.push(d)}t[u]={request:{docs:void 0,endpoint:{method:"POST",path:"/{apiKey}"},baseUrl:void 0,environment:void 0,auth:void 0,pathParameters:{},queryParameters:{},headers:{},requestBody:l.map(d=>d.value)??void 0},response:{docs:void 0,statusCode:void 0,body:a?.value?Ws.V2HttpEndpointResponseBody.json({jsonrpc:"2.0",id:n.examplePairedRequest?.id||"1",result:a.value}):void 0},codeSamples:[]}}++r}return t}};var NRa=class extends Mpi{constructor({context:t,breadcrumbs:r,audiences:i}){super({context:t,breadcrumbs:r,audiences:i})}async convert(){return this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.convertServers({}),this.convertSchemas(),this.convertMethods(),this.finalizeIr()}convertServers({endpointLevelServers:t}){let i=new EHt({context:this.context,breadcrumbs:["servers"],servers:this.context.spec.servers,endpointLevelServers:t}).convert();this.addEnvironmentsToIr({environmentConfig:i?.value})}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{})){let n=new QA.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:["components","schemas",t],schema:r}).convert();n!=null&&(this.addTypeToPackage(t),this.addTypesToIr({...n.inlinedTypes,[t]:n.convertedSchema}))}}convertMethods(){let r=new Uko({context:this.context,breadcrumbs:["methods"],operation:this.context.spec}).convert(),i=[],n=[],a=[];if(r&&r.length>0)for(let[l,d]of r.entries()){let o=new Lko({context:this.context,breadcrumbs:[...this.breadcrumbs,`x-fern-parameters[${l}]`],parameter:d}).convert();if(o!=null)switch(o.type){case"path":{i.push(o.parameter);break}case"query":{n.push(o.parameter);break}case"header":{a.push(o.parameter);break}}}let u=this.context.getGroup({groupParts:[],namespace:this.context.namespace});for(let l of this.context.spec.methods??[]){let d=this.context.resolveMaybeReference({schemaOrReference:l,breadcrumbs:["methods"]});if(d==null)continue;let o=new Vko({context:this.context,breadcrumbs:["methods"],method:d,pathParameters:i,queryParameters:n,headers:a}).convert();o!=null&&(this.addEndpointToIr({endpoint:o.endpoint,audiences:o.audiences,endpointGroup:u,serviceName:"service_root"}),this.addTypesToIr(o.inlinedTypes))}}};var FRa=class extends f8{isReferenceObject(t){return t!=null&&"$ref"in t}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n}){let a=this.getTypeIdFromSchemaReference(t);if(a==null)return{ok:!1};let u=this.resolveReference({reference:t,breadcrumbs:r});if(!u.resolved)return{ok:!1};let l;return n==="reference_identifier"?l=i??u.value.title:(n==="discriminator_key"||n==="schema_identifier")&&(l=u.value.title??i),{ok:!0,reference:gf.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,displayName:l,default:void 0,inline:!1})}}};var VB_={[hy.GenerationLanguage.PHP]:new Set(["abstract","and","as","break","callable","case","catch","class","clone","const","continue","declare","default","do","echo","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","extends","final","finally","fn","for","foreach","function","global","goto","list","if","implements","include","include_once","instanceof","insteadof","interface","match","namespace","new","or","parent","Parent","print","private","protected","public","readonly","require","require_once","return","static","switch","throw","trait","try","use","var","while","xor","yield"].flatMap(e=>[e,iz(e)])),[hy.GenerationLanguage.TYPESCRIPT]:new Set(["any","as","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","module","new","null","number","of","package","private","protected","public","require","return","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","var","void","while","with","yield","Date","Error","File","Object","Record"]),[hy.GenerationLanguage.JAVA]:new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","try","void","volatile","while"]),[hy.GenerationLanguage.PYTHON]:new Set(["False","None","True","and","as","assert","async","","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","float","int","complex","bool","uuid","list","set","map","long","self","all"]),[hy.GenerationLanguage.GO]:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[hy.GenerationLanguage.RUBY]:new Set(["__ENCODING__","__LINE__","__FILE__","alias","and","begin","break","case","class","def","defined","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","Object","JSON","Date","DateTime"]),[hy.GenerationLanguage.CSHARP]:new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while","add","and","alias","ascending","args","async","","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","managed","nameof","nint","not","notnull","nuint","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value","var","when","where","with","yield"]),[hy.GenerationLanguage.SWIFT]:new Set([])};var RJE=["go","ruby"];function njc({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let u=c=>({unsafeName:c,safeName:NJE({name:c,keywords:FJE({generationLanguage:e,keywords:t})})}),l=T_(n),d=iz(l),s=AVi(n),o=SVi(l);return r&&(!VJE(o)&&(e==null||RJE.includes(e))&&(l=o.map((c,b)=>{if(b>0){let g=Wko(c);if(g!=null)return g;if(Hko(c))return c.toUpperCase()}return c}).join(""),d=o.map((c,b)=>{let g=Wko(c);return g??(Hko(c)?c.toUpperCase():b===0?iz(c):c)}).join("")),s=n.split(" ").map(c=>c.split(/(\d+)/).map(AVi).join("")).join("_")),{originalName:n,camelCase:u(a?.casingOverrides?.camel??l),snakeCase:u(a?.casingOverrides?.snake??s),screamingSnakeCase:u(a?.casingOverrides?.["screaming-snake"]??s.toUpperCase()),pascalCase:u(a?.casingOverrides?.pascal??d)}},generateNameAndWireValue:({name:n,wireValue:a,opts:u})=>({name:i.generateName(n,u),wireValue:a})};return i}function NJE({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":UJE(e)?"_"+e:e}function FJE({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return VB_[e]}var LJE=/^[0-9]/;function UJE(e){return LJE.test(e)}function VJE(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=Wko(i)!=null||Hko(i),a=Wko(t)!=null||Hko(t);return n&&a})}function Wko(e){return HJE.get(e.toUpperCase())}function Hko(e){return WJE.has(e.toUpperCase())}var WJE=new Set(["ACL","API","ASCII","CPU","CSS","DNS","EOF","GUID","HTML","HTTP","HTTPS","ID","IP","JSON","LHS","QPS","RAM","RHS","RPC","SAML","SCIM","SLA","SMTP","SQL","SSH","SSO","TCP","TLS","TTL","UDP","UI","UID","UUID","URI","URL","UTF8","VM","XML","XMPP","XSRF","XSS"]),HJE=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]);var WB_=require("fs/promises");async function ajc({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,WB_.readFile)(t)).toString(),n;try{n=JSON.parse(i)}catch{n=qd.load(i)}return r!=null?await i9n({absoluteFilePathToOverrides:r,context:e,data:n}):n}var SR=class extends YIa{type="oss";allSpecs;specs;sources;loader;constructor({allSpecs:t,specs:r,...i}){super({...i,respectReadonlySchemas:r.every(n=>n.settings?.respectReadonlySchemas),respectNullableSchemas:r.every(n=>n.settings?.respectNullableSchemas),onlyIncludeReferencedSchemas:r.every(n=>n.settings?.onlyIncludeReferencedSchemas),inlinePathParameters:r.every(n=>n.settings?.inlinePathParameters),objectQueryParameters:r.every(n=>n.settings?.objectQueryParameters),useBytesForBinaryResponse:r.filter(n=>n.type==="openapi"&&n.source.type==="openapi").some(n=>n.settings?.useBytesForBinaryResponse),respectForwardCompatibleEnums:r.filter(n=>n.type==="openapi"&&n.source.type==="openapi").some(n=>n.settings?.respectForwardCompatibleEnums),exampleGeneration:r[0]?.settings?.exampleGeneration}),this.specs=r,this.allSpecs=t,this.sources=this.convertSpecsToIdentifiableSources(r),this.loader=new wHt(this.absoluteFilePath)}async getOpenAPIIr({context:t,relativePathToDependency:r},i){let n=await CFe({context:t,specs:this.specs,relativePathToDependency:r});return XJi({context:t,documents:await this.loader.loadDocuments({context:t,specs:n}),options:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.objectQueryParameters,exampleGeneration:i?.exampleGeneration??this.exampleGeneration,useBytesForBinaryResponse:i?.useBytesForBinaryResponse??this.useBytesForBinaryResponse}})}async getIntermediateRepresentation({context:t,audiences:r,enableUniqueErrorsPerEndpoint:i}){let n=await CFe({context:t,specs:this.specs}),a=await this.loader.loadDocuments({context:t,specs:n}),u=this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0;u&&t.logger.trace("Using auth overrides from generators configuration");let l=this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0;l&&t.logger.trace("Using environment overrides from generators configuration");let d=this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0;d&&t.logger.trace("Using global header overrides from generators configuration");let s,o=[];for(let c of a){let b=Vu(this.absoluteFilePath,Qa.of(c.source?.file??"")),g=cne(aR(),b),O=new z9n({logger:t.logger,relativeFilepathToSpec:g});o.push(O);let m;switch(c.type){case"openapi":{let E=new RRa({namespace:c.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:c.value,exampleGenerationArgs:{disabled:!1},errorCollector:O,authOverrides:u,environmentOverrides:l,globalHeaderOverrides:d,enableUniqueErrorsPerEndpoint:i});m=await new xRa({context:E,audiences:r}).convert();break}case"asyncapi":{let E=new zRa({namespace:c.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:c.value,exampleGenerationArgs:{disabled:!1},errorCollector:O,enableUniqueErrorsPerEndpoint:i});m=await new IRa({context:E,audiences:r}).convert();break}default:O.collect({message:`Unsupported document type: ${c}`,path:[]});break}let P=njc({generationLanguage:"typescript",keywords:void 0,smartCasing:!1});m!=null&&(s=s===void 0?m:oko(s,m,P))}for(let c of this.allSpecs)if(c.type==="openrpc"){let b=c.absoluteFilepath,g=cne(aR(),b),O=new z9n({logger:t.logger,relativeFilepathToSpec:g});o.push(O);let m=new FRa({namespace:c.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:await ajc({context:t,absoluteFilePath:c.absoluteFilepath,absoluteFilePathToOverrides:c.absoluteFilepathToOverrides}),exampleGenerationArgs:{disabled:!1},errorCollector:O,enableUniqueErrorsPerEndpoint:i}),E=await new NRa({context:m,audiences:r}).convert(),q=njc({generationLanguage:"typescript",keywords:void 0,smartCasing:!1});E!=null&&(s=s===void 0?E:oko(s,E,q))}for(let c of o)if(c.hasErrors()){let b=c.getErrorStats(),g=c.relativeFilepathToSpec?` for ${c.relativeFilepathToSpec}`:"";b.numErrors>0?t.logger.log("error",`API validation${g} completed with ${b.numErrors} errors and ${b.numWarnings} warnings.`):b.numWarnings>0?t.logger.log("warn",`API validation${g} completed with ${b.numWarnings} warnings.`):t.logger.log("info",`All checks passed when parsing OpenAPI${g}.`),t.logger.log("info",""),await c.logErrors({logWarnings:!1})}if(s===void 0)throw new Error("Failed to generate intermediate representation");return s}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new DMe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion,sources:this.sources})}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.specs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(V0)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,i=[];return t.reduce((n,a)=>{let u=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(u)||(r.add(u),n.push({type:a.type,id:Iae(),absoluteFilePath:u})),n},i)}};var HB_={None:"none",Header:"header"};var peu={};jo(peu,{ConjureAliasDeclaration:()=>Xko,ConjureArgument:()=>leu,ConjureArgumentWithParamType:()=>ceu,ConjureAuthDefinition:()=>k9n,ConjureAuthDefinitionType:()=>ueu,ConjureDefinitions:()=>aeu,ConjureEndpointDefinition:()=>feu,ConjureEnumDeclaration:()=>ieu,ConjureEnumVariant:()=>reu,ConjureEnumWithDocs:()=>teu,ConjureObjectDeclaration:()=>eeu,ConjureParamType:()=>seu,ConjurePrimitive:()=>Yko,ConjureService:()=>deu,ConjureServiceName:()=>Kko,ConjureType:()=>JAi,ConjureTypeDeclaration:()=>neu,ConjureTypeReference:()=>KAi,ConjureTypeWithDocs:()=>Zko,ConjureTypes:()=>oeu,ConjureUnionDeclaration:()=>kko,DefinitionFile:()=>bI_,WithDocs:()=>Hir,commons:()=>ljc,conjure:()=>fjc,services:()=>djc,types:()=>pjc});var ljc={};jo(ljc,{WithDocs:()=>Hir});var ip={};jo(ip,{JsonError:()=>Y9n,ParseError:()=>X9n,any:()=>aI_,bigint:()=>GB_,boolean:()=>oI_,booleanLiteral:()=>nI_,date:()=>QB_,discriminant:()=>hI_,enum_:()=>Gko,getObjectLikeUtils:()=>MHt,getObjectUtils:()=>DKi,getSchemaUtils:()=>Qq,isProperty:()=>QAi,lazy:()=>JB_,lazyObject:()=>tI_,list:()=>Jko,number:()=>uI_,object:()=>Qko,objectWithoutOptionalProperties:()=>eI_,optional:()=>ojc,property:()=>YB_,record:()=>fI_,set:()=>dI_,string:()=>sI_,stringLiteral:()=>iI_,transform:()=>ujc,undiscriminatedUnion:()=>_I_,union:()=>vI_,unknown:()=>cI_,withParsedProperties:()=>cjc});var qj={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function yA(e,t){return`Expected ${t}. Received ${$JE(e)}.`}function $JE(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function pL(e){return{...e,json:$B_(e.json),parse:$B_(e.parse)}}function $B_(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1961
1961
|
`)),{ok:!0,value:t}):i}}function $ko(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var Y9n=class e extends Error{errors;constructor(t){super(t.map($ko).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var X9n=class e extends Error{errors;constructor(t){super(t.map($ko).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Qq(e){return{optional:()=>ojc(e),transform:t=>ujc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new X9n(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new Y9n(i.errors)}}}function ojc(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>qj.OPTIONAL};return{...t,...Qq(t)}}function ujc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...Qq(r)}}function GB_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:yA(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:yA(t,"bigint")}]},getType:()=>qj.BIGINT};return{...pL(e),...Qq(e)}}var GJE=/^([+-]?\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 QB_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:yA(t,"string")}]}:GJE.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:yA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:yA(t,"Date object")}]},getType:()=>qj.DATE};return{...pL(e),...Qq(e)}}function wJ(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...pL(r),...Qq(r)}}}function Gko(e){let t=new Set(e);return wJ(qj.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:yA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:yA(i,"enum")}]}:{ok:!0,value:i})()}function JB_(e){let t=sjc(e);return{...t,...Qq(t)}}function sjc(e){return{parse:(t,r)=>Z9n(e).parse(t,r),json:(t,r)=>Z9n(e).json(t,r),getType:()=>Z9n(e).getType()}}function Z9n(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function LRa(e){return Object.entries(e)}function URa(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function GAi(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 VRa(e){return Object.keys(e)}function KB_(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function MHt(e){return{withParsedProperties:t=>cjc(e,t)}}function cjc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((l,[d,s])=>({...l,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!GAi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:yA(i,"object")}]};let a=new Set(Object.keys(t)),u=URa(i,Object.keys(i).filter(l=>!a.has(l)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...Qq(r),...MHt(r)}}function YB_(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function QAi(e){return e.isProperty}function Qko(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>QAi(i)?i.rawKey:r),_getParsedProperties:()=>VRa(e),parse:(r,i)=>{let n={},a=[];for(let[u,l]of LRa(e)){let d=QAi(l)?l.rawKey:u,s=QAi(l)?l.valueSchema:l,o={rawKey:d,parsedKey:u,valueSchema:s};n[d]=o,kB_(s)&&a.push(d)}return XB_({value:r,requiredKeys:a,getProperty:u=>{let l=n[u];if(l!=null)return{transformedKey:l.parsedKey,transform:d=>l.valueSchema.parse(d,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of LRa(e)){let l=QAi(u)?u.valueSchema:u;kB_(l)&&n.push(a)}return XB_({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return QAi(u)?{transformedKey:u.rawKey,transform:l=>u.valueSchema.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:l=>u.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>qj.OBJECT};return{...pL(t),...Qq(t),...MHt(t),...DKi(t)}}function XB_({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!GAi(e))return{ok:!1,errors:[{path:a,message:yA(e,"object")}]};let u=new Set(t),l=[],d={};for(let[s,o]of Object.entries(e)){let c=r(s);if(c!=null){u.delete(s);let b=c.transform(o);b.ok?d[c.transformedKey]=b.value:(d[s]=o,l.push(...b.errors))}else switch(i){case"fail":l.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=o;break}}return l.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),l.length===0||n?{ok:!0,value:d}:{ok:!1,errors:l}}function DKi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>ZB_({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>ZB_({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>qj.OBJECT};return{...r,...Qq(r),...MHt(r),...DKi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>qj.OBJECT};return{...t,...Qq(t),...MHt(t),...DKi(t)}}}}function ZB_({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=KB_(VRa(t),s=>n.has(s)),l=r(URa(t,u)),d=i(URa(t,a));return l.ok&&d.ok?{ok:!0,value:{...l.value,...d.value}}:{ok:!1,errors:[...l.ok?[]:l.errors,...d.ok?[]:d.errors]}}function kB_(e){return!QJE(e)}function QJE(e){switch(e.getType()){case qj.ANY:case qj.UNKNOWN:case qj.OPTIONAL:return!0;default:return!1}}function eI_(e){return Qko(e)}function tI_(e){let t={...sjc(e),_getRawProperties:()=>Z9n(e)._getRawProperties(),_getParsedProperties:()=>Z9n(e)._getParsedProperties()};return{...t,...Qq(t),...MHt(t),...DKi(t)}}function Jko(e){let t={parse:(r,i)=>rI_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>rI_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>qj.LIST};return{...pL(t),...Qq(t)}}function rI_(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:yA(e,"list"),path:[]}]}}function iI_(e){return wJ(qj.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:yA(r,`"${e}"`)}]})()}function nI_(e){return wJ(qj.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:yA(r,`${e.toString()}`)}]})()}var aI_=wJ(qj.ANY,e=>({ok:!0,value:e}));var oI_=wJ(qj.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:yA(e,"boolean")}]});var uI_=wJ(qj.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:yA(e,"number")}]});var sI_=wJ(qj.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:yA(e,"string")}]});var cI_=wJ(qj.UNKNOWN,e=>({ok:!0,value:e}));function fI_(e,t){let r={parse:(i,n)=>lI_({value:i,isKeyNumeric:e.getType()===qj.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>lI_({value:i,isKeyNumeric:e.getType()===qj.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>qj.RECORD};return{...pL(r),...Qq(r)}}function lI_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return GAi(e)?LRa(e).reduce((a,[u,l])=>{if(l==null)return a;let d=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),c=i(l,s);if(d.ok&&o.ok&&c.ok)return{ok:!0,value:{...d.value,[o.value]:c.value}};let b=[];return d.ok||b.push(...d.errors),o.ok||b.push(...o.errors),c.ok||b.push(...c.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:yA(e,"object")}]}}function dI_(e){let t=Jko(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:yA(i,"Set")}]},getType:()=>qj.SET};return{...pL(r),...Qq(r)}}function _I_(e){let t={parse:(r,i)=>pI_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>pI_((n,a)=>n.json(r,a),e,i),getType:()=>qj.UNDISCRIMINATED_UNION};return{...pL(t),...Qq(t)}}function pI_(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let l of u.errors)i.push({path:l.path,message:`[Variant ${n}] ${l.message}`})}return{ok:!1,errors:i}}function hI_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function vI_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=Gko(VRa(t)),a={parse:(u,l)=>yI_({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:d=>n.parse(d,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),json:(u,l)=>yI_({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:d=>n.json(d,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),getType:()=>qj.UNION};return{...pL(a),...Qq(a),...MHt(a)}}function yI_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:l=[]}){if(!GAi(e))return{ok:!1,errors:[{path:l,message:yA(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:l,message:`Missing discriminant ("${t}")`}]};let o=i(d);if(!o.ok)return{ok:!1,errors:o.errors};let c=n(o.value);if(c==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...l,t],message:"Unexpected discriminant value"}]};let b=u(s,c);return b.ok?{ok:!0,value:{[r]:d,...b.value}}:b}var Hir=ip.objectWithoutOptionalProperties({docs:ip.string().optional()});var fjc={};jo(fjc,{ConjureServiceName:()=>Kko,DefinitionFile:()=>bI_});var Kko=ip.string();var Yko=ip.enum_(["rid","string","safelong","integer","double","boolean"]);var JAi=ip.undiscriminatedUnion([Yko,ip.string()]);var Xko=ip.objectWithoutOptionalProperties({alias:JAi,docs:ip.string().optional()});var Zko=ip.objectWithoutOptionalProperties({type:JAi,docs:ip.string().optional()});var KAi=ip.undiscriminatedUnion([JAi,Zko]);var kko=ip.objectWithoutOptionalProperties({union:ip.record(ip.string(),KAi)});var eeu=ip.objectWithoutOptionalProperties({fields:ip.record(ip.string(),KAi)});var teu=ip.objectWithoutOptionalProperties({value:ip.string()}).extend(Hir);var reu=ip.undiscriminatedUnion([ip.string(),teu]);var ieu=ip.objectWithoutOptionalProperties({values:ip.list(reu)});var neu=ip.undiscriminatedUnion([Xko,kko,eeu,ieu]);var aeu=ip.objectWithoutOptionalProperties({objects:ip.record(ip.string(),neu).optional()});var oeu=ip.objectWithoutOptionalProperties({conjureImports:ip.property("conjure-imports",ip.record(ip.string(),ip.string()).optional()),definitions:aeu.optional()});var ueu=ip.enum_(["none","header"]);var k9n=ip.undiscriminatedUnion([ueu,ip.string()]);var seu=ip.enum_(["path","query","body"]);var ceu=ip.objectWithoutOptionalProperties({paramType:ip.property("param-type",seu),type:ip.string()}).extend(Hir);var leu=ip.undiscriminatedUnion([ip.string(),ceu]);var feu=ip.objectWithoutOptionalProperties({http:ip.string(),auth:k9n.optional(),args:ip.record(ip.string(),leu).optional(),returns:KAi.optional()}).extend(Hir);var deu=ip.objectWithoutOptionalProperties({name:ip.string().optional(),package:ip.string().optional(),basePath:ip.property("base-path",ip.string().optional()),defaultAuth:ip.property("default-auth",k9n.optional()),endpoints:ip.record(ip.string(),feu).optional()}).extend(Hir);var bI_=ip.objectWithoutOptionalProperties({types:oeu.optional(),services:ip.record(Kko,deu).optional()});var djc={};jo(djc,{ConjureArgument:()=>leu,ConjureArgumentWithParamType:()=>ceu,ConjureAuthDefinition:()=>k9n,ConjureAuthDefinitionType:()=>ueu,ConjureEndpointDefinition:()=>feu,ConjureParamType:()=>seu,ConjureService:()=>deu});var pjc={};jo(pjc,{ConjureAliasDeclaration:()=>Xko,ConjureDefinitions:()=>aeu,ConjureEnumDeclaration:()=>ieu,ConjureEnumVariant:()=>reu,ConjureEnumWithDocs:()=>teu,ConjureObjectDeclaration:()=>eeu,ConjurePrimitive:()=>Yko,ConjureType:()=>JAi,ConjureTypeDeclaration:()=>neu,ConjureTypeReference:()=>KAi,ConjureTypeWithDocs:()=>Zko,ConjureTypes:()=>oeu,ConjureUnionDeclaration:()=>kko});var gI_=require("fs/promises");async function OI_(e,t){let r=[];for(let i of await Fxe(e,t))r.push(await JJE({relativeFilepath:xq(e,i),absoluteFilepath:i}));return r}async function JJE({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,gI_.readFile)(t)).toString().replaceAll(/: rid(?:$|\s)/g,`: string
|
|
1962
1962
|
`).replaceAll("<rid>","<string>").replaceAll("rid>","string>").replaceAll(": safelong",": long").replaceAll("<safelong>","<long>").replaceAll("safelong>","long>").replaceAll(": any",": unknown").replaceAll("<any>","<unknown>").replaceAll("any>","unknown>");return{relativeFilepath:e,absoluteFilepath:t,fileContents:peu.DefinitionFile.parseOrThrow(qd.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}function mI_(e,t){if(KJE(e))return t.alias(e);if(YJE(e))return t.enum(e);if(XJE(e))return t.object(e);if(ZJE(e))return t.union(e);mo(e)}function KJE(e){return e?.alias!=null}function YJE(e){return e?.values!=null}function XJE(e){return e?.fields!=null}function ZJE(e){return e?.union!=null}var WRa=class extends LIa{fernDefinitionBuilder=new vJi(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:i,globalHeaderOverrides:n}){if(r!=null){for(let[a,u]of Object.entries(r["auth-schemes"]??{}))this.fernDefinitionBuilder.addAuthScheme({name:a,schema:u});r.auth!=null&&this.fernDefinitionBuilder.setAuth(r.auth)}if(i!=null){for(let[a,u]of Object.entries(i.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:u});i["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(i["default-environment"]),i["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(i["default-url"])}return await PI_(t,(a,u,l)=>{for(let[o,c]of Object.entries(l.services??{})){let b=rOo({value:o,suffix:"Service"});this.conjureFilepathToFernFilepath[u]=Qa.of(`${b}/__package__.yml`);return}let s=v2s(u)?.split(".")[0];s!=null&&(this.conjureFilepathToFernFilepath[u]=Qa.of(`${s}/__package__.yml`))}),await PI_(t,(a,u,l)=>{if(l.services==null||Object.keys(l.services??{}).length===0){let d=this.conjureFilepathToFernFilepath[u];if(d==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${u}`);for(let[s,o]of Object.entries(l.types?.conjureImports??{})){let c=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Qa.of(o)});this.fernDefinitionBuilder.addImport({file:d,fileToImport:Qa.of(c),alias:s})}this.importAllTypes({conjureFile:l,fernFilePath:d});return}for(let[d,s]of Object.entries(l.services)){let o=rOo({value:d,suffix:"Service"}),c=Qa.of(`${o}/__package__.yml`),b={};s.basePath!=null&&(b["base-path"]=s.basePath),s.docs!=null&&(b.docs=s.docs),this.fernDefinitionBuilder.setServiceInfo(c,b),this.importAllTypes({conjureFile:l,fernFilePath:c});for(let[g,O]of Object.entries(l.types?.conjureImports??{})){let m=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Qa.of(O)});this.fernDefinitionBuilder.addImport({file:c,fileToImport:Qa.of(m),alias:g})}for(let[g,O]of Object.entries(s.endpoints??{})){let m=D3s(O.http);if(m.type==="failure"){this.context?.logger.error(`Failed to parse ${O.http}. Skipping.`);continue}let E={auth:(O.auth??s.defaultAuth)!==HB_.None,path:m.path,method:m.method,response:O.returns==="binary"?"file":O.returns};O.docs!=null&&(E.docs=O.docs);let q={};if(O.args!=null)for(let M of m.pathParameters){let D=O.args[M];if(D==null)throw new Error(`Failed to find path parameter ${M} in ${O.http}`);q[M]=typeof D=="string"?D:{type:D.type}}Object.entries(q).length>0&&(E["path-parameters"]=q);for(let[M,D]of Object.entries(O.args??{}))if(q[M]==null)if(typeof D=="string")E.request?typeof E.request=="string"&&(E.request={body:E.request}):E.request={},E.request.body=D==="binary"?"bytes":D;else switch(D.paramType){case"body":E.request={body:D.type==="binary"?"bytes":D.type};break;case"query":E.request==null?E.request={"query-parameters":{[M]:D.type}}:typeof E.request!="string"&&E.request?.["query-parameters"]==null?E.request["query-parameters"]={[M]:D.type}:typeof E.request!="string"&&E.request?.["query-parameters"]!=null&&(E.request["query-parameters"][M]=D.type)}E.request!=null&&typeof E.request!="string"&&E.request?.["query-parameters"]!=null&&(E.request.name=`${g}Request`),this.fernDefinitionBuilder.addEndpoint(c,{name:g,schema:E,source:void 0})}}}),this.fernDefinitionBuilder.build()}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[i,n]of Object.entries(t.types?.definitions?.objects??{}))mI_(n,{alias:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{type:a.alias,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{properties:a.fields}})},enum:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{enum:a.values}})},union:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{union:Object.fromEntries(Object.entries(a.union).map(([u,l])=>[u,{type:typeof l=="string"?l:l.type,docs:typeof l=="string"?void 0:l.docs,key:u}]))}})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:i}){let n=Vu(Xd(t),Qa.of(r)),a=cne(i,n),u=this.conjureFilepathToFernFilepath[a];if(u==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return u}};async function PI_(e,t){for(let r of await OI_(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}function jI_(e,t){return dd(e,t)}var _eu=class extends sHt{type="conjure";absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=Vu(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new DMe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion,sources:void 0})}async getDefinition({context:t},r){let n=await new WRa(t).import({absolutePathToConjureFolder:this.absolutePathToConjureFolder,authOverrides:this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0,environmentOverrides:this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:$l.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:n.rootApiFile["default-url"],contents:n.rootApiFile,rawContents:qd.dump(n.rootApiFile)},namedDefinitionFiles:{...jI_(n.definitionFiles,a=>({absoluteFilepath:$l.of("/DUMMY_PATH"),rawContents:qd.dump(a),contents:a})),[Qa.of(zS)]:{absoluteFilepath:$l.of("/DUMMY_PATH"),rawContents:qd.dump(n.packageMarkerFile),contents:n.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};function _jc(e,t){for(let[r,i]of t3(e.failures))kJE({relativeFilepath:r,failure:i,logger:t})}function kJE({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case zP.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 zP.FILE_READ:r.error("Failed to open file: "+e);break;case zP.FILE_MISSING:r.error("Missing file: "+e);break;case zP.FILE_PARSE:t.error instanceof vSa?r.error(vFe({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case zP.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of eKE(i))r.error(vFe({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case zP.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case zP.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${VOo}: `+t.dependencyName);break;case zP.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case zP.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case zP.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(vFe({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(i=>i!=="")]}));break;default:mo(t)}}function eKE(e){switch(e.code){case Jl.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${Gs.underline(e.expected)} but received ${Gs.underline(e.received)}`}];case Jl.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${Gs.underline(t)}`}));case Jl.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>Gs.underline(t)).join(", ")}`}];case Jl.invalid_union:case Jl.invalid_arguments:case Jl.invalid_return_type:case Jl.invalid_date:case Jl.invalid_string:case Jl.too_small:case Jl.too_big:case Jl.invalid_intersection_types:case Jl.not_multiple_of:case Jl.custom:default:return[{title:e.message}]}}var wI_=require("fs/promises");async function SI_(e,t){let r=[];for(let i of await Fxe(e,t))r.push(await tKE({relativeFilepath:xq(e,i),absoluteFilepath:i}));return r}async function tKE({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,wI_.readFile)(t)).toString()}}async function DI_({absolutePathToWorkspace:e}){let t=Vu(e,Qa.of(zqd));if(!await Cf(t))return;let i=await SI_(t,"{md,mdx}");return{files:await Promise.all(i.map(n=>({absoluteFilepath:n.absoluteFilepath,contents:n.fileContents})))}}async function hjc({absolutePathToWorkspace:e,namespace:t,definitions:r}){let i=[];for(let n of r){let a=n.overrides!=null?Vu(e,Qa.of(n.overrides)):void 0;if(n.schema.type==="protobuf"){let l=Qa.of(n.schema.root),d=Vu(e,l);if(!await Cf(d))return{didSucceed:!1,failures:{[Qa.of(n.schema.root)]:{type:zP.FILE_MISSING}}};let s=Vu(e,Qa.of(n.schema.target));if(!await Cf(s))return{didSucceed:!1,failures:{[Qa.of(n.schema.target)]:{type:zP.FILE_MISSING}}};i.push({type:"protobuf",absoluteFilepathToProtobufRoot:d,absoluteFilepathToProtobufTarget:s,absoluteFilepathToOverrides:a,relativeFilepathToProtobufRoot:l,generateLocally:n.schema.localGeneration,settings:{audiences:n.audiences??[],useTitlesAsName:n.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,shouldUseIdiomaticRequestNames:n.settings?.shouldUseIdiomaticRequestNames??!1,optionalAdditionalProperties:n.settings?.shouldUseOptionalAdditionalProperties??!0,coerceEnumsToLiterals:n.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:n.settings?.objectQueryParameters??!1,respectReadonlySchemas:n.settings?.respectReadonlySchemas??!1,respectNullableSchemas:n.settings?.respectNullableSchemas??!1,onlyIncludeReferencedSchemas:n.settings?.onlyIncludeReferencedSchemas??!1,inlinePathParameters:n.settings?.inlinePathParameters??!1,disableExamples:!1,discriminatedUnionV2:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,preserveSchemaIds:!1,asyncApiNaming:n.settings?.asyncApiMessageNaming??"v1",filter:n.settings?.filter,exampleGeneration:void 0,defaultFormParameterEncoding:n.settings?.defaultFormParameterEncoding,useBytesForBinaryResponse:n.settings?.useBytesForBinaryResponse??!1,respectForwardCompatibleEnums:n.settings?.respectForwardCompatibleEnums??!1,additionalPropertiesDefaultsTo:n.settings?.additionalPropertiesDefaultsTo??!1,typeDatesAsStrings:n.settings?.typeDatesAsStrings??!0}});continue}if(n.schema.type==="openrpc"){let l=Qa.of(n.schema.path),d=Vu(e,l);i.push({type:"openrpc",absoluteFilepath:d,absoluteFilepathToOverrides:a,namespace:t});continue}let u=Vu(e,Qa.of(n.schema.path));if(!await Cf(u))return{didSucceed:!1,failures:{[Qa.of(n.schema.path)]:{type:zP.FILE_MISSING}}};if(n.overrides!=null&&a!=null&&!await Cf(a))return{didSucceed:!1,failures:{[Qa.of(n.overrides)]:{type:zP.FILE_MISSING}}};i.push({type:"openapi",absoluteFilepath:u,absoluteFilepathToOverrides:a,settings:{audiences:n.audiences??[],useTitlesAsName:n.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,shouldUseIdiomaticRequestNames:n.settings?.shouldUseIdiomaticRequestNames??!1,optionalAdditionalProperties:n.settings?.shouldUseOptionalAdditionalProperties??!0,coerceEnumsToLiterals:n.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:n.settings?.objectQueryParameters??!1,respectReadonlySchemas:n.settings?.respectReadonlySchemas??!1,respectNullableSchemas:n.settings?.respectNullableSchemas??!1,onlyIncludeReferencedSchemas:n.settings?.onlyIncludeReferencedSchemas??!1,inlinePathParameters:n.settings?.inlinePathParameters??!1,disableExamples:!1,discriminatedUnionV2:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,preserveSchemaIds:!1,asyncApiNaming:n.settings?.asyncApiMessageNaming??"v1",filter:n.settings?.filter,exampleGeneration:n.settings?.exampleGeneration,defaultFormParameterEncoding:n.settings?.defaultFormParameterEncoding,useBytesForBinaryResponse:n.settings?.useBytesForBinaryResponse??!1,respectForwardCompatibleEnums:n.settings?.respectForwardCompatibleEnums??!1,additionalPropertiesDefaultsTo:n.settings?.additionalPropertiesDefaultsTo??!1,typeDatesAsStrings:n.settings?.typeDatesAsStrings??!0},source:{type:"openapi",file:u},namespace:t})}return i}async function HRa({absolutePathToWorkspace:e,context:t,cliVersion:r,workspaceName:i}){let n=await kVt({absolutePathToWorkspace:e,context:t}),a;try{a=await DI_({absolutePathToWorkspace:e})}catch{}if(n?.api!=null&&n?.api.type==="conjure")return{didSucceed:!0,workspace:new _eu({workspaceName:i,absoluteFilePath:e,generatorsConfiguration:n,changelog:a,cliVersion:r,context:t,relativePathToConjureDirectory:Qa.of(n.api.pathToConjureDefinition)})};if(n?.api!=null&&(n.api.type==="singleNamespace"&&n.api.definitions.length>0||n.api.type==="multiNamespace")){let u=[];if(n.api.type==="singleNamespace"){let l=await hjc({absolutePathToWorkspace:e,namespace:void 0,definitions:n.api.definitions});if(!Array.isArray(l))return l;u.push(...l)}else{for(let[l,d]of Object.entries(n.api.definitions)){let s=await hjc({absolutePathToWorkspace:e,namespace:l,definitions:d});if(!Array.isArray(s))return s;u.push(...s)}if(n.api.rootDefinitions!=null){let l=await hjc({absolutePathToWorkspace:e,namespace:void 0,definitions:n.api.rootDefinitions});if(!Array.isArray(l))return l;u.push(...l)}}return{didSucceed:!0,workspace:new SR({specs:u.filter(l=>l.type!=="openrpc"),allSpecs:u,workspaceName:i,absoluteFilePath:e,generatorsConfiguration:n,changelog:a,cliVersion:r})}}return await Cf(Vu(e,Qa.of(v9)))?{didSucceed:!0,workspace:new Fir({absoluteFilePath:e,generatorsConfiguration:n,workspaceName:i,changelog:a,context:t,cliVersion:r,loadAPIWorkspace:HRa})}:{didSucceed:!1,failures:{[Qa.of(UOo)]:{type:zP.MISCONFIGURED_DIRECTORY}}}}var EI_=require("fs/promises");var yjc={};jo(yjc,{additionalProperties:()=>aKE,default:()=>uKE,definitions:()=>oKE,properties:()=>iKE,required:()=>nKE,type:()=>rKE});var rKE="object",iKE={instances:{type:"array",items:{$ref:"#/definitions/docs.DocsInstance"}},title:{oneOf:[{type:"string"},{type:"null"}]},analytics:{oneOf:[{$ref:"#/definitions/docs.AnalyticsConfig"},{type:"null"}]},announcement:{oneOf:[{$ref:"#/definitions/docs.AnnouncementConfig"},{type:"null"}]},roles:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.RoleId"}},{type:"null"}]},tabs:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/docs.TabConfig"}},{type:"null"}]},versions:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.VersionConfig"}},{type:"null"}]},products:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ProductConfig"}},{type:"null"}]},"landing-page":{oneOf:[{$ref:"#/definitions/docs.PageConfiguration"},{type:"null"}]},navigation:{oneOf:[{$ref:"#/definitions/docs.NavigationConfig"},{type:"null"}]},"navbar-links":{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.NavbarLink"}},{type:"null"}]},"footer-links":{oneOf:[{$ref:"#/definitions/docs.FooterLinksConfig"},{type:"null"}]},experimental:{oneOf:[{$ref:"#/definitions/docs.ExperimentalConfig"},{type:"null"}]},"default-language":{oneOf:[{$ref:"#/definitions/docs.ProgrammingLanguage"},{type:"null"}]},"ai-chat":{oneOf:[{$ref:"#/definitions/docs.AIChatConfig"},{type:"null"}]},"ai-search":{oneOf:[{$ref:"#/definitions/docs.AIChatConfig"},{type:"null"}]},metadata:{oneOf:[{$ref:"#/definitions/docs.MetadataConfig"},{type:"null"}]},redirects:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.RedirectConfig"}},{type:"null"}]},logo:{oneOf:[{$ref:"#/definitions/docs.LogoConfiguration"},{type:"null"}]},favicon:{oneOf:[{type:"string"},{type:"null"}]},"background-image":{oneOf:[{$ref:"#/definitions/docs.BackgroundImageConfiguration"},{type:"null"}]},colors:{oneOf:[{$ref:"#/definitions/docs.ColorsConfiguration"},{type:"null"}]},typography:{oneOf:[{$ref:"#/definitions/docs.DocsTypographyConfig"},{type:"null"}]},layout:{oneOf:[{$ref:"#/definitions/docs.LayoutConfig"},{type:"null"}]},integrations:{oneOf:[{$ref:"#/definitions/docs.IntegrationsConfig"},{type:"null"}]},css:{oneOf:[{$ref:"#/definitions/docs.CssConfig"},{type:"null"}]},js:{oneOf:[{$ref:"#/definitions/docs.JsConfig"},{type:"null"}]}},nKE=["instances"],aKE=!1,oKE={"docs.CustomDomain":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"docs.GithubEditThisPageConfig":{type:"object",properties:{host:{oneOf:[{type:"string"},{type:"null"}]},owner:{type:"string"},repo:{type:"string"},branch:{oneOf:[{type:"string"},{type:"null"}]}},required:["owner","repo"],additionalProperties:!1},"docs.EditThisPageConfig":{type:"object",properties:{github:{oneOf:[{$ref:"#/definitions/docs.GithubEditThisPageConfig"},{type:"null"}]}},additionalProperties:!1},"docs.DocsInstance":{type:"object",properties:{url:{type:"string"},"custom-domain":{oneOf:[{$ref:"#/definitions/docs.CustomDomain"},{type:"null"}]},private:{oneOf:[{type:"boolean"},{type:"null"}]},"edit-this-page":{oneOf:[{$ref:"#/definitions/docs.EditThisPageConfig"},{type:"null"}]}},required:["url"],additionalProperties:!1},"docs.SegmentConfig":{type:"object",properties:{"write-key":{type:"string"}},required:["write-key"],additionalProperties:!1},"docs.FullStoryAnalyticsConfig":{type:"object",properties:{"org-id":{type:"string"}},required:["org-id"],additionalProperties:!1},"docs.IntercomConfig":{type:"object",properties:{"app-id":{type:"string"},"api-base":{oneOf:[{type:"string"},{type:"null"}]}},required:["app-id"],additionalProperties:!1},"docs.PostHogConfig":{type:"object",properties:{"api-key":{type:"string"},endpoint:{oneOf:[{type:"string"},{type:"null"}]}},required:["api-key"],additionalProperties:!1},"docs.GTMConfig":{type:"object",properties:{"container-id":{type:"string"}},required:["container-id"],additionalProperties:!1},"docs.GoogleAnalytics4Config":{type:"object",properties:{"measurement-id":{type:"string"}},required:["measurement-id"],additionalProperties:!1},"docs.AnalyticsConfig":{type:"object",properties:{segment:{oneOf:[{$ref:"#/definitions/docs.SegmentConfig"},{type:"null"}]},fullstory:{oneOf:[{$ref:"#/definitions/docs.FullStoryAnalyticsConfig"},{type:"null"}]},intercom:{oneOf:[{$ref:"#/definitions/docs.IntercomConfig"},{type:"null"}]},posthog:{oneOf:[{$ref:"#/definitions/docs.PostHogConfig"},{type:"null"}]},gtm:{oneOf:[{$ref:"#/definitions/docs.GTMConfig"},{type:"null"}]},ga4:{oneOf:[{$ref:"#/definitions/docs.GoogleAnalytics4Config"},{type:"null"}]}},additionalProperties:!1},"docs.AnnouncementConfig":{type:"object",properties:{message:{type:"string"}},required:["message"],additionalProperties:!1},"docs.RoleId":{type:"string"},"docs.Role":{anyOf:[{$ref:"#/definitions/docs.RoleId"},{type:"array",items:{$ref:"#/definitions/docs.RoleId"}}]},"docs.FeatureFlag":{type:"object",properties:{flag:{type:"string"},"fallback-value":{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},match:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]}},required:["flag"],additionalProperties:!1},"docs.FeatureFlagConfiguration":{anyOf:[{type:"string",description:"The name of the feature flag, We assume that it is a boolean feature flag that needs to be evaluated to true."},{$ref:"#/definitions/docs.FeatureFlag",description:"A single feature flag with a configurable name, fallback value, and match value. Especially useful for non boolean feature flags."},{type:"array",items:{$ref:"#/definitions/docs.FeatureFlag"},description:"A list of feature flags. If any of the feature flags are satisfied, we will show all content."}]},"docs.ChangelogFolderRelativePath":{type:"string"},"docs.TabConfig":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},"display-name":{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},changelog:{oneOf:[{$ref:"#/definitions/docs.ChangelogFolderRelativePath"},{type:"null"}]}},required:["display-name"],additionalProperties:!1},"docs.VersionAvailability":{type:"string",enum:["deprecated","ga","stable","beta"]},"docs.VersionConfig":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},"display-name":{type:"string"},path:{type:"string"},slug:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.VersionAvailability"},{type:"null"}]}},required:["display-name","path"],additionalProperties:!1},"docs.ProductConfig":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},"display-name":{type:"string"},path:{type:"string"},subtitle:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},image:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},versions:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.VersionConfig"}},{type:"null"}]}},required:["display-name","path"],additionalProperties:!1},"docs.PageConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},page:{type:"string"},path:{type:"string"},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},noindex:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["page","path"],additionalProperties:!1},"docs.SectionConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},section:{type:"string"},path:{oneOf:[{type:"string"},{type:"null"}]},contents:{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["section","contents"],additionalProperties:!1},"docs.AudienceId":{type:"string"},"docs.VersionedSnippetLanguageConfiguration":{type:"object",properties:{version:{type:"string"},package:{type:"string"}},required:["version","package"],additionalProperties:!1},"docs.SnippetLanguageConfiguration":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.VersionedSnippetLanguageConfiguration"}]},"docs.SnippetsConfiguration":{type:"object",properties:{python:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},typescript:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},go:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},java:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},ruby:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},csharp:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]}},additionalProperties:!1},"docs.PlaygroundButtonSettings":{type:"object",properties:{href:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.PlaygroundSettings":{type:"object",properties:{environments:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},button:{oneOf:[{$ref:"#/definitions/docs.PlaygroundButtonSettings"},{type:"null"}]},oauth:{oneOf:[{type:"boolean"},{type:"null"}]},"limit-websocket-messages-per-connection":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"docs.ApiReferencePackageConfigurationWithOptions":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},title:{oneOf:[{type:"string"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},contents:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},additionalProperties:!1},"docs.ApiReferencePackageConfiguration":{anyOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{$ref:"#/definitions/docs.ApiReferencePackageConfigurationWithOptions"}]},"docs.ApiReferenceSectionConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},section:{type:"string"},"referenced-packages":{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},contents:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["section"],additionalProperties:!1},"docs.ApiReferenceEndpointConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},endpoint:{type:"string"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"docs.LinkConfiguration":{type:"object",properties:{link:{type:"string"},href:{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]}},required:["link","href"],additionalProperties:!1},"docs.ApiReferenceLayoutItem":{anyOf:[{type:"string",description:"This should be either an endpoint, websocket, webhook, or subpackage ID"},{type:"object",additionalProperties:{$ref:"#/definitions/docs.ApiReferencePackageConfiguration"},description:"Keyed by subpackage name, this object allows you to group endpoints and pages together."},{$ref:"#/definitions/docs.ApiReferenceSectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceEndpointConfiguration"},{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"}]},"docs.ApiReferenceConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},api:{type:"string"},"api-name":{oneOf:[{type:"string"},{type:"null"}]},openrpc:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.AudienceId"}},{type:"null"}]},"display-errors":{oneOf:[{type:"boolean"},{type:"null"}]},snippets:{oneOf:[{$ref:"#/definitions/docs.SnippetsConfiguration"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},alphabetized:{oneOf:[{type:"boolean"},{type:"null"}]},flattened:{oneOf:[{type:"boolean"},{type:"null"}]},paginated:{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["api"],additionalProperties:!1},"docs.ChangelogConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},changelog:{$ref:"#/definitions/docs.ChangelogFolderRelativePath"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["changelog"],additionalProperties:!1},"docs.NavigationItem":{anyOf:[{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.SectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"},{$ref:"#/definitions/docs.ChangelogConfiguration"}]},"docs.UntabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},"docs.TabId":{type:"string"},"docs.TabbedNavigationItem":{type:"object",properties:{tab:{$ref:"#/definitions/docs.TabId"},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},{type:"null"}]}},required:["tab"],additionalProperties:!1},"docs.TabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.TabbedNavigationItem"}},"docs.NavigationConfig":{anyOf:[{$ref:"#/definitions/docs.UntabbedNavigationConfig"},{$ref:"#/definitions/docs.TabbedNavigationConfig"}]},"docs.NavbarGithubConfig":{type:"string"},"docs.NavbarLink":{type:"object",properties:{type:{type:"string",enum:["filled","outlined","minimal","github","primary","secondary"]}},required:["type"],oneOf:[{properties:{type:{const:"filled"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]},{properties:{type:{const:"outlined"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]},{properties:{type:{const:"minimal"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]},{properties:{type:{const:"github"},value:{$ref:"#/definitions/docs.NavbarGithubConfig"}},required:["type"]},{properties:{type:{const:"primary"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]},{properties:{type:{const:"secondary"},href:{oneOf:[{type:"string"},{type:"null"}]},url:{oneOf:[{type:"string"},{type:"null"}]},text:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},rightIcon:{oneOf:[{type:"string"},{type:"null"}]},rounded:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"]}]},"docs.FooterLinksConfig":{type:"object",properties:{github:{oneOf:[{type:"string"},{type:"null"}]},twitter:{oneOf:[{type:"string"},{type:"null"}]},x:{oneOf:[{type:"string"},{type:"null"}]},linkedin:{oneOf:[{type:"string"},{type:"null"}]},youtube:{oneOf:[{type:"string"},{type:"null"}]},instagram:{oneOf:[{type:"string"},{type:"null"}]},facebook:{oneOf:[{type:"string"},{type:"null"}]},discord:{oneOf:[{type:"string"},{type:"null"}]},slack:{oneOf:[{type:"string"},{type:"null"}]},hackernews:{oneOf:[{type:"string"},{type:"null"}]},medium:{oneOf:[{type:"string"},{type:"null"}]},website:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.ExperimentalConfig":{type:"object",properties:{"mdx-components":{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"disable-stream-toggle":{oneOf:[{type:"boolean"},{type:"null"}]},"openapi-parser-v2":{oneOf:[{type:"boolean"},{type:"null"}]},"openapi-parser-v3":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"docs.ProgrammingLanguage":{type:"string",enum:["typescript","javascript","python","java","go","ruby","csharp","nodets","nodejs","dotnet","curl","jvm","ts","js"]},"docs.AIChatModel":{type:"string",enum:["claude-3.5","claude-3.7","command-a"]},"docs.AIChatConfig":{type:"object",properties:{model:{oneOf:[{$ref:"#/definitions/docs.AIChatModel"},{type:"null"}]},"system-prompt":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.TwitterCardSetting":{type:"string",enum:["summary","summary_large_image","app","player"]},"docs.MetadataConfig":{type:"object",properties:{"og:site_name":{oneOf:[{type:"string"},{type:"null"}]},"og:title":{oneOf:[{type:"string"},{type:"null"}]},"og:description":{oneOf:[{type:"string"},{type:"null"}]},"og:url":{oneOf:[{type:"string"},{type:"null"}]},"og:image":{oneOf:[{type:"string"},{type:"null"}]},"og:image:width":{oneOf:[{type:"number"},{type:"null"}]},"og:image:height":{oneOf:[{type:"number"},{type:"null"}]},"og:locale":{oneOf:[{type:"string"},{type:"null"}]},"og:logo":{oneOf:[{type:"string"},{type:"null"}]},"twitter:title":{oneOf:[{type:"string"},{type:"null"}]},"twitter:description":{oneOf:[{type:"string"},{type:"null"}]},"twitter:handle":{oneOf:[{type:"string"},{type:"null"}]},"twitter:image":{oneOf:[{type:"string"},{type:"null"}]},"twitter:site":{oneOf:[{type:"string"},{type:"null"}]},"twitter:url":{oneOf:[{type:"string"},{type:"null"}]},"twitter:card":{oneOf:[{$ref:"#/definitions/docs.TwitterCardSetting"},{type:"null"}]}},additionalProperties:!1},"docs.RedirectConfig":{type:"object",properties:{source:{type:"string"},destination:{type:"string"},permanent:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["source","destination"],additionalProperties:!1},"docs.LogoConfiguration":{type:"object",properties:{dark:{oneOf:[{type:"string"},{type:"null"}]},light:{oneOf:[{type:"string"},{type:"null"}]},height:{oneOf:[{type:"number"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.BackgroundImageThemedConfig":{type:"object",properties:{dark:{oneOf:[{type:"string"},{type:"null"}]},light:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.BackgroundImageConfiguration":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.BackgroundImageThemedConfig"}]},"docs.ColorThemedConfig":{type:"object",properties:{dark:{oneOf:[{type:"string"},{type:"null"}]},light:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.ColorConfig":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.ColorThemedConfig"}]},"docs.ColorsConfiguration":{type:"object",properties:{"accent-primary":{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},accentPrimary:{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},background:{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},border:{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},"sidebar-background":{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},"header-background":{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]},"card-background":{oneOf:[{$ref:"#/definitions/docs.ColorConfig"},{type:"null"}]}},additionalProperties:!1},"docs.FontWeight":{anyOf:[{type:"string"},{type:"integer"}]},"docs.FontStyle":{type:"string",enum:["normal","italic"]},"docs.FontConfigVariant":{type:"object",properties:{path:{type:"string"},weight:{oneOf:[{$ref:"#/definitions/docs.FontWeight"},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/docs.FontStyle"},{type:"null"}]}},required:["path"],additionalProperties:!1},"docs.FontConfigPath":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.FontConfigVariant"}]},"docs.FontDisplay":{type:"string",enum:["auto","block","swap","fallback","optional"]},"docs.FontConfig":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},path:{oneOf:[{type:"string"},{type:"null"}]},weight:{oneOf:[{$ref:"#/definitions/docs.FontWeight"},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/docs.FontStyle"},{type:"null"}]},paths:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.FontConfigPath"}},{type:"null"}]},display:{oneOf:[{$ref:"#/definitions/docs.FontDisplay"},{type:"null"}]},fallback:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"font-variation-settings":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.DocsTypographyConfig":{type:"object",properties:{headingsFont:{oneOf:[{$ref:"#/definitions/docs.FontConfig"},{type:"null"}]},bodyFont:{oneOf:[{$ref:"#/definitions/docs.FontConfig"},{type:"null"}]},codeFont:{oneOf:[{$ref:"#/definitions/docs.FontConfig"},{type:"null"}]}},additionalProperties:!1},"docs.SearchbarPlacement":{type:"string",enum:["header","header-tabs","sidebar"]},"docs.TabsPlacement":{type:"string",enum:["header","sidebar"]},"docs.ContentAlignment":{type:"string",enum:["center","left"]},"docs.HeaderPosition":{type:"string",enum:["fixed","static"]},"docs.LayoutConfig":{type:"object",properties:{"page-width":{oneOf:[{type:"string"},{type:"null"}]},"content-width":{oneOf:[{type:"string"},{type:"null"}]},"sidebar-width":{oneOf:[{type:"string"},{type:"null"}]},"header-height":{oneOf:[{type:"string"},{type:"null"}]},"searchbar-placement":{oneOf:[{$ref:"#/definitions/docs.SearchbarPlacement"},{type:"null"}]},"tabs-placement":{oneOf:[{$ref:"#/definitions/docs.TabsPlacement"},{type:"null"}]},"content-alignment":{oneOf:[{$ref:"#/definitions/docs.ContentAlignment"},{type:"null"}]},"header-position":{oneOf:[{$ref:"#/definitions/docs.HeaderPosition"},{type:"null"}]},"disable-header":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"docs.IntegrationsConfig":{type:"object",properties:{intercom:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.CssConfig":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"docs.JsScriptStrategy":{type:"string",enum:["beforeInteractive","afterInteractive","lazyOnload"]},"docs.JsRemoteConfig":{type:"object",properties:{url:{type:"string"},strategy:{oneOf:[{$ref:"#/definitions/docs.JsScriptStrategy"},{type:"null"}]}},required:["url"],additionalProperties:!1},"docs.JsFileConfigSettings":{type:"object",properties:{path:{type:"string"},strategy:{oneOf:[{$ref:"#/definitions/docs.JsScriptStrategy"},{type:"null"}]}},required:["path"],additionalProperties:!1},"docs.JsFileConfig":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.JsFileConfigSettings"}]},"docs.JsConfigOptions":{anyOf:[{$ref:"#/definitions/docs.JsRemoteConfig"},{$ref:"#/definitions/docs.JsFileConfig"}]},"docs.JsConfig":{anyOf:[{$ref:"#/definitions/docs.JsConfigOptions"},{type:"array",items:{$ref:"#/definitions/docs.JsConfigOptions"}}]}},uKE={type:rKE,properties:iKE,required:nKE,additionalProperties:aKE,definitions:oKE};async function vjc({fernDirectory:e,context:t}){let r=Vu(e,Qa.of(_Vt));if(!await Cf(r))return;let i=await sKE({absolutePathToDocsDefinition:e,context:t});if(i!=null)return{type:"docs",absoluteFilePath:e,config:i,workspaceName:void 0,absoluteFilepathToDocsConfig:Vu(e,Qa.of(_Vt))}}async function sKE({absolutePathToDocsDefinition:e,context:t}){if(!await Cf(e))return;let r=Vu(e,Qa.of(_Vt));return await cKE({absolutePathOfConfiguration:r,context:t})}async function cKE({absolutePathOfConfiguration:e,context:t}){let r=await(0,EI_.readFile)(e),i=qd.load(r.toString()),n=pVt(i,yjc);if(n.success)return sne.RawSchemas.Serializer.DocsConfiguration.parseOrThrow(i);throw new Error(`Failed to parse docs.yml because of ${n.error?.message??"Unknown error"}`)}async function bjc({context:e,nameOverride:t,...r}){let i=await SVt(t);return i==null?e.failAndThrow(`Directory "${t??sW}" not found.`):await AI_({absolutePathToFernDirectory:i,context:e,nameOverride:t,...r})}async function AI_({absolutePathToFernDirectory:e,cliName:t,cliVersion:r,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:n,context:a}){let u=[];return(await Cf(Vu(e,Qa.of(gwi)))||await Cf(Vu(e,Qa.of(v9)))||await Cf(Vu(e,Qa.of(n3)))||await Cf(Vu(e,Qa.of(UOo)))||await Cf(Vu(e,Qa.of(xqd))))&&(u=await qI_({cliName:t,fernDirectory:e,cliVersion:r,context:a,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:n})),{config:await Zli({directory:e,context:a}),apiWorkspaces:u,docsWorkspaces:await vjc({fernDirectory:e,context:a}),loadAPIWorkspace:l=>l==null?u[0]:u.find(d=>d.workspaceName===l)}}async function qI_({cliName:e,fernDirectory:t,context:r,cliVersion:i,commandLineApiWorkspace:n,defaultToAllApiWorkspaces:a}){let u=Vu(t,Qa.of(gwi));if(await Cf(u)){let o=(await(0,MI_.readdir)(u,{withFileTypes:!0})).reduce((g,O)=>(O.isDirectory()&&g.push(O.name),g),[]);if(n!=null){if(!o.includes(n))return r.failAndThrow("API does not exist: "+n)}else{if(o.length===0)return r.failAndThrow("No APIs found.");if(o.length>1&&!a){let g=`There are multiple workspaces. You must specify one with --api:
|
|
1963
1963
|
`,O=Math.max(...o.map(m=>m.length));return g+=o.map(m=>{let P=`${e} ${process.argv.slice(2).join(" ")} --api ${m}`;return` \u203A ${Gs.bold(m.padEnd(O))} ${Gs.dim(P)}`}).join(`
|