fern-api 3.47.1 → 3.47.2
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 +6 -6
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1262,7 +1262,7 @@ ${rG_.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&VRc(th
|
|
|
1262
1262
|
`+syn.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?syn.default.cyan(fG_(t,this.opt.mask)):syn.default.italic(syn.default.dim("[hidden]")):this.opt.mask?fG_(t,this.opt.mask):syn.default.italic(syn.default.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 xXo=ce(PR(),1);var fx_=ce(Pzc(),1),WXo=require("child_process"),Jta=require("fs"),VXo=ce(require("path"),1),dx_=ce(require("os"),1),px_=require("crypto"),uNc=ce(cx_(),1);var QXo=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var RGa=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var UXo=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var LXo=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function GXo(e="",t,r){let i=new sNc(e,r);i.runAsync((n,a)=>{if(n)setImmediate(t,n,void 0);else try{i.cleanup(),setImmediate(t,void 0,a)}catch(o){setImmediate(t,o,void 0)}})}function lx_(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function KhD(e){let t=[],r="";for(let i=0;i<e.length;i++){let n=e.charAt(i);i>0&&n===" "&&e[i-1]!=="\\"&&r.length>0?(t.push(r),r=""):r=`${r}${n}`}return r.length>0&&t.push(r),t}var sNc=class{text="";tempFile;editor;lastExitStatus=0;fileOptions={};get temp_file(){return console.log("DEPRECATED: temp_file. Use tempFile moving forward."),this.tempFile}get last_exit_status(){return console.log("DEPRECATED: last_exit_status. Use lastExitStatus moving forward."),this.lastExitStatus}constructor(t="",r){this.text=t,r&&(this.fileOptions=r),this.determineEditor(),this.createTemporaryFile()}run(){return this.launchEditor(),this.readTemporaryFile(),this.text}runAsync(t){try{this.launchEditorAsync(()=>{try{this.readTemporaryFile(),setImmediate(t,void 0,this.text)}catch(r){setImmediate(t,r,void 0)}})}catch(r){setImmediate(t,r,void 0)}}cleanup(){this.removeTemporaryFile()}determineEditor(){let t=process.env.VISUAL?process.env.VISUAL:process.env.EDITOR?process.env.EDITOR:process.platform.startsWith("win")?"notepad":"vim",r=KhD(t).map(n=>n.replace("\\ "," ")),i=r.shift();this.editor={args:r,bin:i}}createTemporaryFile(){try{let t=this.fileOptions.dir??dx_.default.tmpdir(),r=(0,px_.randomUUID)(),i=lx_(this.fileOptions.prefix),n=lx_(this.fileOptions.postfix),a=`${i}${r}${n}`,o=VXo.default.resolve(t,a),c=VXo.default.resolve(t)+VXo.default.sep;if(!o.startsWith(c))throw new Error("Resolved temporary file escaped the base directory");this.tempFile=o;let d={encoding:"utf8",flag:"wx"};Object.prototype.hasOwnProperty.call(this.fileOptions,"mode")&&(d.mode=this.fileOptions.mode),(0,Jta.writeFileSync)(this.tempFile,this.text,d)}catch(t){throw new QXo(t)}}readTemporaryFile(){try{let t=(0,Jta.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,fx_.detect)(t)??"utf8";uNc.default.encodingExists(r)||(r="utf8"),this.text=uNc.default.decode(t,r)}}catch(t){throw new UXo(t)}}removeTemporaryFile(){try{(0,Jta.unlinkSync)(this.tempFile)}catch(t){throw new LXo(t)}}launchEditor(){try{let t=(0,WXo.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new RGa(t)}}launchEditorAsync(t){try{(0,WXo.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",i=>{this.lastExitStatus=i,setImmediate(t)})}catch(r){throw new RGa(r)}}};var _x_=ce(Qve(),1);var zGa=class extends jR{_run(t){this.done=t,this.editorResult=new _x_.Subject;let r=cL(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"?xXo.default.dim("Received"):xXo.default.dim("Press <enter> to launch your preferred editor."),t&&(r=xXo.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),GXo(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 gx_=require("stream");var bx_=ce(require("readline"),1),vx_=ce(yx_(),1),dyn=class{constructor(t){this.rl||=bx_.default.createInterface($hD(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 $hD(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 vx_.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var NGa=class extends dyn{constructor(t={}){super(t),this.log=new gx_.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return OGa(this.rl,this.bottomBar.split(`
|
|
1263
1263
|
`).length),this}updateBottomBar(t){return OGa(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+`
|
|
1264
1264
|
`}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&&pXo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var um=ce(Qve(),1),Ax_=ce(X9a(),1);var HXo=ce(Qve(),1),Ox_=ce(X9a(),1),KXo=function(e,t,r){return typeof e[t]!="function"?(0,HXo.of)(e):(0,HXo.from)((0,Ox_.default)(e[t])(r).then(i=>(e[t]=i,e)))};var mx_={set:(e,t="",r)=>{let i=e;t.split(".").forEach((n,a,o)=>{n==="__proto__"||n==="constructor"||(a===o.length-1?i[n]=r:(!(n in i)||typeof i[n]!="object")&&(i[n]={}),i=i[n])})},get:(e,t="",r)=>{let i=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((o,c)=>o!=null?o[c]:o,e),n=i(/[,[\]]+?/)||i(/[,.[\]]+?/);return n===void 0||n===e?r:n}},$ta=class extends dyn{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let i;return Array.isArray(t)?i=(0,um.from)(t):(0,um.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,um.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,um.from)([t]),this.process=i.pipe((0,um.concatMap)(this.processQuestion.bind(this)),(0,um.publish)()),this.process.connect(),this.process.pipe((0,um.reduce)((n,a)=>(mx_.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,um.defer)(()=>(0,um.of)(t).pipe((0,um.concatMap)(this.setDefaultType.bind(this)),(0,um.concatMap)(this.filterIfRunnable.bind(this)),(0,um.concatMap)(()=>KXo(t,"message",this.answers)),(0,um.concatMap)(()=>KXo(t,"default",this.answers)),(0,um.concatMap)(()=>KXo(t,"choices",this.answers)),(0,um.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,um.defer)(()=>(0,um.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,um.defer)(()=>(0,um.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&mx_.get(this.answers,t.name)!==void 0)return um.EMPTY;if(t.when===!1)return um.EMPTY;if(typeof t.when!="function")return(0,um.of)(t);let{answers:r}=this;return(0,um.defer)(()=>(0,um.from)((0,Ax_.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,um.filter)(i=>i!=null)))}};function Px_(e){let t=function(r,i){let n;try{n=new $ta(t.prompts,e)}catch(o){return Promise.reject(o)}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",AGa),this.registerPrompt("input",uyn),this.registerPrompt("number",PGa),this.registerPrompt("confirm",jGa),this.registerPrompt("rawlist",wGa),this.registerPrompt("expand",EGa),this.registerPrompt("checkbox",SGa),this.registerPrompt("password",MGa),this.registerPrompt("editor",zGa)},t.restoreDefaultPrompts(),t}var lNc=Px_();function XhD(e,t){lNc.registerPrompt(e,t)}function ZhD(){lNc.restoreDefaultPrompts()}var khD={prompt:lNc,ui:{BottomBar:NGa,Prompt:$ta},createPromptModule:Px_,registerPrompt:XhD,restoreDefaultPrompts:ZhD,Separator:G$},JXo=khD;var Yta=require("path");function wx_(){let e=eyD();return async t=>{for(let r of t)r.module=e(r.filename);return t}}function eyD(e=process.argv[1]?(0,Yta.dirname)(process.argv[1]):process.cwd(),t=Yta.sep==="\\"){let r=t?jx_(e):e;return i=>{if(!i)return;let n=t?jx_(i):i,{dir:a,base:o,ext:c}=Yta.posix.parse(n);(c===".js"||c===".mjs"||c===".cjs")&&(o=o.slice(0,-1*c.length));let d=decodeURIComponent(o);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${d}`;if(a.startsWith(r)){let u=a.slice(r.length+1).replace(/\//g,".");return u?`${u}:${d}`:d}return d}}function jx_(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var fNc=e=>{if("flags"in e){let t=Ex_(e.flags),r=Sx_(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,Mx_(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,tyD(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function tyD(e,t,r){return{key:e,enabled:typeof t=="string"?!0:t,variant:typeof t=="string"?t:void 0,reason:void 0,metadata:{id:void 0,version:void 0,payload:r?JSON.stringify(r):void 0,description:void 0}}}var Ex_=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,pyn(r)]).filter(([,t])=>t!==void 0)),Sx_=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let i=t[r];return i.enabled&&i.metadata&&i.metadata.payload!==void 0}).map(r=>{let i=t[r].metadata?.payload;return[r,i?Mx_(i):void 0]}))};var pyn=e=>e===void 0?void 0:e.variant??e.enabled,Mx_=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};var $Xo="0123456789abcdef",YXo=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length===16)return new e(t);throw new TypeError("not 128-bit length")}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/256,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;default: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)}throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=$Xo.charAt(this.bytes[r]>>>4),t+=$Xo.charAt(15&this.bytes[r]),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=$Xo.charAt(this.bytes[r]>>>4),t+=$Xo.charAt(15&this.bytes[r]);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}},dNc=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??ryD()}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))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return YXo.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}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,YXo.ofInner(t)}},ryD=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())}),Dx_,V$t=()=>iyD().toString(),iyD=()=>(Dx_||(Dx_=new dNc)).generate();var nyD=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Bx_=function(e,t=[]){if(!e)return!1;let r=e.toLowerCase();return nyD.concat(t).some(i=>{let n=i.toLowerCase();return r.indexOf(n)!==-1})};var H$=(function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",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",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e})({});var oyD=Array.isArray,Ix_=Object.prototype,o59=Ix_.hasOwnProperty,pNc=Ix_.toString,Cx_=oyD||function(e){return pNc.call(e)==="[object Array]"};var Xta=e=>e===void 0,FGa=e=>pNc.call(e)=="[object String]",qx_=e=>FGa(e)&&e.trim().length===0;var Tx_=e=>pNc.call(e)=="[object Number]";var _Nc=e=>e instanceof Error;function uyD(e,t){try{return e instanceof t}catch{return!1}}function QGa(e){return e===null||typeof e!="object"}function _yn(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function Rx_(e){return _yn(e,"ErrorEvent")}function XXo(e){return!Xta(Event)&&uyD(e,Event)}function zx_(e){return _yn(e,"Object")}function UGa(e,t,r,i,n){return t>r&&(i.warn("min cannot be greater than max."),t=r),Tx_(e)?e>r?(i.warn(" cannot be greater than max: "+r+". Using max value instead."),r):e<t?(i.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(i.warn(" must be a number. using max or fallback. max: "+r+", fallback: "+n),UGa(n||r,t,r,i))}var syD=864e5,ZXo=class{constructor(t){this._buckets={},this._onBucketRateLimited=t._onBucketRateLimited,this._bucketSize=UGa(t.bucketSize,0,100,t._logger),this._refillRate=UGa(t.refillRate,0,this._bucketSize,t._logger),this._refillInterval=UGa(t.refillInterval,0,syD,t._logger)}_applyRefill(t,r){let i=r-t.lastAccess,n=Math.floor(i/this._refillInterval);if(n>0){let a=n*this._refillRate;t.tokens=Math.min(t.tokens+a,this._bucketSize),t.lastAccess=t.lastAccess+n*this._refillInterval}}consumeRateLimit(t){let r=Date.now(),i=String(t),n=this._buckets[i];return n?this._applyRefill(n,r):(n={tokens:this._bucketSize,lastAccess:r},this._buckets[i]=n),n.tokens===0?!0:(n.tokens--,n.tokens===0&&this._onBucketRateLimited?.(t),n.tokens===0)}stop(){this._buckets={}}};var kXo=class{add(t){let r=V$t();return this.promiseByIds[r]=t,t.catch(()=>{}).finally(()=>{delete this.promiseByIds[r]}),t}async join(){let t=Object.values(this.promiseByIds),r=t.length;for(;r>0;)await Promise.all(t),t=Object.values(this.promiseByIds),r=t.length}get length(){return Object.keys(this.promiseByIds).length}constructor(){this.promiseByIds={}}};function cyD(e=console){return{log:e.log.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),debug:e.debug.bind(e)}}var Nx_=(e,t,r)=>{function i(a,...o){t(()=>{let c=r[a];c(e,...o)})}return{info:(...a)=>{i("log",...a)},warn:(...a)=>{i("warn",...a)},error:(...a)=>{i("error",...a)},critical:(...a)=>{r.error(e,...a)},createLogger:a=>Nx_(`${e} ${a}`,t,r)}},lyD=e=>e();function Fx_(e,t=lyD){return Nx_(e,t,cyD())}var kta="Mobile",tZo="iOS",Zta="Android",Qx_="Tablet",v59=Zta+" "+Qx_;var fyD="Apple",g59=fyD+" Watch",Ux_="Safari",rZo="BlackBerry",Lx_="Samsung",dyD=Lx_+"Browser",pyD=Lx_+" Internet",iZo="Chrome",_yD=iZo+" OS",hyD=iZo+" "+tZo,Vx_="Internet Explorer",yyD=Vx_+" "+kta,yNc="Opera",O59=yNc+" Mini",Wx_="Edge",byD="Microsoft "+Wx_,bNc="Firefox",vyD=bNc+" "+tZo,vNc="Nintendo",gNc="PlayStation",eZo="Xbox",gyD=Zta+" "+kta,OyD=kta+" "+Ux_,LGa="Windows",myD=LGa+" Phone";var Gx_="Generic",m59=Gx_+" "+kta.toLowerCase(),A59=Gx_+" "+Qx_.toLowerCase(),AyD="Konqueror",ex="(\\d+(\\.\\d+)?)",hNc=new RegExp("Version/"+ex),P59=new RegExp(eZo,"i"),j59=new RegExp(gNc+" \\w+","i"),w59=new RegExp(vNc+" \\w+","i"),PyD=new RegExp(rZo+"|PlayBook|BB10","i"),jyD={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000","5.1":"XP","5.2":"XP","6.0":"Vista","6.1":"7","6.2":"8","6.3":"8.1","6.4":"10","10.0":"10"};var E59={[yyD]:[new RegExp("rv:"+ex)],[byD]:[new RegExp(Wx_+"?\\/"+ex)],[iZo]:[new RegExp("("+iZo+"|CrMo)\\/"+ex)],[hyD]:[new RegExp("CriOS\\/"+ex)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ex)],[Ux_]:[hNc],[OyD]:[hNc],[yNc]:[new RegExp("("+yNc+"|OPR)\\/"+ex)],[bNc]:[new RegExp(bNc+"\\/"+ex)],[vyD]:[new RegExp("FxiOS\\/"+ex)],[AyD]:[new RegExp("Konqueror[:/]?"+ex,"i")],[rZo]:[new RegExp(rZo+" "+ex),hNc],[gyD]:[new RegExp("android\\s"+ex,"i")],[pyD]:[new RegExp(dyD+"\\/"+ex)],[Vx_]:[new RegExp("(rv:|MSIE )"+ex)],Mozilla:[new RegExp("rv:"+ex)]};var S59=[[new RegExp(eZo+"; "+eZo+" (.*?)[);]","i"),e=>[eZo,e&&e[1]||""]],[new RegExp(vNc,"i"),[vNc,""]],[new RegExp(gNc,"i"),[gNc,""]],[PyD,[rZo,""]],[new RegExp(LGa,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[myD,""];if(new RegExp(kta).test(t)&&!/IEMobile\b/.test(t))return[LGa+" "+kta,""];let r=/Windows NT ([0-9.]+)/i.exec(t);if(r&&r[1]){let i=r[1],n=jyD[i]||"";return/arm/i.test(t)&&(n="RT"),[LGa,n]}return[LGa,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){let t=[e[3],e[4],e[5]||"0"];return[tZo,t.join(".")]}return[tZo,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=Xta(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Zta+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Zta+")","i"),e=>{if(e&&e[2]){let t=[e[2],e[3],e[4]||"0"];return[Zta,t.join(".")]}return[Zta,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{let t=["Mac OS X",""];if(e&&e[1]){let r=[e[1],e[2],e[3]||"0"];t[1]=r.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[_yD,""]],[/Linux|debian/i,["Linux",""]]];var xx_="utf8";function Hx_(e,t){if(!e||typeof e!="string"||wyD(e))throw new Error(t)}function wyD(e){return e.trim().length===0}function Kx_(e){return e?.replace(/\/+$/,"")}async function Jx_(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 nZo(){return new Date().toISOString()}function hyn(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var $x_=e=>e instanceof Error;function ONc(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var aZo=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)}};function Yx_(){return"CompressionStream"in globalThis}async function mNc(e,t=!0){try{let i=new Blob([e],{type:"text/plain"}).stream().pipeThrough(new CompressionStream("gzip"));return await new Response(i).blob()}catch(r){return t&&console.error("Failed to gzip compress data",r),null}}var era=class extends Error{constructor(t,r){super("HTTP error while fetching PostHog: status="+t.status+", reqByteLength="+r),this.response=t,this.reqByteLength=r,this.name="PostHogFetchHttpError"}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}},VGa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function Xx_(e){if(e instanceof era){let t="";try{t=await e.text}catch{}console.error(`Error while flushing PostHog: message=${e.message}, response body=${t}`,e)}else console.error("Error while flushing PostHog",e);return Promise.resolve()}function ANc(e){return typeof e=="object"&&(e instanceof era||e instanceof VGa)}function Zx_(e){return typeof e=="object"&&e instanceof era&&e.status===413}var WGa=class{constructor(t,r={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new kXo,this._events=new aZo,this._isInitialized=!1,Hx_(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=Kx_(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.preloadFeatureFlags=r.preloadFeatureFlags??!0,this.defaultOptIn=r.defaultOptIn??!0,this.disableSurveys=r.disableSurveys??!1,this._retryOptions={retryCount:r.fetchRetryCount??3,retryDelay:r.fetchRetryDelay??3e3,retryCheck:ANc},this.requestTimeout=r.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r.featureFlagsRequestTimeoutMs??3e3,this.remoteConfigRequestTimeoutMs=r.remoteConfigRequestTimeoutMs??3e3,this.disableGeoip=r.disableGeoip??!0,this.disabled=r.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this.evaluationEnvironments=r?.evaluationEnvironments,this._initPromise=Promise.resolve(),this._isInitialized=!0,this._logger=Fx_("[PostHog]",this.logMsgIfDebug.bind(this)),this.disableCompression=!Yx_()||(r?.disableCompression??!1)}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled)return void this._logger.warn("The client is disabled");if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(H$.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(H$.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(H$.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>this._logger.info(i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){return this.promiseQueue.add(t)}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}async identifyStatelessImmediate(t,r,i){let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("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)})}async captureStatelessImmediate(t,r,i,n){let a=this.buildPayload({distinct_id:t,event:r,properties:i});await this.sendImmediate("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)})}async aliasStatelessImmediate(t,r,i,n){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,n)}groupIdentifyStateless(t,r,i,n,a,o){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...o||{}}});this.enqueue("capture",c,n)})}async getRemoteConfig(){await this._initPromise;let t=this.host;t==="https://us.i.posthog.com"?t="https://us-assets.i.posthog.com":t==="https://eu.i.posthog.com"&&(t="https://eu-assets.i.posthog.com");let r=`${t}/array/${this.apiKey}/config`,i={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,i,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(n=>n.json()).catch(n=>{this._logger.error("Remote config could not be loaded",n),this._events.emit("error",n)})}async getFlags(t,r={},i={},n={},a={},o=!0){await this._initPromise;let c=o?"&config=true":"",d=`${this.host}/flags/?v=2${c}`,s={token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a};this.evaluationEnvironments&&this.evaluationEnvironments.length>0&&(s.evaluation_environments=this.evaluationEnvironments);let u={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify(s)};return this._logger.info("Flags URL",d),this.fetchWithRetry(d,u,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(l=>l.json()).then(l=>fNc(l)).catch(l=>{this._events.emit("error",l)})}async getFeatureFlagStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,i,n,a,o);if(c===void 0)return{response:void 0,requestId:void 0};let d=pyn(c.response);return d===void 0&&(d=!1),{response:d,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,i,n,a,o,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId,evaluatedAt:c.evaluatedAt}}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,i,n,a,o,[t]);if(!c)return;let d=c[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a,o){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,o)).payloads}async getFeatureFlagsStateless(t,r={},i={},n={},a,o){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,o)}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a,o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,i,n,a,o);return c?{flags:c.featureFlags,payloads:c.featureFlagPayloads,requestId:c.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},i={},n={},a,o){await this._initPromise;let c={};(a??this.disableGeoip)&&(c.geoip_disable=!0),o&&(c.flag_keys_to_evaluate=o);let d=await this.getFlags(t,r,i,n,c);if(d!==void 0)return d.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),d.quotaLimited?.includes("feature_flags")?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:d?.requestId}):d}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this._logger.info("Loading surveys is disabled."),[];let t=`${this.host}/api/surveys/?token=${this.apiKey}`,r={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},n=(await this.fetchWithRetry(t,r).then(a=>{if(a.status!==200||!a.json){let o=`Surveys API could not be loaded: ${a.status}`,c=new Error(o);this._logger.error(c),this._events.emit("error",new Error(o));return}return a.json()}).catch(a=>{this._logger.error("Surveys API could not be loaded",a),this._events.emit("error",a)}))?.surveys;return n&&this._logger.info("Surveys fetched from API: ",JSON.stringify(n)),n??[]}get props(){return this._props||(this._props=this.getPersistedProperty(H$.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(H$.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(H$.Props,this.props)})}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut)return void this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");let n=this.prepareMessage(t,r,i),a=this.getPersistedProperty(H$.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this._logger.info("Queue is full, the oldest event is dropped.")),a.push({message:n}),this.setPersistedProperty(H$.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=hyn(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,i){if(this.disabled)return void this._logger.warn("The client is disabled");if(this._isInitialized||await this._initPromise,this.optedOut)return void this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");let n={api_key:this.apiKey,batch:[this.prepareMessage(t,r,i)],sent_at:nZo()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),o=`${this.host}/batch/`,c=this.disableCompression?null:await mNc(a,this.isDebug),d={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",...c!==null&&{"Content-Encoding":"gzip"}},body:c||a};try{await this.fetchWithRetry(o,d)}catch(s){this._events.emit("error",s)}}prepareMessage(t,r,i){let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:nZo(),uuid:i?.uuid?i.uuid:V$t()};return(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId),n}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await Xx_(t)})}async flush(){let t=ONc([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),ONc([t]).then(()=>{this.flushPromise===t&&(this.flushPromise=null)}),t}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(H$.Queue)||[];if(!t.length)return;let r=[],i=t.length;for(;t.length>0&&r.length<i;){let n=t.slice(0,this.maxBatchSize),a=n.map(_=>_.message),o=()=>{let h=(this.getPersistedProperty(H$.Queue)||[]).slice(n.length);this.setPersistedProperty(H$.Queue,h),t=h},c={api_key:this.apiKey,batch:a,sent_at:nZo()};this.historicalMigration&&(c.historical_migration=!0);let d=JSON.stringify(c),s=`${this.host}/batch/`,u=this.disableCompression?null:await mNc(d,this.isDebug),l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",...u!==null&&{"Content-Encoding":"gzip"}},body:u||d},p={retryCheck:_=>Zx_(_)?!1:ANc(_)};try{await this.fetchWithRetry(s,l,p)}catch(_){if(Zx_(_)&&a.length>1){this.maxBatchSize=Math.max(1,Math.floor(a.length/2)),this._logger.warn(`Received 413 when sending batch of size ${a.length}, reducing batch size to ${this.maxBatchSize}`);continue}throw _ instanceof VGa||o(),this._events.emit("error",_),_}o(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,i,n){AbortSignal.timeout??=function(c){let d=new AbortController;return setTimeout(()=>d.abort(),c),d.signal};let a=r.body?r.body:"",o=-1;try{o=a instanceof Blob?a.size:Buffer.byteLength(a,xx_)}catch{a instanceof Blob?o=a.size:o=new TextEncoder().encode(a).length}return await Jx_(async()=>{let c=null;try{c=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(s){throw new VGa(s)}if(!(r.mode==="no-cors")&&(c.status<200||c.status>=400))throw new era(c,o);return c},{...this._retryOptions,...i})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let i=async()=>{try{for(await this.promiseQueue.join();!((this.getPersistedProperty(H$.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!ANc(n))throw n;await Xx_(n)}};return Promise.race([new Promise((n,a)=>{hyn(()=>{this._logger.error("Timed out while shutting down PostHog"),r=!0,a("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),i()])}async shutdown(t=3e4){return this.shutdownPromise?this._logger.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup"):this.shutdownPromise=this._shutdown(t).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}};var K$={};Yt(K$,{DOMExceptionCoercer:()=>jNc,ErrorCoercer:()=>wNc,ErrorEventCoercer:()=>ENc,ErrorPropertiesBuilder:()=>PNc,EventCoercer:()=>DNc,ObjectCoercer:()=>MNc,PrimitiveCoercer:()=>BNc,PromiseRejectionEventCoercer:()=>INc,ReduceableCache:()=>CNc,StringCoercer:()=>SNc,chromeStackLineParser:()=>tH_,createStackParser:()=>QyD,geckoStackLineParser:()=>iH_,nodeStackLineParser:()=>uH_,opera10StackLineParser:()=>nH_,opera11StackLineParser:()=>aH_,reverseAndStripFrames:()=>lH_,winjsStackLineParser:()=>rH_});var oZo,kx_,uZo;function eH_(e){let t=globalThis._posthogChunkIds;if(!t)return;let r=Object.keys(t);return uZo&&r.length===kx_||(kx_=r.length,uZo=r.reduce((i,n)=>{oZo||(oZo={});let a=oZo[n];if(a)i[a[0]]=a[1];else{let o=e(n);for(let c=o.length-1;c>=0;c--){let s=o[c]?.filename,u=t[n];if(s&&u){i[s]=u,oZo[n]=[s,u];break}}}return i},{})),uZo}var EyD=4,PNc=class{constructor(t,r,i=[]){this.coercers=t,this.stackParser=r,this.modifiers=i}buildFromUnknown(t,r={}){let n=r&&r.mechanism||{handled:!0,type:"generic"},o=this.buildCoercingContext(n,r,0).apply(t),c=this.buildParsingContext(),d=this.parseStacktrace(o,c);return{$exception_list:this.convertToExceptionList(d,n),$exception_level:"error"}}async modifyFrames(t){for(let r of t)r.stacktrace&&r.stacktrace.frames&&Cx_(r.stacktrace.frames)&&(r.stacktrace.frames=await this.applyModifiers(r.stacktrace.frames));return t}coerceFallback(t){return{type:"Error",value:"Unknown error",stack:t.syntheticException?.stack,synthetic:!0}}parseStacktrace(t,r){let i;t.cause!=null&&(i=this.parseStacktrace(t.cause,r));let n;return t.stack!=""&&t.stack!=null&&(n=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?1:0),r.chunkIdMap)),{...t,cause:i,stack:n}}applyChunkIds(t,r){return t.map(i=>(i.filename&&r&&(i.chunk_id=r[i.filename]),i))}applyCoercers(t,r){for(let i of this.coercers)if(i.match(t))return i.coerce(t,r);return this.coerceFallback(r)}async applyModifiers(t){let r=t;for(let i of this.modifiers)r=await i(r);return r}convertToExceptionList(t,r){let i={type:t.type,value:t.value,mechanism:{type:r.type??"generic",handled:r.handled??!0,synthetic:t.synthetic??!1}};t.stack&&(i.stacktrace={type:"raw",frames:t.stack});let n=[i];return t.cause!=null&&n.push(...this.convertToExceptionList(t.cause,{...r,handled:!0})),n}buildParsingContext(){return{chunkIdMap:eH_(this.stackParser)}}buildCoercingContext(t,r,i=0){let n=(o,c)=>{if(c<=EyD){let d=this.buildCoercingContext(t,r,c);return this.applyCoercers(o,d)}};return{...r,syntheticException:i==0?r.syntheticException:void 0,mechanism:t,apply:o=>n(o,i),next:o=>n(o,i+1)}}};var fL="?";function W$t(e,t,r,i,n){let a={platform:e,filename:t,function:r==="<anonymous>"?fL:r,in_app:!0};return Xta(i)||(a.lineno=i),Xta(n)||(a.colno=n),a}var sZo=(e,t)=>{let r=e.indexOf("safari-extension")!==-1,i=e.indexOf("safari-web-extension")!==-1;return r||i?[e.indexOf("@")!==-1?e.split("@")[0]:fL,r?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]};var SyD=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,MyD=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,DyD=/\((\S*)(?::(\d+))(?::(\d+))\)/,tH_=(e,t)=>{let r=SyD.exec(e);if(r){let[,n,a,o]=r;return W$t(t,n,fL,+a,+o)}let i=MyD.exec(e);if(i){if(i[2]&&i[2].indexOf("eval")===0){let c=DyD.exec(i[2]);c&&(i[2]=c[1],i[3]=c[2],i[4]=c[3])}let[a,o]=sZo(i[1]||fL,i[2]);return W$t(t,o,a,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}};var ByD=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i,rH_=(e,t)=>{let r=ByD.exec(e);return r?W$t(t,r[2],r[1]||fL,+r[3],r[4]?+r[4]:void 0):void 0};var IyD=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,CyD=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,iH_=(e,t)=>{let r=IyD.exec(e);if(r){if(r[3]&&r[3].indexOf(" > eval")>-1){let o=CyD.exec(r[3]);o&&(r[1]=r[1]||"eval",r[3]=o[1],r[4]=o[2],r[5]="")}let n=r[3],a=r[1]||fL;return[a,n]=sZo(a,n),W$t(t,n,a,r[4]?+r[4]:void 0,r[5]?+r[5]:void 0)}};var qyD=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,nH_=(e,t)=>{let r=qyD.exec(e);return r?W$t(t,r[2],r[3]||fL,+r[1]):void 0},TyD=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i,aH_=(e,t)=>{let r=TyD.exec(e);return r?W$t(t,r[5],r[3]||r[4]||fL,+r[1],+r[2]):void 0};var RyD=/^\s*[-]{4,}$/,zyD=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,uH_=(e,t)=>{let r=e.match(zyD);if(r){let i,n,a,o,c;if(r[1]){a=r[1];let u=a.lastIndexOf(".");if(a[u-1]==="."&&u--,u>0){i=a.slice(0,u),n=a.slice(u+1);let l=i.indexOf(".Module");l>0&&(a=a.slice(l+1),i=i.slice(0,l))}o=void 0}n&&(o=i,c=n),n==="<anonymous>"&&(c=void 0,a=void 0),a===void 0&&(c=c||fL,a=o?`${o}.${c}`:c);let d=r[2]?.startsWith("file://")?r[2].slice(7):r[2],s=r[5]==="native";return d?.match(/\/[A-Z]:/)&&(d=d.slice(1)),!d&&r[5]&&!s&&(d=r[5]),{filename:d?decodeURI(d):void 0,module:void 0,function:a,lineno:oH_(r[3]),colno:oH_(r[4]),in_app:NyD(d||"",s),platform:t}}if(e.match(RyD))return{filename:e,platform:t}};function NyD(e,t=!1){return!(t||e&&!e.startsWith("/")&&!e.match(/^[A-Z]:/)&&!e.startsWith(".")&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&e!==void 0&&!e.includes("node_modules/")}function oH_(e){return parseInt(e||"",10)||void 0}var sH_=/\(error: (.*)\)/,cH_=50;function lH_(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,cH_).map(r=>({...r,filename:r.filename||FyD(t).filename,function:r.function||fL}))}function FyD(e){return e[e.length-1]||{}}function QyD(e,...t){return(r,i=0)=>{let n=[],a=r.split(`
|
|
1265
|
-
`);for(let o=i;o<a.length;o++){let c=a[o];if(c.length>1024)continue;let d=sH_.test(c)?c.replace(sH_,"$1"):c;if(!d.match(/\S*Error: /)){for(let s of t){let u=s(d,e);if(u){n.push(u);break}}if(n.length>=cH_)break}}return lH_(n)}}var jNc=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,r){let i=FGa(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?r.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){let r=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?`${r}: ${t.message}`:r}isDOMException(t){return _yn(t,"DOMException")}isDOMError(t){return _yn(t,"DOMError")}};var wNc=class{match(t){return _Nc(t)}coerce(t,r){return{type:this.getType(t),value:this.getMessage(t,r),stack:this.getStack(t),cause:t.cause?r.next(t.cause):void 0,synthetic:!1}}getType(t){return t.name||t.constructor.name}getMessage(t,r){let i=t.message;return i.error&&typeof i.error.message=="string"?String(i.error.message):String(i)}getStack(t){return t.stacktrace||t.stack||void 0}};var ENc=class{constructor(){}match(t){return Rx_(t)&&t.error!=null}coerce(t,r){let i=r.apply(t.error);return i||{type:"ErrorEvent",value:t.message,stack:r.syntheticException?.stack,synthetic:!0}}};var UyD=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,SNc=class{match(t){return typeof t=="string"}coerce(t,r){let[i,n]=this.getInfos(t);return{type:i??"Error",value:n??t,stack:r.syntheticException?.stack,synthetic:!0}}getInfos(t){let r="Error",i=t,n=t.match(UyD);return n&&(r=n[1],i=n[2]),[r,i]}};var fH_=["fatal","error","warning","log","info","debug"];function cZo(e,t=40){let r=Object.keys(e);if(r.sort(),!r.length)return"[object has no keys]";for(let i=r.length;i>0;i--){let n=r.slice(0,i).join(", ");if(!(n.length>t))return i===r.length||n.length<=t?n:`${n.slice(0,t)}...`}return""}var MNc=class{match(t){return typeof t=="object"&&t!==null}coerce(t,r){let i=this.getErrorPropertyFromObject(t);return i?r.apply(i):{type:this.getType(t),value:this.getValue(t),stack:r.syntheticException?.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return XXo(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){let n=`'${t.name}' captured as exception`;return"message"in t&&typeof t.message=="string"&&(n+=` with message: '${t.message}'`),n}if("message"in t&&typeof t.message=="string")return t.message;let r=this.getObjectClassName(t),i=cZo(t);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${i}`}isSeverityLevel(t){return FGa(t)&&!qx_(t)&&fH_.indexOf(t)>=0}getErrorPropertyFromObject(t){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if($x_(i))return i}}getObjectClassName(t){try{let r=Object.getPrototypeOf(t);return r?r.constructor.name:void 0}catch{return}}};var DNc=class{match(t){return XXo(t)}coerce(t,r){let i=t.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${cZo(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var BNc=class{match(t){return QGa(t)}coerce(t,r){return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var INc=class{match(t){return _yn(t,"PromiseRejectionEvent")}coerce(t,r){let i=this.getUnhandledRejectionReason(t);return QGa(i)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(i)}`,stack:r.syntheticException?.stack,synthetic:!0}:r.apply(i)}getUnhandledRejectionReason(t){if(QGa(t))return t;try{if("reason"in t)return t.reason;if("detail"in t&&"reason"in t.detail)return t.detail.reason}catch{}return t}};var CNc=class{constructor(t){this._maxSize=t,this._cache=new Map}get(t){let r=this._cache.get(t);if(r!==void 0)return this._cache.delete(t),this._cache.set(t,r),r}set(t,r){this._cache.set(t,r)}reduce(){for(;this._cache.size>=this._maxSize;){let t=this._cache.keys().next().value;t&&this._cache.delete(t)}}};var _H_=require("fs"),hH_=require("readline"),lZo=new K$.ReduceableCache(25),yH_=new K$.ReduceableCache(20),qNc=7,LyD=1e3,VyD=1e4;async function bH_(e){let t={};for(let n=e.length-1;n>=0;n--){let a=e[n],o=a?.filename;if(!a||typeof o!="string"||typeof a.lineno!="number"||HyD(o)||KyD(a))continue;t[o]||(t[o]=[]),t[o].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let i=[];for(let n of r){if(yH_.get(n))continue;let a=t[n];if(!a)continue;a.sort((d,s)=>d-s);let o=$yD(a);if(o.every(d=>JyD(n,d)))continue;let c=YyD(lZo,n,{});i.push(WyD(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&GyD(e,lZo),lZo.reduce(),e}function WyD(e,t,r){return new Promise(i=>{let n=(0,_H_.createReadStream)(e),a=(0,hH_.createInterface)({input:n});function o(){n.destroy(),i()}let c=0,d=0,s=t[d];if(s===void 0)return void o();let u=s[0],l=s[1];function p(){yH_.set(e,1),a.close(),a.removeAllListeners(),o()}n.on("error",p),a.on("error",p),a.on("close",o),a.on("line",_=>{if(c++,!(c<u)&&(r[c]=XyD(_,0),c>=l)){if(d===t.length-1){a.close(),a.removeAllListeners();return}d++;let h=t[d];if(h===void 0){a.close(),a.removeAllListeners();return}u=h[0],l=h[1]}})})}function GyD(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let i=t.get(r.filename);if(i===void 0)continue;xyD(r.lineno,r,i)}}function xyD(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=vH_(e);n<e;n++){let a=r[n];if(a===void 0)return void dH_(t);t.pre_context.push(a)}if(r[e]===void 0)return void dH_(t);t.context_line=r[e];let i=gH_(e);t.post_context=[];for(let n=e+1;n<=i;n++){let a=r[n];if(a===void 0)break;t.post_context.push(a)}}function dH_(e){delete e.pre_context,delete e.context_line,delete e.post_context}function HyD(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function KyD(e){return e.lineno!==void 0&&e.lineno>VyD||e.colno!==void 0&&e.colno>LyD}function JyD(e,t){let r=lZo.get(e);if(r===void 0)return!1;for(let i=t[0];i<=t[1];i++)if(r[i]===void 0)return!1;return!0}function $yD(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=pH_(r),n=[];for(;;){if(t===e.length-1){n.push(i);break}let a=e[t+1];if(typeof a!="number")break;a<=i[1]?i[1]=a+qNc:(n.push(i),i=pH_(a)),t++}return n}function pH_(e){return[vH_(e),gH_(e)]}function vH_(e){return Math.max(1,e-qNc)}function gH_(e){return e+qNc}function YyD(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function XyD(e,t){let r=e,i=r.length;if(i<=150)return r;t>i&&(t=i);let n=Math.max(t-60,0);n<5&&(n=0);let a=Math.min(n+140,i);return a>i-5&&(a=i),a===i&&(n=Math.max(a-140,0)),r=r.slice(n,a),n>0&&(r=`...${r}`),a<i&&(r+="..."),r}function ZyD(e,t){let r=!1;return Object.assign(i=>{let a=global.process.listeners("uncaughtException").filter(o=>o.name!=="domainUncaughtExceptionClear"&&o._posthogErrorHandler!==!0).length===0;e(i,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t(i))},{_posthogErrorHandler:!0})}function OH_(e,t){globalThis.process?.on("uncaughtException",ZyD(e,t))}function mH_(e){globalThis.process?.on("unhandledRejection",t=>e(t,{mechanism:{type:"onunhandledrejection",handled:!1}}))}var kyD=2e3,SQi=class e{constructor(t,r,i){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this._logger=i,this._rateLimiter=new ZXo({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static async buildEventMessage(t,r,i,n){let a={...n};i||(a.$process_person_profile=!1);let o=this.errorPropertiesBuilder.buildFromUnknown(t,r);return o.$exception_list=await this.errorPropertiesBuilder.modifyFrames(o.$exception_list),{event:"$exception",distinctId:i||V$t(),properties:{...o,...a}}}startAutocaptureIfEnabled(){this.isEnabled()&&(OH_(this.onException.bind(this),this.onFatalError.bind(this)),mH_(this.onException.bind(this)))}onException(t,r){this.client.addPendingPromise((async()=>{let i=await e.buildEventMessage(t,r),a=i.properties?.$exception_list[0]?.type??"Exception";return this._rateLimiter.consumeRateLimit(a)?void this._logger.info("Skipping exception capture because of client rate limiting.",{exception:a}):this.client.capture(i)})())}async onFatalError(t){console.error(t),await this.client.shutdown(kyD),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};var AH_="5.17.4";async function PH_(e){let t=globalThis.crypto?.subtle;if(!t)throw new Error("SubtleCrypto API not available");let r=await t.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(r)).map(n=>n.toString(16).padStart(2,"0")).join("")}var ebD=6e4,tbD=1152921504606847e3,rbD=["is_not"],tra=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},I0=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},G$t=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},fZo=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:o,...c}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,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=c.fetch||fetch,this.onError=c.onError,this.customHeaders=o,this.onLoad=c.onLoad,this.cacheProvider=c.cacheProvider,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let o,c;if(!this.loadedSuccessfullyOnce)return o;if(c=this.featureFlagsByKey[t],c!==void 0)try{o=(await this.computeFlagAndPayloadLocally(c,r,i,n,a)).value,this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${o}`))}catch(d){d instanceof G$t||d instanceof I0?this.logMsgIfDebug(()=>console.debug(`${d.name} when computing flag locally: ${t}: ${d.message}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return o}async getAllFlagsAndPayloads(t,r={},i={},n={},a){await this.loadFeatureFlags();let o={},c={},d=this.featureFlags.length==0,s=a?a.map(l=>this.featureFlagsByKey[l]).filter(Boolean):this.featureFlags,u={};return await Promise.all(s.map(async l=>{try{let{value:p,payload:_}=await this.computeFlagAndPayloadLocally(l,t,r,i,n,void 0,u);o[l.key]=p,_&&(c[l.key]=_)}catch(p){p instanceof G$t||p instanceof I0?this.logMsgIfDebug(()=>console.debug(`${p.name} when computing flag locally: ${l.key}: ${p.message}`)):p instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${l.key}: ${p}`)),d=!0}})),{response:o,payloads:c,fallbackToFlags:d}}async computeFlagAndPayloadLocally(t,r,i={},n={},a={},o,c,d=!1){if(d||await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return{value:!1,payload:null};let s;s=o!==void 0?o:await this.computeFlagValueLocally(t,r,i,n,a,c);let u=this.getFeatureFlagPayload(t.key,s);return{value:s,payload:u}}async computeFlagValueLocally(t,r,i={},n={},a={},o={}){if(t.ensure_experience_continuity)throw new I0("Flag has experience continuity enabled");if(!t.active)return!1;let d=(t.filters||{}).aggregation_group_type_index;if(d==null)return await this.matchFeatureFlagProperties(t,r,n,o);{let s=this.groupTypeMapping[String(d)];if(!s)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${d} for feature flag ${t.key}`)),new I0("Flag has unknown group type index");if(!(s in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let u=a[s];return await this.matchFeatureFlagProperties(t,i[s],u,o)}}getFeatureFlagPayload(t,r){let i=null;if(r!==!1&&r!=null&&(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]||null:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]||null),i!=null)){if(typeof i=="object")return i;if(typeof i=="string")try{return JSON.parse(i)}catch{}return i}return null}async evaluateFlagDependency(t,r,i,n){let a=t.key;if(!this.featureFlagsByKey)throw new I0("Feature flags not available for dependency evaluation");if(!("dependency_chain"in t))throw new I0(`Flag dependency property for '${a}' is missing required 'dependency_chain' field`);let o=t.dependency_chain;if(!Array.isArray(o))throw new I0(`Flag dependency property for '${a}' has an invalid 'dependency_chain' (expected array, got ${typeof o})`);if(o.length===0)throw new I0(`Circular dependency detected for flag '${a}' (empty dependency chain)`);for(let d of o){if(!(d in n)){let u=this.featureFlagsByKey[d];if(u)if(u.active)try{let l=await this.matchFeatureFlagProperties(u,r,i,n);n[d]=l}catch(l){throw new I0(`Error evaluating flag dependency '${d}' for flag '${a}': ${l}`)}else n[d]=!1;else throw new I0(`Missing flag dependency '${d}' for flag '${a}'`)}if(n[d]==null)throw new I0(`Dependency '${d}' could not be evaluated`)}let c=n[a];return this.flagEvaluatesToExpectedValue(t.value,c)}flagEvaluatesToExpectedValue(t,r){return typeof t=="boolean"?t===r||typeof r=="string"&&r!==""&&t===!0:typeof t=="string"?r===t:!1}async matchFeatureFlagProperties(t,r,i,n={}){let a=t.filters||{},o=a.groups||[],c=!1,d;for(let s of o)try{if(await this.isConditionMatch(t,r,s,i,n)){let u=s.variant,l=a.multivariate?.variants||[];d=u&&l.some(p=>p.key===u)?u:await this.getMatchingVariant(t,r)||!0;break}}catch(u){if(u instanceof G$t)throw u;if(u instanceof I0)c=!0;else throw u}if(d!==void 0)return d;if(c)throw new I0("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,i,n,a={}){let o=i.rollout_percentage,c=d=>{this.logMsgIfDebug(()=>console.warn(d))};if((i.properties||[]).length>0){for(let d of i.properties){let s=d.type,u=!1;if(u=s==="cohort"?MH_(d,n,this.cohorts,this.debugMode):s==="flag"?await this.evaluateFlagDependency(d,r,n,a):SH_(d,n,c),!u)return!1}if(o==null)return!0}return!(o!=null&&await jH_(t.key,r)>o/100)}async getMatchingVariant(t,r){let i=await jH_(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(c=>{n=i+c.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:c.key}),i=n}),r}updateFlagState(t){this.featureFlags=t.flags,this.featureFlagsByKey=t.flags.reduce((r,i)=>(r[i.key]=i,r),{}),this.groupTypeMapping=t.groupTypeMapping,this.cohorts=t.cohorts,this.loadedSuccessfullyOnce=!0}async loadFromCache(t){if(!this.cacheProvider)return!1;try{let r=await this.cacheProvider.getFlagDefinitions();return r?(this.updateFlagState(r),this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] ${t} (${r.flags.length} flags)`)),this.onLoad?.(this.featureFlags.length),!0):!1}catch(r){return this.onError?.(new Error(`Failed to load from cache: ${r}`)),!1}}async loadFeatureFlags(t=!1){if(!(this.loadedSuccessfullyOnce&&!t))return this.loadingPromise||(this.loadingPromise=this._loadFeatureFlags().catch(r=>this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Failed to load feature flags: ${r}`))).finally(()=>{this.loadingPromise=void 0})),this.loadingPromise}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(ebD,this.pollingInterval*2**this.backOffCount):this.pollingInterval}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this.loadFeatureFlags(!0),this.getPollingInterval());try{let t=!0;if(this.cacheProvider)try{t=await this.cacheProvider.shouldFetchFlagDefinitions()}catch(i){this.onError?.(new Error(`Error in shouldFetchFlagDefinitions: ${i}`))}if(!t&&(await this.loadFromCache("Loaded flags from cache (skipped fetch)")||this.loadedSuccessfullyOnce))return;let r=await this._requestFeatureFlagDefinitions();if(!r)return;switch(r.status){case 304:this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Flags not modified (304), using cached data")),this.flagsEtag=r.headers?.get("ETag")??this.flagsEtag,this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0;return;case 401:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new tra(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new tra(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new tra(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let i=await r.json()??{};if(!("flags"in i))return void this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(i)}`));this.flagsEtag=r.headers?.get("ETag")??void 0;let n={flags:i.flags??[],groupTypeMapping:i.group_type_mapping||{},cohorts:i.cohorts||{}};if(this.updateFlagState(n),this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.cacheProvider&&t)try{await this.cacheProvider.onFlagDefinitionsReceived(n)}catch(a){this.onError?.(new Error(`Failed to store in cache: ${a}`))}this.onLoad?.(this.featureFlags.length);break}default:return}}catch(t){t instanceof tra&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET",r){let i={...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`};return r&&(i["If-None-Match"]=r),{method:t,headers:i}}_requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions("GET",this.flagsEtag),i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=hyn(()=>{n.abort()},this.timeout),r.signal=n.signal}try{let n=this.fetch;return n(t,r)}finally{clearTimeout(i)}}async stopPoller(t=3e4){if(clearTimeout(this.poller),this.cacheProvider)try{let r=this.cacheProvider.shutdown();r instanceof Promise&&await Promise.race([r,new Promise((i,n)=>setTimeout(()=>n(new Error(`Cache shutdown timeout after ${t}ms`)),t))])}catch(r){this.onError?.(new Error(`Error during cache shutdown: ${r}`))}}};async function jH_(e,t,r=""){let i=await PH_(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/tbD}function SH_(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 I0("Operator is_not_set is not supported")}else throw new I0(`Property ${i} not found in propertyValues`);let o=t[i];if(o==null&&!rbD.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,u){return Array.isArray(s)?s.map(l=>String(l).toLowerCase()).includes(String(u).toLowerCase()):String(s).toLowerCase()===String(u).toLowerCase()}function d(s,u,l){if(l==="gt")return s>u;if(l==="gte")return s>=u;if(l==="lt")return s<u;if(l==="lte")return s<=u;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(n,o);case"is_not":return!c(n,o);case"is_set":return i in t;case"icontains":return String(o).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(n).toLowerCase());case"regex":return wH_(String(n))&&String(o).match(String(n))!==null;case"not_regex":return wH_(String(n))&&String(o).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||o==null?d(String(o),String(n),a):typeof o=="string"?d(o,String(n),a):d(o,s,a)}case"is_date_after":case"is_date_before":{if(typeof n=="boolean")throw new I0("Date operations cannot be performed on boolean values");let s=nbD(String(n));if(s==null&&(s=EH_(n)),s==null)throw new I0(`Invalid date: ${n}`);let u=EH_(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new I0(`Unknown operator: ${a}`)}}function ibD(e,t){if(!(e in t))throw new G$t(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function MH_(e,t,r,i=!1){let n=String(e.value);ibD(n,r);let a=r[n];return DH_(a,t,r,i)}function DH_(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if("values"in a[0]){for(let c of a)try{let d=DH_(c,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof G$t)throw d;if(d instanceof I0)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new I0("Can't match cohort without a given cohort property value");return n==="AND"}for(let c of a)try{let d;if(c.type==="cohort")d=MH_(c,t,r,i);else if(c.type==="flag"){i&&console.warn(`[FEATURE FLAGS] Flag dependency filters are not supported in local evaluation. Skipping condition with dependency on flag '${c.key||"unknown"}'`);continue}else d=SH_(c,t);let s=c.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 G$t)throw d;if(d instanceof I0)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new I0("can't match cohort without a given cohort property value");return n==="AND"}function wH_(e){try{return new RegExp(e),!0}catch{return!1}}function EH_(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 I0(`${e} is in an invalid date format`)}throw new I0(`The date provided ${e} must be a string, number, or date object`)}function nbD(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(!r)return null;{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()-7*n);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else{if(a!="y")return null;i.setUTCFullYear(i.getUTCFullYear()-n)}return i}}var dZo=class{getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}constructor(){this._memoryStorage={}}};var abD=100,BH_=3e4,obD=5e4,pZo=class extends WGa{constructor(t,r={}){if(super(t,r),this._memoryStorage=new dZo,this.options=r,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,abD):BH_,r.personalApiKey){if(r.personalApiKey.includes("phc_"))throw new Error('Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.');r.enableLocalEvaluation!==!1&&(this.featureFlagsPoller=new fZo({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:n=>{this._events.emit("error",n)},onLoad:n=>{this._events.emit("localEvaluationFlagsLoaded",n)},customHeaders:this.getCustomHeaders(),cacheProvider:r.flagDefinitionCacheProvider}))}this.errorTracking=new SQi(this,r,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||obD}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):fetch(t,r)}getLibraryVersion(){return AH_}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(t){typeof t=="string"&&this._logger.warn("Called capture() with a string as the first argument when an object was expected."),this.addPendingPromise(this.prepareEventMessage(t).then(({distinctId:r,event:i,properties:n,options:a})=>super.captureStateless(r,i,n,{timestamp:a.timestamp,disableGeoip:a.disableGeoip,uuid:a.uuid})).catch(r=>{r&&console.error(r)}))}async captureImmediate(t){return typeof t=="string"&&this._logger.warn("Called captureImmediate() with a string as the first argument when an object was expected."),this.addPendingPromise(this.prepareEventMessage(t).then(({distinctId:r,event:i,properties:n,options:a})=>super.captureStatelessImmediate(r,i,n,{timestamp:a.timestamp,disableGeoip:a.disableGeoip,uuid:a.uuid})).catch(r=>{r&&console.error(r)}))}identify({distinctId:t,properties:r={},disableGeoip:i}){let{$set:n,$set_once:a,$anon_distinct_id:o,...c}=r,u={$set:n||c,$set_once:a||{},$anon_distinct_id:o??void 0};super.identifyStateless(t,u,{disableGeoip:i})}async identifyImmediate({distinctId:t,properties:r={},disableGeoip:i}){let{$set:n,$set_once:a,$anon_distinct_id:o,...c}=r,u={$set:n||c,$set_once:a||{},$anon_distinct_id:o??void 0};super.identifyStatelessImmediate(t,u,{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=BH_){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let i=setTimeout(()=>{n(),r(!1)},t),n=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(i),n(),r(a>0)})})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:o,sendFeatureFlagEvents:c,personProperties:d,groupProperties:s}=i||{},u=this.addLocalPersonAndGroupProperties(r,n,d,s);d=u.allPersonProperties,s=u.allGroupProperties,o==null&&(o=!1),c==null&&(c=this.options.sendFeatureFlagEvent??!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,d,s),p=l!==void 0,_,h,y;if(!p&&!o){let v=await super.getFeatureFlagDetailStateless(t,r,n,d,s,a);if(v===void 0)return;y=v.response,l=pyn(y),_=v?.requestId,h=v?.evaluatedAt}let b=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(b))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(b):this.distinctIdHasSentFlagCalls[r]=[b],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:y?.metadata?.id,$feature_flag_version:y?.metadata?.version,$feature_flag_reason:y?.reason?.description??y?.reason?.code,locally_evaluated:p,[`$feature/${t}`]:l,$feature_flag_request_id:_,$feature_flag_evaluated_at:h},groups:n,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:o}=n||{},{onlyEvaluateLocally:c,personProperties:d,groupProperties:s}=n||{},u=this.addLocalPersonAndGroupProperties(r,a,d,s);d=u.allPersonProperties,s=u.allGroupProperties;let l;if(this.featureFlagsPoller!==void 0){await this.featureFlagsPoller?.loadFeatureFlags();let h=this.featureFlagsPoller?.featureFlagsByKey[t];if(h)try{let y=await this.featureFlagsPoller?.computeFlagAndPayloadLocally(h,r,a,d,s,i);y&&(i=y.value,l=y.payload)}catch(y){if(y instanceof G$t||y instanceof I0)this._logger?.info(`${y.name} when computing flag locally: ${h.key}: ${y.message}`);else throw y}}return c==null&&(c=!1),!(l!==void 0)&&!c&&(l=await super.getFeatureFlagPayloadStateless(t,r,a,d,s,o)),l}async getRemoteConfigPayload(t){if(!this.options.personalApiKey)throw new Error("Personal API key is required for remote config payload decryption");let r=await this._requestRemoteConfigPayload(t);if(!r)return;let i=await r.json();if(typeof i=="string")try{return JSON.parse(i)}catch{}return i}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,flagKeys:a}=r||{},{onlyEvaluateLocally:o,personProperties:c,groupProperties:d}=r||{},s=this.addLocalPersonAndGroupProperties(t,i,c,d);c=s.allPersonProperties,d=s.allGroupProperties,o==null&&(o=!1);let u=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,c,d,a),l={},p={},_=!0;if(u&&(l=u.response,p=u.payloads,_=u.fallbackToFlags),_&&!o){let h=await super.getFeatureFlagsAndPayloadsStateless(t,i,c,d,n,a);l={...l,...h.flags||{}},p={...p,...h.payloads||{}}}return{featureFlags:l,featureFlagPayloads:p}}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)}withContext(t,r,i){return this.context?this.context.run(t,r,i):r()}getContext(){return this.context?.get()}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(t),this.errorTracking.shutdown(),super._shutdown(t)}async _requestRemoteConfigPayload(t){if(!this.options.personalApiKey)return;let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config?token=${encodeURIComponent(this.apiKey)}`,i={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",Authorization:`Bearer ${this.options.personalApiKey}`}},n=null;if(this.options.requestTimeout&&typeof this.options.requestTimeout=="number"){let a=new AbortController;n=hyn(()=>{a.abort()},this.options.requestTimeout),i.signal=a.signal}try{return await this.fetch(r,i)}catch(a){this._events.emit("error",a);return}finally{n&&clearTimeout(n)}}extractPropertiesFromEvent(t,r){if(!t)return{personProperties:{},groupProperties:{}};let i={},n={};for(let[a,o]of Object.entries(t))if(zx_(o)&&r&&a in r){let c={};for(let[d,s]of Object.entries(o))c[String(d)]=String(s);n[String(a)]=c}else i[String(a)]=String(o);return{personProperties:i,groupProperties:n}}async getFeatureFlagsForEvent(t,r,i,n){let a=n?.personProperties||{},o=n?.groupProperties||{},c=n?.flagKeys;if(n?.onlyEvaluateLocally??!1)if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let s={};for(let[u,l]of Object.entries(r||{}))s[u]=String(l);return await this.getAllFlags(t,{groups:s,personProperties:a,groupProperties:o,disableGeoip:i,onlyEvaluateLocally:!0,flagKeys:c})}else return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let s={};for(let[u,l]of Object.entries(r||{}))s[u]=String(l);return await this.getAllFlags(t,{groups:s,personProperties:a,groupProperties:o,disableGeoip:i,onlyEvaluateLocally:!0,flagKeys:c})}return(await super.getFeatureFlagsStateless(t,r,a,o,i)).flags}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...n?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,i){let n=new Error("PostHog syntheticException");this.addPendingPromise(SQi.buildEventMessage(t,{syntheticException:n},r,i).then(a=>this.capture(a)))}async captureExceptionImmediate(t,r,i){let n=new Error("PostHog syntheticException");this.addPendingPromise(SQi.buildEventMessage(t,{syntheticException:n},r,i).then(a=>this.captureImmediate(a)))}async prepareEventMessage(t){let{distinctId:r,event:i,properties:n,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:d,uuid:s}=t,u=this.context?.get(),l=r||u?.distinctId,p={...u?.properties||{},...n||{}};l||(l=V$t(),p.$process_person_profile=!1),u?.sessionId&&!p.$session_id&&(p.$session_id=u.sessionId);let _=this._runBeforeSend({distinctId:l,event:i,properties:p,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:d,uuid:s});if(!_)return Promise.reject(null);let h=await Promise.resolve().then(async()=>{if(o){let y=typeof o=="object"?o:void 0;return await this.getFeatureFlagsForEvent(_.distinctId,a,d,y)}return _.event,{}}).then(y=>{let b={};if(y)for(let[O,m]of Object.entries(y))b[`$feature/${O}`]=m;let v=Object.keys(y||{}).filter(O=>y?.[O]!==!1).sort();return v.length>0&&(b.$active_feature_flags=v),b}).catch(()=>({})).then(y=>({...y,..._.properties||{},$groups:_.groups||a}));return _.event==="$pageview"&&this.options.__preview_capture_bot_pageviews&&typeof h.$raw_user_agent=="string"&&Bx_(h.$raw_user_agent,this.options.custom_blocked_useragents||[])&&(_.event="$bot_pageview",h.$browser_type="bot"),{distinctId:_.distinctId,event:_.event,properties:h,options:{timestamp:_.timestamp,disableGeoip:_.disableGeoip,uuid:_.uuid}}}_runBeforeSend(t){let r=this.options.before_send;if(!r)return t;let i=Array.isArray(r)?r:[r],n=t;for(let a of i){if(n=a(n),!n)return this._logger.info(`Event '${t.event}' was rejected in beforeSend function`),null;if(!n.properties||Object.keys(n.properties).length===0){let o=`Event '${n.event}' has no properties after beforeSend function, this is likely an error.`;this._logger.warn(o)}}return n}};var IH_=require("async_hooks"),_Zo=class{constructor(){this.storage=new IH_.AsyncLocalStorage}get(){return this.storage.getStore()}run(t,r,i){if(i?.fresh===!0)return this.storage.run(t,r);{let a=this.get()||{},o={distinctId:t.distinctId??a.distinctId,sessionId:t.sessionId??a.sessionId,properties:{...a.properties||{},...t.properties||{}}};return this.storage.run(o,r)}}};var CH_="posthog-node";function ubD(e,{organization:t,projectId:r,prefix:i,severityAllowList:n=["error"],sendExceptionsToPostHog:a=!0}={}){return o=>{if(!(n==="*"||n.includes(o.level)))return o;o.tags||(o.tags={});let d=o.tags[TNc.POSTHOG_ID_TAG];if(d===void 0)return o;let s=e.options.host??"https://us.i.posthog.com",u=new URL(`/project/${e.apiKey}/person/${d}`,s).toString();o.tags["PostHog Person URL"]=u;let l=o.exception?.values||[],p=l.map(h=>({...h,stacktrace:h.stacktrace?{...h.stacktrace,type:"raw",frames:(h.stacktrace.frames||[]).map(y=>({...y,platform:"node:javascript"}))}:void 0})),_={$exception_message:l[0]?.value||o.message,$exception_type:l[0]?.type,$exception_level:o.level,$exception_list:p,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:l[0]?.value||o.message,$sentry_exception_type:l[0]?.type,$sentry_tags:o.tags};return t&&r&&(_.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+o.event_id),a&&e.capture({event:"$exception",distinctId:d,properties:_}),o}}var TNc=class{static#e=this.POSTHOG_ID_TAG="posthog_distinct_id";constructor(t,r,i,n,a){this.name=CH_,this.name=CH_,this.setupOnce=function(o,c){let d=c()?.getClient()?.getDsn()?.projectId;o(ubD(t,{organization:r,projectId:d,prefix:i,severityAllowList:n,sendExceptionsToPostHog:a??!0}))}}};SQi.errorPropertiesBuilder=new K$.ErrorPropertiesBuilder([new K$.EventCoercer,new K$.ErrorCoercer,new K$.ObjectCoercer,new K$.StringCoercer,new K$.PrimitiveCoercer],K$.createStackParser("node:javascript",K$.nodeStackLineParser),[wx_(),bH_]);var rra=class extends pZo{getLibraryId(){return"posthog-node"}initializeContext(){return new _Zo}};var hZo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new rra(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.47.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var GGa=class{async sendEvent(){}async identify(){}async flush(){}};var ira=require("fs/promises"),zH_=require("os"),NH_=require("path");var qH_=ce(require("crypto")),bZo=new Uint8Array(256),yZo=bZo.length;function RNc(){return yZo>bZo.length-16&&(qH_.default.randomFillSync(bZo),yZo=0),bZo.slice(yZo,yZo+=16)}var dL=[];for(let e=0;e<256;++e)dL.push((e+256).toString(16).slice(1));function TH_(e,t=0){return dL[e[t+0]]+dL[e[t+1]]+dL[e[t+2]]+dL[e[t+3]]+"-"+dL[e[t+4]]+dL[e[t+5]]+"-"+dL[e[t+6]]+dL[e[t+7]]+"-"+dL[e[t+8]]+dL[e[t+9]]+"-"+dL[e[t+10]]+dL[e[t+11]]+dL[e[t+12]]+dL[e[t+13]]+dL[e[t+14]]+dL[e[t+15]]}var RH_=ce(require("crypto")),zNc={randomUUID:RH_.default.randomUUID};function sbD(e,t,r){if(zNc.randomUUID&&!t&&!e)return zNc.randomUUID();e=e||{};let i=e.random||(e.rng||RNc)();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 TH_(i)}var Lve=sbD;var cbD="id",lbD=".fern",xGa=class{posthog;userId;token;constructor({token:t,posthogApiKey:r}){this.posthog=new rra(r),this.userId=t==null?void 0:sCc(t),this.token=t}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){let r=await this.getUserEmail();this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"3.47.1",...t,...t.properties,usingAccessToken:!1,...r!=null?{userEmail:r}:{}}})}async flush(){await this.posthog.flush()}userEmail;async getUserEmail(){if(this.userEmail!==null){if(this.userEmail!=null)return this.userEmail;if(this.token==null){this.userEmail=null;return}try{let t=await rL({token:this.token.value}).user.getMyself();if(t.ok&&t.body.email!=null)return this.userEmail=t.body.email,this.userEmail}catch{}this.userEmail=null}}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Tt(Sr.of((0,zH_.homedir)()),Je.of(lbD),Je.of(cbD));await Ai(t)||(await(0,ira.mkdir)((0,NH_.dirname)(t),{recursive:!0}),await(0,ira.writeFile)(t,Lve())),this.persistedDistinctId=(await(0,ira.readFile)(t)).toString()}return this.persistedDistinctId}};var NNc;async function nra(){return NNc==null&&(NNc=await fbD()),NNc}async function fbD(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new GGa;let r=await c7o();return r!=null?new xGa({token:r,posthogApiKey:e}):await Oea()!=null?new hZo({posthogApiKey:e}):new xGa({token:void 0,posthogApiKey:e})}catch{return new GGa}}function HGa(e,t){return function(){return e.apply(t,arguments)}}var{toString:dbD}=Object.prototype,{getPrototypeOf:QNc}=Object,{iterator:gZo,toStringTag:QH_}=Symbol,OZo=(e=>t=>{let r=dbD.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),r8t=e=>(e=e.toLowerCase(),t=>OZo(t)===e),mZo=e=>t=>typeof t===e,{isArray:ora}=Array,ara=mZo("undefined");function KGa(e){return e!==null&&!ara(e)&&e.constructor!==null&&!ara(e.constructor)&&J$(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var UH_=r8t("ArrayBuffer");function pbD(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&UH_(e.buffer),t}var _bD=mZo("string"),J$=mZo("function"),LH_=mZo("number"),JGa=e=>e!==null&&typeof e=="object",hbD=e=>e===!0||e===!1,vZo=e=>{if(OZo(e)!=="object")return!1;let t=QNc(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(QH_ in e)&&!(gZo in e)},ybD=e=>{if(!JGa(e)||KGa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},bbD=r8t("Date"),vbD=r8t("File"),gbD=r8t("Blob"),ObD=r8t("FileList"),mbD=e=>JGa(e)&&J$(e.pipe),AbD=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||J$(e.append)&&((t=OZo(e))==="formdata"||t==="object"&&J$(e.toString)&&e.toString()==="[object FormData]"))},PbD=r8t("URLSearchParams"),[jbD,wbD,EbD,SbD]=["ReadableStream","Request","Response","Headers"].map(r8t),MbD=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function $Ga(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),ora(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(KGa(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(i=0;i<o;i++)c=a[i],t.call(null,e[c],c,e)}}function VH_(e,t){if(KGa(e))return null;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 yyn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,WH_=e=>!ara(e)&&e!==yyn;function FNc(){let{caseless:e,skipUndefined:t}=WH_(this)&&this||{},r={},i=(n,a)=>{let o=e&&VH_(r,a)||a;vZo(r[o])&&vZo(n)?r[o]=FNc(r[o],n):vZo(n)?r[o]=FNc({},n):ora(n)?r[o]=n.slice():(!t||!ara(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&$Ga(arguments[n],i);return r}var DbD=(e,t,r,{allOwnKeys:i}={})=>($Ga(t,(n,a)=>{r&&J$(n)?e[a]=HGa(n,r):e[a]=n},{allOwnKeys:i}),e),BbD=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),IbD=(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)},CbD=(e,t,r,i)=>{let n,a,o,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)o=n[a],(!i||i(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&QNc(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},qbD=(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},TbD=e=>{if(!e)return null;if(ora(e))return e;let t=e.length;if(!LH_(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},RbD=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&QNc(Uint8Array)),zbD=(e,t)=>{let i=(e&&e[gZo]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},NbD=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},FbD=r8t("HTMLFormElement"),QbD=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),FH_=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),UbD=r8t("RegExp"),GH_=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};$Ga(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},LbD=e=>{GH_(e,(t,r)=>{if(J$(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(J$(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+"'")})}})},VbD=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return ora(e)?i(e):i(String(e).split(t)),r},WbD=()=>{},GbD=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function xbD(e){return!!(e&&J$(e.append)&&e[QH_]==="FormData"&&e[gZo])}var HbD=e=>{let t=new Array(10),r=(i,n)=>{if(JGa(i)){if(t.indexOf(i)>=0)return;if(KGa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=ora(i)?[]:{};return $Ga(i,(o,c)=>{let d=r(o,n+1);!ara(d)&&(a[c]=d)}),t[n]=void 0,a}}return i};return r(e,0)},KbD=r8t("AsyncFunction"),JbD=e=>e&&(JGa(e)||J$(e))&&J$(e.then)&&J$(e.catch),xH_=((e,t)=>e?setImmediate:t?((r,i)=>(yyn.addEventListener("message",({source:n,data:a})=>{n===yyn&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),yyn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",J$(yyn.postMessage)),$bD=typeof queueMicrotask<"u"?queueMicrotask.bind(yyn):typeof process<"u"&&process.nextTick||xH_,YbD=e=>e!=null&&J$(e[gZo]),ir={isArray:ora,isArrayBuffer:UH_,isBuffer:KGa,isFormData:AbD,isArrayBufferView:pbD,isString:_bD,isNumber:LH_,isBoolean:hbD,isObject:JGa,isPlainObject:vZo,isEmptyObject:ybD,isReadableStream:jbD,isRequest:wbD,isResponse:EbD,isHeaders:SbD,isUndefined:ara,isDate:bbD,isFile:vbD,isBlob:gbD,isRegExp:UbD,isFunction:J$,isStream:mbD,isURLSearchParams:PbD,isTypedArray:RbD,isFileList:ObD,forEach:$Ga,merge:FNc,extend:DbD,trim:MbD,stripBOM:BbD,inherits:IbD,toFlatObject:CbD,kindOf:OZo,kindOfTest:r8t,endsWith:qbD,toArray:TbD,forEachEntry:zbD,matchAll:NbD,isHTMLForm:FbD,hasOwnProperty:FH_,hasOwnProp:FH_,reduceDescriptors:GH_,freezeMethods:LbD,toObjectSet:VbD,toCamelCase:QbD,noop:WbD,toFiniteNumber:GbD,findKey:VH_,global:yyn,isContextDefined:WH_,isSpecCompliantForm:xbD,toJSONObject:HbD,isAsyncFn:KbD,isThenable:JbD,setImmediate:xH_,asap:$bD,isIterable:YbD};function ura(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)}ir.inherits(ura,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:ir.toJSONObject(this.config),code:this.code,status:this.status}}});var HH_=ura.prototype,KH_={};["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=>{KH_[e]={value:e}});Object.defineProperties(ura,KH_);Object.defineProperty(HH_,"isAxiosError",{value:!0});ura.from=(e,t,r,i,n,a)=>{let o=Object.create(HH_);ir.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return ura.call(o,c,d,r,i,n),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var za=ura;var JH_=ce(Fkn(),1),AZo=JH_.default;function UNc(e){return ir.isPlainObject(e)||ir.isArray(e)}function YH_(e){return ir.endsWith(e,"[]")?e.slice(0,-2):e}function $H_(e,t,r){return e?e.concat(t).map(function(n,a){return n=YH_(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function XbD(e){return ir.isArray(e)&&!e.some(UNc)}var ZbD=ir.toFlatObject(ir,{},null,function(t){return/^is[A-Z]/.test(t)});function kbD(e,t,r){if(!ir.isObject(e))throw new TypeError("target must be an object");t=t||new(AZo||FormData),r=ir.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!ir.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&ir.isSpecCompliantForm(t);if(!ir.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(ir.isDate(h))return h.toISOString();if(ir.isBoolean(h))return h.toString();if(!d&&ir.isBlob(h))throw new za("Blob is not supported. Use a Buffer instead.");return ir.isArrayBuffer(h)||ir.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,y,b){let v=h;if(h&&!b&&typeof h=="object"){if(ir.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(ir.isArray(h)&&XbD(h)||(ir.isFileList(h)||ir.endsWith(y,"[]"))&&(v=ir.toArray(h)))return y=YH_(y),v.forEach(function(m,g){!(ir.isUndefined(m)||m===null)&&t.append(o===!0?$H_([y],g,a):o===null?y:y+"[]",s(m))}),!1}return UNc(h)?!0:(t.append($H_(b,y,a),s(h)),!1)}let l=[],p=Object.assign(ZbD,{defaultVisitor:u,convertValue:s,isVisitable:UNc});function _(h,y){if(!ir.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),ir.forEach(h,function(v,O){(!(ir.isUndefined(v)||v===null)&&n.call(t,v,ir.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!ir.isObject(e))throw new TypeError("data must be an object");return _(e),t}var _Ki=kbD;function XH_(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function ZH_(e,t){this._pairs=[],e&&_Ki(e,this,t)}var kH_=ZH_.prototype;kH_.append=function(t,r){this._pairs.push([t,r])};kH_.toString=function(t){let r=t?function(i){return t.call(this,i,XH_)}:XH_;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var e7_=ZH_;function evD(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function byn(e,t,r){if(!t)return e;let i=r&&r.encode||evD;ir.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=ir.isURLSearchParams(t)?t.toString():new e7_(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var LNc=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){ir.forEach(this.handlers,function(i){i!==null&&t(i)})}},VNc=LNc;var sra={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var n7_=ce(require("crypto"),1);var t7_=ce(require("url"),1),r7_=t7_.default.URLSearchParams;var WNc="abcdefghijklmnopqrstuvwxyz",i7_="0123456789",a7_={DIGIT:i7_,ALPHA:WNc,ALPHA_DIGIT:WNc+WNc.toUpperCase()+i7_},tvD=(e=16,t=a7_.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);n7_.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},o7_={isNode:!0,classes:{URLSearchParams:r7_,FormData:AZo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:a7_,generateString:tvD,protocols:["http","https","file","data"]};var HNc={};Yt(HNc,{hasBrowserEnv:()=>xNc,hasStandardBrowserEnv:()=>rvD,hasStandardBrowserWebWorkerEnv:()=>ivD,navigator:()=>GNc,origin:()=>nvD});var xNc=typeof window<"u"&&typeof document<"u",GNc=typeof navigator=="object"&&navigator||void 0,rvD=xNc&&(!GNc||["ReactNative","NativeScript","NS"].indexOf(GNc.product)<0),ivD=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",nvD=xNc&&window.location.href||"http://localhost";var yA={...HNc,...o7_};function KNc(e,t){return _Ki(e,new yA.classes.URLSearchParams,{visitor:function(r,i,n,a){return yA.isNode&&ir.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function avD(e){return ir.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function ovD(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 uvD(e){function t(r,i,n,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),d=a>=r.length;return o=!o&&ir.isArray(n)?n.length:o,d?(ir.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!ir.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&ir.isArray(n[o])&&(n[o]=ovD(n[o])),!c)}if(ir.isFormData(e)&&ir.isFunction(e.entries)){let r={};return ir.forEachEntry(e,(i,n)=>{t(avD(i),n,r,0)}),r}return null}var PZo=uvD;function svD(e,t,r){if(ir.isString(e))try{return(t||JSON.parse)(e),ir.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var JNc={transitional:sra,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=ir.isObject(t);if(a&&ir.isHTMLForm(t)&&(t=new FormData(t)),ir.isFormData(t))return n?JSON.stringify(PZo(t)):t;if(ir.isArrayBuffer(t)||ir.isBuffer(t)||ir.isStream(t)||ir.isFile(t)||ir.isBlob(t)||ir.isReadableStream(t))return t;if(ir.isArrayBufferView(t))return t.buffer;if(ir.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return KNc(t,this.formSerializer).toString();if((c=ir.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return _Ki(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),svD(t)):t}],transformResponse:[function(t){let r=this.transitional||JNc.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(ir.isResponse(t)||ir.isReadableStream(t))return t;if(t&&ir.isString(t)&&(i&&!this.responseType||n)){let o=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?za.from(c,za.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:yA.classes.FormData,Blob:yA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ir.forEach(["delete","get","head","post","put","patch"],e=>{JNc.headers[e]={}});var cra=JNc;var cvD=ir.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"]),u7_=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1265
|
+
`);for(let o=i;o<a.length;o++){let c=a[o];if(c.length>1024)continue;let d=sH_.test(c)?c.replace(sH_,"$1"):c;if(!d.match(/\S*Error: /)){for(let s of t){let u=s(d,e);if(u){n.push(u);break}}if(n.length>=cH_)break}}return lH_(n)}}var jNc=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,r){let i=FGa(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?r.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){let r=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?`${r}: ${t.message}`:r}isDOMException(t){return _yn(t,"DOMException")}isDOMError(t){return _yn(t,"DOMError")}};var wNc=class{match(t){return _Nc(t)}coerce(t,r){return{type:this.getType(t),value:this.getMessage(t,r),stack:this.getStack(t),cause:t.cause?r.next(t.cause):void 0,synthetic:!1}}getType(t){return t.name||t.constructor.name}getMessage(t,r){let i=t.message;return i.error&&typeof i.error.message=="string"?String(i.error.message):String(i)}getStack(t){return t.stacktrace||t.stack||void 0}};var ENc=class{constructor(){}match(t){return Rx_(t)&&t.error!=null}coerce(t,r){let i=r.apply(t.error);return i||{type:"ErrorEvent",value:t.message,stack:r.syntheticException?.stack,synthetic:!0}}};var UyD=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,SNc=class{match(t){return typeof t=="string"}coerce(t,r){let[i,n]=this.getInfos(t);return{type:i??"Error",value:n??t,stack:r.syntheticException?.stack,synthetic:!0}}getInfos(t){let r="Error",i=t,n=t.match(UyD);return n&&(r=n[1],i=n[2]),[r,i]}};var fH_=["fatal","error","warning","log","info","debug"];function cZo(e,t=40){let r=Object.keys(e);if(r.sort(),!r.length)return"[object has no keys]";for(let i=r.length;i>0;i--){let n=r.slice(0,i).join(", ");if(!(n.length>t))return i===r.length||n.length<=t?n:`${n.slice(0,t)}...`}return""}var MNc=class{match(t){return typeof t=="object"&&t!==null}coerce(t,r){let i=this.getErrorPropertyFromObject(t);return i?r.apply(i):{type:this.getType(t),value:this.getValue(t),stack:r.syntheticException?.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return XXo(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){let n=`'${t.name}' captured as exception`;return"message"in t&&typeof t.message=="string"&&(n+=` with message: '${t.message}'`),n}if("message"in t&&typeof t.message=="string")return t.message;let r=this.getObjectClassName(t),i=cZo(t);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${i}`}isSeverityLevel(t){return FGa(t)&&!qx_(t)&&fH_.indexOf(t)>=0}getErrorPropertyFromObject(t){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if($x_(i))return i}}getObjectClassName(t){try{let r=Object.getPrototypeOf(t);return r?r.constructor.name:void 0}catch{return}}};var DNc=class{match(t){return XXo(t)}coerce(t,r){let i=t.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${cZo(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var BNc=class{match(t){return QGa(t)}coerce(t,r){return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var INc=class{match(t){return _yn(t,"PromiseRejectionEvent")}coerce(t,r){let i=this.getUnhandledRejectionReason(t);return QGa(i)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(i)}`,stack:r.syntheticException?.stack,synthetic:!0}:r.apply(i)}getUnhandledRejectionReason(t){if(QGa(t))return t;try{if("reason"in t)return t.reason;if("detail"in t&&"reason"in t.detail)return t.detail.reason}catch{}return t}};var CNc=class{constructor(t){this._maxSize=t,this._cache=new Map}get(t){let r=this._cache.get(t);if(r!==void 0)return this._cache.delete(t),this._cache.set(t,r),r}set(t,r){this._cache.set(t,r)}reduce(){for(;this._cache.size>=this._maxSize;){let t=this._cache.keys().next().value;t&&this._cache.delete(t)}}};var _H_=require("fs"),hH_=require("readline"),lZo=new K$.ReduceableCache(25),yH_=new K$.ReduceableCache(20),qNc=7,LyD=1e3,VyD=1e4;async function bH_(e){let t={};for(let n=e.length-1;n>=0;n--){let a=e[n],o=a?.filename;if(!a||typeof o!="string"||typeof a.lineno!="number"||HyD(o)||KyD(a))continue;t[o]||(t[o]=[]),t[o].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let i=[];for(let n of r){if(yH_.get(n))continue;let a=t[n];if(!a)continue;a.sort((d,s)=>d-s);let o=$yD(a);if(o.every(d=>JyD(n,d)))continue;let c=YyD(lZo,n,{});i.push(WyD(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&GyD(e,lZo),lZo.reduce(),e}function WyD(e,t,r){return new Promise(i=>{let n=(0,_H_.createReadStream)(e),a=(0,hH_.createInterface)({input:n});function o(){n.destroy(),i()}let c=0,d=0,s=t[d];if(s===void 0)return void o();let u=s[0],l=s[1];function p(){yH_.set(e,1),a.close(),a.removeAllListeners(),o()}n.on("error",p),a.on("error",p),a.on("close",o),a.on("line",_=>{if(c++,!(c<u)&&(r[c]=XyD(_,0),c>=l)){if(d===t.length-1){a.close(),a.removeAllListeners();return}d++;let h=t[d];if(h===void 0){a.close(),a.removeAllListeners();return}u=h[0],l=h[1]}})})}function GyD(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let i=t.get(r.filename);if(i===void 0)continue;xyD(r.lineno,r,i)}}function xyD(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=vH_(e);n<e;n++){let a=r[n];if(a===void 0)return void dH_(t);t.pre_context.push(a)}if(r[e]===void 0)return void dH_(t);t.context_line=r[e];let i=gH_(e);t.post_context=[];for(let n=e+1;n<=i;n++){let a=r[n];if(a===void 0)break;t.post_context.push(a)}}function dH_(e){delete e.pre_context,delete e.context_line,delete e.post_context}function HyD(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function KyD(e){return e.lineno!==void 0&&e.lineno>VyD||e.colno!==void 0&&e.colno>LyD}function JyD(e,t){let r=lZo.get(e);if(r===void 0)return!1;for(let i=t[0];i<=t[1];i++)if(r[i]===void 0)return!1;return!0}function $yD(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=pH_(r),n=[];for(;;){if(t===e.length-1){n.push(i);break}let a=e[t+1];if(typeof a!="number")break;a<=i[1]?i[1]=a+qNc:(n.push(i),i=pH_(a)),t++}return n}function pH_(e){return[vH_(e),gH_(e)]}function vH_(e){return Math.max(1,e-qNc)}function gH_(e){return e+qNc}function YyD(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function XyD(e,t){let r=e,i=r.length;if(i<=150)return r;t>i&&(t=i);let n=Math.max(t-60,0);n<5&&(n=0);let a=Math.min(n+140,i);return a>i-5&&(a=i),a===i&&(n=Math.max(a-140,0)),r=r.slice(n,a),n>0&&(r=`...${r}`),a<i&&(r+="..."),r}function ZyD(e,t){let r=!1;return Object.assign(i=>{let a=global.process.listeners("uncaughtException").filter(o=>o.name!=="domainUncaughtExceptionClear"&&o._posthogErrorHandler!==!0).length===0;e(i,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t(i))},{_posthogErrorHandler:!0})}function OH_(e,t){globalThis.process?.on("uncaughtException",ZyD(e,t))}function mH_(e){globalThis.process?.on("unhandledRejection",t=>e(t,{mechanism:{type:"onunhandledrejection",handled:!1}}))}var kyD=2e3,SQi=class e{constructor(t,r,i){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this._logger=i,this._rateLimiter=new ZXo({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static async buildEventMessage(t,r,i,n){let a={...n};i||(a.$process_person_profile=!1);let o=this.errorPropertiesBuilder.buildFromUnknown(t,r);return o.$exception_list=await this.errorPropertiesBuilder.modifyFrames(o.$exception_list),{event:"$exception",distinctId:i||V$t(),properties:{...o,...a}}}startAutocaptureIfEnabled(){this.isEnabled()&&(OH_(this.onException.bind(this),this.onFatalError.bind(this)),mH_(this.onException.bind(this)))}onException(t,r){this.client.addPendingPromise((async()=>{let i=await e.buildEventMessage(t,r),a=i.properties?.$exception_list[0]?.type??"Exception";return this._rateLimiter.consumeRateLimit(a)?void this._logger.info("Skipping exception capture because of client rate limiting.",{exception:a}):this.client.capture(i)})())}async onFatalError(t){console.error(t),await this.client.shutdown(kyD),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};var AH_="5.17.4";async function PH_(e){let t=globalThis.crypto?.subtle;if(!t)throw new Error("SubtleCrypto API not available");let r=await t.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(r)).map(n=>n.toString(16).padStart(2,"0")).join("")}var ebD=6e4,tbD=1152921504606847e3,rbD=["is_not"],tra=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},I0=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},G$t=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},fZo=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:o,...c}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,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=c.fetch||fetch,this.onError=c.onError,this.customHeaders=o,this.onLoad=c.onLoad,this.cacheProvider=c.cacheProvider,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let o,c;if(!this.loadedSuccessfullyOnce)return o;if(c=this.featureFlagsByKey[t],c!==void 0)try{o=(await this.computeFlagAndPayloadLocally(c,r,i,n,a)).value,this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${o}`))}catch(d){d instanceof G$t||d instanceof I0?this.logMsgIfDebug(()=>console.debug(`${d.name} when computing flag locally: ${t}: ${d.message}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return o}async getAllFlagsAndPayloads(t,r={},i={},n={},a){await this.loadFeatureFlags();let o={},c={},d=this.featureFlags.length==0,s=a?a.map(l=>this.featureFlagsByKey[l]).filter(Boolean):this.featureFlags,u={};return await Promise.all(s.map(async l=>{try{let{value:p,payload:_}=await this.computeFlagAndPayloadLocally(l,t,r,i,n,void 0,u);o[l.key]=p,_&&(c[l.key]=_)}catch(p){p instanceof G$t||p instanceof I0?this.logMsgIfDebug(()=>console.debug(`${p.name} when computing flag locally: ${l.key}: ${p.message}`)):p instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${l.key}: ${p}`)),d=!0}})),{response:o,payloads:c,fallbackToFlags:d}}async computeFlagAndPayloadLocally(t,r,i={},n={},a={},o,c,d=!1){if(d||await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return{value:!1,payload:null};let s;s=o!==void 0?o:await this.computeFlagValueLocally(t,r,i,n,a,c);let u=this.getFeatureFlagPayload(t.key,s);return{value:s,payload:u}}async computeFlagValueLocally(t,r,i={},n={},a={},o={}){if(t.ensure_experience_continuity)throw new I0("Flag has experience continuity enabled");if(!t.active)return!1;let d=(t.filters||{}).aggregation_group_type_index;if(d==null)return await this.matchFeatureFlagProperties(t,r,n,o);{let s=this.groupTypeMapping[String(d)];if(!s)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${d} for feature flag ${t.key}`)),new I0("Flag has unknown group type index");if(!(s in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let u=a[s];return await this.matchFeatureFlagProperties(t,i[s],u,o)}}getFeatureFlagPayload(t,r){let i=null;if(r!==!1&&r!=null&&(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]||null:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]||null),i!=null)){if(typeof i=="object")return i;if(typeof i=="string")try{return JSON.parse(i)}catch{}return i}return null}async evaluateFlagDependency(t,r,i,n){let a=t.key;if(!this.featureFlagsByKey)throw new I0("Feature flags not available for dependency evaluation");if(!("dependency_chain"in t))throw new I0(`Flag dependency property for '${a}' is missing required 'dependency_chain' field`);let o=t.dependency_chain;if(!Array.isArray(o))throw new I0(`Flag dependency property for '${a}' has an invalid 'dependency_chain' (expected array, got ${typeof o})`);if(o.length===0)throw new I0(`Circular dependency detected for flag '${a}' (empty dependency chain)`);for(let d of o){if(!(d in n)){let u=this.featureFlagsByKey[d];if(u)if(u.active)try{let l=await this.matchFeatureFlagProperties(u,r,i,n);n[d]=l}catch(l){throw new I0(`Error evaluating flag dependency '${d}' for flag '${a}': ${l}`)}else n[d]=!1;else throw new I0(`Missing flag dependency '${d}' for flag '${a}'`)}if(n[d]==null)throw new I0(`Dependency '${d}' could not be evaluated`)}let c=n[a];return this.flagEvaluatesToExpectedValue(t.value,c)}flagEvaluatesToExpectedValue(t,r){return typeof t=="boolean"?t===r||typeof r=="string"&&r!==""&&t===!0:typeof t=="string"?r===t:!1}async matchFeatureFlagProperties(t,r,i,n={}){let a=t.filters||{},o=a.groups||[],c=!1,d;for(let s of o)try{if(await this.isConditionMatch(t,r,s,i,n)){let u=s.variant,l=a.multivariate?.variants||[];d=u&&l.some(p=>p.key===u)?u:await this.getMatchingVariant(t,r)||!0;break}}catch(u){if(u instanceof G$t)throw u;if(u instanceof I0)c=!0;else throw u}if(d!==void 0)return d;if(c)throw new I0("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,i,n,a={}){let o=i.rollout_percentage,c=d=>{this.logMsgIfDebug(()=>console.warn(d))};if((i.properties||[]).length>0){for(let d of i.properties){let s=d.type,u=!1;if(u=s==="cohort"?MH_(d,n,this.cohorts,this.debugMode):s==="flag"?await this.evaluateFlagDependency(d,r,n,a):SH_(d,n,c),!u)return!1}if(o==null)return!0}return!(o!=null&&await jH_(t.key,r)>o/100)}async getMatchingVariant(t,r){let i=await jH_(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(c=>{n=i+c.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:c.key}),i=n}),r}updateFlagState(t){this.featureFlags=t.flags,this.featureFlagsByKey=t.flags.reduce((r,i)=>(r[i.key]=i,r),{}),this.groupTypeMapping=t.groupTypeMapping,this.cohorts=t.cohorts,this.loadedSuccessfullyOnce=!0}async loadFromCache(t){if(!this.cacheProvider)return!1;try{let r=await this.cacheProvider.getFlagDefinitions();return r?(this.updateFlagState(r),this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] ${t} (${r.flags.length} flags)`)),this.onLoad?.(this.featureFlags.length),!0):!1}catch(r){return this.onError?.(new Error(`Failed to load from cache: ${r}`)),!1}}async loadFeatureFlags(t=!1){if(!(this.loadedSuccessfullyOnce&&!t))return this.loadingPromise||(this.loadingPromise=this._loadFeatureFlags().catch(r=>this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Failed to load feature flags: ${r}`))).finally(()=>{this.loadingPromise=void 0})),this.loadingPromise}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(ebD,this.pollingInterval*2**this.backOffCount):this.pollingInterval}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this.loadFeatureFlags(!0),this.getPollingInterval());try{let t=!0;if(this.cacheProvider)try{t=await this.cacheProvider.shouldFetchFlagDefinitions()}catch(i){this.onError?.(new Error(`Error in shouldFetchFlagDefinitions: ${i}`))}if(!t&&(await this.loadFromCache("Loaded flags from cache (skipped fetch)")||this.loadedSuccessfullyOnce))return;let r=await this._requestFeatureFlagDefinitions();if(!r)return;switch(r.status){case 304:this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Flags not modified (304), using cached data")),this.flagsEtag=r.headers?.get("ETag")??this.flagsEtag,this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0;return;case 401:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new tra(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new tra(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new tra(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let i=await r.json()??{};if(!("flags"in i))return void this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(i)}`));this.flagsEtag=r.headers?.get("ETag")??void 0;let n={flags:i.flags??[],groupTypeMapping:i.group_type_mapping||{},cohorts:i.cohorts||{}};if(this.updateFlagState(n),this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.cacheProvider&&t)try{await this.cacheProvider.onFlagDefinitionsReceived(n)}catch(a){this.onError?.(new Error(`Failed to store in cache: ${a}`))}this.onLoad?.(this.featureFlags.length);break}default:return}}catch(t){t instanceof tra&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET",r){let i={...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`};return r&&(i["If-None-Match"]=r),{method:t,headers:i}}_requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions("GET",this.flagsEtag),i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=hyn(()=>{n.abort()},this.timeout),r.signal=n.signal}try{let n=this.fetch;return n(t,r)}finally{clearTimeout(i)}}async stopPoller(t=3e4){if(clearTimeout(this.poller),this.cacheProvider)try{let r=this.cacheProvider.shutdown();r instanceof Promise&&await Promise.race([r,new Promise((i,n)=>setTimeout(()=>n(new Error(`Cache shutdown timeout after ${t}ms`)),t))])}catch(r){this.onError?.(new Error(`Error during cache shutdown: ${r}`))}}};async function jH_(e,t,r=""){let i=await PH_(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/tbD}function SH_(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 I0("Operator is_not_set is not supported")}else throw new I0(`Property ${i} not found in propertyValues`);let o=t[i];if(o==null&&!rbD.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,u){return Array.isArray(s)?s.map(l=>String(l).toLowerCase()).includes(String(u).toLowerCase()):String(s).toLowerCase()===String(u).toLowerCase()}function d(s,u,l){if(l==="gt")return s>u;if(l==="gte")return s>=u;if(l==="lt")return s<u;if(l==="lte")return s<=u;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(n,o);case"is_not":return!c(n,o);case"is_set":return i in t;case"icontains":return String(o).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(n).toLowerCase());case"regex":return wH_(String(n))&&String(o).match(String(n))!==null;case"not_regex":return wH_(String(n))&&String(o).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||o==null?d(String(o),String(n),a):typeof o=="string"?d(o,String(n),a):d(o,s,a)}case"is_date_after":case"is_date_before":{if(typeof n=="boolean")throw new I0("Date operations cannot be performed on boolean values");let s=nbD(String(n));if(s==null&&(s=EH_(n)),s==null)throw new I0(`Invalid date: ${n}`);let u=EH_(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new I0(`Unknown operator: ${a}`)}}function ibD(e,t){if(!(e in t))throw new G$t(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function MH_(e,t,r,i=!1){let n=String(e.value);ibD(n,r);let a=r[n];return DH_(a,t,r,i)}function DH_(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if("values"in a[0]){for(let c of a)try{let d=DH_(c,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof G$t)throw d;if(d instanceof I0)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new I0("Can't match cohort without a given cohort property value");return n==="AND"}for(let c of a)try{let d;if(c.type==="cohort")d=MH_(c,t,r,i);else if(c.type==="flag"){i&&console.warn(`[FEATURE FLAGS] Flag dependency filters are not supported in local evaluation. Skipping condition with dependency on flag '${c.key||"unknown"}'`);continue}else d=SH_(c,t);let s=c.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 G$t)throw d;if(d instanceof I0)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new I0("can't match cohort without a given cohort property value");return n==="AND"}function wH_(e){try{return new RegExp(e),!0}catch{return!1}}function EH_(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 I0(`${e} is in an invalid date format`)}throw new I0(`The date provided ${e} must be a string, number, or date object`)}function nbD(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(!r)return null;{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()-7*n);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else{if(a!="y")return null;i.setUTCFullYear(i.getUTCFullYear()-n)}return i}}var dZo=class{getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}constructor(){this._memoryStorage={}}};var abD=100,BH_=3e4,obD=5e4,pZo=class extends WGa{constructor(t,r={}){if(super(t,r),this._memoryStorage=new dZo,this.options=r,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,abD):BH_,r.personalApiKey){if(r.personalApiKey.includes("phc_"))throw new Error('Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.');r.enableLocalEvaluation!==!1&&(this.featureFlagsPoller=new fZo({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:n=>{this._events.emit("error",n)},onLoad:n=>{this._events.emit("localEvaluationFlagsLoaded",n)},customHeaders:this.getCustomHeaders(),cacheProvider:r.flagDefinitionCacheProvider}))}this.errorTracking=new SQi(this,r,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||obD}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):fetch(t,r)}getLibraryVersion(){return AH_}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(t){typeof t=="string"&&this._logger.warn("Called capture() with a string as the first argument when an object was expected."),this.addPendingPromise(this.prepareEventMessage(t).then(({distinctId:r,event:i,properties:n,options:a})=>super.captureStateless(r,i,n,{timestamp:a.timestamp,disableGeoip:a.disableGeoip,uuid:a.uuid})).catch(r=>{r&&console.error(r)}))}async captureImmediate(t){return typeof t=="string"&&this._logger.warn("Called captureImmediate() with a string as the first argument when an object was expected."),this.addPendingPromise(this.prepareEventMessage(t).then(({distinctId:r,event:i,properties:n,options:a})=>super.captureStatelessImmediate(r,i,n,{timestamp:a.timestamp,disableGeoip:a.disableGeoip,uuid:a.uuid})).catch(r=>{r&&console.error(r)}))}identify({distinctId:t,properties:r={},disableGeoip:i}){let{$set:n,$set_once:a,$anon_distinct_id:o,...c}=r,u={$set:n||c,$set_once:a||{},$anon_distinct_id:o??void 0};super.identifyStateless(t,u,{disableGeoip:i})}async identifyImmediate({distinctId:t,properties:r={},disableGeoip:i}){let{$set:n,$set_once:a,$anon_distinct_id:o,...c}=r,u={$set:n||c,$set_once:a||{},$anon_distinct_id:o??void 0};super.identifyStatelessImmediate(t,u,{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=BH_){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let i=setTimeout(()=>{n(),r(!1)},t),n=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(i),n(),r(a>0)})})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:o,sendFeatureFlagEvents:c,personProperties:d,groupProperties:s}=i||{},u=this.addLocalPersonAndGroupProperties(r,n,d,s);d=u.allPersonProperties,s=u.allGroupProperties,o==null&&(o=!1),c==null&&(c=this.options.sendFeatureFlagEvent??!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,d,s),p=l!==void 0,_,h,y;if(!p&&!o){let v=await super.getFeatureFlagDetailStateless(t,r,n,d,s,a);if(v===void 0)return;y=v.response,l=pyn(y),_=v?.requestId,h=v?.evaluatedAt}let b=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(b))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(b):this.distinctIdHasSentFlagCalls[r]=[b],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:y?.metadata?.id,$feature_flag_version:y?.metadata?.version,$feature_flag_reason:y?.reason?.description??y?.reason?.code,locally_evaluated:p,[`$feature/${t}`]:l,$feature_flag_request_id:_,$feature_flag_evaluated_at:h},groups:n,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:o}=n||{},{onlyEvaluateLocally:c,personProperties:d,groupProperties:s}=n||{},u=this.addLocalPersonAndGroupProperties(r,a,d,s);d=u.allPersonProperties,s=u.allGroupProperties;let l;if(this.featureFlagsPoller!==void 0){await this.featureFlagsPoller?.loadFeatureFlags();let h=this.featureFlagsPoller?.featureFlagsByKey[t];if(h)try{let y=await this.featureFlagsPoller?.computeFlagAndPayloadLocally(h,r,a,d,s,i);y&&(i=y.value,l=y.payload)}catch(y){if(y instanceof G$t||y instanceof I0)this._logger?.info(`${y.name} when computing flag locally: ${h.key}: ${y.message}`);else throw y}}return c==null&&(c=!1),!(l!==void 0)&&!c&&(l=await super.getFeatureFlagPayloadStateless(t,r,a,d,s,o)),l}async getRemoteConfigPayload(t){if(!this.options.personalApiKey)throw new Error("Personal API key is required for remote config payload decryption");let r=await this._requestRemoteConfigPayload(t);if(!r)return;let i=await r.json();if(typeof i=="string")try{return JSON.parse(i)}catch{}return i}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,flagKeys:a}=r||{},{onlyEvaluateLocally:o,personProperties:c,groupProperties:d}=r||{},s=this.addLocalPersonAndGroupProperties(t,i,c,d);c=s.allPersonProperties,d=s.allGroupProperties,o==null&&(o=!1);let u=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,c,d,a),l={},p={},_=!0;if(u&&(l=u.response,p=u.payloads,_=u.fallbackToFlags),_&&!o){let h=await super.getFeatureFlagsAndPayloadsStateless(t,i,c,d,n,a);l={...l,...h.flags||{}},p={...p,...h.payloads||{}}}return{featureFlags:l,featureFlagPayloads:p}}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)}withContext(t,r,i){return this.context?this.context.run(t,r,i):r()}getContext(){return this.context?.get()}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(t),this.errorTracking.shutdown(),super._shutdown(t)}async _requestRemoteConfigPayload(t){if(!this.options.personalApiKey)return;let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config?token=${encodeURIComponent(this.apiKey)}`,i={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",Authorization:`Bearer ${this.options.personalApiKey}`}},n=null;if(this.options.requestTimeout&&typeof this.options.requestTimeout=="number"){let a=new AbortController;n=hyn(()=>{a.abort()},this.options.requestTimeout),i.signal=a.signal}try{return await this.fetch(r,i)}catch(a){this._events.emit("error",a);return}finally{n&&clearTimeout(n)}}extractPropertiesFromEvent(t,r){if(!t)return{personProperties:{},groupProperties:{}};let i={},n={};for(let[a,o]of Object.entries(t))if(zx_(o)&&r&&a in r){let c={};for(let[d,s]of Object.entries(o))c[String(d)]=String(s);n[String(a)]=c}else i[String(a)]=String(o);return{personProperties:i,groupProperties:n}}async getFeatureFlagsForEvent(t,r,i,n){let a=n?.personProperties||{},o=n?.groupProperties||{},c=n?.flagKeys;if(n?.onlyEvaluateLocally??!1)if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let s={};for(let[u,l]of Object.entries(r||{}))s[u]=String(l);return await this.getAllFlags(t,{groups:s,personProperties:a,groupProperties:o,disableGeoip:i,onlyEvaluateLocally:!0,flagKeys:c})}else return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let s={};for(let[u,l]of Object.entries(r||{}))s[u]=String(l);return await this.getAllFlags(t,{groups:s,personProperties:a,groupProperties:o,disableGeoip:i,onlyEvaluateLocally:!0,flagKeys:c})}return(await super.getFeatureFlagsStateless(t,r,a,o,i)).flags}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...n?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,i){let n=new Error("PostHog syntheticException");this.addPendingPromise(SQi.buildEventMessage(t,{syntheticException:n},r,i).then(a=>this.capture(a)))}async captureExceptionImmediate(t,r,i){let n=new Error("PostHog syntheticException");this.addPendingPromise(SQi.buildEventMessage(t,{syntheticException:n},r,i).then(a=>this.captureImmediate(a)))}async prepareEventMessage(t){let{distinctId:r,event:i,properties:n,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:d,uuid:s}=t,u=this.context?.get(),l=r||u?.distinctId,p={...u?.properties||{},...n||{}};l||(l=V$t(),p.$process_person_profile=!1),u?.sessionId&&!p.$session_id&&(p.$session_id=u.sessionId);let _=this._runBeforeSend({distinctId:l,event:i,properties:p,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:d,uuid:s});if(!_)return Promise.reject(null);let h=await Promise.resolve().then(async()=>{if(o){let y=typeof o=="object"?o:void 0;return await this.getFeatureFlagsForEvent(_.distinctId,a,d,y)}return _.event,{}}).then(y=>{let b={};if(y)for(let[O,m]of Object.entries(y))b[`$feature/${O}`]=m;let v=Object.keys(y||{}).filter(O=>y?.[O]!==!1).sort();return v.length>0&&(b.$active_feature_flags=v),b}).catch(()=>({})).then(y=>({...y,..._.properties||{},$groups:_.groups||a}));return _.event==="$pageview"&&this.options.__preview_capture_bot_pageviews&&typeof h.$raw_user_agent=="string"&&Bx_(h.$raw_user_agent,this.options.custom_blocked_useragents||[])&&(_.event="$bot_pageview",h.$browser_type="bot"),{distinctId:_.distinctId,event:_.event,properties:h,options:{timestamp:_.timestamp,disableGeoip:_.disableGeoip,uuid:_.uuid}}}_runBeforeSend(t){let r=this.options.before_send;if(!r)return t;let i=Array.isArray(r)?r:[r],n=t;for(let a of i){if(n=a(n),!n)return this._logger.info(`Event '${t.event}' was rejected in beforeSend function`),null;if(!n.properties||Object.keys(n.properties).length===0){let o=`Event '${n.event}' has no properties after beforeSend function, this is likely an error.`;this._logger.warn(o)}}return n}};var IH_=require("async_hooks"),_Zo=class{constructor(){this.storage=new IH_.AsyncLocalStorage}get(){return this.storage.getStore()}run(t,r,i){if(i?.fresh===!0)return this.storage.run(t,r);{let a=this.get()||{},o={distinctId:t.distinctId??a.distinctId,sessionId:t.sessionId??a.sessionId,properties:{...a.properties||{},...t.properties||{}}};return this.storage.run(o,r)}}};var CH_="posthog-node";function ubD(e,{organization:t,projectId:r,prefix:i,severityAllowList:n=["error"],sendExceptionsToPostHog:a=!0}={}){return o=>{if(!(n==="*"||n.includes(o.level)))return o;o.tags||(o.tags={});let d=o.tags[TNc.POSTHOG_ID_TAG];if(d===void 0)return o;let s=e.options.host??"https://us.i.posthog.com",u=new URL(`/project/${e.apiKey}/person/${d}`,s).toString();o.tags["PostHog Person URL"]=u;let l=o.exception?.values||[],p=l.map(h=>({...h,stacktrace:h.stacktrace?{...h.stacktrace,type:"raw",frames:(h.stacktrace.frames||[]).map(y=>({...y,platform:"node:javascript"}))}:void 0})),_={$exception_message:l[0]?.value||o.message,$exception_type:l[0]?.type,$exception_level:o.level,$exception_list:p,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:l[0]?.value||o.message,$sentry_exception_type:l[0]?.type,$sentry_tags:o.tags};return t&&r&&(_.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+o.event_id),a&&e.capture({event:"$exception",distinctId:d,properties:_}),o}}var TNc=class{static#e=this.POSTHOG_ID_TAG="posthog_distinct_id";constructor(t,r,i,n,a){this.name=CH_,this.name=CH_,this.setupOnce=function(o,c){let d=c()?.getClient()?.getDsn()?.projectId;o(ubD(t,{organization:r,projectId:d,prefix:i,severityAllowList:n,sendExceptionsToPostHog:a??!0}))}}};SQi.errorPropertiesBuilder=new K$.ErrorPropertiesBuilder([new K$.EventCoercer,new K$.ErrorCoercer,new K$.ObjectCoercer,new K$.StringCoercer,new K$.PrimitiveCoercer],K$.createStackParser("node:javascript",K$.nodeStackLineParser),[wx_(),bH_]);var rra=class extends pZo{getLibraryId(){return"posthog-node"}initializeContext(){return new _Zo}};var hZo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new rra(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.47.2",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var GGa=class{async sendEvent(){}async identify(){}async flush(){}};var ira=require("fs/promises"),zH_=require("os"),NH_=require("path");var qH_=ce(require("crypto")),bZo=new Uint8Array(256),yZo=bZo.length;function RNc(){return yZo>bZo.length-16&&(qH_.default.randomFillSync(bZo),yZo=0),bZo.slice(yZo,yZo+=16)}var dL=[];for(let e=0;e<256;++e)dL.push((e+256).toString(16).slice(1));function TH_(e,t=0){return dL[e[t+0]]+dL[e[t+1]]+dL[e[t+2]]+dL[e[t+3]]+"-"+dL[e[t+4]]+dL[e[t+5]]+"-"+dL[e[t+6]]+dL[e[t+7]]+"-"+dL[e[t+8]]+dL[e[t+9]]+"-"+dL[e[t+10]]+dL[e[t+11]]+dL[e[t+12]]+dL[e[t+13]]+dL[e[t+14]]+dL[e[t+15]]}var RH_=ce(require("crypto")),zNc={randomUUID:RH_.default.randomUUID};function sbD(e,t,r){if(zNc.randomUUID&&!t&&!e)return zNc.randomUUID();e=e||{};let i=e.random||(e.rng||RNc)();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 TH_(i)}var Lve=sbD;var cbD="id",lbD=".fern",xGa=class{posthog;userId;token;constructor({token:t,posthogApiKey:r}){this.posthog=new rra(r),this.userId=t==null?void 0:sCc(t),this.token=t}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){let r=await this.getUserEmail();this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"3.47.2",...t,...t.properties,usingAccessToken:!1,...r!=null?{userEmail:r}:{}}})}async flush(){await this.posthog.flush()}userEmail;async getUserEmail(){if(this.userEmail!==null){if(this.userEmail!=null)return this.userEmail;if(this.token==null){this.userEmail=null;return}try{let t=await rL({token:this.token.value}).user.getMyself();if(t.ok&&t.body.email!=null)return this.userEmail=t.body.email,this.userEmail}catch{}this.userEmail=null}}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Tt(Sr.of((0,zH_.homedir)()),Je.of(lbD),Je.of(cbD));await Ai(t)||(await(0,ira.mkdir)((0,NH_.dirname)(t),{recursive:!0}),await(0,ira.writeFile)(t,Lve())),this.persistedDistinctId=(await(0,ira.readFile)(t)).toString()}return this.persistedDistinctId}};var NNc;async function nra(){return NNc==null&&(NNc=await fbD()),NNc}async function fbD(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new GGa;let r=await c7o();return r!=null?new xGa({token:r,posthogApiKey:e}):await Oea()!=null?new hZo({posthogApiKey:e}):new xGa({token:void 0,posthogApiKey:e})}catch{return new GGa}}function HGa(e,t){return function(){return e.apply(t,arguments)}}var{toString:dbD}=Object.prototype,{getPrototypeOf:QNc}=Object,{iterator:gZo,toStringTag:QH_}=Symbol,OZo=(e=>t=>{let r=dbD.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),r8t=e=>(e=e.toLowerCase(),t=>OZo(t)===e),mZo=e=>t=>typeof t===e,{isArray:ora}=Array,ara=mZo("undefined");function KGa(e){return e!==null&&!ara(e)&&e.constructor!==null&&!ara(e.constructor)&&J$(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var UH_=r8t("ArrayBuffer");function pbD(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&UH_(e.buffer),t}var _bD=mZo("string"),J$=mZo("function"),LH_=mZo("number"),JGa=e=>e!==null&&typeof e=="object",hbD=e=>e===!0||e===!1,vZo=e=>{if(OZo(e)!=="object")return!1;let t=QNc(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(QH_ in e)&&!(gZo in e)},ybD=e=>{if(!JGa(e)||KGa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},bbD=r8t("Date"),vbD=r8t("File"),gbD=r8t("Blob"),ObD=r8t("FileList"),mbD=e=>JGa(e)&&J$(e.pipe),AbD=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||J$(e.append)&&((t=OZo(e))==="formdata"||t==="object"&&J$(e.toString)&&e.toString()==="[object FormData]"))},PbD=r8t("URLSearchParams"),[jbD,wbD,EbD,SbD]=["ReadableStream","Request","Response","Headers"].map(r8t),MbD=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function $Ga(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),ora(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(KGa(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(i=0;i<o;i++)c=a[i],t.call(null,e[c],c,e)}}function VH_(e,t){if(KGa(e))return null;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 yyn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,WH_=e=>!ara(e)&&e!==yyn;function FNc(){let{caseless:e,skipUndefined:t}=WH_(this)&&this||{},r={},i=(n,a)=>{let o=e&&VH_(r,a)||a;vZo(r[o])&&vZo(n)?r[o]=FNc(r[o],n):vZo(n)?r[o]=FNc({},n):ora(n)?r[o]=n.slice():(!t||!ara(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&$Ga(arguments[n],i);return r}var DbD=(e,t,r,{allOwnKeys:i}={})=>($Ga(t,(n,a)=>{r&&J$(n)?e[a]=HGa(n,r):e[a]=n},{allOwnKeys:i}),e),BbD=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),IbD=(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)},CbD=(e,t,r,i)=>{let n,a,o,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)o=n[a],(!i||i(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&QNc(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},qbD=(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},TbD=e=>{if(!e)return null;if(ora(e))return e;let t=e.length;if(!LH_(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},RbD=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&QNc(Uint8Array)),zbD=(e,t)=>{let i=(e&&e[gZo]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},NbD=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},FbD=r8t("HTMLFormElement"),QbD=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),FH_=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),UbD=r8t("RegExp"),GH_=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};$Ga(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},LbD=e=>{GH_(e,(t,r)=>{if(J$(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(J$(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+"'")})}})},VbD=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return ora(e)?i(e):i(String(e).split(t)),r},WbD=()=>{},GbD=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function xbD(e){return!!(e&&J$(e.append)&&e[QH_]==="FormData"&&e[gZo])}var HbD=e=>{let t=new Array(10),r=(i,n)=>{if(JGa(i)){if(t.indexOf(i)>=0)return;if(KGa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=ora(i)?[]:{};return $Ga(i,(o,c)=>{let d=r(o,n+1);!ara(d)&&(a[c]=d)}),t[n]=void 0,a}}return i};return r(e,0)},KbD=r8t("AsyncFunction"),JbD=e=>e&&(JGa(e)||J$(e))&&J$(e.then)&&J$(e.catch),xH_=((e,t)=>e?setImmediate:t?((r,i)=>(yyn.addEventListener("message",({source:n,data:a})=>{n===yyn&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),yyn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",J$(yyn.postMessage)),$bD=typeof queueMicrotask<"u"?queueMicrotask.bind(yyn):typeof process<"u"&&process.nextTick||xH_,YbD=e=>e!=null&&J$(e[gZo]),ir={isArray:ora,isArrayBuffer:UH_,isBuffer:KGa,isFormData:AbD,isArrayBufferView:pbD,isString:_bD,isNumber:LH_,isBoolean:hbD,isObject:JGa,isPlainObject:vZo,isEmptyObject:ybD,isReadableStream:jbD,isRequest:wbD,isResponse:EbD,isHeaders:SbD,isUndefined:ara,isDate:bbD,isFile:vbD,isBlob:gbD,isRegExp:UbD,isFunction:J$,isStream:mbD,isURLSearchParams:PbD,isTypedArray:RbD,isFileList:ObD,forEach:$Ga,merge:FNc,extend:DbD,trim:MbD,stripBOM:BbD,inherits:IbD,toFlatObject:CbD,kindOf:OZo,kindOfTest:r8t,endsWith:qbD,toArray:TbD,forEachEntry:zbD,matchAll:NbD,isHTMLForm:FbD,hasOwnProperty:FH_,hasOwnProp:FH_,reduceDescriptors:GH_,freezeMethods:LbD,toObjectSet:VbD,toCamelCase:QbD,noop:WbD,toFiniteNumber:GbD,findKey:VH_,global:yyn,isContextDefined:WH_,isSpecCompliantForm:xbD,toJSONObject:HbD,isAsyncFn:KbD,isThenable:JbD,setImmediate:xH_,asap:$bD,isIterable:YbD};function ura(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)}ir.inherits(ura,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:ir.toJSONObject(this.config),code:this.code,status:this.status}}});var HH_=ura.prototype,KH_={};["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=>{KH_[e]={value:e}});Object.defineProperties(ura,KH_);Object.defineProperty(HH_,"isAxiosError",{value:!0});ura.from=(e,t,r,i,n,a)=>{let o=Object.create(HH_);ir.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return ura.call(o,c,d,r,i,n),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var za=ura;var JH_=ce(Fkn(),1),AZo=JH_.default;function UNc(e){return ir.isPlainObject(e)||ir.isArray(e)}function YH_(e){return ir.endsWith(e,"[]")?e.slice(0,-2):e}function $H_(e,t,r){return e?e.concat(t).map(function(n,a){return n=YH_(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function XbD(e){return ir.isArray(e)&&!e.some(UNc)}var ZbD=ir.toFlatObject(ir,{},null,function(t){return/^is[A-Z]/.test(t)});function kbD(e,t,r){if(!ir.isObject(e))throw new TypeError("target must be an object");t=t||new(AZo||FormData),r=ir.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!ir.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&ir.isSpecCompliantForm(t);if(!ir.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(ir.isDate(h))return h.toISOString();if(ir.isBoolean(h))return h.toString();if(!d&&ir.isBlob(h))throw new za("Blob is not supported. Use a Buffer instead.");return ir.isArrayBuffer(h)||ir.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,y,b){let v=h;if(h&&!b&&typeof h=="object"){if(ir.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(ir.isArray(h)&&XbD(h)||(ir.isFileList(h)||ir.endsWith(y,"[]"))&&(v=ir.toArray(h)))return y=YH_(y),v.forEach(function(m,g){!(ir.isUndefined(m)||m===null)&&t.append(o===!0?$H_([y],g,a):o===null?y:y+"[]",s(m))}),!1}return UNc(h)?!0:(t.append($H_(b,y,a),s(h)),!1)}let l=[],p=Object.assign(ZbD,{defaultVisitor:u,convertValue:s,isVisitable:UNc});function _(h,y){if(!ir.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),ir.forEach(h,function(v,O){(!(ir.isUndefined(v)||v===null)&&n.call(t,v,ir.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!ir.isObject(e))throw new TypeError("data must be an object");return _(e),t}var _Ki=kbD;function XH_(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function ZH_(e,t){this._pairs=[],e&&_Ki(e,this,t)}var kH_=ZH_.prototype;kH_.append=function(t,r){this._pairs.push([t,r])};kH_.toString=function(t){let r=t?function(i){return t.call(this,i,XH_)}:XH_;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var e7_=ZH_;function evD(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function byn(e,t,r){if(!t)return e;let i=r&&r.encode||evD;ir.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=ir.isURLSearchParams(t)?t.toString():new e7_(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var LNc=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){ir.forEach(this.handlers,function(i){i!==null&&t(i)})}},VNc=LNc;var sra={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var n7_=ce(require("crypto"),1);var t7_=ce(require("url"),1),r7_=t7_.default.URLSearchParams;var WNc="abcdefghijklmnopqrstuvwxyz",i7_="0123456789",a7_={DIGIT:i7_,ALPHA:WNc,ALPHA_DIGIT:WNc+WNc.toUpperCase()+i7_},tvD=(e=16,t=a7_.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);n7_.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},o7_={isNode:!0,classes:{URLSearchParams:r7_,FormData:AZo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:a7_,generateString:tvD,protocols:["http","https","file","data"]};var HNc={};Yt(HNc,{hasBrowserEnv:()=>xNc,hasStandardBrowserEnv:()=>rvD,hasStandardBrowserWebWorkerEnv:()=>ivD,navigator:()=>GNc,origin:()=>nvD});var xNc=typeof window<"u"&&typeof document<"u",GNc=typeof navigator=="object"&&navigator||void 0,rvD=xNc&&(!GNc||["ReactNative","NativeScript","NS"].indexOf(GNc.product)<0),ivD=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",nvD=xNc&&window.location.href||"http://localhost";var yA={...HNc,...o7_};function KNc(e,t){return _Ki(e,new yA.classes.URLSearchParams,{visitor:function(r,i,n,a){return yA.isNode&&ir.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function avD(e){return ir.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function ovD(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 uvD(e){function t(r,i,n,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),d=a>=r.length;return o=!o&&ir.isArray(n)?n.length:o,d?(ir.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!ir.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&ir.isArray(n[o])&&(n[o]=ovD(n[o])),!c)}if(ir.isFormData(e)&&ir.isFunction(e.entries)){let r={};return ir.forEachEntry(e,(i,n)=>{t(avD(i),n,r,0)}),r}return null}var PZo=uvD;function svD(e,t,r){if(ir.isString(e))try{return(t||JSON.parse)(e),ir.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var JNc={transitional:sra,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=ir.isObject(t);if(a&&ir.isHTMLForm(t)&&(t=new FormData(t)),ir.isFormData(t))return n?JSON.stringify(PZo(t)):t;if(ir.isArrayBuffer(t)||ir.isBuffer(t)||ir.isStream(t)||ir.isFile(t)||ir.isBlob(t)||ir.isReadableStream(t))return t;if(ir.isArrayBufferView(t))return t.buffer;if(ir.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return KNc(t,this.formSerializer).toString();if((c=ir.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return _Ki(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),svD(t)):t}],transformResponse:[function(t){let r=this.transitional||JNc.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(ir.isResponse(t)||ir.isReadableStream(t))return t;if(t&&ir.isString(t)&&(i&&!this.responseType||n)){let o=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?za.from(c,za.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:yA.classes.FormData,Blob:yA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ir.forEach(["delete","get","head","post","put","patch"],e=>{JNc.headers[e]={}});var cra=JNc;var cvD=ir.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"]),u7_=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1266
1266
|
`).forEach(function(o){n=o.indexOf(":"),r=o.substring(0,n).trim().toLowerCase(),i=o.substring(n+1).trim(),!(!r||t[r]&&cvD[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var s7_=Symbol("internals");function YGa(e){return e&&String(e).trim().toLowerCase()}function jZo(e){return e===!1||e==null?e:ir.isArray(e)?e.map(jZo):String(e)}function lvD(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 fvD=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function $Nc(e,t,r,i,n){if(ir.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!ir.isString(t)){if(ir.isString(i))return t.indexOf(i)!==-1;if(ir.isRegExp(i))return i.test(t)}}function dvD(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function pvD(e,t){let r=ir.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,o){return this[i].call(this,t,n,a,o)},configurable:!0})})}var lra=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(c,d,s){let u=YGa(d);if(!u)throw new Error("header name must be a non-empty string");let l=ir.findKey(n,u);(!l||n[l]===void 0||s===!0||s===void 0&&n[l]!==!1)&&(n[l||d]=jZo(c))}let o=(c,d)=>ir.forEach(c,(s,u)=>a(s,u,d));if(ir.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(ir.isString(t)&&(t=t.trim())&&!fvD(t))o(u7_(t),r);else if(ir.isObject(t)&&ir.isIterable(t)){let c={},d,s;for(let u of t){if(!ir.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[s=u[0]]=(d=c[s])?ir.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}o(c,r)}else t!=null&&a(r,t,i);return this}get(t,r){if(t=YGa(t),t){let i=ir.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return lvD(n);if(ir.isFunction(r))return r.call(this,n,i);if(ir.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=YGa(t),t){let i=ir.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||$Nc(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(o){if(o=YGa(o),o){let c=ir.findKey(i,o);c&&(!r||$Nc(i,i[c],c,r))&&(delete i[c],n=!0)}}return ir.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||$Nc(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return ir.forEach(this,(n,a)=>{let o=ir.findKey(i,a);if(o){r[o]=jZo(n),delete r[a];return}let c=t?dvD(a):String(a).trim();c!==a&&delete r[a],r[c]=jZo(n),i[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return ir.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&ir.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(`
|
|
1267
1267
|
`)}getSetCookie(){return this.get("set-cookie")||[]}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[s7_]=this[s7_]={accessors:{}}).accessors,n=this.prototype;function a(o){let c=YGa(o);i[c]||(pvD(n,o),i[c]=!0)}return ir.isArray(t)?t.forEach(a):a(t),this}};lra.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ir.reduceDescriptors(lra.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});ir.freezeMethods(lra);var mD=lra;function XGa(e,t){let r=this||cra,i=t||r,n=mD.from(i.headers),a=i.data;return ir.forEach(e,function(c){a=c.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function ZGa(e){return!!(e&&e.__CANCEL__)}function c7_(e,t,r){za.call(this,e??"canceled",za.ERR_CANCELED,t,r),this.name="CanceledError"}ir.inherits(c7_,za,{__CANCEL__:!0});var Vve=c7_;function x$t(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new za("Request failed with status code "+r.status,[za.ERR_BAD_REQUEST,za.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function YNc(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function XNc(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function vyn(e,t,r){let i=!YNc(t);return e&&(i||r==!1)?XNc(e,t):t}var q7_=ce(ZNc(),1),T7_=ce(require("http"),1),R7_=ce(require("https"),1),z7_=ce(require("util"),1),N7_=ce(b7_(),1),DQi=ce(require("zlib"),1);var myn="1.12.2";function ixa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var BvD=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function fFc(e,t,r){let i=r&&r.Blob||yA.classes.Blob,n=ixa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=BvD.exec(e);if(!a)throw new za("Invalid URL",za.ERR_INVALID_URL);let o=a[1],c=a[2],d=a[3],s=Buffer.from(decodeURIComponent(d),c?"base64":"utf8");if(t){if(!i)throw new za("Blob is not supported",za.ERR_NOT_SUPPORT);return new i([s],{type:o})}return s}throw new za("Unsupported protocol "+n,za.ERR_NOT_SUPPORT)}var Pyn=ce(require("stream"),1);var v7_=ce(require("stream"),1);var dFc=Symbol("internals"),pFc=class extends v7_.default.Transform{constructor(t){t=ir.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!ir.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[dFc]={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[dFc];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[dFc],a=n.maxRate,o=this.readableHighWaterMark,c=n.timeWindow,d=1e3/c,s=a/d,u=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,l=(_,h)=>{let y=Buffer.byteLength(_);n.bytesSeen+=y,n.bytes+=y,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(_)?process.nextTick(h):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(h)}},p=(_,h)=>{let y=Buffer.byteLength(_),b=null,v=o,O,m=0;if(a){let g=Date.now();(!n.ts||(m=g-n.ts)>=c)&&(n.ts=g,O=s-n.bytes,n.bytes=O<0?-O:0,m=0),O=s-n.bytes}if(a){if(O<=0)return setTimeout(()=>{h(null,_)},c-m);O<v&&(v=O)}v&&y>v&&y-v>u&&(b=_.subarray(v),_=_.subarray(0,v)),l(_,b?()=>{process.nextTick(h,null,b)}:h)};p(t,function _(h,y){if(h)return i(h);y?p(y,_):i(null)})}},_Fc=pFc;var F7_=require("events");var O7_=ce(require("util"),1),m7_=require("stream");var{asyncIterator:g7_}=Symbol,IvD=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[g7_]?yield*e[g7_]():yield e},wZo=IvD;var CvD=yA.ALPHABET.ALPHA_DIGIT+"-_",nxa=typeof TextEncoder=="function"?new TextEncoder:new O7_.default.TextEncoder,Ayn=`\r
|
|
1268
1268
|
`,qvD=nxa.encode(Ayn),TvD=2,hFc=class{constructor(t,r){let{escapeName:i}=this.constructor,n=ir.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${Ayn}`;n?r=nxa.encode(String(r).replace(/\r?\n|\r\n?/g,Ayn)):a+=`Content-Type: ${r.type||"application/octet-stream"}${Ayn}`,this.headers=nxa.encode(a+Ayn),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+TvD,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;ir.isTypedArray(t)?yield t:yield*wZo(t),yield qvD}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},RvD=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+yA.generateString(n,CvD)}=r||{};if(!ir.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let o=nxa.encode("--"+a+Ayn),c=nxa.encode("--"+a+"--"+Ayn),d=c.byteLength,s=Array.from(e.entries()).map(([l,p])=>{let _=new hFc(l,p);return d+=_.size,_});d+=o.byteLength*s.length,d=ir.toFiniteNumber(d);let u={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(u["Content-Length"]=d),t&&t(u),m7_.Readable.from((async function*(){for(let l of s)yield o,yield*l.encode();yield c})())},A7_=RvD;var P7_=ce(require("stream"),1),yFc=class extends P7_.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)}},j7_=yFc;var zvD=(e,t)=>ir.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,w7_=zvD;function NvD(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,o;return t=t!==void 0?t:1e3,function(d){let s=Date.now(),u=i[a];o||(o=s),r[n]=d,i[n]=s;let l=a,p=0;for(;l!==n;)p+=r[l++],l=l%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-o<t)return;let _=u&&s-u;return _?Math.round(p*1e3/_):void 0}}var E7_=NvD;function FvD(e,t){let r=0,i=1e3/t,n,a,o=(s,u=Date.now())=>{r=u,n=null,a&&(clearTimeout(a),a=null),e(...s)};return[(...s)=>{let u=Date.now(),l=u-r;l>=i?o(s,u):(n=s,a||(a=setTimeout(()=>{a=null,o(n)},i-l)))},()=>n&&o(n)]}var S7_=FvD;var MQi=(e,t,r=3)=>{let i=0,n=E7_(50,250);return S7_(a=>{let o=a.loaded,c=a.lengthComputable?a.total:void 0,d=o-i,s=n(d),u=o<=c;i=o;let l={loaded:o,total:c,progress:c?o/c:void 0,bytes:d,rate:s||void 0,estimated:s&&c&&u?(c-o)/s:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},dra=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},pra=e=>(...t)=>ir.asap(()=>e(...t));function bFc(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let t=e.indexOf(",");if(t<0)return 0;let r=e.slice(5,t),i=e.slice(t+1);if(/;base64/i.test(r)){let a=i.length,o=i.length;for(let p=0;p<o;p++)if(i.charCodeAt(p)===37&&p+2<o){let _=i.charCodeAt(p+1),h=i.charCodeAt(p+2);(_>=48&&_<=57||_>=65&&_<=70||_>=97&&_<=102)&&(h>=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102)&&(a-=2,p+=2)}let c=0,d=o-1,s=p=>p>=2&&i.charCodeAt(p-2)===37&&i.charCodeAt(p-1)===51&&(i.charCodeAt(p)===68||i.charCodeAt(p)===100);d>=0&&(i.charCodeAt(d)===61?(c++,d--):s(d)&&(c++,d-=3)),c===1&&d>=0&&(i.charCodeAt(d)===61||s(d))&&c++;let l=Math.floor(a/4)*3-(c||0);return l>0?l:0}return Buffer.byteLength(i,"utf8")}var M7_={flush:DQi.default.constants.Z_SYNC_FLUSH,finishFlush:DQi.default.constants.Z_SYNC_FLUSH},QvD={flush:DQi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:DQi.default.constants.BROTLI_OPERATION_FLUSH},D7_=ir.isFunction(DQi.default.createBrotliDecompress),{http:UvD,https:LvD}=N7_.default,VvD=/https:?/,B7_=yA.protocols.map(e=>e+":"),I7_=(e,[t,r])=>(e.on("end",r).on("error",r),t);function WvD(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function Q7_(e,t,r){let i=t;if(!i&&i!==!1){let n=q7_.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){Q7_(a,t,a.href)}}var GvD=typeof process<"u"&&ir.kindOf(process)==="process",xvD=e=>new Promise((t,r)=>{let i,n,a=(d,s)=>{n||(n=!0,i&&i(d,s))},o=d=>{a(d),t(d)},c=d=>{a(d,!0),r(d)};e(o,c,d=>i=d).catch(c)}),HvD=({address:e,family:t})=>{if(!ir.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},C7_=(e,t)=>HvD(ir.isObject(e)?e:{address:e,family:t}),U7_=GvD&&function(t){return xvD(async function(i,n,a){let{data:o,lookup:c,family:d}=t,{responseType:s,responseEncoding:u}=t,l=t.method.toUpperCase(),p,_=!1,h;if(c){let Y=w7_(c,he=>ir.isArray(he)?he:[he]);c=(he,be,W)=>{Y(he,be,(x,Ee,ue)=>{if(x)return W(x);let Oe=ir.isArray(Ee)?Ee.map(Fe=>C7_(Fe)):[C7_(Ee,ue)];be.all?W(x,Oe):W(x,Oe[0].address,Oe[0].family)})}}let y=new F7_.EventEmitter,b=()=>{t.cancelToken&&t.cancelToken.unsubscribe(v),t.signal&&t.signal.removeEventListener("abort",v),y.removeAllListeners()};a((Y,he)=>{p=!0,he&&(_=!0,b())});function v(Y){y.emit("abort",!Y||Y.type?new Vve(null,t,h):Y)}y.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(v),t.signal&&(t.signal.aborted?v():t.signal.addEventListener("abort",v)));let O=vyn(t.baseURL,t.url,t.allowAbsoluteUrls),m=new URL(O,yA.hasBrowserEnv?yA.origin:void 0),g=m.protocol||B7_[0];if(g==="data:"){if(t.maxContentLength>-1){let he=String(t.url||O||"");if(bFc(he)>t.maxContentLength)return n(new za("maxContentLength size of "+t.maxContentLength+" exceeded",za.ERR_BAD_RESPONSE,t))}let Y;if(l!=="GET")return x$t(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{Y=fFc(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(he){throw za.from(he,za.ERR_BAD_REQUEST,t)}return s==="text"?(Y=Y.toString(u),(!u||u==="utf8")&&(Y=ir.stripBOM(Y))):s==="stream"&&(Y=Pyn.default.Readable.from(Y)),x$t(i,n,{data:Y,status:200,statusText:"OK",headers:new mD,config:t})}if(B7_.indexOf(g)===-1)return n(new za("Unsupported protocol "+g,za.ERR_BAD_REQUEST,t));let A=mD.from(t.headers).normalize();A.set("User-Agent","axios/"+myn,!1);let{onUploadProgress:j,onDownloadProgress:M}=t,w=t.maxRate,D,B;if(ir.isSpecCompliantForm(o)){let Y=A.getContentType(/boundary=([-_\w\d]{10,70})/i);o=A7_(o,he=>{A.set(he)},{tag:`axios-${myn}-boundary`,boundary:Y&&Y[1]||void 0})}else if(ir.isFormData(o)&&ir.isFunction(o.getHeaders)){if(A.set(o.getHeaders()),!A.hasContentLength())try{let Y=await z7_.default.promisify(o.getLength).call(o);Number.isFinite(Y)&&Y>=0&&A.setContentLength(Y)}catch{}}else if(ir.isBlob(o)||ir.isFile(o))o.size&&A.setContentType(o.type||"application/octet-stream"),A.setContentLength(o.size||0),o=Pyn.default.Readable.from(wZo(o));else if(o&&!ir.isStream(o)){if(!Buffer.isBuffer(o))if(ir.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(ir.isString(o))o=Buffer.from(o,"utf-8");else return n(new za("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",za.ERR_BAD_REQUEST,t));if(A.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return n(new za("Request body larger than maxBodyLength limit",za.ERR_BAD_REQUEST,t))}let T=ir.toFiniteNumber(A.getContentLength());ir.isArray(w)?(D=w[0],B=w[1]):D=B=w,o&&(j||D)&&(ir.isStream(o)||(o=Pyn.default.Readable.from(o,{objectMode:!1})),o=Pyn.default.pipeline([o,new _Fc({maxRate:ir.toFiniteNumber(D)})],ir.noop),j&&o.on("progress",I7_(o,dra(T,MQi(pra(j),!1,3)))));let R;if(t.auth){let Y=t.auth.username||"",he=t.auth.password||"";R=Y+":"+he}if(!R&&m.username){let Y=m.username,he=m.password;R=Y+":"+he}R&&A.delete("authorization");let q;try{q=byn(m.pathname+m.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Y){let he=new Error(Y.message);return he.config=t,he.url=t.url,he.exists=!0,n(he)}A.set("Accept-Encoding","gzip, compress, deflate"+(D7_?", br":""),!1);let z={path:q,method:l,headers:A.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:R,protocol:g,family:d,beforeRedirect:WvD,beforeRedirects:{}};!ir.isUndefined(c)&&(z.lookup=c),t.socketPath?z.socketPath=t.socketPath:(z.hostname=m.hostname.startsWith("[")?m.hostname.slice(1,-1):m.hostname,z.port=m.port,Q7_(z,t.proxy,g+"//"+m.hostname+(m.port?":"+m.port:"")+z.path));let Q,H=VvD.test(z.protocol);if(z.agent=H?t.httpsAgent:t.httpAgent,t.transport?Q=t.transport:t.maxRedirects===0?Q=H?R7_.default:T7_.default:(t.maxRedirects&&(z.maxRedirects=t.maxRedirects),t.beforeRedirect&&(z.beforeRedirects.config=t.beforeRedirect),Q=H?LvD:UvD),t.maxBodyLength>-1?z.maxBodyLength=t.maxBodyLength:z.maxBodyLength=1/0,t.insecureHTTPParser&&(z.insecureHTTPParser=t.insecureHTTPParser),h=Q.request(z,function(he){if(h.destroyed)return;let be=[he],W=+he.headers["content-length"];if(M||B){let Fe=new _Fc({maxRate:ir.toFiniteNumber(B)});M&&Fe.on("progress",I7_(Fe,dra(W,MQi(pra(M),!0,3)))),be.push(Fe)}let x=he,Ee=he.req||h;if(t.decompress!==!1&&he.headers["content-encoding"])switch((l==="HEAD"||he.statusCode===204)&&delete he.headers["content-encoding"],(he.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":be.push(DQi.default.createUnzip(M7_)),delete he.headers["content-encoding"];break;case"deflate":be.push(new j7_),be.push(DQi.default.createUnzip(M7_)),delete he.headers["content-encoding"];break;case"br":D7_&&(be.push(DQi.default.createBrotliDecompress(QvD)),delete he.headers["content-encoding"])}x=be.length>1?Pyn.default.pipeline(be,ir.noop):be[0];let ue=Pyn.default.finished(x,()=>{ue(),b()}),Oe={status:he.statusCode,statusText:he.statusMessage,headers:new mD(he.headers),config:t,request:Ee};if(s==="stream")Oe.data=x,x$t(i,n,Oe);else{let Fe=[],ae=0;x.on("data",function(Ge){Fe.push(Ge),ae+=Ge.length,t.maxContentLength>-1&&ae>t.maxContentLength&&(_=!0,x.destroy(),n(new za("maxContentLength size of "+t.maxContentLength+" exceeded",za.ERR_BAD_RESPONSE,t,Ee)))}),x.on("aborted",function(){if(_)return;let Ge=new za("stream has been aborted",za.ERR_BAD_RESPONSE,t,Ee);x.destroy(Ge),n(Ge)}),x.on("error",function(Ge){h.destroyed||n(za.from(Ge,null,t,Ee))}),x.on("end",function(){try{let Ge=Fe.length===1?Fe[0]:Buffer.concat(Fe);s!=="arraybuffer"&&(Ge=Ge.toString(u),(!u||u==="utf8")&&(Ge=ir.stripBOM(Ge))),Oe.data=Ge}catch(Ge){return n(za.from(Ge,null,t,Oe.request,Oe))}x$t(i,n,Oe)})}y.once("abort",Fe=>{x.destroyed||(x.emit("error",Fe),x.destroy())})}),y.once("abort",Y=>{n(Y),h.destroy(Y)}),h.on("error",function(he){n(za.from(he,null,t,h))}),h.on("socket",function(he){he.setKeepAlive(!0,1e3*60)}),t.timeout){let Y=parseInt(t.timeout,10);if(Number.isNaN(Y)){n(new za("error trying to parse `config.timeout` to int",za.ERR_BAD_OPTION_VALUE,t,h));return}h.setTimeout(Y,function(){if(p)return;let be=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",W=t.transitional||sra;t.timeoutErrorMessage&&(be=t.timeoutErrorMessage),n(new za(be,W.clarifyTimeoutError?za.ETIMEDOUT:za.ECONNABORTED,t,h)),v()})}if(ir.isStream(o)){let Y=!1,he=!1;o.on("end",()=>{Y=!0}),o.once("error",be=>{he=!0,h.destroy(be)}),o.on("close",()=>{!Y&&!he&&v(new Vve("Request stream has been aborted",t,h))}),o.pipe(h)}else h.end(o)})};var L7_=yA.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,yA.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(yA.origin),yA.navigator&&/(msie|trident)/i.test(yA.navigator.userAgent)):()=>!0;var V7_=yA.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let o=[e+"="+encodeURIComponent(t)];ir.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),ir.isString(i)&&o.push("path="+i),ir.isString(n)&&o.push("domain="+n),a===!0&&o.push("secure"),document.cookie=o.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 W7_=e=>e instanceof mD?{...e}:e;function i8t(e,t){t=t||{};let r={};function i(s,u,l,p){return ir.isPlainObject(s)&&ir.isPlainObject(u)?ir.merge.call({caseless:p},s,u):ir.isPlainObject(u)?ir.merge({},u):ir.isArray(u)?u.slice():u}function n(s,u,l,p){if(ir.isUndefined(u)){if(!ir.isUndefined(s))return i(void 0,s,l,p)}else return i(s,u,l,p)}function a(s,u){if(!ir.isUndefined(u))return i(void 0,u)}function o(s,u){if(ir.isUndefined(u)){if(!ir.isUndefined(s))return i(void 0,s)}else return i(void 0,u)}function c(s,u,l){if(l in t)return i(s,u);if(l in e)return i(void 0,s)}let d={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(s,u,l)=>n(W7_(s),W7_(u),l,!0)};return ir.forEach(Object.keys({...e,...t}),function(u){let l=d[u]||n,p=l(e[u],t[u],u);ir.isUndefined(p)&&l!==c||(r[u]=p)}),r}var EZo=e=>{let t=i8t({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=mD.from(o),t.url=byn(vyn(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),ir.isFormData(r)){if(yA.hasStandardBrowserEnv||yA.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(ir.isFunction(r.getHeaders)){let d=r.getHeaders(),s=["content-type","content-length"];Object.entries(d).forEach(([u,l])=>{s.includes(u.toLowerCase())&&o.set(u,l)})}}if(yA.hasStandardBrowserEnv&&(i&&ir.isFunction(i)&&(i=i(t)),i||i!==!1&&L7_(t.url))){let d=n&&a&&V7_.read(a);d&&o.set(n,d)}return t};var KvD=typeof XMLHttpRequest<"u",G7_=KvD&&function(e){return new Promise(function(r,i){let n=EZo(e),a=n.data,o=mD.from(n.headers).normalize(),{responseType:c,onUploadProgress:d,onDownloadProgress:s}=n,u,l,p,_,h;function y(){_&&_(),h&&h(),n.cancelToken&&n.cancelToken.unsubscribe(u),n.signal&&n.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(n.method.toUpperCase(),n.url,!0),b.timeout=n.timeout;function v(){if(!b)return;let m=mD.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),A={data:!c||c==="text"||c==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:m,config:e,request:b};x$t(function(M){r(M),y()},function(M){i(M),y()},A),b=null}"onloadend"in b?b.onloadend=v:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(v)},b.onabort=function(){b&&(i(new za("Request aborted",za.ECONNABORTED,e,b)),b=null)},b.onerror=function(g){let A=g&&g.message?g.message:"Network Error",j=new za(A,za.ERR_NETWORK,e,b);j.event=g||null,i(j),b=null},b.ontimeout=function(){let g=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",A=n.transitional||sra;n.timeoutErrorMessage&&(g=n.timeoutErrorMessage),i(new za(g,A.clarifyTimeoutError?za.ETIMEDOUT:za.ECONNABORTED,e,b)),b=null},a===void 0&&o.setContentType(null),"setRequestHeader"in b&&ir.forEach(o.toJSON(),function(g,A){b.setRequestHeader(A,g)}),ir.isUndefined(n.withCredentials)||(b.withCredentials=!!n.withCredentials),c&&c!=="json"&&(b.responseType=n.responseType),s&&([p,h]=MQi(s,!0),b.addEventListener("progress",p)),d&&b.upload&&([l,_]=MQi(d),b.upload.addEventListener("progress",l),b.upload.addEventListener("loadend",_)),(n.cancelToken||n.signal)&&(u=m=>{b&&(i(!m||m.type?new Vve(null,e,b):m),b.abort(),b=null)},n.cancelToken&&n.cancelToken.subscribe(u),n.signal&&(n.signal.aborted?u():n.signal.addEventListener("abort",u)));let O=ixa(n.url);if(O&&yA.protocols.indexOf(O)===-1){i(new za("Unsupported protocol "+O+":",za.ERR_BAD_REQUEST,e));return}b.send(a||null)})};var JvD=(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,c();let u=s instanceof Error?s:this.reason;i.abort(u instanceof za?u:new Vve(u instanceof Error?u.message:u))}},o=t&&setTimeout(()=>{o=null,a(new za(`timeout ${t} of ms exceeded`,za.ETIMEDOUT))},t),c=()=>{e&&(o&&clearTimeout(o),o=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=()=>ir.asap(c),d}},x7_=JvD;var $vD=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},YvD=async function*(e,t){for await(let r of XvD(e))yield*$vD(r,t)},XvD=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()}},vFc=(e,t,r,i)=>{let n=YvD(e,t),a=0,o,c=d=>{o||(o=!0,i&&i(d))};return new ReadableStream({async pull(d){try{let{done:s,value:u}=await n.next();if(s){c(),d.close();return}let l=u.byteLength;if(r){let p=a+=l;r(p)}d.enqueue(new Uint8Array(u))}catch(s){throw c(s),s}},cancel(d){return c(d),n.return()}},{highWaterMark:2})};var H7_=64*1024,{isFunction:SZo}=ir,ZvD=(({Request:e,Response:t})=>({Request:e,Response:t}))(ir.global),{ReadableStream:K7_,TextEncoder:J7_}=ir.global,$7_=(e,...t)=>{try{return!!e(...t)}catch{return!1}},kvD=e=>{e=ir.merge.call({skipUndefined:!0},ZvD,e);let{fetch:t,Request:r,Response:i}=e,n=t?SZo(t):typeof fetch=="function",a=SZo(r),o=SZo(i);if(!n)return!1;let c=n&&SZo(K7_),d=n&&(typeof J7_=="function"?(h=>y=>h.encode(y))(new J7_):async h=>new Uint8Array(await new r(h).arrayBuffer())),s=a&&c&&$7_(()=>{let h=!1,y=new r(yA.origin,{body:new K7_,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return h&&!y}),u=o&&c&&$7_(()=>ir.isReadableStream(new i("").body)),l={stream:u&&(h=>h.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!l[h]&&(l[h]=(y,b)=>{let v=y&&y[h];if(v)return v.call(y);throw new za(`Response type '${h}' is not supported`,za.ERR_NOT_SUPPORT,b)})});let p=async h=>{if(h==null)return 0;if(ir.isBlob(h))return h.size;if(ir.isSpecCompliantForm(h))return(await new r(yA.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(ir.isArrayBufferView(h)||ir.isArrayBuffer(h))return h.byteLength;if(ir.isURLSearchParams(h)&&(h=h+""),ir.isString(h))return(await d(h)).byteLength},_=async(h,y)=>{let b=ir.toFiniteNumber(h.getContentLength());return b??p(y)};return async h=>{let{url:y,method:b,data:v,signal:O,cancelToken:m,timeout:g,onDownloadProgress:A,onUploadProgress:j,responseType:M,headers:w,withCredentials:D="same-origin",fetchOptions:B}=EZo(h),T=t||fetch;M=M?(M+"").toLowerCase():"text";let R=x7_([O,m&&m.toAbortSignal()],g),q=null,z=R&&R.unsubscribe&&(()=>{R.unsubscribe()}),Q;try{if(j&&s&&b!=="get"&&b!=="head"&&(Q=await _(w,v))!==0){let x=new r(y,{method:"POST",body:v,duplex:"half"}),Ee;if(ir.isFormData(v)&&(Ee=x.headers.get("content-type"))&&w.setContentType(Ee),x.body){let[ue,Oe]=dra(Q,MQi(pra(j)));v=vFc(x.body,H7_,ue,Oe)}}ir.isString(D)||(D=D?"include":"omit");let H=a&&"credentials"in r.prototype,Y={...B,signal:R,method:b.toUpperCase(),headers:w.normalize().toJSON(),body:v,duplex:"half",credentials:H?D:void 0};q=a&&new r(y,Y);let he=await(a?T(q,B):T(y,Y)),be=u&&(M==="stream"||M==="response");if(u&&(A||be&&z)){let x={};["status","statusText","headers"].forEach(Fe=>{x[Fe]=he[Fe]});let Ee=ir.toFiniteNumber(he.headers.get("content-length")),[ue,Oe]=A&&dra(Ee,MQi(pra(A),!0))||[];he=new i(vFc(he.body,H7_,ue,()=>{Oe&&Oe(),z&&z()}),x)}M=M||"text";let W=await l[ir.findKey(l,M)||"text"](he,h);return!be&&z&&z(),await new Promise((x,Ee)=>{x$t(x,Ee,{data:W,headers:mD.from(he.headers),status:he.status,statusText:he.statusText,config:h,request:q})})}catch(H){throw z&&z(),H&&H.name==="TypeError"&&/Load failed|fetch/i.test(H.message)?Object.assign(new za("Network Error",za.ERR_NETWORK,h,q),{cause:H.cause||H}):za.from(H,H&&H.code,h,q)}}},egD=new Map,gFc=e=>{let t=e?e.env:{},{fetch:r,Request:i,Response:n}=t,a=[i,n,r],o=a.length,c=o,d,s,u=egD;for(;c--;)d=a[c],s=u.get(d),s===void 0&&u.set(d,s=c?new Map:kvD(t)),u=s;return s},o79=gFc();var OFc={http:U7_,xhr:G7_,fetch:{get:gFc}};ir.forEach(OFc,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var Y7_=e=>`- ${e}`,rgD=e=>ir.isFunction(e)||e===null||e===!1,MZo={getAdapter:(e,t)=>{e=ir.isArray(e)?e:[e];let{length:r}=e,i,n,a={};for(let o=0;o<r;o++){i=e[o];let c;if(n=i,!rgD(i)&&(n=OFc[(c=String(i)).toLowerCase()],n===void 0))throw new za(`Unknown adapter '${c}'`);if(n&&(ir.isFunction(n)||(n=n.get(t))))break;a[c||"#"+o]=n}if(!n){let o=Object.entries(a).map(([d,s])=>`adapter ${d} `+(s===!1?"is not supported by the environment":"is not available in the build")),c=r?o.length>1?`since :
|
|
@@ -1501,7 +1501,7 @@ ${g}${O}${A}${Hoa}`});var TKa=class{result=Fw.Success;logImmediately;logPrefix;s
|
|
|
1501
1501
|
Run ${Rt.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1502
1502
|
Run ${Rt.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),hra(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function $Hc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!tbh(e))return;let n=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let o=a.sort((c,d)=>c.generatorName.localeCompare(d.generatorName)||c.currentVersion.localeCompare(d.currentVersion));for(let c of o)n+=`
|
|
1503
1503
|
${await G6D(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Rt.dim(c.currentVersion)+Rt.reset(" \u2192 ")+Rt.green(c.latestVersion);return n+=`
|
|
1504
|
-
`,i?hra(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function G6D(e){let r=await new ebh.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 x6D({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await ibh({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=PHi(u.name,l),_=await C3t({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:l});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await ibh({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,d,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][d]==null&&(o.versions[c][d]={});let l=PHi(s.name,u),p=await C3t({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][d][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function ibh({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await zve({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(c==null||c.groups==null)return;let d=i!=null?NN(i):void 0;for(let s of c.groups)if(!(n!=null&&s.groupName!==n))for(let u of s.generators)d!=null&&u.name!==d||await r(a.workspaceName,s.groupName,u,o)})}))}function nbh(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let d=yY(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function A_u({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await x6D({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[d,s]of Object.entries(c.versions))o.push(...nbh(s,d,t.logger));else o.push(...nbh(c.versions,void 0,t.logger))}return o}var RKa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${n} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var Joa=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var YHc=(()=>{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})(),abh=typeof globalThis.AbortController=="function",obh=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",ubh=typeof globalThis.ReadableStream=="function",sbh=typeof globalThis.FormData=="function",P_u=["get","post","put","patch","head","delete"],H6D=()=>{};H6D();var cbh={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},j_u=2147483647,lbh=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,w_u=Symbol("stop"),fbh={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},dbh={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 K6D=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=lbh,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},pbh=(e,t,r)=>{let i,n=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),i){n+=i.byteLength;let c=t===0?0:n/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,n),transferredBytes:n},i)}i=a},flush(){i&&(n+=i.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},i))}}))},_bh=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let r=Number(e.headers.get("content-length"))||0;return new Response(pbh(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},hbh=(e,t,r)=>{if(!e.body)return e;let i=K6D(r??e.body);return new Request(e,{duplex:"half",body:pbh(e.body,i,t)})};var $oa=e=>e!==null&&typeof e=="object";var zKa=(...e)=>{for(let t of e)if((!$oa(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return kHc({},...e)},XHc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,o]of n.entries())i&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function E_u(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:kHc(e[r]??[],t[r]??[])}var ZHc=(e={},t={})=>({beforeRequest:E_u(e,t,"beforeRequest"),beforeRetry:E_u(e,t,"beforeRetry"),afterResponse:E_u(e,t,"afterResponse"),beforeError:E_u(e,t,"beforeError")}),kHc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if($oa(n)){for(let[a,o]of Object.entries(n))$oa(o)&&a in t&&(o=kHc(t[a],o)),t={...t,[a]:o};$oa(n.hooks)&&(i=ZHc(i,n.hooks),t.hooks=i),$oa(n.headers)&&(r=XHc(r,n.headers),t.headers=r)}return t};var bbh=e=>P_u.includes(e)?e.toUpperCase():e,J6D=["get","put","head","delete","options","trace"],$6D=[408,413,429,500,502,503,504],Y6D=[413,429,503],ybh={limit:2,methods:J6D,statusCodes:$6D,afterStatusCodes:Y6D,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},vbh=(e={})=>{if(typeof e=="number")return{...ybh,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{...ybh,...e}};async function e7c(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new Joa(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function t7c(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 gbh=(e,t)=>{let r={};for(let i in t)!(i in dbh)&&!(i in fbh)&&!(i in e)&&(r[i]=t[i]);return r},Obh=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;var NKa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>j_u)throw new RangeError(`The \`timeout\` option cannot be greater than ${j_u}`);await Promise.resolve();let c=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let d=new RKa(c,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(!ubh)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return _bh(c.clone(),i._options.onDownloadProgress)}return c},o=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{let c=i._originalRequest,d=[];c&&!c.bodyUsed&&d.push(c.body?.cancel()),i.request.bodyUsed||d.push(i.request.body?.cancel()),await Promise.all(d)});for(let[c,d]of Object.entries(cbh))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:XHc(this._input.headers,r.headers),hooks:ZHc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:bbh(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:vbh(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(abh&&obh){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(YHc&&(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),Obh(this._options.searchParams)){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(sbh&&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)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!YHc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=hbh(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Joa)throw t;if(t instanceof RKa){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),j_u);if(this._retryCount<1)throw r;await t7c(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})===w_u)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let i=await r(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=gbh(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):e7c(this._originalRequest,t,this.abortController,this._options)}};var r7c=e=>{let t=(r,i)=>NKa.create(r,zKa(e,i));for(let r of P_u)t[r]=(i,n)=>NKa.create(i,zKa(e,n,{method:r}));return t.create=r=>r7c(zKa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),r7c(zKa(e,r))),t.stop=w_u,t},X6D=r7c(),mbh=X6D;var Gbh=ce(Wbh(),1);function u7c(e){let t=(0,Gbh.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Fvh=ce(Nvh(),1),Qvh=ce(BJ(),1),O7c=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},m7c=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function A7c(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??u7c(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Fvh.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,c&&(d.authorization=`${c.type} ${c.token}`);let s;try{s=await mbh(o,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new O7c(e):l}if(t.allVersions)return s;let u=new m7c(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(i&&!l)for(let[_,h]of Object.entries(s.versions))h.deprecated&&delete s.versions[_];if(!l){let _=Object.keys(s.versions);if(r=Qvh.default.maxSatisfying(_,r),!r)throw u}let{time:p}=s;if(s=s.versions[r],s.time=p,!s)throw u}return s}async function WKa(e,t){let{version:r}=await A7c(e.toLowerCase(),t);return r}async function ZJi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:WKa(e.packageName,{version:t?"prerelease":"latest"})}var Uvh=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],F_u=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Ou.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new _dn(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(n==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"3.47.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Rt.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new pM}failWithoutThrowing(t,r){this.didSucceed=!1,cLa({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await nra()).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 rbh({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1504
|
+
`,i?hra(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function G6D(e){let r=await new ebh.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 x6D({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await ibh({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=PHi(u.name,l),_=await C3t({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:l});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await ibh({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,d,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][d]==null&&(o.versions[c][d]={});let l=PHi(s.name,u),p=await C3t({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][d][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function ibh({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await zve({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(c==null||c.groups==null)return;let d=i!=null?NN(i):void 0;for(let s of c.groups)if(!(n!=null&&s.groupName!==n))for(let u of s.generators)d!=null&&u.name!==d||await r(a.workspaceName,s.groupName,u,o)})}))}function nbh(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let d=yY(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function A_u({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await x6D({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[d,s]of Object.entries(c.versions))o.push(...nbh(s,d,t.logger));else o.push(...nbh(c.versions,void 0,t.logger))}return o}var RKa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${n} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var Joa=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var YHc=(()=>{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})(),abh=typeof globalThis.AbortController=="function",obh=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",ubh=typeof globalThis.ReadableStream=="function",sbh=typeof globalThis.FormData=="function",P_u=["get","post","put","patch","head","delete"],H6D=()=>{};H6D();var cbh={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},j_u=2147483647,lbh=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,w_u=Symbol("stop"),fbh={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},dbh={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 K6D=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=lbh,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},pbh=(e,t,r)=>{let i,n=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),i){n+=i.byteLength;let c=t===0?0:n/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,n),transferredBytes:n},i)}i=a},flush(){i&&(n+=i.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},i))}}))},_bh=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let r=Number(e.headers.get("content-length"))||0;return new Response(pbh(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},hbh=(e,t,r)=>{if(!e.body)return e;let i=K6D(r??e.body);return new Request(e,{duplex:"half",body:pbh(e.body,i,t)})};var $oa=e=>e!==null&&typeof e=="object";var zKa=(...e)=>{for(let t of e)if((!$oa(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return kHc({},...e)},XHc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,o]of n.entries())i&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function E_u(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:kHc(e[r]??[],t[r]??[])}var ZHc=(e={},t={})=>({beforeRequest:E_u(e,t,"beforeRequest"),beforeRetry:E_u(e,t,"beforeRetry"),afterResponse:E_u(e,t,"afterResponse"),beforeError:E_u(e,t,"beforeError")}),kHc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if($oa(n)){for(let[a,o]of Object.entries(n))$oa(o)&&a in t&&(o=kHc(t[a],o)),t={...t,[a]:o};$oa(n.hooks)&&(i=ZHc(i,n.hooks),t.hooks=i),$oa(n.headers)&&(r=XHc(r,n.headers),t.headers=r)}return t};var bbh=e=>P_u.includes(e)?e.toUpperCase():e,J6D=["get","put","head","delete","options","trace"],$6D=[408,413,429,500,502,503,504],Y6D=[413,429,503],ybh={limit:2,methods:J6D,statusCodes:$6D,afterStatusCodes:Y6D,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},vbh=(e={})=>{if(typeof e=="number")return{...ybh,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{...ybh,...e}};async function e7c(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new Joa(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function t7c(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 gbh=(e,t)=>{let r={};for(let i in t)!(i in dbh)&&!(i in fbh)&&!(i in e)&&(r[i]=t[i]);return r},Obh=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;var NKa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>j_u)throw new RangeError(`The \`timeout\` option cannot be greater than ${j_u}`);await Promise.resolve();let c=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let d=new RKa(c,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(!ubh)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return _bh(c.clone(),i._options.onDownloadProgress)}return c},o=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{let c=i._originalRequest,d=[];c&&!c.bodyUsed&&d.push(c.body?.cancel()),i.request.bodyUsed||d.push(i.request.body?.cancel()),await Promise.all(d)});for(let[c,d]of Object.entries(cbh))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:XHc(this._input.headers,r.headers),hooks:ZHc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:bbh(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:vbh(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(abh&&obh){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(YHc&&(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),Obh(this._options.searchParams)){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(sbh&&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)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!YHc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=hbh(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Joa)throw t;if(t instanceof RKa){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),j_u);if(this._retryCount<1)throw r;await t7c(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})===w_u)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let i=await r(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=gbh(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):e7c(this._originalRequest,t,this.abortController,this._options)}};var r7c=e=>{let t=(r,i)=>NKa.create(r,zKa(e,i));for(let r of P_u)t[r]=(i,n)=>NKa.create(i,zKa(e,n,{method:r}));return t.create=r=>r7c(zKa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),r7c(zKa(e,r))),t.stop=w_u,t},X6D=r7c(),mbh=X6D;var Gbh=ce(Wbh(),1);function u7c(e){let t=(0,Gbh.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Fvh=ce(Nvh(),1),Qvh=ce(BJ(),1),O7c=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},m7c=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function A7c(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??u7c(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Fvh.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,c&&(d.authorization=`${c.type} ${c.token}`);let s;try{s=await mbh(o,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new O7c(e):l}if(t.allVersions)return s;let u=new m7c(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(i&&!l)for(let[_,h]of Object.entries(s.versions))h.deprecated&&delete s.versions[_];if(!l){let _=Object.keys(s.versions);if(r=Qvh.default.maxSatisfying(_,r),!r)throw u}let{time:p}=s;if(s=s.versions[r],s.time=p,!s)throw u}return s}async function WKa(e,t){let{version:r}=await A7c(e.toLowerCase(),t);return r}async function ZJi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:WKa(e.packageName,{version:t?"prerelease":"latest"})}var Uvh=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],F_u=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Ou.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new _dn(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(n==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"3.47.2"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Rt.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new pM}failWithoutThrowing(t,r){this.didSucceed=!1,cLa({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await nra()).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 rbh({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1505
1505
|
`)||(r+=`
|
|
1506
1506
|
`),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=Nnc(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 TKa(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 pM}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await nra()).sendEvent(t)}logger=ave((t,...r)=>this.log(t,...r));stderr=ave((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=Lvh(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?Lvh(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=Uvh[this.numTasks++%Uvh.length],o=Rt.hex(a)(n);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===Fw.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=>lVt.indexOf(n.level)>=lVt.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===Ou.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 ZJi({cliEnvironment:this.environment,includePreReleases:t}),i=yY(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await A_u({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await KHc({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:Rt.yellow("?"),style:{answer:n=>Rt.cyan(n),message:n=>Rt.bold(n),highlight:n=>Rt.cyan(n)}}})}catch(i){throw i?.name==="ExitPromptError"?(this.logger.info(`
|
|
1507
1507
|
Cancelled by user.`),new pM):i}}async getInput(t){return await WHc({message:t.message,default:t.default})}};function Lvh(e){return`[${e}]:`}var B8t=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}};function Q_u(e,t,r,i){if(typeof r!="function")throw new Error("method for before hook must be a function");return i||(i={}),Array.isArray(t)?t.reverse().reduce((n,a)=>Q_u.bind(null,e,a,n,i),r)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((n,a)=>a.hook.bind(null,n,i),r)():r(i))}function Vvh(e,t,r,i){let n=i;e.registry[r]||(e.registry[r]=[]),t==="before"&&(i=(a,o)=>Promise.resolve().then(n.bind(null,o)).then(a.bind(null,o))),t==="after"&&(i=(a,o)=>{let c;return Promise.resolve().then(a.bind(null,o)).then(d=>(c=d,n(c,o))).then(()=>c)}),t==="error"&&(i=(a,o)=>Promise.resolve().then(a.bind(null,o)).catch(c=>n(c,o))),e.registry[r].push({hook:i,orig:n})}function Wvh(e,t,r){if(!e.registry[t])return;let i=e.registry[t].map(n=>n.orig).indexOf(r);i!==-1&&e.registry[t].splice(i,1)}var Gvh=Function.bind,xvh=Gvh.bind(Gvh);function Hvh(e,t,r){let i=xvh(Wvh,null).apply(null,r?[t,r]:[t]);e.api={remove:i},e.remove=i,["before","error","after","wrap"].forEach(n=>{let a=r?[t,n,r]:[t,n];e[n]=e.api[n]=xvh(Vvh,null).apply(null,a)})}function iGD(){let e=Symbol("Singular"),t={registry:{}},r=Q_u.bind(null,t,e);return Hvh(r,t,e),r}function nGD(){let e={registry:{}},t=Q_u.bind(null,e);return Hvh(t,e),t}var Kvh={Singular:iGD,Collection:nGD};var aGD="0.0.0-development",oGD=`octokit-endpoint.js/${aGD} ${VN()}`,uGD={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":oGD},mediaType:{format:""}};function sGD(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function cGD(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}function Yvh(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(i=>{cGD(t[i])?i in e?r[i]=Yvh(e[i],t[i]):Object.assign(r,{[i]:t[i]}):Object.assign(r,{[i]:t[i]})}),r}function Jvh(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function j7c(e,t,r){if(typeof t=="string"){let[n,a]=t.split(" ");r=Object.assign(a?{method:n,url:a}:{url:n},r)}else r=Object.assign({},t);r.headers=sGD(r.headers),Jvh(r),Jvh(r.headers);let i=Yvh(e||{},r);return r.url==="/graphql"&&(e&&e.mediaType.previews?.length&&(i.mediaType.previews=e.mediaType.previews.filter(n=>!i.mediaType.previews.includes(n)).concat(i.mediaType.previews)),i.mediaType.previews=(i.mediaType.previews||[]).map(n=>n.replace(/-preview/,""))),i}function lGD(e,t){let r=/\?/.test(e)?"&":"?",i=Object.keys(t);return i.length===0?e:e+r+i.map(n=>n==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${n}=${encodeURIComponent(t[n])}`).join("&")}var fGD=/\{[^{}}]+\}/g;function dGD(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function pGD(e){let t=e.match(fGD);return t?t.map(dGD).reduce((r,i)=>r.concat(i),[]):[]}function $vh(e,t){let r={__proto__:null};for(let i of Object.keys(e))t.indexOf(i)===-1&&(r[i]=e[i]);return r}function Xvh(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t).replace(/%5B/g,"[").replace(/%5D/g,"]")),t}).join("")}function iua(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function GKa(e,t,r){return t=e==="+"||e==="#"?Xvh(t):iua(t),r?iua(r)+"="+t:t}function rua(e){return e!=null}function P7c(e){return e===";"||e==="&"||e==="?"}function _GD(e,t,r,i){var n=e[r],a=[];if(rua(n)&&n!=="")if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")n=n.toString(),i&&i!=="*"&&(n=n.substring(0,parseInt(i,10))),a.push(GKa(t,n,P7c(t)?r:""));else if(i==="*")Array.isArray(n)?n.filter(rua).forEach(function(o){a.push(GKa(t,o,P7c(t)?r:""))}):Object.keys(n).forEach(function(o){rua(n[o])&&a.push(GKa(t,n[o],o))});else{let o=[];Array.isArray(n)?n.filter(rua).forEach(function(c){o.push(GKa(t,c))}):Object.keys(n).forEach(function(c){rua(n[c])&&(o.push(iua(c)),o.push(GKa(t,n[c].toString())))}),P7c(t)?a.push(iua(r)+"="+o.join(",")):o.length!==0&&a.push(o.join(","))}else t===";"?rua(n)&&a.push(iua(r)):n===""&&(t==="&"||t==="?")?a.push(iua(r)+"="):n===""&&a.push("");return a}function hGD(e){return{expand:yGD.bind(null,e)}}function yGD(e,t){var r=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(i,n,a){if(n){let c="",d=[];if(r.indexOf(n.charAt(0))!==-1&&(c=n.charAt(0),n=n.substr(1)),n.split(/,/g).forEach(function(s){var u=/([^:\*]*)(?::(\d+)|(\*))?/.exec(s);d.push(_GD(t,c,u[1],u[2]||u[3]))}),c&&c!=="+"){var o=",";return c==="?"?o="&":c!=="#"&&(o=c),(d.length!==0?c:"")+d.join(o)}else return d.join(",")}else return Xvh(a)}),e==="/"?e:e.replace(/\/$/,"")}function Zvh(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),i=Object.assign({},e.headers),n,a=$vh(e,["method","baseUrl","url","headers","request","mediaType"]),o=pGD(r);r=hGD(r).expand(a),/^http/.test(r)||(r=e.baseUrl+r);let c=Object.keys(e).filter(u=>o.includes(u)).concat("baseUrl"),d=$vh(a,c);if(!/application\/octet-stream/i.test(i.accept)&&(e.mediaType.format&&(i.accept=i.accept.split(/,/).map(u=>u.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),r.endsWith("/graphql")&&e.mediaType.previews?.length)){let u=i.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g)||[];i.accept=u.concat(e.mediaType.previews).map(l=>{let p=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${l}-preview${p}`}).join(",")}return["GET","HEAD"].includes(t)?r=lGD(r,d):"data"in d?n=d.data:Object.keys(d).length&&(n=d),!i["content-type"]&&typeof n<"u"&&(i["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof n>"u"&&(n=""),Object.assign({method:t,url:r,headers:i},typeof n<"u"?{body:n}:null,e.request?{request:e.request}:null)}function bGD(e,t,r){return Zvh(j7c(e,t,r))}function kvh(e,t){let r=j7c(e,t),i=bGD.bind(null,r);return Object.assign(i,{DEFAULTS:r,defaults:kvh.bind(null,r),merge:j7c.bind(null,r),parse:Zvh})}var egh=kvh(null,uGD);var ogh=ce(ngh(),1);var I8t=class extends Error{name;status;request;response;constructor(t,r,i){super(t),this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0),"response"in i&&(this.response=i.response);let n=Object.assign({},i.request);i.request.headers.authorization&&(n.headers=Object.assign({},i.request.headers,{authorization:i.request.headers.authorization.replace(/(?<! ) .*$/," [REDACTED]")})),n.url=n.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=n}};var vGD="10.0.6",gGD={headers:{"user-agent":`octokit-request.js/${vGD} ${VN()}`}};function OGD(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}async function agh(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");let r=e.request?.log||console,i=e.request?.parseSuccessResponseBody!==!1,n=OGD(e.body)||Array.isArray(e.body)?JSON.stringify(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([l,p])=>[l,String(p)])),o;try{o=await t(e.url,{method:e.method,body:n,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:"half"}})}catch(l){let p="Unknown Error";if(l instanceof Error){if(l.name==="AbortError")throw l.status=500,l;p=l.message,l.name==="TypeError"&&"cause"in l&&(l.cause instanceof Error?p=l.cause.message:typeof l.cause=="string"&&(p=l.cause))}let _=new I8t(p,500,{request:e});throw _.cause=l,_}let c=o.status,d=o.url,s={};for(let[l,p]of o.headers)s[l]=p;let u={url:d,status:c,headers:s,data:""};if("deprecation"in s){let l=s.link&&s.link.match(/<([^<>]+)>; rel="deprecation"/),p=l&&l.pop();r.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${s.sunset}${p?`. See ${p}`:""}`)}if(c===204||c===205)return u;if(e.method==="HEAD"){if(c<400)return u;throw new I8t(o.statusText,c,{response:u,request:e})}if(c===304)throw u.data=await w7c(o),new I8t("Not modified",c,{response:u,request:e});if(c>=400)throw u.data=await w7c(o),new I8t(AGD(u.data),c,{response:u,request:e});return u.data=i?await w7c(o):o.body,u}async function w7c(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(()=>"");let r=(0,ogh.safeParse)(t);if(mGD(r)){let i="";try{return i=await e.text(),JSON.parse(i)}catch{return i}}else return r.type.startsWith("text/")||r.parameters.charset?.toLowerCase()==="utf-8"?e.text().catch(()=>""):e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function mGD(e){return e.type==="application/json"||e.type==="application/scim+json"}function AGD(e){if(typeof e=="string")return e;if(e instanceof ArrayBuffer)return"Unknown error";if("message"in e){let t="documentation_url"in e?` - ${e.documentation_url}`:"";return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(r=>JSON.stringify(r)).join(", ")}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function E7c(e,t){let r=e.defaults(t);return Object.assign(function(n,a){let o=r.merge(n,a);if(!o.request||!o.request.hook)return agh(r.parse(o));let c=(d,s)=>agh(r.parse(r.merge(d,s)));return Object.assign(c,{endpoint:r,defaults:E7c.bind(null,r)}),o.request.hook(c,o)},{endpoint:r,defaults:E7c.bind(null,r)})}var Fm=E7c(egh,gGD);var PGD="0.0.0-development";function jGD(e){return`Request failed due to following response errors:
|
|
@@ -1525,7 +1525,7 @@ Cancelled by user.`),new pM):i}}async getInput(t){return await WHc({message:t.me
|
|
|
1525
1525
|
`);try{Kua.writeFileSync(i,n,"utf8"),this.logger.info(`Missing examples report written to: ${i}`)}catch(a){this.logger.warn(`Failed to write missing examples report to ${i}:`,String(a))}}finalize(){}convertExampleToJson(t){switch(t.type){case"primitive":return t.value;case"array":return t.value.map(r=>this.convertExampleToJson(r));case"object":{let r={};return Object.entries(t.properties).forEach(([i,n])=>{r[i]=this.convertExampleToJson(n)}),r}case"map":{let r={};return t.value.forEach(i=>{r[String(i.key)]=this.convertExampleToJson(i.value)}),r}case"oneOf":if(t.value.type==="undiscriminated")return this.convertExampleToJson(t.value.value);{let r={};return Object.entries(t.value.value).forEach(([i,n])=>{r[i]=this.convertExampleToJson(n)}),r}case"enum":return t.value;case"literal":return t.value;case"null":return null;case"unknown":return this.convertExampleToJson(t.value);default:return t}}getSchemaDescription(t){if("description"in t)return t.description}getSchemaTypeName(t){switch(t.type){case"primitive":return`primitive (${t.schema.type})`;case"object":return t.generatedName||"object";case"array":return"array";case"map":return"map";case"optional":return`optional (${this.getSchemaTypeName(t.value)})`;case"nullable":return`nullable (${this.getSchemaTypeName(t.value)})`;case"reference":return t.generatedName||"reference";case"enum":return t.generatedName||"enum";case"literal":return"literal";case"oneOf":return"oneOf";case"unknown":return"unknown";default:return"unknown"}}buildEndpointExample(t){let r=hKD(t.request),i=yKD(t.response);if(r?.type==="unsupported"||i?.type==="unsupported")return[];let n=[];if(r!=null&&r.type==="present"){let l=this.isSchemaRequired(r.schema);if(r.examples.length===0){let p=this.exampleTypeFactory.buildExample({skipReadonly:EKc(t.method),schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});p!=null?(n.push([void 0,p]),this.addMissingExampleRecord(t,"request",this.getSchemaTypeName(r.schema),"No user-provided examples found in OpenAPI spec",{schemaDescription:this.getSchemaDescription(r.schema),autoGeneratedExample:this.convertExampleToJson(p)})):this.addMissingExampleRecord(t,"request",this.getSchemaTypeName(r.schema),"Auto-generation failed (schema too complex or circular references)",{schemaDescription:this.getSchemaDescription(r.schema)})}else for(let{name:p,value:_}of r.examples){let h=this.exampleTypeFactory.buildExample({skipReadonly:EKc(t.method),schema:r.schema,exampleId:p,example:_,options:{isParameter:!1,ignoreOptionals:!0}});h!=null?n.push([p,h]):this.addMissingExampleRecord(t,"request",this.getSchemaTypeName(r.schema),`Failed to build example from provided data (example id: ${p})`,{schemaDescription:this.getSchemaDescription(r.schema)})}if(l&&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 l=this.isSchemaRequired(i.schema);if(i.examples.length===0){let p=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}});p!=null?(t.response?.type==="json"?a.push([void 0,oSe.withoutStreaming(p)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,oSe.withStreaming({sse:t.response?.type==="streamingSse",events:[p]})]),this.addMissingExampleRecord(t,"response",this.getSchemaTypeName(i.schema),"No user-provided examples found in OpenAPI spec",{schemaDescription:this.getSchemaDescription(i.schema),autoGeneratedExample:this.convertExampleToJson(p)})):this.addMissingExampleRecord(t,"response",this.getSchemaTypeName(i.schema),"Auto-generation failed (schema too complex or circular references)",{schemaDescription:this.getSchemaDescription(i.schema)})}else for(let{name:p,value:_}of i.examples){let h=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:p,example:_,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});h!=null?t.response?.type==="json"?a.push([p,oSe.withoutStreaming(h)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,oSe.withStreaming({sse:t.response?.type==="streamingSse",events:[h]})]):this.addMissingExampleRecord(t,"response",this.getSchemaTypeName(i.schema),`Failed to build example from provided data (example id: ${p})`,{schemaDescription:this.getSchemaDescription(i.schema)})}if(l&&a.length===0)return this.logger.trace(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let o=[];for(let l of t.pathParameters){let p=this.isSchemaRequired(l.schema),_=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(_!=null&&!z8t(_)&&(this.logger.debug(`Expected a primitive example but got ${_.type} for path parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),_=void 0),p&&_==null)return[];_!=null&&o.push({name:l.name,parameterNameOverride:l.parameterNameOverride,value:_})}let c=[];for(let l of t.queryParameters){let p=this.isSchemaRequired(l.schema),_=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(_!=null&&!z8t(_)&&(this.logger.debug(`Expected a primitive example but got ${_.type} for query parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),_=void 0),p&&_==null)return[];_!=null&&c.push({name:l.name,value:_})}let d=[];for(let l of t.headers){let p=this.isSchemaRequired(l.schema),_=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(_!=null&&!z8t(_)&&(this.logger.debug(`Expected a primitive example but got ${_.type} for header ${l.name} for ${t.method.toUpperCase()} ${t.path}`),_=void 0),p&&_==null)return[];_!=null&&d.push({name:l.name,value:_})}for(let l of this.globalHeaders){let p=l.schema!=null?R8t(l.schema):ai.primitive({nameOverride:void 0,generatedName:"",title:void 0,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,schema:kn.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})}),_=this.exampleTypeFactory.buildExample({schema:p,exampleId:void 0,example:void 0,options:{name:l.header,isParameter:!0,ignoreOptionals:!0}});if(_!=null&&!z8t(_)&&(this.logger.debug(`Expected a primitive example but got ${_.type} for global header ${l.header} for ${t.method.toUpperCase()} ${t.path}`),_=void 0),_==null)return[];_!=null&&d.push({name:l.header,value:_})}let s=[];t.request!=null&&t.response!=null?s=_KD(n,a):t.request!=null?s=n.map(([l,p])=>({id:l,request:p,response:void 0})):t.response!=null&&(s=a.map(([l,p])=>({id:l,request:void 0,response:p})));let u=t.examples.filter(l=>yJa(l)).flatMap(l=>{if(l.type==="unknown"){if(l.value!=null){let p=l.value["code-samples"];if(p!=null)return this.convertCodeSamples(p)}return}else return l.codeSamples}).filter(l=>us(l));return s.length===0?[aSe.full({name:void 0,description:void 0,pathParameters:o,queryParameters:c,headers:d,request:void 0,response:void 0,codeSamples:u})]:s.map(({id:l,request:p,response:_})=>aSe.full({name:l,description:void 0,pathParameters:o,queryParameters:c,headers:d,request:p,response:_,codeSamples:u}))}convertCodeSamples(t){return t.map(r=>"language"in r?JYt.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):JYt.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?wF.Csharp:r.sdk,code:r.code})).filter(us)}isSchemaRequired(t){return wbu(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function _KD(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[o,c]of t)r.push({id:o??n,request:a,response:c});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[o,c]of e)r.push({id:o??n,request:c,response:a});return r}let i=new Set;for(let[n,a]of e){let o=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(n==null){if(o==null)continue;r.push({id:void 0,request:a,response:o});continue}let c=!1;for(let d=0;d<t.length;d++){let[s,u]=t[d];s==null||i.has(d)||n===s&&(r.push({id:n,request:a,response:u}),s!=null&&i.add(d),c=!0)}!c&&o!=null&&r.push({id:n,request:a,response:o})}for(let n=0;n<t.length;n++){if(i.has(n))continue;let[a,o]=t[n],c=e.find(([d])=>d==null)?.[1]??e[0]?.[1];c!=null&&r.push({id:a,request:c,response:o})}return r}function hKD(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:bKD(e),examples:[]}:e.type==="json"||e.type==="formUrlEncoded"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function yKD(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 z8t(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return z8t(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undiscriminated":return z8t(e.value.value);default:return!1}case"null":return!0;default:vt(e)}}function bKD(e){return ai.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:R8t(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0,writeonly:void 0,inline:void 0}).filter(us),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,minProperties:void 0,maxProperties:void 0})}var Jua=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new b$i(t,new Set,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,handshake:i,source:n,namespace:a}){let o=[];for(let c of r){let d=[];for(let l of i.queryParameters){let p=this.isSchemaRequired(l.schema),_=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:c.queryParameters?.[l.name],options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});_!=null&&!z8t(_)&&(_=void 0),!(p&&_==null)&&_!=null&&d.push({name:l.name,value:_})}let s=[];for(let l of i.headers){let p=this.isSchemaRequired(l.schema),_=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:c.headers?.[l.name],options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});_!=null&&!z8t(_)&&(_=void 0),!(p&&_==null)&&_!=null&&s.push({name:l.name,value:_})}let u=[];for(let l of c.messages){let p=t.getExampleMessageReference(l),_=t.resolveMessageReference({$ref:p}),h=Bn(_.payload)?t.resolveSchemaReference(_.payload):_.payload,y=this.exampleTypeFactory.buildExample({schema:kl(h,!1,!1,t,[l.messageId],n,a),exampleId:void 0,example:l.value,options:{isParameter:!1,ignoreOptionals:!0}});y!=null&&u.push({messageType:l.type,payload:y,description:void 0})}o.push({name:c.summary,queryParameters:d,headers:s,description:c.description,messages:u})}return o}buildWebsocketSessionExample({handshake:t,messages:r}){let i={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},n=[];for(let o of t.queryParameters){let c=this.isSchemaRequired(o.schema),d=this.exampleTypeFactory.buildExample({schema:o.schema,exampleId:void 0,example:void 0,options:{name:o.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!z8t(d)&&(d=void 0),c&&d==null)return;d!=null&&n.push({name:o.name,value:d})}let a=[];for(let o of t.headers){let c=this.isSchemaRequired(o.schema),d=this.exampleTypeFactory.buildExample({schema:o.schema,exampleId:void 0,example:void 0,options:{name:o.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!z8t(d)&&(d=void 0),c&&d==null)return;d!=null&&a.push({name:o.name,value:d})}for(let o of r){let c=this.exampleTypeFactory.buildExample({schema:o.payload,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});c!=null&&i.messages.push({messageType:o.type,payload:c,description:void 0})}return i}isSchemaRequired(t){return wbu(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 jL={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_SDK_METHOD_NAME:"x-fern-sdk-method-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path",FERN_ENUM:"x-fern-enum",IGNORE:"x-fern-ignore",FERN_PARAMETER_NAME:"x-fern-parameter-name"};function Sbu(e){return Ei(e,jL.FERN_EXAMPLES)??[]}function Mbu(e,t){return t.includes("://")?t:`${e}://${t}`}function Dbu(e){return e.startsWith("/")?e:"/"+e}function aAh({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},o={};for(let[s,u]of Object.entries(n.components?.schemas??{})){let l=kl(u,!1,!1,e,[s],r,e.namespace);a[s]=l}let c=new Jua(a,e),d={};for(let[s,u]of Object.entries(n.servers??{}))d[s]={name:s,url:Mbu(u.protocol,u.url)};for(let[s,u]of Object.entries(n.channels??{})){let l=Ei(u,jL.IGNORE);if(l!=null&&l){e.logger.debug(`Channel ${s} is marked with x-fern-ignore. Skipping.`);continue}let p=[];if(u.parameters!=null)for(let[v,O]of Object.entries(u.parameters??{})){let m=Ei(O,jL.FERN_PARAMETER_NAME);p.push({name:v,description:O.description,parameterNameOverride:m,schema:O.schema!=null?kl(O.schema,!1,!1,e,t,r,e.namespace):ai.primitive({schema:kn.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:RW(O),source:r,explode:void 0})}let _=[],h=[];if(u.bindings?.ws!=null){if(u.bindings.ws.headers!=null){let v=u.bindings.ws.headers.required??[];for(let[O,m]of Object.entries(u.bindings.ws.headers.properties??{})){if(Bn(m)){let M=e.resolveSchemaReference(m);_.push({name:O,schema:CUi(m,!1,!1,e,t,void 0,r,e.namespace),description:M.description,parameterNameOverride:void 0,env:void 0,availability:RW(M),source:r});continue}let g=v.includes(O),[A,j]=e.options.coerceOptionalSchemasToNullable?[!1,!g]:[!g,!1];_.push({name:O,schema:kl(m,A,j,e,[...t,O],r,e.namespace),description:m.description,parameterNameOverride:void 0,env:void 0,availability:RW(m),source:r})}}if(u.bindings.ws.query!=null){let v=u.bindings.ws.query.required??[];for(let[O,m]of Object.entries(u.bindings.ws.query.properties??{})){if(Bn(m)){let M=e.resolveSchemaReference(m);h.push({name:O,schema:CUi(m,!1,!1,e,t,void 0,r,e.namespace),description:M.description,parameterNameOverride:void 0,availability:RW(M),source:r,explode:void 0});continue}let g=v.includes(O),[A,j]=e.options.coerceOptionalSchemasToNullable?[!1,!g]:[!g,!1];h.push({name:O,schema:kl(m,A,j,e,[...t,O],r,e.namespace),description:m.description,parameterNameOverride:void 0,availability:RW(m),source:r,explode:void 0})}}}let y;u.publish!=null&&("oneOf"in u.publish.message?y=iAh({generatedName:u.publish.operationId??"PublishEvent",event:u.publish,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):y=nAh({action:"Publish",channelPath:s,message:u.publish.message,context:e,source:r}));let b;if(u.subscribe!=null&&("oneOf"in u.subscribe.message?b=iAh({generatedName:u.subscribe.operationId??"SubscribeEvent",event:u.subscribe,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):b=nAh({action:"Subscribe",channelPath:s,message:u.subscribe.message,context:e,source:r})),_.length>0||h.length>0||y!=null||b!=null){let v=Sbu(u),O=[];if(v.length>0)O=c.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:v,handshake:{headers:_,queryParameters:h},source:r,namespace:e.namespace});else{let j=[];y!=null&&j.push({type:"publish",payload:y}),b!=null&&j.push({type:"subscribe",payload:b});let M=c.buildWebsocketSessionExample({handshake:{headers:_,queryParameters:h},messages:j});M!=null&&O.push(M)}let m=Ei(u,jL.FERN_CHANNEL_ADDRESS),g=m??Dbu(s),A=[];y!=null&&A.push({origin:"client",name:"publish",body:Qm(y),methodName:void 0}),b!=null&&A.push({origin:"server",name:"subscribe",body:Qm(b),methodName:void 0}),o[s]={audiences:Ei(u,xi.AUDIENCES)??[],handshake:{headers:_.map(j=>({...j,schema:Qm(j.schema),env:j.env})),queryParameters:h.map(j=>({...j,schema:Qm(j.schema)})),pathParameters:p.map(j=>({...j,schema:Qm(j.schema)}))},groupName:e.resolveGroupName([Ei(u,jL.FERN_SDK_GROUP_NAME)??s]),messages:A,servers:(u.servers?.map(j=>d[j])??Object.values(d)).filter(j=>j!=null&&j.name!=null).map(j=>({...j,name:j.name})),summary:Ei(u,jL.FERN_DISPLAY_NAME),path:g,description:u.description,examples:O,source:r}}}return{groupedSchemas:Hua(e.namespace,a),channels:o??void 0,servers:Object.values(d).map(s=>({...s,name:s.name})),basePath:Ei(n,jL.BASE_PATH)}}function iAh({generatedName:e,event:t,context:r,breadcrumbs:i,source:n,options:a,asyncApiOptions:o}){if("oneOf"in t.message&&t.message.oneOf!=null){let c=[],d=[];for(let s of t.message.oneOf){let u,l={type:"notFound"};if(Bn(s)){let p=r.resolveMessageReference(s);!Bn(p.payload)&&o.naming==="v2"?(l=p.name?{type:"name",name:p.name}:l,u={...p.payload,title:p.name??p.payload.title,description:p.name??p.payload.description}):u=p.payload}else u=s;d.push(l),c.push(u)}return h$i({description:t.description??t.message.description,availability:RW(t.message),subtypes:c,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsOptional:!1,wrapAsNullable:!1,breadcrumbs:i,context:r,encoding:void 0,source:n,namespace:r.namespace,subtypeSuffixOverrides:o.naming==="v2"?d:[]})}}function nAh({action:e,channelPath:t,message:r,context:i,source:n}){if(r.payload!=null){let a=r.payload;return Bn(r.payload)&&(a=i.resolveSchemaReference(r.payload)),kl(a,!1,!1,i,[t,e],n,i.namespace)}}var Bbu=class extends xua{getExampleMessageReference(t){return`#/channels/${t.channelId}/messages/${t.messageId}`}resolveParameterReference(t){let r="#/components/parameters/";if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve ${t.$ref}`);let i=t.$ref.substring(r.length),n=this.document.components.parameters[i];if(n==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in n?this.resolveParameterReference(n):n}resolveMessageReference(t,r=!1){let i="#/channels/",n="#/components/messages/";if(t.$ref.startsWith(i)){let d=t.$ref.split("/"),s=d[2],u=d[4];if(s==null||u==null||!this.document.channels?.[s])throw new Error(`Failed to resolve message reference ${t.$ref} in channel ${s}`);let p=this.document.channels[s].messages?.[u];if(p==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in p&&!r?this.resolveMessageReference(p):{...p,name:u}}let a=this.document.components;if(!t.$ref.startsWith(n)||!a?.messages)throw new Error(`Failed to resolve message reference: ${t.$ref} in v3 components`);let o=t.$ref.substring(n.length),c=a.messages[o];if(c==null)throw new Error(`${t.$ref} is undefined`);return{...c,name:o}}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}};var oAh="#/channels/",uAh="#/servers/",SKc="$message.";function cAh({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},o={},c={},d=[],s={};e.logger.debug("Parsing V3 AsyncAPI...");for(let[v,O]of Object.entries(n.components?.schemas??{}))a[v]=kl(O,!1,!1,e,[v],r,e.namespace);for(let[v,O]of Object.entries(n.channels??{}))if(o[v]||(o[v]={}),O.messages)for(let[m,g]of Object.entries(O.messages))if(c[m]||(c[m]=[]),e.isReferenceObject(g)){let A=e.resolveMessageReference(g);c[m].push({channelId:v,payload:A.payload})}else e.isMessageWithPayload(g)&&c[m].push({channelId:v,payload:g.payload});for(let[v,O]of Object.entries(c))if(O.length===1){let m=O[0],g=m.channelId;o[g]=o[g]||{},o[g][v]=kl(m.payload,!1,!1,e,[v],r,e.namespace)}else{d.push(v);for(let{channelId:m,payload:g}of O){let A=`${m}_${v}`;o[m]||(o[m]={}),o[m][A]=kl(g,!1,!1,e,[A],r,e.namespace)}}let u=Object.values(o).reduce((v,O)=>({...v,...O}),{}),l=new Jua(u,e),p={};for(let[v,O]of Object.entries(n.servers??{}))p[v]={name:v,url:Mbu(O.protocol,O.host)};let _={};for(let[v,O]of Object.entries(n.operations??{})){if(Ei(O,jL.IGNORE))continue;let m=vKD(O);_[m]||(_[m]={subscribe:[],publish:[],__parsedMessages:[]});let g=Ei(O,jL.FERN_SDK_METHOD_NAME),A=O.messages.map(j=>({ref:j,methodName:g}));if(O.action==="receive")_[m].subscribe.push(...A);else if(O.action==="send")_[m].publish.push(...A);else throw new Error(`Operation ${v} has an invalid action: ${O.action}`)}for(let[v,O]of Object.entries(_)){let m=[];m.push(...sAh({messages:O.subscribe,channelPath:v,origin:"server",messageSchemas:o[v]??{},duplicatedMessageIds:d,context:e})),m.push(...sAh({messages:O.publish,channelPath:v,origin:"client",messageSchemas:o[v]??{},duplicatedMessageIds:d,context:e})),_[v]!=null&&(_[v].__parsedMessages=m)}for(let[v,O]of Object.entries(n.channels??{})){if(Ei(O,jL.IGNORE))continue;let m=[],g=[],A=[];if(O.parameters!=null)for(let[j,M]of Object.entries(O.parameters)){let w=e.isReferenceObject(M)?e.resolveParameterReference(M):M,{type:D,parameterKey:B}=w.location!=null?gKD(w.location):{type:O.address?.includes(`={${j}}`)?"query":"path",parameterKey:j},T=Ei(w,jL.FERN_PARAMETER_OPTIONAL),R=X0(ou(v))+X0(ou(j)),q={...w,type:"string",title:R,example:w.examples?.[0],default:w.default,enum:w.enum,required:void 0},z=kl(q,!1,!1,e,[B],r,e.namespace);T&&(z=ai.optional({value:z,description:void 0,availability:void 0,generatedName:"",title:R,namespace:void 0,groupName:void 0,nameOverride:void 0,inline:void 0}));let Q={name:B,description:w.description,parameterNameOverride:void 0,schema:z,variableReference:void 0,availability:RW(M),source:r,explode:void 0};D==="header"?m.push({...Q,env:void 0}):D==="path"?g.push(Q):(D==="payload"||D==="query")&&A.push(Q)}if(m.length>0||A.length>0||_[v]!=null&&(_[v].publish!=null||_[v].subscribe!=null)){let j=Sbu(O),M=_[v]?.__parsedMessages??[],w=[];if(j.length>0)w=l.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:j,handshake:{headers:m,queryParameters:A},source:r,namespace:e.namespace});else{let R=[],{examplePublishMessage:q,exampleSubscribeMessage:z}=mKD({messages:M,messageSchemas:o[v]??{}});q!=null&&R.push(q),z!=null&&R.push(z);let Q=l.buildWebsocketSessionExample({handshake:{headers:m,queryParameters:A},messages:R});Q!=null&&w.push(Q)}let D=Ei(O,jL.FERN_SDK_GROUP_NAME),B=(O.servers?.map(R=>OKD(p,R))??Object.values(p)).map(R=>({...R,name:R.name})),T=O.address?.split("?")[0]??Dbu(v);s[v]={audiences:Ei(O,xi.AUDIENCES)??[],handshake:{headers:m.map(R=>({...R,schema:Qm(R.schema),env:R.env})),queryParameters:A.map(R=>({...R,schema:Qm(R.schema)})),pathParameters:g.map(R=>({...R,parameterNameOverride:void 0,schema:Qm(R.schema)}))},groupName:e.resolveGroupName(typeof D=="string"?[D]:D??[v]),messages:M,summary:Ei(O,jL.FERN_DISPLAY_NAME),servers:B,path:T,description:O.description,examples:w,source:r}}else e.logger.warn(`Skipping AsyncAPI channel ${v} as it does not qualify for inclusion (no headers, query params, or operations)`)}let h=Hua(e.namespace,a),y=Object.values(p).map(v=>({...v,name:v.name})),b=Ei(n,jL.BASE_PATH);return{groupedSchemas:h,channels:s,servers:y,basePath:b}}function vKD(e){if(!e.channel.$ref.startsWith(oAh))throw new Error(`Failed to resolve channel path from operation ${e.channel.$ref}`);return e.channel.$ref.substring(oAh.length)}function gKD(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(SKc))throw new Error(`Invalid location format: ${e}; expected ${SKc} prefix`);let i=t.substring(SKc.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 OKD(e,t){if(!t.$ref.startsWith(uAh))throw new Error(`Failed to resolve server name from server ref ${t.$ref}`);let r=t.$ref.substring(uAh.length),i=e[r];if(i==null)throw new Error(`Failed to find server with name ${r}`);return i}function sAh({messages:e,channelPath:t,origin:r,messageSchemas:i,duplicatedMessageIds:n,context:a}){let o=[];return e.forEach((c,d)=>{let u=a.resolveMessageReference(c.ref,!0).name;n.includes(u)&&(u=`${t}_${u}`);let l=i[u];l!=null&&o.push({origin:r,name:u??`${r}Message${d+1}`,body:Qm(l),methodName:c.methodName})}),o}function mKD({messages:e,messageSchemas:t}){let r=e.find(o=>o.origin==="client")?.name,i=e.find(o=>o.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 lAh({document:e,taskContext:t,options:r,source:i,asyncApiOptions:n,namespace:a}){let o=[];if(a!=null&&o.push(a),parseFloat(e.asyncapi)<3){let c=e;c.tags?.[0]!=null?o.push(c.tags[0].name):n.naming!=="v2"&&o.push("websocket");let d=new jbu({document:c,taskContext:t,options:r,namespace:a});return aAh({context:d,breadcrumbs:o,source:i,asyncApiOptions:n,document:c})}else{let c=e,d=new Bbu({document:c,taskContext:t,options:r,namespace:a});return cAh({context:d,breadcrumbs:o,source:i,asyncApiOptions:n,document:c})}}function fAh(e){return Ei(e,xi.ASYNC_CONFIG)}var dAh="$request.";function pAh(e){let t=Ei(e,xi.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:AKD(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function AKD(e){return e.startsWith(dAh)?e.slice(dAh.length):e}function _Ah(e){let t=e;if(t.cursor!=null)return _ge.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});if("offset"in e){let r=e;return _ge.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 _ge.custom({results:r.results})}throw new Error("Invalid pagination extension")}function hAh(e,t){let r=Ei(t,xi.PAGINATION);if(r!=null){if(typeof r=="boolean"){let i=Ei(e,xi.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:_Ah(i)}return _Ah(r)}}function yAh(e){let t=PKD(e),r={};return MKc({obj:t,occurrences:r,breadcrumbs:[]}),r}function MKc({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let i of e)MKc({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)MKc({obj:e[i],occurrences:t,breadcrumbs:[...r,i]})}}}function PKD(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?bJa(r.get):void 0,put:r?.put!=null?bJa(r.put):void 0,post:r?.post!=null?bJa(r.post):void 0,patch:r?.patch!=null?bJa(r.patch):void 0,delete:r?.delete!=null?bJa(r.delete):void 0}]))}}function bJa(e){return{...e,requestBody:e.requestBody!=null?Bn(e.requestBody)?e.requestBody:jKD(e.requestBody):void 0}}function jKD(e){let t,r;for(let i in e.content){let n=em.parse(i);n!=null&&(n.isJSON()?t=e.content[i]:n.isMultipart()&&(r=e.content[i]))}return r!=null&&t!=null?{...e,content:{[em.MULTIPART_FORM_DATA]:r}}:e}var Ibu=class{endpoints;parser=new Zbn;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 bAh="#/components/parameters/",vAh="#/components/responses/",gAh="#/components/examples/",OAh="#/components/requestBodies/",mAh="#/components/securitySchemes/",$ua=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;filter;namespace;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:o}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=i,this.refOccurrences=yAh(t),this.options=n,this.source=a,this.filter=new Ibu({context:r,options:n}),this.DUMMY=this.getDummy(),this.namespace=o}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.debug(`Encountered undefined reference: ${t.$ref}`),{"x-fern-type":"unknown"}):(Bn(i)&&(i=this.resolveSchemaReference(i)),i)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(bAh))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(bAh.length),i=this.document.components.parameters[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return Bn(i)?this.resolveParameterReference(i):i}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(OAh))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(OAh.length),i=this.document.components.requestBodies[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return Bn(i)?this.resolveRequestBodyReference(i):i}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(vAh))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(vAh.length),i=this.document.components.responses[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return Bn(i)?this.resolveResponseReference(i):i}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(gAh))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(gAh.length),i=this.document.components.examples[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return Bn(i)?this.resolveExampleReference(i):i}resolveSecuritySchemeReference(t){if(this.document.components==null||this.document.components.securitySchemes==null||!t.$ref.startsWith(mAh))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(mAh.length),i=this.document.components.securitySchemes[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return Bn(i)?this.resolveSecuritySchemeReference(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 Zvn=class extends $ua{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 Cbu=require("fs"),qbu=require("path");var wKD=Qt.object({lang:Qt.string(),label:Qt.optional(Qt.string()),source:Qt.string()}),DKc=Qt.array(wKD);var AAh={README_EXT:"x-readme"};function EKD(e){if(!Array.isArray(e))return!1;for(let t of e)if(!yl(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function PAh(e){let t=Ei(e,AAh.README_EXT);if(!yl(t))return[];let r=t["code-samples"];if(!EKD(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 SKD(e){return yl(e)&&typeof e.$ref=="string"}function MKD(e,t){if(e!=null){if(typeof e=="string")return e;if(SKD(e)){let r=(0,qbu.resolve)(t??process.cwd(),e.$ref);if((0,Cbu.existsSync)(r))try{return(0,Cbu.readFileSync)(r,"utf-8")}catch{return}}}}function DKD(e,t){if(!Array.isArray(e))return[];let r=[];for(let i of e){if(!yl(i))continue;let a=MKD(i.code,t);a!=null&&r.push({...i,code:a})}return r}function jAh(e,t,r){let i=Ei(t,xi.EXAMPLES),n=r.source.type==="openapi"?(0,qbu.dirname)(r.source.file):void 0,o=(i??[]).map(l=>{if(!yl(l))return l;let _=l["code-samples"];if(_!=null){let h=DKD(_,n);return{...l,"code-samples":h}}return l}).filter(l=>{let p=cI.serialization.ExampleEndpointCallSchema.parse(l);return p.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),p.ok}),c=fJa(t,PL.REDOCLY_CODE_SAMPLES_KEBAB,DKc,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],s=[...fJa(t,PL.REDOCLY_CODE_SAMPLES_CAMEL,DKc,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...c];s.length>0&&o.push({"code-samples":s.map(l=>({name:l.label??l.lang,language:l.lang,code:l.source,install:void 0,docs:void 0}))});let u=PAh(t);return u.length>0&&o.push({"code-samples":u}),o.map(aSe.unknown)}function wAh(e){let t=Ei(e,xi.AVAILABILITY);if(t==="ga"||t==="generally-available")return jF.GenerallyAvailable;if(t==="beta"||t==="pre-release")return jF.Beta;if(t==="deprecated")return jF.Deprecated;if(e.deprecated)return jF.Deprecated}function EAh(e){let t=Ei(e,xi.RETRIES);if(t!=null&&t.disabled===!0)return ehu.RetriesConfiguration.disabled(t.disabled)}function Tbu(e,t){return{url:BKD({url:e.url,variables:e.variables??{}}),description:e.description,name:IKD(e,t),audiences:Ei(e,xi.AUDIENCES)}}function BKD({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}}`,encodeURIComponent(n));return e}function IKD(e,t){let r=Ei(e,[xi.SERVER_NAME_V1,xi.SERVER_NAME_V2]);if(r!=null)return r;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox";if(t?.groupMultiApiEnvironments&&e.description!=null&&e.description.trim()!==""){let i=e.description.toLowerCase();return i==="prd"?"Production":i==="sbx"?"Sandbox":i==="staging"||i==="stg"?"Staging":i==="development"||i==="dev"?"Development":e.description}}function SAh(e){return Ei(e,xi.PARAMETER_NAME)}function MAh(e){return Ei(e,xi.SDK_VARIABLE)}function Rbu({path:e,httpMethod:t,parameters:r,context:i,requestBreadcrumbs:n,source:a}){let o={pathParameters:[],queryParameters:[],headers:[]};for(let c of r){let d=Ei(c,xi.IGNORE);if(d!=null&&d){i.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let s=Bn(c)?i.resolveParameterReference(c):c,u=s.required??!1,l=RW(s),p=[...n,s.name],_=jC(p,i.options.preserveSchemaIds),[h,y]=i.options.coerceOptionalSchemasToNullable?[!1,!u]:[!u,!1],b=s.schema!=null?kl(s.schema,h,y,i,p,a,i.namespace,!1,new Set,rXt({schema:s,logger:i.logger})):u?ai.primitive({nameOverride:void 0,generatedName:_,title:void 0,schema:kn.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:rXt({schema:s,logger:i.logger})}),description:void 0,availability:l,namespace:void 0,groupName:void 0}):ai.optional({nameOverride:void 0,generatedName:_,title:void 0,value:ai.primitive({nameOverride:void 0,generatedName:_,title:void 0,schema:kn.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:rXt({schema:s,logger:i.logger})}),description:void 0,availability:void 0,namespace:void 0,groupName:void 0}),description:void 0,availability:l,namespace:void 0,groupName:void 0,inline:void 0});if(s.in==="header"&&s.schema!=null&&!Bn(s.schema)&&s.schema.default!=null){let O=s.schema.default;typeof O=="string"&&O.length>0&&(b=ai.literal({nameOverride:void 0,generatedName:_,title:void 0,value:iE.string(O),description:void 0,availability:l,namespace:void 0,groupName:void 0}))}let v={name:s.name,schema:b,description:s.description,parameterNameOverride:SAh(s),availability:l,source:a};s.in==="query"?o.queryParameters.push({...v,explode:qKD(s)}):s.in==="path"?o.pathParameters.push({...v,variableReference:MAh(s),explode:TKD(s)}):s.in==="header"?!CKD.has(s.name.toLowerCase())&&!i.authHeaders.has(s.name)?o.headers.push({...v,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 o}var CKD=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function qKD(e){let t=e.style??"form",r=e.explode;if(r!==void 0)return t==="form"?r===!0?void 0:r:r===!1?void 0:r}function TKD(e){let t=e.explode;if(t!==void 0)return t===!1?void 0:t}function DAh(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:vJa(i,t)}}}function RKD(e){return e.includes("json")||e==="*/*"}function BKc({content:e,context:t}){for(let[r,i]of Object.entries(e))if(zbu({mediaType:r,mediaTypeObject:i,context:t})!=null)return[r,i]}function zbu({mediaType:e,mediaTypeObject:t,context:r}){if(!RKD(e))return;let i=t.schema;return{contentType:e.includes("*")?void 0:e,schema:i??{},examples:vJa(t,r)}}function Nbu({content:e,context:t}){let r=BKc({content:e,context:t});if(!r)return;let[i,n]=r;return zbu({mediaType:i,mediaTypeObject:n,context:t})}function BAh(e,t){for(let r of Object.keys(e)){let i=e[r];if(i==null)continue;return{schema:i.schema??{},examples:vJa(i,t)}}}function vJa(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let i=Ei(e,PL.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 o=Bn(a)?t.resolveExampleReference(a):a;return{name:o.summary??n,value:o.value,description:o.description}})),r}function zKD({content:e,context:t}){for(let[r,i]of Object.entries(e))if(CAh({mediaType:r,mediaTypeObject:i,context:t}))return[r,i]}function CAh({mediaType:e,mediaTypeObject:t,context:r}){if(em.parse(e)?.isURLEncoded())return{schema:t.schema,contentType:e,examples:vJa(t,r)}}function NKD({content:e}){for(let[t,r]of Object.entries(e))if(qAh({mediaType:t,mediaTypeObject:r}))return[t,r]}function qAh({mediaType:e,mediaTypeObject:t}){if(em.parse(e)?.isMultipart())return{schema:t.schema,encoding:t.encoding}}function TAh({mediaType:e}){return em.parse(e)?.isBinary()??!1}function FKD({content:e}){for(let[t,r]of Object.entries(e))if(TAh({mediaType:t}))return[t,r]}function QKD(e,t){let r=Bn(e)?IKc(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([i,n])=>!Bn(n)&&n.type==="string"&&n.format==="binary")!=null}function Qbu({content:e,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:o}){let c=FKD({content:e});if(c){let[p,_]=c;return nXt({mediaType:p,mediaTypeObject:_,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:o})}let d=NKD({content:e}),s=BKc({content:e,context:i}),u=UKD({json:s,multipart:d,document:r,visitor:{json:([p,_])=>nXt({mediaType:p,mediaTypeObject:_,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:o}),multipart:([p,_])=>nXt({mediaType:p,mediaTypeObject:_,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:o}),neither:()=>{}}});if(u)return u;let l=zKD({content:e,context:i});if(l){let[p,_]=l;return nXt({mediaType:p,mediaTypeObject:_,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:o})}}function UKD({json:e,multipart:t,document:r,visitor:i}){if(!e&&!t)return i.neither();let[,n]=e??[void 0,void 0],[,a]=t??[void 0,void 0];return!n?.schema&&!a?.schema?i.neither():n?.schema&&a?.schema?n.schema&&QKD(n.schema,r)?i.multipart(t):i.json(e):n?.schema?i.json(e):a?.schema?i.multipart(t):i.neither()}function nXt({mediaType:e,mediaTypeObject:t,description:r,document:i,context:n,requestBreadcrumbs:a,source:o,namespace:c}){let d=LKD({mediaTypeObject:t});if(TAh({mediaType:e}))return mx.octetStream({description:r,source:o,sdkMethodName:d,contentType:e});let s=qAh({mediaType:e,mediaTypeObject:t}),u=s?.schema,l=s?.encoding;if(u){let h=Bn(u)?IKc(u,i):{id:void 0,schema:u},y=kl(h.schema,!1,!1,n,a,o,c,!1),b=[];if(y.type==="object"){let v=new Set(h.schema.required??[]);for(let O of y.properties){let m=v.has(O.key),{isFile:g,isOptional:A,isArray:j,description:M}=Fbu({schema:O.schema,isOptional:!m});if(g){let w=IAh(O.key,l);b.push({key:O.key,schema:$Yt.file({isOptional:A,isArray:j,description:M}),description:M,contentType:w,exploded:!1,encoding:w==null?n.options.defaultFormParameterEncoding:void 0})}else{let w=IAh(O.key,l);b.push({key:O.key,schema:$Yt.json(O.schema),description:void 0,contentType:w,exploded:l?.[O.key]?.explode,encoding:w==null?n.options.defaultFormParameterEncoding:WKD(w)})}}}return mx.multipart({name:Bn(u)&&n.getNumberOfOccurrencesForRef(u)===1?h.id:void 0,description:h.schema.description,properties:b,source:o,sdkMethodName:d})}let p=zbu({mediaType:e,mediaTypeObject:t,context:n});if(p){let h=kl(p.schema,!1,!1,n,a,o,c,!0);return mx.json({description:void 0,schema:h,contentType:p.contentType,fullExamples:p.examples,additionalProperties:!Bn(p.schema)&&pJa(p.schema.additionalProperties,n.options),source:o,sdkMethodName:d})}let _=CAh({mediaType:e,mediaTypeObject:t,context:n});if(_!=null&&_.schema!=null){let h=kl(_.schema,!1,!1,n,a,o,c,!1);return mx.formUrlEncoded({schema:h,description:r,contentType:_.contentType,source:o,fullExamples:_.examples,additionalProperties:!1,sdkMethodName:d})}}function LKD({mediaTypeObject:e}){return Ei(e,xi.SDK_METHOD_NAME)}var VKD={"application/json":"json"};function WKD(e){return e?VKD[e]:void 0}function IKc(e,t){if(!e.$ref.startsWith(Yvn))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=_$i(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 Bn(i)?IKc(i,t):{id:r,schema:i}}function Fbu({schema:e,isOptional:t,isArray:r,description:i}){return xKD(e)?Fbu({schema:e.value,isOptional:!0,isArray:r,description:e.description}):HKD(e)?Fbu({schema:e.value,isOptional:t,isArray:r,description:e.description}):KKD(e)?Fbu({schema:e.value,isOptional:t,isArray:!0,description:e.description}):GKD(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 GKD(e){return e.type==="primitive"&&e.schema.type==="string"&&e.schema.format==="binary"}function xKD(e){return e.type==="optional"}function HKD(e){return e.type==="nullable"}function KKD(e){return e.type==="array"}function IAh(e,t){return t?.[e]?.contentType}var CKc={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"},RAh=new Set(Object.values(CKc));var JKD=["200","201","202","204"];function Ubu({operationContext:e,responses:t,context:r,responseBreadcrumbs:i,responseStatusCode:n,streamFormat:a,source:o}){if(t==null)return{value:void 0,errors:{}};let c=$KD({responses:t,context:r,source:o,namespace:r.namespace}),d=!1,s;for(let u of n!=null?[n]:JKD){let l=t[u];l!=null&&(d=!0,s==null&&(s=zAh({operationContext:e,response:l,context:r,responseBreadcrumbs:i,streamFormat:a,source:o,namespace:r.namespace,statusCode:typeof u=="string"?parseInt(u):u})))}if(s==null&&!d&&t.default!=null&&(s=zAh({operationContext:e,response:t.default,context:r,responseBreadcrumbs:i,streamFormat:a,source:o,namespace:r.namespace})),s!=null)switch(s.type){case"json":return{value:s,errors:c};case"streamingJson":case"streamingSse":return{value:s,errors:c};case"bytes":case"file":case"text":case"streamingText":return{value:s,errors:c};default:vt(s)}return{value:void 0,errors:c}}function zAh({operationContext:e,streamFormat:t,response:r,context:i,responseBreadcrumbs:n,source:a,namespace:o,statusCode:c}){let d=Bn(r)?i.resolveResponseReference(r):r;if(d.content!=null&&Object.entries(d.content).find(([p,_])=>{if(_.schema==null)return!1;let h=Bn(_.schema)?i.resolveSchemaReference(_.schema):_.schema;return h.type==="string"&&h.format==="binary"}))return i.options.useBytesForBinaryResponse&&t==null?q0.bytes({description:d.description,source:a,statusCode:c}):q0.file({description:d.description,source:a,statusCode:c});let s=DAh(d.content??{},i);if(s!=null&&t!=null)switch(t){case"json":return q0.streamingJson({statusCode:c,description:d.description,responseProperty:Ei(e.operation,xi.RESPONSE_PROPERTY),fullExamples:s.examples,schema:kl(s.schema,!1,!1,i,n,a,o),source:a});case"sse":return q0.streamingSse({description:d.description,responseProperty:void 0,fullExamples:s.examples,schema:kl(s.schema,!1,!1,i,n,a,o),source:a,statusCode:c})}let u=Nbu({context:i,content:d.content??{}});if(u){if(t!=null)switch(t){case"json":return q0.streamingJson({description:d.description,responseProperty:void 0,fullExamples:u.examples,schema:kl(u.schema,!1,!1,i,n,a,o),source:a,statusCode:c});case"sse":return q0.streamingSse({description:d.description,responseProperty:void 0,fullExamples:u.examples,schema:kl(u.schema,!1,!1,i,n,a,o),source:a,statusCode:c})}return q0.json({description:d.description,schema:kl(u.schema,!1,!1,i,n,a,o),responseProperty:Ei(e.operation,xi.RESPONSE_PROPERTY),fullExamples:u.examples,source:a,statusCode:c})}for(let[l,p]of Object.entries(d.content??{})){let _=em.parse(l);if(_!=null){if(_.isOctetStream()||_.isPDF()||_.isAudio()||_.isImage()||_.isVideo()||_.isMultiPartMixed())return q0.file({description:d.description,source:a,statusCode:c});if(_.isPlainText()){let h=p.schema;if(h==null)return q0.text({description:d.description,source:a,statusCode:c});let y=Bn(h)?i.resolveSchemaReference(h):h;return y.type==="string"&&y.format==="byte"?q0.file({description:d.description,source:a,statusCode:c}):q0.text({description:d.description,source:a,statusCode:c})}}}}function $KD({responses:e,context:t,source:r,namespace:i}){let n={};for(let[a,o]of Object.entries(e)){if(a==="default")continue;let c=parseInt(a);if(c<400||c>600)continue;let d=Bn(o)?t.resolveResponseReference(o):o,s=BAh(d.content??{},t),u=CKc[c];if(u==null){t.logger.warn(`No error name found for status code ${a}`);continue}n[c]={statusCode:c,nameOverride:void 0,generatedName:u,description:d.description,schema:kl(s?.schema??{},!1,!1,t,[u,"Body"],r,i),fullExamples:s?.examples,source:r}}return n}function qUi({operationContext:e,context:t,responseStatusCode:r,suffix:i,streamFormat:n,source:a}){let{document:o,operation:c,path:d,method:s,baseBreadcrumbs:u}=e,l=Ei(c,xi.IDEMPOTENT),p=Ei(c,[xi.REQUEST_NAME_V1,xi.REQUEST_NAME_V2]),_=[...u,"Request"],h=Rbu({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:_,path:d,httpMethod:s,source:a}),y=/{([^}]+)}/g,b=[...d.matchAll(y)].map(B=>B[1]).filter(B=>B!==void 0),v=[...d.matchAll(y)].map(B=>B[1]);switch(t.options.pathParameterOrder){case an.PathParameterOrder.SpecOrder:{let B=v.filter(T=>!h.pathParameters.some(R=>R.name===T));if(B.length>0)for(let T of B)h.pathParameters.push({name:T??"",variableReference:void 0,parameterNameOverride:void 0,availability:void 0,source:a,schema:ai.primitive({schema:kn.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,explode:void 0})}break;case an.PathParameterOrder.UrlOrder:if(b.length>0){let B=new Map(h.pathParameters.map(q=>[q.name,q])),T=[],R=new Set;for(let q of b){let z=B.get(q);R.add(q),z?T.push(z):T.push({name:q,variableReference:void 0,parameterNameOverride:void 0,availability:void 0,source:a,schema:ai.primitive({schema:kn.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,explode:void 0})}for(let q of h.pathParameters)R.has(q.name)||T.push(q);h.pathParameters=T}break;default:vt(t.options.pathParameterOrder)}let O=(()=>{if(e.method==="GET")return[void 0];if(!c.requestBody)return[void 0];let B=Bn(c.requestBody)?t.resolveRequestBodyReference(c.requestBody):c.requestBody,T=Object.values(B.content).every(q=>XKD({mediaTypeObject:q})!=null),R=[];if(T)return R.push(...Object.entries(B.content).map(([q,z])=>{let Q=nXt({mediaType:q,mediaTypeObject:z,description:B.description,document:o,context:new Zvn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:_,source:a,namespace:t.namespace});return NAh({context:t,convertedParameters:h})&&Q!=null&&(Q.type==="json"||Q.type==="formUrlEncoded")&&Q.schema.type!=="object"&&c.requestBody!=null?Q=nXt({mediaType:q,mediaTypeObject:z,description:B.description,document:o,context:t,requestBreadcrumbs:[..._,"Body"],source:a,namespace:t.namespace}):c.requestBody!=null&&(Q=nXt({mediaType:q,mediaTypeObject:z,description:B.description,document:o,context:t,requestBreadcrumbs:[..._],source:a,namespace:t.namespace})),Q}).filter(q=>q!=null)),R.length===0?[void 0]:R;{let q=Qbu({content:B.content,description:B.description,document:o,context:new Zvn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:_,source:a,namespace:t.namespace});return NAh({context:t,convertedParameters:h})&&q!=null&&(q.type==="json"||q.type==="formUrlEncoded")&&q.schema.type!=="object"&&c.requestBody!=null?q=Qbu({content:B.content,description:B.description,document:o,context:t,requestBreadcrumbs:[..._,"Body"],source:a,namespace:t.namespace}):c.requestBody!=null&&(q=Qbu({content:B.content,description:B.description,document:o,context:t,requestBreadcrumbs:[..._],source:a,namespace:t.namespace})),[q]}})(),m=O.length>1,g=[...u,"Response"],A=Ubu({operationContext:e,streamFormat:n,responses:c.responses,context:t,responseBreadcrumbs:g,responseStatusCode:r,source:a}),j=EAh(c),M=wAh(c),w=jAh(e,c,t),D=Ei(c,xi.SERVER_NAME_V2);return O.map(B=>({summary:c.summary,internal:Ei(c,PL.INTERNAL),idempotent:l,audiences:Ei(c,xi.AUDIENCES)??[],operationId:c.operationId!=null&&i!=null?c.operationId+"_"+i:c.operationId,tags:t.resolveTagsToTagIds(c.tags),namespace:t.namespace,sdkName:ZKD({operationContext:e,request:B}),pathParameters:h.pathParameters,queryParameters:h.queryParameters,headers:h.headers,requestNameOverride:p??void 0,generatedRequestName:jC(m?YKD({breadcrumbs:_,request:B}):_,t.options.preserveSchemaIds),request:B,response:A.value,errors:A.errors,servers:D!=null?[{name:D,url:void 0,audiences:void 0}]:(c.servers??[]).map(T=>Tbu(T,{groupMultiApiEnvironments:t.options.groupMultiApiEnvironments})),description:c.description,authed:eJD(c,o),security:kKD(c),availability:M,method:s,path:d,examples:w,pagination:e.pagination,source:a,retries:j}))}function YKD({breadcrumbs:e,request:t}){return t?[...e,t.type]:e}function XKD({mediaTypeObject:e}){return Ei(e,xi.SDK_METHOD_NAME)}function ZKD({operationContext:e,request:t}){return!t||!t.sdkMethodName?e.sdkMethodName:e.sdkMethodName?{groupName:[...e.sdkMethodName.groupName],methodName:t.sdkMethodName??e.sdkMethodName.methodName}:{groupName:[],methodName:t.sdkMethodName}}function kKD(e){return e.security}function eJD(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function NAh({context:e,convertedParameters:t}){return e.options.inlinePathParameters&&t.pathParameters.length>0||t.queryParameters.length>0||t.headers.length>0}function QAh({operationContext:e,context:t,asyncExtension:r,source:i}){let{operation:n,pathItemParameters:a,operationParameters:o}=e,c=r.discriminant.name,d=r.discriminant.value,s=r["response-status-code"],u=FAh({context:t,headerToIgnore:c,parameters:a}),l=FAh({context:t,headerToIgnore:c,parameters:o}),p=qUi({operationContext:{...e,pathItemParameters:u,operationParameters:l,operation:{...n,responses:Object.fromEntries(Object.entries(n.responses).filter(([h])=>parseInt(h)!==s))}},context:t,streamFormat:void 0,source:i}),_=qUi({operationContext:{...e,pathItemParameters:u,operationParameters:l,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:s,streamFormat:void 0,source:i});return _.forEach(h=>{h.headers.push({name:c,schema:ai.literal({nameOverride:void 0,generatedName:jC([c],t.options.preserveSchemaIds),title:void 0,description:void 0,availability:void 0,value:iE.string(d),namespace:void 0,groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:i})}),{sync:p,async:_}}function FAh({context:e,headerToIgnore:t,parameters:r}){return r.filter(i=>{let n=Bn(i)?e.resolveParameterReference(i):i;return!(n.in==="header"&&n.name===t)})}var qKc="stream";function WAh({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:qUi({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:[]};case"streamCondition":{let i=UAh({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(i?.schemaReference!=null){let s=_$i(i.schemaReference);s!=null&&t.excludeSchema(s)}let n=LAh({operation:e.operation,response:r.responseStream}),a=qUi({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+qKc}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:i?.requestBody,responses:n},baseBreadcrumbs:[...e.baseBreadcrumbs,qKc]},context:t,streamFormat:r.format,suffix:qKc,source:t.source});a.forEach(s=>{s.examples=s.examples.filter(u=>VAh(u,t)!==!1)});let o=UAh({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),c=LAh({operation:e.operation,response:r.response}),d=qUi({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:o?.requestBody,responses:c}},context:t,source:t.source});return d.forEach(s=>{s.examples=s.examples.filter(u=>VAh(u,t)!==!0)}),{streaming:a,nonStreaming:d}}default:vt(r)}}function UAh({context:e,operation:t,streamingExtension:r,isStreaming:i}){if(t.requestBody==null)return;let n=Bn(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=Nbu({content:n.content,context:e});if(a==null)return;let o=Bn(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(o.allOf==null&&o.properties==null)return;let c=o.properties?.[r.streamConditionProperty];c!=null&&Bn(c)&&(c=void 0);let d={...o,properties:{...o.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":i,...c??{}}},title:void 0,required:[...o.required??[],r.streamConditionProperty]};return{requestBody:{content:{[em.APPLICATION_JSON]:{schema:d}}},schemaReference:Bn(a.schema)?a.schema:void 0}}function LAh({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[em.APPLICATION_JSON]:{schema:t}}}}}function VAh(e,t){return e._visit({unknown:r=>{let i=cI.serialization.ExampleEndpointCallSchema.parse(r);if(i.ok&&i.value.response!=null)return i.value.response.stream!=null},full:()=>{},_other:()=>{}})}var GAh=require("crypto");function xAh({context:e,operationContext:t,source:r}){let{document:i,operation:n,path:a,method:o,baseBreadcrumbs:c,sdkMethodName:d}=t,s=[...c,"Payload"],u=[...c,"Response"],l=Rbu({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:s,path:a,httpMethod:o,source:r});if(n.requestBody==null)return e.logger.error(`Skipping webhook ${o.toUpperCase()} ${a}: Missing a request body`),[];let p=n.operationId??rJD({path:a,method:o,sdkMethodName:d}),_=n.responses?Ubu({operationContext:t,streamFormat:void 0,responses:n.responses,context:e,responseBreadcrumbs:u,source:r}):void 0;if(o!=="POST"&&o!=="GET")return e.logger.error(`Skipping webhook ${o.toUpperCase()} ${a}: Not POST or GET`),[];let h=Bn(n.requestBody)?e.resolveRequestBodyReference(n.requestBody):n.requestBody;return Object.entries(h.content).map(([y,b])=>nXt({mediaType:y,mediaTypeObject:b,description:h.description,document:i,context:e,requestBreadcrumbs:[...c,"Payload"],source:r,namespace:e.namespace})).filter(y=>y!=null).map(y=>{if(y==null||y.type!=="json"&&y.type!=="formUrlEncoded"&&y.type!=="multipart"){e.logger.error(`Skipping webhook ${a} because non-json, non-formUrlEncoded, and non-multipart request body`);return}let b,v;return y.type==="multipart"?(b={name:y.name,properties:y.properties,description:y.description,source:y.source},v=ai.unknown({nameOverride:void 0,generatedName:jC(s,e.options.preserveSchemaIds),title:void 0,description:y.description,availability:void 0,namespace:e.namespace,groupName:void 0,example:void 0})):v=y.schema,{summary:n.summary,audiences:Ei(n,xi.AUDIENCES)??[],sdkName:d,namespace:e.namespace,method:o,operationId:p,tags:e.resolveTagsToTagIds(n.tags),headers:l.headers,generatedPayloadName:jC(s,e.options.preserveSchemaIds),payload:v,multipartFormData:b,response:_?.value,description:n.description,examples:tJD(y.type==="multipart"?void 0:y.fullExamples),source:r}}).filter(y=>y!=null)}function tJD(e){if(e==null)return[];let t=[];for(let r of e){let i=y$i(r.value);i!=null&&t.push({description:r.description,name:r.name,payload:i})}return t}function rJD({path:e,method:t,sdkMethodName:r}){let i=r?.methodName??iJD(e),n=(0,GAh.createHash)("sha256").update(e).digest("hex").slice(0,8);return nJD(`${i}_${t.toLowerCase()}_${n}`)}function iJD(e){return e.replace(/[{$}#]/g,"").replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_+/g,"_").toLowerCase().slice(0,64)}function nJD(e){return e.split("_").map((t,r)=>r===0?t.toLowerCase():t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function TKc({context:e,pathItemContext:t,operation:r,convertToWebhook:i}){let n=Ei(r,xi.IGNORE);if(n!=null&&n){e.logger.debug(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=aJD(r,e),o=hAh(e.document,r),c={...t,sdkMethodName:a,baseBreadcrumbs:oJD({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path,shouldUseIdiomaticRequestNames:e.options.shouldUseIdiomaticRequestNames}),operation:r,operationParameters:r.parameters??[],pagination:o};if(i)return{type:"webhook",value:xAh({context:e,operationContext:c,source:e.source})};let d=pAh(r);if(d!=null){let l=WAh({context:e,operationContext:c,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let s=fAh(r);if(s!=null){let l=QAh({context:e,operationContext:c,asyncExtension:s,source:e.source});return{type:"async",async:l.async,sync:l.sync}}return{type:"http",value:qUi({context:e,operationContext:c,streamFormat:void 0,source:e.source})}}function aJD(e,t){let r=Ei(e,xi.SDK_METHOD_NAME),i=Ei(e,xi.SDK_GROUP_NAME)??[];if(r!=null){let n=typeof i=="string"?[i]:i;return n=t.resolveGroupName(n),{groupName:n,methodName:r}}}function oJD({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 o=e.groupName[e.groupName.length-1];o!=null&&a.push(typeof o=="string"?o:o.name)}n||a.push(e.methodName)}else t.operationId!=null?a.push(t.operationId):a.push(ou(`${r}_${i.split("/").join("_")}`));return a}function HAh(e,t,r,i){let n=[],a=JAh(t),o={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let c of a){if(i.filter.skipEndpoint({method:c.method,path:e})){i.logger.debug(`Skipping endpoint "${c.method} ${e}"`);continue}let d=uJD({operation:c.operation}),s=TKc({context:i,pathItemContext:{...o,method:c.method},operation:c.operation,convertToWebhook:d});s&&n.push(s)}return n}function KAh(e,t,r,i){let n=[],a=JAh(t),o={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let c of a){if(i.filter.skipEndpoint({method:c.method,path:e})){i.logger.debug(`Skipping endpoint "${c.method} ${e}"`);continue}let d=TKc({context:i,pathItemContext:{...o,method:c.method},operation:c.operation,convertToWebhook:!0});d&&n.push(d)}return n}function JAh(e){let t=[];return e.get!=null&&t.push({method:EF.Get,operation:e.get}),e.post!=null&&t.push({method:EF.Post,operation:e.post}),e.put!=null&&t.push({method:EF.Put,operation:e.put}),e.delete!=null&&t.push({method:EF.Delete,operation:e.delete}),e.patch!=null&&t.push({method:EF.Patch,operation:e.patch}),e.head!=null&&t.push({method:EF.Head,operation:e.head}),t}function uJD({operation:e}){return Ei(e,[xi.WEBHOOK])??!1}function $Ah(e){let t=Ei(e,xi.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=Ei(e,xi.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function YAh(e){return Ei(e,xi.FERN_BASIC_AUTH)}function ZAh(e,t,r,i){if(Bn(e)){if(i==null)throw new Error(`Converting referenced security schemes requires context: ${JSON.stringify(e)}`);let n=i.resolveSecuritySchemeReference(e);return XAh(n,t,r)}return XAh(e,t,r)}function XAh(e,t,r){try{if(e.type==="apiKey"&&e.in==="header"){let i=Ei(e,PL.BEARER_FORMAT),n=Ei(e,xi.FERN_HEADER_AUTH);return PF.header({headerName:e.name,prefix:i!=null?"Bearer":n?.prefix,headerVariableName:n?.name??Ei(e,xi.HEADER_VARIABLE_NAME),headerEnvVar:n?.env})}else if(e.type==="http"&&e.scheme?.toLowerCase()==="bearer"){let i=Ei(e,xi.FERN_BEARER_TOKEN);return PF.bearer({tokenVariableName:i?.name??Ei(e,xi.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:i?.env})}else if(e.type==="http"&&e.scheme?.toLowerCase()==="basic"){let i=YAh(e),n=$Ah(e);return PF.basic({usernameVariableName:i?.username?.name??n.usernameVariable,usernameEnvVar:i?.username?.env,passwordVariableName:i?.password?.name??n.passwordVariable,passwordEnvVar:i?.password?.env})}else{if(e.type==="openIdConnect")return PF.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return PF.oauth({scopesEnum:sJD(e,t)})}}catch(i){r.logger.debug(`Error converting security scheme: ${i?.message}`)}r.logger.debug(`Skipping security scheme: ${JSON.stringify(e,null)} - not currently supported. Please reach out to Fern support team!`)}function sJD(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=p$i({nameOverride:void 0,generatedName:"OauthScope",title:void 0,enumValues:Object.keys(r),fernEnum:Object.fromEntries(Object.entries(r).map(([a,o])=>[a,{description:o}])),_default:void 0,description:void 0,availability:void 0,enumVarNames:void 0,wrapAsOptional:!1,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 kAh(e){return Ei(e,xi.BASE_PATH)}var cJD=Qt.record(Qt.string(),Qt.object({summary:Qt.string().optional(),description:Qt.string().optional()}));function ePh({document:e,context:t}){return fJa(e,xi.GROUPS,cJD,t.logger)}function tPh({context:e,document:t}){return Ei(t,xi.FERN_VERSION)??void 0}function rPh(e){let t=Ei(e,xi.FERN_GLOBAL_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?dJa({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 iPh(e){let t=Ei(e,xi.FERN_IDEMPOTENCY_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?dJa({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 nPh(e,t){let r=Ei(e,xi.SDK_VARIABLES);return r==null?{}:Object.fromEntries(Object.entries(r).map(([i,n])=>{if(n.type==="string")return[i,{nameOverride:void 0,generatedName:jC([i],t),title:n.title,schema:Qh.string({default:Gua(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 lJD="webhooks";function aPh(e){return Ei(e,lJD)??{}}var gJa=class extends $ua{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:o}){super({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:o})}getDummy(){return new Zvn({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 oPh(e){return Ei(e,xi.RESOLUTIONS)}function uPh({openapi:e}){let t=oPh(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=fJD({openapi:e,schemaReference:a,schemaName:i.name}),e=sPh({openapi:e,replaceReference:a,schemaReference:n,replacedReferences:r}),r={...r,...Object.fromEntries(i.resolutions.map(o=>[n,o]))}}return e}function fJD({openapi:e,schemaReference:t,schemaName:r}){let i=t.replace("#/","").split("/").map(a=>a.replaceAll("~1","/")),n=e;for(let a of i){let o=n[a];if(o==null)return e;n=o}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=n,e}function sPh({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 sPh({openapi:e,replaceReference:t,schemaReference:s,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replaceAll("~1","/")),o=e;for(let d of a.slice(0,-1)){let s=o[d];if(s==null)return e;o=s}let c=a[a.length-1];return c==null||(o[c]={$ref:r}),e}function lPh({openApi:e,taskContext:t,options:r,source:i,namespace:n}){e=uPh({openapi:e});let a=new gJa({document:e,taskContext:t,authHeaders:new Set,options:r,source:i,namespace:n}),o=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([B,T])=>{let R=ZAh(T,i,t,a);return R==null?null:[B,R]}).filter(B=>B!==null)),c=e.security?.filter(B=>B!=null),d=new Set(...Object.entries(o).map(([B,T])=>T.type==="basic"||T.type==="bearer"?"Authorization":T.type==="header"?T.headerName:null)),s=nPh(e,r.preserveSchemaIds),u=rPh(e),l=iPh(e),p=r.audiences??[],_=[],h=[],y=new gJa({document:e,taskContext:t,authHeaders:d,options:r,source:i,namespace:n});y.filter.hasEndpoints()&&t.logger.debug("Endpoint filter applied..."),Object.entries(e.paths??{}).forEach(([B,T])=>{if(T==null)return;let R=HAh(B,T,e,y);for(let q of R){let z=cPh({operation:q});if(!(p.length>0&&!p.some(Q=>z.includes(Q))))switch(q.type){case"async":_.push(...q.sync),_.push(...q.async);break;case"http":_.push(...q.value);break;case"streaming":_.push(...q.streaming),q.nonStreaming&&_.push(...q.nonStreaming);break;case"webhook":h.push(...q.value);break;default:vt(q)}}}),Object.entries(aPh(e)).forEach(([B,T])=>{if(T==null)return;t.logger.debug(`Converting path ${B}`);let R=KAh(B,T,e,y);for(let q of R){let z=cPh({operation:q});p.length>0&&!p.some(Q=>z.includes(Q))||h.push(...q.value)}});let b=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([B,T])=>{let R=Ei(T,xi.SDK_NAMESPACE);if(!Bn(T)){let q=Ei(T,xi.IGNORE);if(q!=null&&q)return[];if(RAh.has(B))return[B,kl({...T,"x-fern-type-name":`${B}Body`},!1,!1,y,[B],i,R??n)]}return[B,kl(T,!1,!1,y,[B],i,R??n)]}).filter(B=>B.length>0)),v=dJD(b,y,i),O=pJD(v,y),m={};for(let[B,T]of Object.entries(O)){let R=Qm(T);y.isSchemaExcluded(B)||(m[B]=R)}let g=new b$i(O,y.nonRequestReferencedSchemas,y),A=h.map(B=>{let R=B.examples;if(!r.disableExamples&&R.length===0){let q=g.buildExample({schema:B.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});q!=null&&(R=[{name:void 0,description:void 0,payload:q}])}return{...B,payload:Qm(B.payload),examples:R}}),j=new Ebu(O,y,u),M=_.map(B=>{let T=B.examples,R=T;if(!r.disableExamples&&(T.length===0||T.every(yJa))){let Q=j.buildEndpointExample(B);Q.length>0&&(R=[...Q,...T.filter(H=>!yJa(H))])}let q=B.request,z=B.response;return{...B,request:q?.type==="json"||q?.type==="formUrlEncoded"?{...q,schema:Qm(q.schema)}:q,response:z?.type==="json"?{...z,schema:Qm(z.schema)}:z,queryParameters:B.queryParameters.map(Q=>({description:Q.description,name:Q.name,schema:Qm(Q.schema),parameterNameOverride:Q.parameterNameOverride,availability:Q.availability,source:Q.source})),pathParameters:B.pathParameters.map(Q=>({description:Q.description,name:Q.name,schema:Qm(Q.schema),parameterNameOverride:Q.parameterNameOverride,variableReference:Q.variableReference,availability:Q.availability,source:Q.source})),headers:B.headers.map(Q=>({description:Q.description,name:Q.name,schema:Qm(Q.schema),parameterNameOverride:Q.parameterNameOverride,env:Q.env,availability:Q.availability,source:Q.source})),examples:R,errors:rn(B.errors,Q=>{let H=Q.fullExamples?.map(Y=>{let he=y$i(Y.value);if(he!=null)return{name:Y.name,description:Y.description,example:he}}).filter(us);if(H?.length===0){let Y=g.buildExample({schema:Q.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});Y!=null&&H.push({name:void 0,description:void 0,example:Y})}return{generatedName:Q.generatedName,nameOverride:Q.nameOverride,schema:Qm(Q.schema),description:Q.description,source:Q.source,examples:H}}),retries:B.retries}});j.finalize();let w=ePh({document:e,context:y});return{apiVersion:tPh({context:y,document:e}),basePath:kAh(e),title:e.info.title??"",description:e.info.description,groups:Object.fromEntries(Object.entries(w??{}).map(([B,T])=>[B,{summary:T.summary??void 0,description:T.description??void 0}])),servers:(e.servers??[]).map(B=>Tbu(B,{groupMultiApiEnvironments:r.groupMultiApiEnvironments})),websocketServers:[],tags:{tagsById:Object.fromEntries((e.tags??[]).map(B=>[B.name,{id:B.name,description:B.description}])),orderedTagIds:e.tags?.map(B=>B.name)},endpoints:M,webhooks:A,channels:{},groupedSchemas:Hua(n,m),securitySchemes:o,security:c,hasEndpointsMarkedInternal:M.some(B=>B.internal),nonRequestReferencedSchemas:y.getReferencedSchemas(),variables:s,globalHeaders:u,idempotencyHeaders:l}}function dJD(e,t,r){if(t.options.removeDiscriminantsFromSchemas===an.RemoveDiscriminantsFromSchemas.Never)return e;let i={};for(let[n,a]of Object.entries(e)){if(a.type!=="object"){i[n]=a;continue}let o={$ref:`#/components/schemas/${n}`},c=t.getReferencesFromDiscriminatedUnion(o);if(c==null){i[n]=a;continue}if(t.getReferencedSchemas().has(n)){i[n]=a;continue}let s={...a,type:"object",properties:a.properties.filter(l=>!c.discriminants.has(l.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(l=>!c.discriminants.has(l.propertyKey)),source:r};i[n]=s;let u=fPh({schema:a,schemas:e});for(let l of[...new Set(u)]){let p=i[l]??e[l];p==null||p.type!=="object"||(i[l]={...p,type:"object",properties:p.properties.filter(_=>!c.discriminants.has(_.key)),allOfPropertyConflicts:p.allOfPropertyConflicts.filter(_=>!c.discriminants.has(_.propertyKey))})}}return i}function pJD(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}`},o=t.getDiscriminatedUnionMetadata(a);if(o==null){r[i]=n;continue}let c=[];for(let s of n.properties)if(o.discriminants.has(s.key)){let u=o.discriminants.get(s.key);u!=null&&c.push({...s,schema:ai.literal({nameOverride:void 0,generatedName:jC([n.generatedName,u],t.options.preserveSchemaIds),title:void 0,value:iE.string(u),namespace:void 0,groupName:void 0,description:void 0,availability:n.availability})})}else c.push(s);let d={...n,type:"object",properties:c};r[i]=d}return r}function fPh({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(...fPh({schema:n,schemas:t}))}return r}function Lbu(e){return[...new Set(e)]}function cPh({operation:e}){let t=[];switch(e.type){case"async":t=Lbu(e.async.flatMap(r=>r.audiences));break;case"http":t=Lbu(e.value.flatMap(r=>r.audiences));break;case"streaming":t=Lbu(e.streaming.flatMap(r=>r.audiences));break;case"webhook":t=Lbu(e.value.flatMap(r=>r.audiences));break;default:vt(e)}return t}function kvn({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:{},security:void 0,globalHeaders:[],idempotencyHeaders:[],groups:{}},n=0;for(let a of t)try{let o=a.source!=null?a.source:CW.openapi({file:"<memory>"});switch(a.type){case"openapi":{let c=lPh({taskContext:e,openApi:a.value,options:lSe({options:a.settings,overrides:r}),source:o,namespace:a.namespace});i=bJD(i,c,lSe({options:a.settings,overrides:r})),n++;break}case"asyncapi":{let c=lAh({document:a.value,taskContext:e,options:lSe({options:a.settings,overrides:r}),source:o,asyncApiOptions:_JD({options:a.settings}),namespace:a.namespace});c.servers!=null&&(i.websocketServers=[...i.websocketServers,...c.servers.map(d=>({...d,audiences:void 0,description:void 0}))]),c.channels!=null&&(i.channels={...i.channels,...c.channels}),c.groupedSchemas!=null&&(i.groupedSchemas=Vbu(i.groupedSchemas,c.groupedSchemas)),c.basePath!=null&&(i.basePath=c.basePath),n++;break}default:vt(a)}}catch(o){e.logger.debug(`Skipping parsing document ${a.type==="openapi"?a.value.info?.title:a.source?.file}`),o instanceof Error&&e.logger.debug(o.message,o.stack?`
|
|
1526
1526
|
`+o.stack:"")}return i}function _JD({options:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??Mmh.naming}}function Wbu(e){let t=String(e.description||e.name||e["x-fern-server-name"]||"default").trim(),r=t.toUpperCase();return r==="PRODUCTION"||r==="PRD"||r==="PROD"?"PRD":r==="SANDBOX"||r==="SBX"?"SBX":r==="STAGING"||r==="STG"?"STG":r==="PERFORMANCE"||r==="PRF"||r==="PERF"?"PRF":r==="E2E"||r==="E_2_E"?"E2E":r==="QAL"||r==="QUALITY"?"QAL":t}function hJD(e){try{let i=new URL(e).hostname.split("."),n=new Set(["api","www","service","services","example","com","org","net","io"]);for(let o of i){let c=o.split("-")[0];if(c&&!n.has(c.toLowerCase())&&c.length>2)return c.toLowerCase()}let a=i[0]?.split("-")[0];return a?a.toLowerCase():"api"}catch{let t=e.match(/https?:\/\/([^./-]+)/);return t&&t[1]?t[1].toLowerCase():"api"}}function RKc(e,t){let r=e??[],i=t??[];if(r.length===0&&i.length===0)return;let n=new Map;for(let a of[...r,...i]){let o=Object.keys(a).sort(),c={};for(let s of o)c[s]=a[s]??[];let d=JSON.stringify(c);n.has(d)||n.set(d,a)}return Array.from(n.values())}function yJD(e,t){if(e.length===0||t.length===0||e.length!==t.length)return!1;let r=new Map;for(let a of e){let o=Wbu(a);r.set(o,a.url)}let i=!0,n=!0;for(let a of t){let o=Wbu(a),c=r.get(o);c?c===a.url&&(n=!1):i=!1}return i&&n}function dPh(e){if(e.length===0||!e[0])return"api";let t=e[0].url;return hJD(t)}function bJD(e,t,r){if(!(r?.groupMultiApiEnvironments===!0))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:Vbu(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},security:RKc(e.security,t.security),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}};if(yJD(e.servers,t.servers)){let a=[],o=[],c=dPh(e.servers),d=dPh(t.servers),s=new Map;for(let p of e.servers){let _=Wbu(p);s.has(_)||s.set(_,{});let h=s.get(_);h&&(h[c]={url:p.url,audiences:p.audiences})}for(let p of t.servers){let _=Wbu(p);s.has(_)||s.set(_,{});let h=s.get(_);h&&(h[d]={url:p.url,audiences:p.audiences})}for(let[p,_]of s.entries()){let h={type:"grouped",name:p,description:`${p} environment`,urls:_};a.push(h)}let u=e.endpoints.map(p=>({...p,type:"multi-api",apiName:c,servers:[{name:c,url:void 0,audiences:void 0}]})),l=t.endpoints.map(p=>({...p,type:"multi-api",apiName:d,servers:[{name:d,url:void 0,audiences:void 0}]}));return o=[...u,...l],{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:a.map(p=>(p.type==="single",p)),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:o.map(p=>{if(p.type==="multi-api"){let{type:y,apiName:b,servers:v,...O}=p;return{...O,__apiName:b,servers:v}}let{type:_,...h}=p;return h}),webhooks:[...e.webhooks,...t.webhooks],channels:{...e.channels,...t.channels},groupedSchemas:Vbu(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},security:RKc(e.security,t.security),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}}}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:Vbu(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},security:RKc(e.security,t.security),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 Vbu(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 PIh=ce(zmu(),1),Nmu={config:new PIh.Config({apis:{},styleguide:{plugins:[OKc],rules:{struct:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!1};function x8t({options:e,overrides:t}={}){return{...lSe({options:e,overrides:t}),...Vvn({options:e,overrides:t})}}var abB={shouldUseTitleAsName:"useTitlesAsName",shouldUseUndiscriminatedUnionsWithLiterals:["shouldUseUndiscriminatedUnionsWithLiterals","discriminatedUnionV2"],shouldUseIdiomaticRequestNames:"shouldUseIdiomaticRequestNames",asyncApiMessageNaming:"asyncApiNaming",shouldUseOptionalAdditionalProperties:"optionalAdditionalProperties",coerceEnumsToLiterals:"coerceEnumsToLiterals",objectQueryParameters:"objectQueryParameters",respectReadonlySchemas:"respectReadonlySchemas",respectNullableSchemas:"respectNullableSchemas",onlyIncludeReferencedSchemas:"onlyIncludeReferencedSchemas",inlinePathParameters:"inlinePathParameters",useBytesForBinaryResponse:"useBytesForBinaryResponse",respectForwardCompatibleEnums:"respectForwardCompatibleEnums",filter:"filter",defaultFormParameterEncoding:"defaultFormParameterEncoding",exampleGeneration:"exampleGeneration",additionalPropertiesDefaultsTo:"additionalPropertiesDefaultsTo",typeDatesAsStrings:"typeDatesAsStrings",preserveSingleSchemaOneOf:"preserveSingleSchemaOneOf",inlineAllOfSchemas:"inlineAllOfSchemas",resolveAliases:"resolveAliases",groupMultiApiEnvironments:"groupMultiApiEnvironments",groupEnvironmentsByHost:"groupEnvironmentsByHost",wrapReferencesToNullableInOptional:"wrapReferencesToNullableInOptional",coerceOptionalSchemasToNullable:"coerceOptionalSchemasToNullable",removeDiscriminantsFromSchemas:"removeDiscriminantsFromSchemas",defaultIntegerFormat:"defaultIntegerFormat",pathParameterOrder:"pathParameterOrder"};function obB(e,t,r){r!==void 0&&(e[t]=r)}function Fmu(e){let t={};if(e!=null)for(let[r,i]of Object.entries(abB)){let n=e[r],a=Array.isArray(i)?i:[i];for(let o of a)obB(t,o,n)}return x8t({options:t})}function xsa(e){if(e.settings==null&&e.apiOverride?.auth==null&&e.apiOverride?.["auth-schemes"]==null)return;let t={detectGlobalHeaders:!0};return e.settings?.unions==="v1"&&(t.discriminatedUnionV2=!0),e.apiOverride?.auth!=null&&(t.auth=e.apiOverride.auth),e.apiOverride?.["auth-schemes"]!=null&&(t.authSchemes=e.apiOverride["auth-schemes"]),t}function P$a(e){return e.swagger!=null}function KZc(e){return e.openapi!=null}function x$i(e,t={}){return{...Object.fromEntries(UI(e.namedDefinitionFiles).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...UI(e.importedDefinitions).reduce((r,[i,n])=>({...r,...m4a(x$i(n.definition,{defaultURL:n.url}),(a,o)=>VB(i,Vu.of(o)))}),{})}}function j$a(e,t={}){return{...Object.fromEntries(UI(e.packageMarkers).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...UI(e.importedDefinitions).reduce((r,[i,n])=>({...r,...m4a(j$a(n.definition,{defaultURL:n.url}),(a,o)=>VB(i,Vu.of(o)))}),{})}}function XUi(e){return{...j$a(e),...x$i(e)}}function gSe(e,t){return XUi(e.definition)[t]?.contents}function SC(e,t){for(let[r,i]of UI(XUi(e.definition)))t(r,i.contents,{isPackageMarker:Pdn(r)===Yb,defaultUrl:i.defaultUrl})}function wgn(e,t){for(let[r,i]of UI(j$a(e.definition)))t(r,i.contents)}var jIh={None:"none",Header:"header"};var uAu={};Yt(uAu,{ConjureAliasDeclaration:()=>xmu,ConjureArgument:()=>nAu,ConjureArgumentWithParamType:()=>iAu,ConjureAuthDefinition:()=>$sa,ConjureAuthDefinitionType:()=>tAu,ConjureDefinitions:()=>kmu,ConjureEndpointDefinition:()=>aAu,ConjureEnumDeclaration:()=>Xmu,ConjureEnumVariant:()=>Ymu,ConjureEnumWithDocs:()=>$mu,ConjureObjectDeclaration:()=>Jmu,ConjureParamType:()=>rAu,ConjurePrimitive:()=>Gmu,ConjureService:()=>oAu,ConjureServiceName:()=>Wmu,ConjureType:()=>J$i,ConjureTypeDeclaration:()=>Zmu,ConjureTypeReference:()=>$$i,ConjureTypeWithDocs:()=>Hmu,ConjureTypes:()=>eAu,ConjureUnionDeclaration:()=>Kmu,DefinitionFile:()=>ZIh,WithDocs:()=>pXt,commons:()=>ZZc,conjure:()=>kZc,services:()=>e2c,types:()=>t2c});var ZZc={};Yt(ZZc,{WithDocs:()=>pXt});var ea={};Yt(ea,{JsonError:()=>Hsa,ParseError:()=>Ksa,any:()=>QIh,bigint:()=>EIh,boolean:()=>UIh,booleanLiteral:()=>FIh,date:()=>SIh,discriminant:()=>$Ih,enum_:()=>Umu,getObjectLikeUtils:()=>H8t,getObjectUtils:()=>Egn,getSchemaUtils:()=>kP,isProperty:()=>K$i,lazy:()=>MIh,lazyObject:()=>RIh,list:()=>Vmu,number:()=>LIh,object:()=>Lmu,objectWithoutOptionalProperties:()=>TIh,optional:()=>JZc,property:()=>BIh,record:()=>xIh,set:()=>HIh,string:()=>VIh,stringLiteral:()=>NIh,transform:()=>$Zc,undiscriminatedUnion:()=>JIh,union:()=>XIh,unknown:()=>WIh,withParsedProperties:()=>XZc});var Vh={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 EA(e,t){return`Expected ${t}. Received ${ubB(e)}.`}function ubB(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 BF(e){return{...e,json:wIh(e.json),parse:wIh(e.parse)}}function wIh(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(`
|
|
1527
1527
|
`)),{ok:!0,value:t}):i}}function Qmu(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var Hsa=class e extends Error{errors;constructor(t){super(t.map(Qmu).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var Ksa=class e extends Error{errors;constructor(t){super(t.map(Qmu).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function kP(e){return{optional:()=>JZc(e),transform:t=>$Zc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new Ksa(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new Hsa(i.errors)}}}function JZc(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:()=>Vh.OPTIONAL};return{...t,...kP(t)}}function $Zc(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,...kP(r)}}function EIh(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:EA(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:EA(t,"bigint")}]},getType:()=>Vh.BIGINT};return{...BF(e),...kP(e)}}var sbB=/^([+-]?\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 SIh(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:EA(t,"string")}]}:sbB.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:EA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:EA(t,"Date object")}]},getType:()=>Vh.DATE};return{...BF(e),...kP(e)}}function VW(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...BF(r),...kP(r)}}}function Umu(e){let t=new Set(e);return VW(Vh.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:EA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:EA(i,"enum")}]}:{ok:!0,value:i})()}function MIh(e){let t=YZc(e);return{...t,...kP(t)}}function YZc(e){return{parse:(t,r)=>Jsa(e).parse(t,r),json:(t,r)=>Jsa(e).json(t,r),getType:()=>Jsa(e).getType()}}function Jsa(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function w$a(e){return Object.entries(e)}function E$a(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function H$i(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 S$a(e){return Object.keys(e)}function DIh(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function H8t(e){return{withParsedProperties:t=>XZc(e,t)}}function XZc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let o=Object.entries(t).reduce((c,[d,s])=>({...c,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...o}}},json:(i,n)=>{if(!H$i(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:EA(i,"object")}]};let a=new Set(Object.keys(t)),o=E$a(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(o,n)},getType:()=>e.getType()};return{...r,...kP(r),...H8t(r)}}function BIh(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function K$i(e){return e.isProperty}function Lmu(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>K$i(i)?i.rawKey:r),_getParsedProperties:()=>S$a(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of w$a(e)){let d=K$i(c)?c.rawKey:o,s=K$i(c)?c.valueSchema:c,u={rawKey:d,parsedKey:o,valueSchema:s};n[d]=u,qIh(s)&&a.push(d)}return IIh({value:r,requiredKeys:a,getProperty:o=>{let c=n[o];if(c!=null)return{transformedKey:c.parsedKey,transform:d=>c.valueSchema.parse(d,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],o]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,o]of w$a(e)){let c=K$i(o)?o.valueSchema:o;qIh(c)&&n.push(a)}return IIh({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return K$i(o)?{transformedKey:o.rawKey,transform:c=>o.valueSchema.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>o.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>Vh.OBJECT};return{...BF(t),...kP(t),...H8t(t),...Egn(t)}}function IIh({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!H$i(e))return{ok:!1,errors:[{path:a,message:EA(e,"object")}]};let o=new Set(t),c=[],d={};for(let[s,u]of Object.entries(e)){let l=r(s);if(l!=null){o.delete(s);let p=l.transform(u);p.ok?d[l.transformedKey]=p.value:(d[s]=u,c.push(...p.errors))}else switch(i){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=u;break}}return c.push(...t.filter(s=>o.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||n?{ok:!0,value:d}:{ok:!1,errors:c}}function Egn(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>CIh({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>CIh({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>Vh.OBJECT};return{...r,...kP(r),...H8t(r),...Egn(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:()=>Vh.OBJECT};return{...t,...kP(t),...H8t(t),...Egn(t)}}}}function CIh({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,o]=DIh(S$a(t),s=>n.has(s)),c=r(E$a(t,o)),d=i(E$a(t,a));return c.ok&&d.ok?{ok:!0,value:{...c.value,...d.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...d.ok?[]:d.errors]}}function qIh(e){return!cbB(e)}function cbB(e){switch(e.getType()){case Vh.ANY:case Vh.UNKNOWN:case Vh.OPTIONAL:return!0;default:return!1}}function TIh(e){return Lmu(e)}function RIh(e){let t={...YZc(e),_getRawProperties:()=>Jsa(e)._getRawProperties(),_getParsedProperties:()=>Jsa(e)._getParsedProperties()};return{...t,...kP(t),...H8t(t),...Egn(t)}}function Vmu(e){let t={parse:(r,i)=>zIh(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>zIh(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>Vh.LIST};return{...BF(t),...kP(t)}}function zIh(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:EA(e,"list"),path:[]}]}}function NIh(e){return VW(Vh.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:EA(r,`"${e}"`)}]})()}function FIh(e){return VW(Vh.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:EA(r,`${e.toString()}`)}]})()}var QIh=VW(Vh.ANY,e=>({ok:!0,value:e}));var UIh=VW(Vh.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:EA(e,"boolean")}]});var LIh=VW(Vh.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:EA(e,"number")}]});var VIh=VW(Vh.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:EA(e,"string")}]});var WIh=VW(Vh.UNKNOWN,e=>({ok:!0,value:e}));function xIh(e,t){let r={parse:(i,n)=>GIh({value:i,isKeyNumeric:e.getType()===Vh.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>GIh({value:i,isKeyNumeric:e.getType()===Vh.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>Vh.RECORD};return{...BF(r),...kP(r)}}function GIh({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return H$i(e)?w$a(e).reduce((a,[o,c])=>{if(c==null)return a;let d=a,s=o;if(t){let _=o.length>0?Number(o):NaN;isNaN(_)||(s=_)}let u=r(s),l=i(c,s);if(d.ok&&u.ok&&l.ok)return{ok:!0,value:{...d.value,[u.value]:l.value}};let p=[];return d.ok||p.push(...d.errors),u.ok||p.push(...u.errors),l.ok||p.push(...l.errors),{ok:!1,errors:p}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:EA(e,"object")}]}}function HIh(e){let t=Vmu(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:EA(i,"Set")}]},getType:()=>Vh.SET};return{...BF(r),...kP(r)}}function JIh(e){let t={parse:(r,i)=>KIh((n,a)=>n.parse(r,a),e,i),json:(r,i)=>KIh((n,a)=>n.json(r,a),e,i),getType:()=>Vh.UNDISCRIMINATED_UNION};return{...BF(t),...kP(t)}}function KIh(e,t,r){let i=[];for(let[n,a]of t.entries()){let o=e(a,{...r,skipValidation:!1});if(o.ok)return o;for(let c of o.errors)i.push({path:c.path,message:`[Variant ${n}] ${c.message}`})}return{ok:!1,errors:i}}function $Ih(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function XIh(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=Umu(S$a(t)),a={parse:(o,c)=>YIh({value:o,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:d=>n.parse(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(o,c)=>YIh({value:o,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:d=>n.json(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>Vh.UNION};return{...BF(a),...kP(a),...H8t(a)}}function YIh({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!H$i(e))return{ok:!1,errors:[{path:c,message:EA(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let u=i(d);if(!u.ok)return{ok:!1,errors:u.errors};let l=n(u.value);if(l==null)return a?{ok:!0,value:{[r]:u.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let p=o(s,l);return p.ok?{ok:!0,value:{[r]:d,...p.value}}:p}var pXt=ea.objectWithoutOptionalProperties({docs:ea.string().optional()});var kZc={};Yt(kZc,{ConjureServiceName:()=>Wmu,DefinitionFile:()=>ZIh});var Wmu=ea.string();var Gmu=ea.enum_(["rid","string","safelong","integer","double","boolean","binary"]);var J$i=ea.undiscriminatedUnion([Gmu,ea.string()]);var xmu=ea.objectWithoutOptionalProperties({alias:J$i,docs:ea.string().optional()});var Hmu=ea.objectWithoutOptionalProperties({type:J$i,docs:ea.string().optional()});var $$i=ea.undiscriminatedUnion([J$i,Hmu]);var Kmu=ea.objectWithoutOptionalProperties({union:ea.record(ea.string(),$$i)});var Jmu=ea.objectWithoutOptionalProperties({fields:ea.record(ea.string(),$$i)});var $mu=ea.objectWithoutOptionalProperties({value:ea.string()}).extend(pXt);var Ymu=ea.undiscriminatedUnion([ea.string(),$mu]);var Xmu=ea.objectWithoutOptionalProperties({values:ea.list(Ymu)});var Zmu=ea.undiscriminatedUnion([xmu,Kmu,Jmu,Xmu]);var kmu=ea.objectWithoutOptionalProperties({objects:ea.record(ea.string(),Zmu).optional()});var eAu=ea.objectWithoutOptionalProperties({conjureImports:ea.property("conjure-imports",ea.record(ea.string(),ea.string()).optional()),definitions:kmu.optional()});var tAu=ea.enum_(["none","header"]);var $sa=ea.undiscriminatedUnion([tAu,ea.string()]);var rAu=ea.enum_(["path","query","body"]);var iAu=ea.objectWithoutOptionalProperties({paramType:ea.property("param-type",rAu),type:ea.string()}).extend(pXt);var nAu=ea.undiscriminatedUnion([ea.string(),iAu]);var aAu=ea.objectWithoutOptionalProperties({http:ea.string(),auth:$sa.optional(),args:ea.record(ea.string(),nAu).optional(),returns:$$i.optional()}).extend(pXt);var oAu=ea.objectWithoutOptionalProperties({name:ea.string().optional(),package:ea.string().optional(),basePath:ea.property("base-path",ea.string().optional()),defaultAuth:ea.property("default-auth",$sa.optional()),endpoints:ea.record(ea.string(),aAu).optional()}).extend(pXt);var ZIh=ea.objectWithoutOptionalProperties({types:eAu.optional(),services:ea.record(Wmu,oAu).optional()});var e2c={};Yt(e2c,{ConjureArgument:()=>nAu,ConjureArgumentWithParamType:()=>iAu,ConjureAuthDefinition:()=>$sa,ConjureAuthDefinitionType:()=>tAu,ConjureEndpointDefinition:()=>aAu,ConjureParamType:()=>rAu,ConjureService:()=>oAu});var t2c={};Yt(t2c,{ConjureAliasDeclaration:()=>xmu,ConjureDefinitions:()=>kmu,ConjureEnumDeclaration:()=>Xmu,ConjureEnumVariant:()=>Ymu,ConjureEnumWithDocs:()=>$mu,ConjureObjectDeclaration:()=>Jmu,ConjurePrimitive:()=>Gmu,ConjureType:()=>J$i,ConjureTypeDeclaration:()=>Zmu,ConjureTypeReference:()=>$$i,ConjureTypeWithDocs:()=>Hmu,ConjureTypes:()=>eAu,ConjureUnionDeclaration:()=>Kmu});var kIh=require("fs/promises");async function eCh(e,t){let r=[];for(let i of await w4(e,t))r.push(await lbB({relativeFilepath:pp(e,i),absoluteFilepath:i}));return r}async function lbB({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,kIh.readFile)(t)).toString().replaceAll(/: rid(?:$|\s)/g,`: string
|
|
1528
|
-
`).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:uAu.conjure.DefinitionFile.parseOrThrow(qi.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}function tCh(e,t){if(fbB(e))return t.alias(e);if(dbB(e))return t.enum(e);if(pbB(e))return t.object(e);if(_bB(e))return t.union(e);vt(e)}function fbB(e){return e?.alias!=null}function dbB(e){return e?.values!=null}function pbB(e){return e?.fields!=null}function _bB(e){return e?.union!=null}var M$a=class extends cJa{fernDefinitionBuilder=new Kvn(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:i,globalHeaderOverrides:n}){if(r!=null){for(let[a,o]of Object.entries(r["auth-schemes"]??{}))this.fernDefinitionBuilder.addAuthScheme({name:a,schema:o});r.auth!=null&&this.fernDefinitionBuilder.setAuth(r.auth)}if(i!=null){for(let[a,o]of Object.entries(i.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:o});i["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(i["default-environment"]),i["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(i["default-url"])}return await rCh(t,(a,o,c)=>{for(let[u,l]of Object.entries(c.services??{})){let p=MRo({value:u,suffix:"Service"});this.conjureFilepathToFernFilepath[o]=Je.of(`${p}/__package__.yml`);return}let s=lNi(o)?.split(".")[0];s!=null&&(this.conjureFilepathToFernFilepath[o]=Je.of(`${s}/__package__.yml`))}),await rCh(t,(a,o,c)=>{if(c.services==null||Object.keys(c.services??{}).length===0){let d=this.conjureFilepathToFernFilepath[o];if(d==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${o}`);for(let[s,u]of Object.entries(c.types?.conjureImports??{})){let l=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Je.of(u)});this.fernDefinitionBuilder.addImport({file:d,fileToImport:Je.of(l),alias:s})}this.importAllTypes({conjureFile:c,fernFilePath:d});return}for(let[d,s]of Object.entries(c.services)){let u=MRo({value:d,suffix:"Service"}),l=Je.of(`${u}/__package__.yml`),p={};s.basePath!=null&&(p["base-path"]=s.basePath),s.docs!=null&&(p.docs=s.docs),this.fernDefinitionBuilder.setServiceInfo(l,p),this.importAllTypes({conjureFile:c,fernFilePath:l});for(let[_,h]of Object.entries(c.types?.conjureImports??{})){let y=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Je.of(h)});this.fernDefinitionBuilder.addImport({file:l,fileToImport:Je.of(y),alias:_})}for(let[_,h]of Object.entries(s.endpoints??{})){let y=Znc(h.http);if(y.type==="failure"){this.context?.logger.error(`Failed to parse ${h.http}. Skipping.`);continue}let v={auth:(h.auth??s.defaultAuth)!==jIh.None,path:y.path,method:y.method,response:h.returns==="binary"?"file":h.returns};h.docs!=null&&(v.docs=h.docs);let O={};if(h.args!=null)for(let m of y.pathParameters){let g=h.args[m];if(g==null)throw new Error(`Failed to find path parameter ${m} in ${h.http}`);O[m]=typeof g=="string"?g:{type:g.type}}Object.entries(O).length>0&&(v["path-parameters"]=O);for(let[m,g]of Object.entries(h.args??{}))if(O[m]==null)if(typeof g=="string")v.request?typeof v.request=="string"&&(v.request={body:v.request}):v.request={},v.request.body=g==="binary"?"bytes":g;else switch(g.paramType){case"body":v.request={body:g.type==="binary"?"bytes":g.type};break;case"query":v.request==null?v.request={"query-parameters":{[m]:g.type}}:typeof v.request!="string"&&v.request?.["query-parameters"]==null?v.request["query-parameters"]={[m]:g.type}:typeof v.request!="string"&&v.request?.["query-parameters"]!=null&&(v.request["query-parameters"][m]=g.type)}v.request!=null&&typeof v.request!="string"&&v.request?.["query-parameters"]!=null&&(v.request.name=`${_}Request`),this.fernDefinitionBuilder.addEndpoint(l,{name:_,schema:v,source:void 0})}}}),this.fernDefinitionBuilder.build()}convertBinaryType(t){return typeof t=="string"?t==="binary"?{type:"string",validation:{format:"binary"}}:t:t.type==="binary"?{...t,type:"string",validation:{format:"binary"}}:t}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[i,n]of Object.entries(t.types?.definitions?.objects??{}))tCh(n,{alias:a=>{let o=a.alias==="binary"?{type:"string",validation:{format:"binary"}}:a.alias;this.fernDefinitionBuilder.addType(r,{name:i,schema:typeof o=="string"?{type:o,docs:a.docs}:{...o,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{properties:Object.fromEntries(Object.entries(a.fields).map(([o,c])=>[o,this.convertBinaryType(c)]))}})},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(([o,c])=>{let d=this.convertBinaryType(c);return[o,{type:typeof d=="string"?d:d.type,docs:typeof d=="string"?void 0:d.docs,key:o}]}))}})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:i}){let n=Tt(nn(t),Je.of(r)),a=FJ(i,n),o=this.conjureFilepathToFernFilepath[a];if(o==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return o}};async function rCh(e,t){for(let r of await eCh(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}function iCh(e,t){return rn(e,t)}var sAu=class extends B8t{type="conjure";absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=Tt(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new gY({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 M$a(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:Sr.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:n.rootApiFile["default-url"],contents:n.rootApiFile,rawContents:qi.dump(n.rootApiFile)},namedDefinitionFiles:{...iCh(n.definitionFiles,a=>({absoluteFilepath:Sr.of("/DUMMY_PATH"),rawContents:qi.dump(a),contents:a})),[Je.of(Yb)]:{absoluteFilepath:Sr.of("/DUMMY_PATH"),rawContents:qi.dump(n.packageMarkerFile),contents:n.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};var PTh=ce(cCh(),1);var Wp;(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"})(Wp||(Wp={}));function lCh(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function cAu(e,t){for(let[r,i]of UI(e))ybB({relativeFilepath:r,failure:i,logger:t})}function ybB({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case Wp.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 Wp.FILE_READ:r.error("Failed to open file: "+e);break;case Wp.FILE_MISSING:r.error("Missing file: "+e);break;case Wp.FILE_PARSE:t.error instanceof L3a?r.error(b0e({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case Wp.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of bbB(i))r.error(b0e({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case Wp.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case Wp.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${vUo}: `+t.dependencyName);break;case Wp.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case Wp.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case Wp.JSONSCHEMA_VALIDATION:if(t.error.error!=null){let i=t.error.error.instancePath.split("/").filter(n=>n!=="").map(lCh);t.error.error.keyword==="required"&&t.error.error.params?.missingProperty?i.push(t.error.error.params.missingProperty):t.error.error.keyword==="additionalProperties"&&t.error.error.params?.additionalProperty&&i.push(t.error.error.params.additionalProperty),r.error(b0e({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...i]}))}for(let i of t.error.allErrors)if(i!==t.error.error){let n=i.instancePath.split("/").filter(a=>a!=="").map(lCh);i.keyword==="required"&&i.params?.missingProperty?n.push(i.params.missingProperty):i.keyword==="additionalProperties"&&i.params?.additionalProperty&&n.push(i.params.additionalProperty),r.debug(b0e({title:i.message??"Unknown error",breadcrumbs:[e,...n]}))}break;default:vt(t)}}function bbB(e){switch(e.code){case wi.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${Rt.underline(e.expected)} but received ${Rt.underline(e.received)}`}];case wi.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${Rt.underline(t)}`}));case wi.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>Rt.underline(t)).join(", ")}`}];case wi.invalid_union:case wi.invalid_arguments:case wi.invalid_return_type:case wi.invalid_date:case wi.invalid_string:case wi.too_small:case wi.too_big:case wi.invalid_intersection_types:case wi.not_multiple_of:case wi.custom:default:return[{title:e.message}]}}var fCh=require("fs/promises");async function dCh(e,t){let r=[];for(let i of await w4(e,t))r.push(await vbB({relativeFilepath:pp(e,i),absoluteFilepath:i}));return r}async function vbB({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,fCh.readFile)(t)).toString()}}async function pCh(e){let t={},r={};function i(n){try{t[n.relativeFilepath]={defaultUrl:void 0,contents:qi.load(n.fileContents,{schema:qi.CORE_SCHEMA}),rawContents:n.fileContents}}catch(a){r[n.relativeFilepath]={type:Wp.FILE_PARSE,error:a}}}return await Promise.all(e.map(i)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}var Hkc=ce(O7i(),1);var dTh=require("fs"),Oca=require("fs/promises");var pTh=require("os"),_Th=ce(require("path"),1),hTh=require("stream/promises"),yTh=ce(xkc(),1),bTh=ce(M4(),1);var JgB=dQi();async function vTh({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:i,cliVersion:n,settings:a,loadAPIWorkspace:o}){let c,d={type:Wp.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},s=t.dependencies[e];return s==null?d={type:Wp.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${tOB(s)}`},async u=>{switch(s.type){case"version":c=await kgB({context:u,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:o});return;case"local":c=await ZgB({context:u,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:o});return;default:vt(s)}}),c!=null?{didSucceed:!0,definition:c}:{didSucceed:!1,failure:d}}var gTh="dependencies";var $gB="metadata.json",YgB=".fern";function XgB(e){return Tt(Sr.of((0,pTh.homedir)()),Je.of(YgB),Je.of(gTh),Je.of(e.organization),Je.of(e.apiName),Je.of(e.version))}async function ZgB({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 o=await a.workspace.getDefinition({context:t,relativePathToDependency:Je.of(e.path)},i);return t.logger.info("Loaded..."),o}async function kgB({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){let a=XgB(e),o=Tt(a,Je.of(gTh)),c=Tt(a,Je.of($gB)),d;if(!await Ai(o)||!await Ai(c)){t.logger.info("Downloading manifest...");let l=await JgB.definitionRegistry.get(Hkc.FernFiddle.OrganizationId(e.organization),Hkc.FernFiddle.ApiId(e.apiName),e.version);if(!l.ok){l.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:y=>{t.failWithoutThrowing("Failed to download API manifest",y)}});return}let p=l.body.yamlSchemaVersion!=null?parseInt(l.body.yamlSchemaVersion):void 0,_=Avn(r),h=Avn(l.body.cliVersion);if(p!=null){if(p>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${l.body.cliVersion}`);return}else if(p<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(_.major!==h.major||_.minor!==h.minor){t.failWithoutThrowing(`CLI version is ${l.body.cliVersion}. Expected ${_.major}.${_.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+l.body.definitionS3DownloadUrl),await(0,Oca.mkdir)(o,{recursive:!0});try{await eOB({s3PreSignedReadUrl:l.body.definitionS3DownloadUrl,absolutePathToLocalOutput:o})}catch(y){t.failWithoutThrowing("Failed to download API",y);return}d=l.body,await(0,Oca.writeFile)(c,JSON.stringify(d))}else d=JSON.parse((await(0,Oca.readFile)(c)).toString());if(t.logger.info("Parsing..."),n==null){t.failWithoutThrowing("Failed to load API");return}let s=await n({absolutePathToWorkspace:o,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 eOB({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await eI.get(e,{responseType:"stream"}),i=await bTh.default.dir(),n=_Th.default.join(i.path,"api.tgz");await(0,hTh.pipeline)(r.data,(0,dTh.createWriteStream)(n)),await(0,yTh.extract)({file:n,cwd:t})}function tOB(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:vt(e)}}async function OTh({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:i,settings:n,loadAPIWorkspace:a}){let o={},c={},d={};return await Promise.all(UI(t.packageMarkers).map(async([s,u])=>{if(u.contents.export==null)o[s]=u;else{let{export:l,...p}=u.contents;if(QA(p)>0)d[s]={type:Wp.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:s};else{let _=nn(s);if(_Vt(t.namedDefinitionFiles).some(y=>y!==s&&y.startsWith(_)))d[s]={type:Wp.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:_};else{let y=await vTh({dependencyName:typeof u.contents.export=="string"?u.contents.export:u.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:i,settings:n,loadAPIWorkspace:a});y.didSucceed?c[nn(s)]={definition:y.definition,url:typeof u.contents.export=="object"?u.contents.export.url:void 0}:d[s]=y.failure}}}})),QA(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:o,importedDefinitions:c}}var mTh=ce(require("path"),1);var Kkc={};Yt(Kkc,{additionalProperties:()=>aOB,default:()=>uOB,definitions:()=>oOB,properties:()=>iOB,required:()=>nOB,type:()=>rOB});var rOB="object",iOB={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"}]}},nOB=["name"],aOB=!1,oOB={"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.EndpointSecuritySchemaDetails":{type:"object",additionalProperties:!1},"auth.EndpointSecuritySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"endpoint-security":{$ref:"#/definitions/auth.EndpointSecuritySchemaDetails"}},required:["endpoint-security"],additionalProperties:!1},"auth.ApiAuthSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"},{$ref:"#/definitions/auth.AnyAuthSchemesSchema"},{$ref:"#/definitions/auth.EndpointSecuritySchema"}]},"auth.AuthScope":{type:"string"},"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:{$ref:"#/definitions/auth.AuthScope"}},{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.TokenBearerAuthSchema":{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.InferredAuthenticatedRequestHeader":{type:"object",properties:{"response-property":{type:"string"},"header-name":{type:"string"},"value-prefix":{oneOf:[{type:"string"},{type:"null"}]}},required:["response-property","header-name"],additionalProperties:!1},"auth.InferredGetTokenEndpointSchemaObject":{type:"object",properties:{endpoint:{type:"string"},"expiry-response-property":{oneOf:[{type:"string"},{type:"null"}]},"authenticated-request-headers":{oneOf:[{type:"array",items:{$ref:"#/definitions/auth.InferredAuthenticatedRequestHeader"}},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.InferredGetTokenEndpointSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.InferredGetTokenEndpointSchemaObject"}]},"auth.InferredBearerAuthSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},"get-token":{$ref:"#/definitions/auth.InferredGetTokenEndpointSchema"}},required:["scheme","get-token"],additionalProperties:!1},"auth.BearerAuthSchemeSchema":{anyOf:[{$ref:"#/definitions/auth.TokenBearerAuthSchema"},{$ref:"#/definitions/auth.InferredBearerAuthSchema"}]},"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}},uOB={type:rOB,properties:iOB,required:nOB,additionalProperties:aOB,definitions:oOB};var Jkc={};Yt(Jkc,{additionalProperties:()=>lOB,default:()=>dOB,definitions:()=>fOB,properties:()=>cOB,type:()=>sOB});var sOB="object",cOB={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"}]}},lOB=!1,fOB={"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"}]},"auth.AuthScope":{type:"string"},"service.HttpEndpointSecurityItem":{type:"object",additionalProperties:{type:"array",items:{$ref:"#/definitions/auth.AuthScope"}}},"service.HttpEndpointSecurity":{type:"array",items:{$ref:"#/definitions/service.HttpEndpointSecurityItem"}},"service.HttpEndpointAuth":{anyOf:[{type:"boolean"},{$ref:"#/definitions/service.HttpEndpointSecurity"}]},"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.RetriesDisabledSchema":{type:"object",properties:{disabled:{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"service.RetriesConfiguration":{anyOf:[{$ref:"#/definitions/service.RetriesDisabledSchema"}]},"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:[{$ref:"#/definitions/service.HttpEndpointAuth"},{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"}]},retries:{oneOf:[{$ref:"#/definitions/service.RetriesConfiguration"},{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"},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},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"}]},"method-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}},dOB={type:sOB,properties:cOB,additionalProperties:lOB,definitions:fOB};var $kc={};Yt($kc,{additionalProperties:()=>hOB,default:()=>bOB,definitions:()=>yOB,properties:()=>_OB,type:()=>pOB});var pOB="object",_OB={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"}]}},hOB=!1,yOB={"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"}]},"auth.AuthScope":{type:"string"},"service.HttpEndpointSecurityItem":{type:"object",additionalProperties:{type:"array",items:{$ref:"#/definitions/auth.AuthScope"}}},"service.HttpEndpointSecurity":{type:"array",items:{$ref:"#/definitions/service.HttpEndpointSecurityItem"}},"service.HttpEndpointAuth":{anyOf:[{type:"boolean"},{$ref:"#/definitions/service.HttpEndpointSecurity"}]},"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.RetriesDisabledSchema":{type:"object",properties:{disabled:{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"service.RetriesConfiguration":{anyOf:[{$ref:"#/definitions/service.RetriesDisabledSchema"}]},"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:[{$ref:"#/definitions/service.HttpEndpointAuth"},{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"}]},retries:{oneOf:[{$ref:"#/definitions/service.RetriesConfiguration"},{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"},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},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"}]},"method-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"}]}},bOB={type:pOB,properties:_OB,additionalProperties:hOB,definitions:yOB};function ATh({files:e,absolutePathToDefinition:t}){let r,i={},n={},a={};for(let[o,c]of UI(e)){let d=c.contents,s=u=>{a[o]={type:Wp.JSONSCHEMA_VALIDATION,error:u}};if(o===GB){let u=OVt(d,Kkc);if(u.success){let l=cI.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:l["default-url"],contents:l,rawContents:c.rawContents}}else s(u)}else if(mTh.default.basename(o)===Yb){let u=OVt(d,$kc);if(u.success){let l=cI.serialization.PackageMarkerFileSchema.parseOrThrow(d);n[o]={defaultUrl:typeof l.export=="object"?l.export.url:void 0,contents:l,rawContents:c.rawContents}}else s(u)}else{let u=OVt(d,Jkc);if(u.success){let l=cI.serialization.DefinitionFileSchema.parseOrThrow(d);i[o]={defaultUrl:void 0,contents:l,rawContents:c.rawContents,absoluteFilePath:Tt(t,o)}}else s(u)}}return r==null?{didSucceed:!1,failures:{[Je.of(GB)]:{type:Wp.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:i,rootApiFile:r,packageMarkers:n}}var ESe=class extends B8t{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,PTh.default)(r??{}),n=this.fernWorkspaces[i];if(n==null){let a=t||this.context,o=Tt(this.absoluteFilePath,Je.of(e1)),c=await wbc({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await dCh(o,"{yml,yaml}"),s=await pCh(d);if(!s.didSucceed)return cAu(s.failures,a.logger),a.failAndThrow();let u=ATh({files:s.files,absolutePathToDefinition:o});if(!u.didSucceed)return cAu(u.failures,a.logger),a.failAndThrow();let l=await OTh({dependenciesConfiguration:c,structuralValidationResult:u,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!l.didSucceed)return cAu(l.failures,a.logger),a.failAndThrow();let p={absoluteFilePath:o,rootApiFile:u.rootApiFile,namedDefinitionFiles:u.namedDefinitionFiles,packageMarkers:l.packageMarkers,importedDefinitions:l.importedDefinitions};r?.auth!=null&&(p={...p,rootApiFile:{...p.rootApiFile,contents:{...p.rootApiFile.contents,auth:r?.auth}}}),n=new gY({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:c,workspaceName:this.workspaceName,definition:p,cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[i]=n}return n}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var tzh=require("fs/promises");var JRh=ce(KRh(),1);async function pYa(e){return(await(0,JRh.convertObj)(e,{})).openapi}var YRh=require("fs/promises");var $Rh=require("fs/promises");async function Mca({absoluteFilePathToOverrides:e,data:t,context:r,allowNullKeys:i}){let n=null;try{let a=(await(0,$Rh.readFile)(e,"utf8")).toString();try{n=JSON.parse(a)}catch{n=qi.load(a,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return Jnc({data:t,overrides:n,allowNullKeys:i})}async function vel({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,YRh.readFile)(t)).toString(),n=await qi.load(i);return r!=null?await Mca({absoluteFilePathToOverrides:r,context:e,data:n}):n}var ezh=require("fs/promises");var qPu=require("fs/promises");var CPu=ce(require("path"),1),XRh=ce(M4(),1),gel;async function oAB(){return gel===void 0&&(gel=(await XRh.default.dir({prefix:"fern-overlay-"})).path),gel}async function ZRh({absoluteFilePathToOverlay:e,absoluteFilePathToOpenAPI:t,data:r,context:i}){let n=await uAB(e,i);if(!sAB(n,i))return r;i.logger.debug(`Applying overlay "${n.info.title}" v${n.info.version}`);let a=Lnc({data:r,overlay:n}),o=await oAB(),c=CPu.default.basename(t),d=`${CPu.default.parse(c).name}.overlaid.json`,s=CPu.default.join(o,d);return await(0,qPu.writeFile)(s,JSON.stringify(a,null,2),"utf8"),i.logger.info(`Wrote overlaid OpenAPI spec to: ${s}`),a}async function uAB(e,t){let r;try{r=await(0,qPu.readFile)(e,"utf8")}catch(i){return t.failAndThrow(`Failed to read overlay file at ${e}: ${i}`)}try{try{return JSON.parse(r)}catch{return qi.load(r,{json:!0})}}catch(i){return t.failAndThrow(`Failed to parse overlay file at ${e}: ${i}`)}}function sAB(e,t){if(!e.overlay)return t.logger.error("Overlay file missing required 'overlay' version field"),!1;if(!e.info?.title||!e.info?.version)return t.logger.error("Overlay file missing required 'info.title' or 'info.version' field"),!1;if(!Array.isArray(e.actions)||e.actions.length===0)return t.logger.error("Overlay file must have at least one action"),!1;for(let r=0;r<e.actions.length;r++){let i=e.actions[r];if(!i?.target)return t.logger.error(`Overlay action at index ${r} missing required 'target' field`),!1;if(i.update===void 0&&!i.remove)return t.logger.error(`Overlay action at index ${r} must have either 'update' or 'remove'`),!1}return!0}var yYa=ce(zmu(),1);var kRh=ce(zmu(),1),_Ya=ce(require("path"),1),hYa=class extends kRh.BaseResolver{absolutePathToOpenAPIOverrides;absolutePathToOpenAPIOverlays;constructor({absolutePathToOpenAPIOverrides:t,absolutePathToOpenAPIOverlays:r}){super(),this.absolutePathToOpenAPIOverrides=t,this.absolutePathToOpenAPIOverlays=r}resolveExternalRef(t,r){let i=super.resolveExternalRef(t,r);if(i.startsWith("http://")||i.startsWith("https://")||E0e(Sr.of(i)))return i;if(this.absolutePathToOpenAPIOverlays!=null){let n=_Ya.default.resolve(_Ya.default.dirname(this.absolutePathToOpenAPIOverlays),r);if(E0e(Sr.of(n)))return n}return this.absolutePathToOpenAPIOverrides!=null?_Ya.default.resolve(_Ya.default.dirname(this.absolutePathToOpenAPIOverrides),r):i}};async function Oel({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,absolutePathToOpenAPIOverlays:r,parsed:i}){return(i!=null?await(0,yYa.bundle)({...Nmu,doc:{source:new yYa.Source(e,"<openapi>"),parsed:i},externalRefResolver:new hYa({absolutePathToOpenAPIOverrides:t,absolutePathToOpenAPIOverlays:r})}):await(0,yYa.bundle)({...Nmu,ref:e,externalRefResolver:new hYa({absolutePathToOpenAPIOverrides:t,absolutePathToOpenAPIOverlays:r})})).bundle.parsed}function cAB(e,t){if(t.includes(e))return e;for(let r of t){let i=r.replace(/\{[^}]+\}/g,"([^/]+)");if(new RegExp(`^${i}$`).test(e))return r}}var lAB=["examples","example",xi.EXAMPLES,PL.REDOCLY_CODE_SAMPLES_CAMEL,PL.REDOCLY_CODE_SAMPLES_KEBAB];async function bYa({context:e,absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r,absolutePathToOpenAPIOverlays:i}){let n=await Oel({absolutePathToOpenAPI:t}),a;r!=null?a=r:typeof n=="object"&&n[xi.OPENAPI_OVERIDES_FILEPATH]!=null&&(a=Tt(nn(t),Je.of(n[xi.OPENAPI_OVERIDES_FILEPATH])));let o=n;a!=null&&(o=await Mca({absoluteFilePathToOverrides:a,context:e,data:o,allowNullKeys:lAB})),i!=null&&(o=await ZRh({absoluteFilePathToOverlay:i,absoluteFilePathToOpenAPI:t,context:e,data:o}));let c=Tt(nn(t),Je.of("ai_examples_override.yml"));try{let d=await(0,ezh.readFile)(c,"utf-8"),s=qi.load(d);if(s?.paths&&o.paths){for(let[u,l]of Object.entries(s.paths))if(l&&typeof l=="object")for(let[p,_]of Object.entries(l)){let h=p.toLowerCase(),y=o.paths[u];if(!y&&o.paths){let b=cAB(u,Object.keys(o.paths));b&&(y=o.paths[b],e.logger.debug(`Matched override path "${u}" to OpenAPI path "${b}" using pattern matching`))}if(y&&typeof y=="object"){let v=y[h];if(v&&typeof v=="object"){let O=v;!O["x-fern-examples"]&&_["x-fern-examples"]&&(O["x-fern-examples"]=_["x-fern-examples"],e.logger.debug(`Added AI examples for ${p.toUpperCase()} ${u} from override file`))}}}}e.logger.debug(`Processed AI examples from ${c}`)}catch{}return a!=null||i!=null||o!==n?await Oel({absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:a,absolutePathToOpenAPIOverlays:i,parsed:o}):o}var Y8t=class{absoluteFilePath;constructor(t){this.absoluteFilePath=t}async loadDocuments({context:t,specs:r}){let i=[];for(let n of r)try{let a=(await(0,tzh.readFile)(n.absoluteFilepath)).toString(),o=pp(this.absoluteFilePath,n.source.file);n.source.relativePathToDependency!=null&&(o=Tt(n.source.relativePathToDependency,o));let c=n.source.type==="protobuf"?CW.protobuf({file:o}):CW.openapi({file:o});if(a.includes("openapi")||a.includes("swagger"))try{let d=await bYa({absolutePathToOpenAPI:n.absoluteFilepath,context:t,absolutePathToOpenAPIOverrides:n.absoluteFilepathToOverrides,absolutePathToOpenAPIOverlays:n.absoluteFilepathToOverlays});if(KZc(d)){i.push({type:"openapi",value:d,source:c,namespace:n.namespace,settings:lSe({options:n.settings})});continue}else if(P$a(d)){(!d.schemes||d.schemes.length===0)&&(d.schemes=["https"]);let s=await pYa(d);i.push({type:"openapi",value:s,source:c,namespace:n.namespace,settings:lSe({options:n.settings})});continue}}catch(d){t.logger.debug(`Failed to parse OpenAPI document at ${n.absoluteFilepath}: ${d}. Skipping...`);continue}if(a.includes("asyncapi"))try{let d=await vel({context:t,absoluteFilePath:n.absoluteFilepath,absoluteFilePathToOverrides:n.absoluteFilepathToOverrides});i.push({type:"asyncapi",value:d,source:c,namespace:n.namespace,settings:lSe({options:n.settings})});continue}catch(d){t.logger.error(`Failed to parse AsyncAPI document at ${n.absoluteFilepath}: ${d}. Skipping...`);continue}if(a.includes("openrpc"))try{let d=await vel({context:t,absoluteFilePath:n.absoluteFilepath,absoluteFilePathToOverrides:n.absoluteFilepathToOverrides});i.push({type:"asyncapi",value:d,source:c,namespace:n.namespace,settings:lSe({options:n.settings})});continue}catch(d){t.logger.error(`Failed to parse OpenRPC document at ${n.absoluteFilepath}: ${d}. Skipping...`);continue}t.logger.warn(`${n.absoluteFilepath} is not a valid OpenAPI, AsyncAPI, or OpenRPC file. Skipping...`)}catch(a){t.logger.error(`Failed to read or process file ${n.absoluteFilepath}: ${a}. Skipping...`);continue}return i}};var fAB=Qt.object({type:Qt.string(),channelId:Qt.string().optional(),messageId:Qt.string(),value:Qt.any()}),dAB=Qt.object({summary:Qt.string().optional(),description:Qt.string().optional(),"query-parameters":Qt.record(Qt.string()).optional(),headers:Qt.record(Qt.string()).optional(),messages:Qt.array(fAB)}),rzh=Qt.array(dAB);var TPu=class extends fl{channel;baseDir;key="x-fern-examples";constructor({breadcrumbs:t,channel:r,context:i,baseDir:n}){super({breadcrumbs:t??[],context:i}),this.channel=r,this.baseDir=n}convert(){let t=this.getExtensionValue(this.channel);if(t==null)return;let r=rzh.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 Dca=class extends Oa{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 TPu({context:this.context,breadcrumbs:this.breadcrumbs,channel:this.channel,baseDir:this.context.documentBaseDir}).convert();return a==null?{}:Object.fromEntries(a.map((o,c)=>[c.toString(),{channel:{method:"GET",path:t},baseUrl:t,environment:r,auth:void 0,pathParameters:{},queryParameters:o.queryParameters,headers:o.headers,messages:o.messages.map(d=>({type:i==="v2"?d.type:d.messageId,body:d.value}))}]))}transformToValidPath(t){return t.startsWith("/")?t:"/"+t}};var bYi=class extends Nm.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 NR.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},c=new Nm.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 c!=null&&(t=c.type,r=c.inlinedTypes??{}),this.convertToOutput({schema:a,typeReference:t,inlinedTypes:r})}};var RPu=class extends fl{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 Bca=class extends fl{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 zPu=class extends Dca{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 Bca({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 o;this.channel.subscribe!=null&&(o=this.convertMessage({context:this.context,operation:this.channel.subscribe,origin:"server"}));let c;this.channel.publish!=null&&(c=this.convertMessage({context:this.context,operation:this.channel.publish,origin:"client"}));let d=[];o!=null&&d.push(o),c!=null&&d.push(c);let u=new RPu({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert(),l=this.transformToValidPath(u??this.channelPath),p=this.channel.servers?.[0]??Object.keys(this.context.spec.servers??{})[0],_=DM(l),h=ou(this.channelPath),y=this.context.getAudiences({operation:this.channel,breadcrumbs:this.breadcrumbs})??[];return{channel:{name:this.context.casingsGenerator.generateName(h),displayName:a,baseUrl:p,path:_,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:l,baseUrl:p,asyncApiVersion:"v2"})}},audiences:y,inlinedTypes:this.inlinedTypes}}convertMessage({context:t,operation:r,origin:i}){let n,a=i==="server"?"subscribe":"publish",o=[...this.breadcrumbs,a],c=t.resolveMaybeReference({schemaOrReference:r.message,breadcrumbs:o});c!=null&&(r.message=c);let d=Jfn(ou(`${this.channelPath}_${a}`)).replace(/ /g,"");if("oneOf"in r.message){let u=new Nm.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:o,schemaOrReference:r.message,schemaIdOverride:d}).convert();u!=null&&u.schema!=null&&(n=u.schema,this.inlinedTypes={...this.inlinedTypes,...u.inlinedTypes})}else if(t.isMessageWithPayload(r.message)){let s=t.resolveMaybeReference({schemaOrReference:r.message.payload,breadcrumbs:o});if(s!=null){let l=new Nm.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:o,schemaOrReference:s,schemaIdOverride:d}).convert();l!=null&&l.schema!=null&&(n=l.schema,this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes})}}if(n!=null){let s=n,u=ii.named({fernFilepath:t.createFernFilepath(),name:s.typeDeclaration.name.name,typeId:s.typeDeclaration.name.typeId,displayName:void 0,default:void 0,inline:!1}),l=bL.reference({bodyType:u,docs:r.description}),p=i==="server"?"subscribe":"publish";return{type:p,displayName:p,origin:i,body:l,availability:t.getAvailability({node:r,breadcrumbs:this.breadcrumbs}),docs:r.description,methodName:void 0}}}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 c=new bYi({context:this.context,breadcrumbs:this.breadcrumbs,parameter:{...a,name:i,in:"path",description:a.description,required:a.required??!0}}).convert();c!=null&&(this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes},c.type==="path"&&r.push(c.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 o=t.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,n]});if(o==null)continue;let d=new bYi({context:this.context,breadcrumbs:[...this.breadcrumbs,n],parameter:{name:n,in:"header",required:i.includes(n),schema:o,description:"description"in o?o.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 o=t.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,n]});if(o==null)continue;let d=new bYi({context:this.context,breadcrumbs:[...this.breadcrumbs,n],parameter:{name:n,in:"query",required:i.includes(n),schema:o,description:"description"in o?o.description:void 0,deprecated:o.deprecated??!1}}).convert();d!=null&&d.type==="query"&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},r.push(d.parameter))}}}};var Ica=class extends Oa{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:SM.singleBaseUrl({environments:t})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var NPu=class extends Ica{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 mel="$message.",izh="#/channels/",nzh="#/servers/",FPu=class extends Dca{operations;inlinedTypes={};constructor({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a,operations:o}){super({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a}),this.operations=o}convert(){let t=[],r=[],i=[],a=new Bca({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 o=Object.entries(this.operations).reduce((p,[_,h])=>{try{this.getChannelPathFromOperation(h)===this.channelPath&&(p[_]=h)}catch{}return p},{}),c=[];for(let[p,_]of Object.entries(o))for(let h of _.messages){let y=this.context.convertReferenceToTypeReference({reference:h});if(y.ok){let b=bL.reference({bodyType:y.reference,docs:_.description});c.push({type:p,displayName:p,origin:_.action==="send"?"client":"server",body:b,availability:this.context.getAvailability({node:_,breadcrumbs:this.breadcrumbs}),docs:_.description,methodName:void 0})}}let d=this.resolveChannelServersFromReference(this.channel.servers??[])??Object.keys(this.context.spec.servers??{})[0],s=this.transformToValidPath(this.channel.address??this.channelPath),u=DM(s),l=this.context.getAudiences({operation:this.channel,breadcrumbs:this.breadcrumbs})??[];return{channel:{name:this.context.casingsGenerator.generateName(a),displayName:a,baseUrl:d,path:u,auth:!1,headers:i,queryParameters:r,pathParameters:t,messages:c,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:l,inlinedTypes:this.inlinedTypes}}convertChannelParameters({pathParameters:t,queryParameters:r,headers:i,channelPath:n}){for(let a of Object.values(this.channel.parameters??{})){let o=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,"parameters"]});if(o==null)continue;let c=this.convertChannelParameterLocation(o.location);if(c==null)continue;let{type:d,parameterKey:s}=c,l=new bYi({context:this.context,breadcrumbs:this.breadcrumbs,parameter:{...o,name:s,in:d},parameterNamePrefix:this.channelPath}).convert();if(l!=null)switch(this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes},l.type){case"path":t.push(l.parameter);break;case"query":r.push(l.parameter);break;case"header":i.push(l.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(mel)){this.context.errorCollector.collect({message:`Invalid location format: ${t}; expected ${mel} prefix`,path:this.breadcrumbs});return}let n=r.substring(mel.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(nzh)){this.context.errorCollector.collect({message:`Failed to resolve server name from server ref ${r.$ref}`,path:this.breadcrumbs});return}let i=r.$ref.substring(nzh.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(izh))throw new Error(`Failed to resolve channel path from operation ${t.channel.$ref}`);return t.channel.$ref.substring(izh.length)}};var QPu=class extends Ica{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 vYa=class extends w8t{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 o=["channels",r,"messages",n],c=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:o});if(!this.context.isMessageWithPayload(c))continue;let d=this.context.resolveMaybeReference({schemaOrReference:c.payload,breadcrumbs:o});if(d==null)continue;let s=`${r}_${n}`;this.convertSchema({id:s,breadcrumbs:o,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 Nm.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:r,schema:i}).convert();a!=null&&this.addSchemaOutputToIr(t,a)}convertServers(){let t;if(this.isAsyncAPIV3(this.context)){let r=this.context.spec.servers;t=new QPu({context:this.context,breadcrumbs:["servers"],servers:r}).convert()}else{let r=this.context.spec.servers;t=new NPu({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 NR.SdkGroupNameExtension({breadcrumbs:["channels",t],operation:r,context:this.context}).convert()?.groups,a;if(this.isAsyncAPIV3(this.context)){let c=this.context.spec.operations??{};a=new FPu({context:this.context,breadcrumbs:["channels",t],websocketGroup:n,channel:r,channelPath:t,operations:c}).convert()}else a=new zPu({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 gYa=class extends bC{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,o=t.$ref.match(/^.*\/schemas\/(.+)$/),c=t.$ref.match(/^.*\/channels\/([^/]+)\/messages\/(.+)$/),d=t.$ref.match(/^.*\/messages\/(.+)$/);if(o&&o[1])return a=o[1],this.convertSchemaReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a});if(c&&c[2]){let s=c[1],u=c[2];return a=`${s}_${u}`,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 o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return n==="reference_identifier"?c=i??o.value.title:(n==="discriminator_key"||n==="schema_identifier")&&(c=o.value.title??i),{ok:!0,reference:ii.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}convertV3MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a}){let o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return n==="reference_identifier"?c=i??o.value.name:(n==="discriminator_key"||n==="schema_identifier")&&(c=o.value.name??i),{ok:!0,reference:ii.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}convertV2MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a}){let o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return n==="reference_identifier"?c=i??o.value.messageId??o.value.name:(n==="discriminator_key"||n==="schema_identifier")&&(c=o.value.messageId??o.value.name??i),{ok:!0,reference:ii.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}};var fzh=ce(UPu(),1);var LPu=class extends fl{document;key="x-fern-base-path";constructor({breadcrumbs:t,document:r,context:i}){super({breadcrumbs:t,context:i}),this.document=r}convert(){let t=this.getExtensionValue(this.document);if(t!=null){if(typeof t!="string"){this.context.errorCollector.collect({message:"Received unexpected non-string value for x-fern-base-path",path:this.breadcrumbs});return}return t}}};var VPu=class extends fl{document;key="x-fern-global-headers";constructor({breadcrumbs:t,document:r,context:i}){super({breadcrumbs:t,context:i}),this.document=r}convert(){let t=this.getExtensionValue(this.document);if(t!=null){if(!Array.isArray(t)){this.context.errorCollector.collect({message:"Received unexpected non-array value for x-fern-global-headers",path:this.breadcrumbs});return}return t}}};function azh({globalHeaders:e,context:t}){return e.map(r=>({name:t.casingsGenerator.generateNameAndWireValue({name:r.name??"",wireValue:r.header}),valueType:r.optional?Oa.OPTIONAL_STRING:Oa.STRING,env:r.env,v2Examples:r.optional?void 0:hAB({header:r,context:t}),availability:void 0,docs:void 0}))}function hAB({header:e,context:t}){let r=new OF({breadcrumbs:[],context:t,schema:{type:"string"},example:e.header}),{validExample:i}=r.convert();return{userSpecifiedExamples:{},autogeneratedExamples:{globalHeaderExample:i}}}var WPu=class extends Nm.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 Nm.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,this.parameter.name,"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 GPu=class extends Nm.AbstractConverters.AbstractMediaTypeObjectConverter{contentType;mediaType;description;required;schemaId;streamingExtension;queryParameters;constructor({context:t,breadcrumbs:r,contentType:i,mediaType:n,description:a,required:o,group:c,method:d,streamingExtension:s,queryParameters:u}){super({context:t,breadcrumbs:r,group:c,method:d}),this.contentType=i,this.mediaType=n,this.description=a,this.required=o,this.schemaId=[...this.group,this.method,"Request"].join("_"),this.streamingExtension=s,this.queryParameters=u??[]}convert(){return this.streamingExtension?.type=="streamCondition"?this.convertStreamConditionRequestBody():this.convertNonStreamConditionRequestBody()}convertStreamConditionRequestBody(){if(this.isOrderedJsonOrFormContentType())return this.handleStreamConditionJsonOrFormContent({contentType:this.contentType})}convertNonStreamConditionRequestBody(){if(this.isOrderedJsonOrFormContentType())return this.handleJsonOrFormContent({contentType:this.contentType});if(em.parse(this.contentType)?.isMultipart())return this.handleMultipartContent({contentType:this.contentType});if(this.isBinaryContentType())return this.handleBinaryContent({contentType:this.contentType})}isOrderedJsonOrFormContentType(){let t=em.parse(this.contentType);return t?t.isJSON()||t.isURLEncoded()||t.isPlainText()||t.isCSV()||t.isHTML()||t.isXML()||t.isDNS()||t.isApplicationText():!1}isBinaryContentType(){let t=em.parse(this.contentType);return t?t.isBinary():!1}handleJsonOrFormContent({contentType:t}){let r=this.mediaType;if(r==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,contentType:t});if(i==null)return;let n=i.schema?.typeDeclaration.shape;return n?.type==="object"?this.hasBodyQueryParameterOverlap(n.properties)?{requestBody:zm.reference({contentType:t,docs:this.description,requestBodyType:i.type,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:i.inlinedTypes??{}}:{requestBody:zm.inlinedRequestBody({contentType:t,docs:this.description,name:this.context.casingsGenerator.generateName(this.schemaId),extendedProperties:n.extendedProperties,extends:n.extends,properties:n.properties,extraProperties:n.extraProperties,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:i.inlinedTypes})}:{requestBody:zm.reference({contentType:t,docs:this.description,requestBodyType:i.type,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:i.inlinedTypes??{}}}handleMultipartContent({contentType:t}){let r=this.mediaType;if(r==null||r.schema==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,resolveSchema:!0,contentType:t});if(i==null)return;let n=i.schema?.typeDeclaration.shape;if(n?.type==="object")return{requestBody:zm.fileUpload({contentType:t,docs:this.description,name:this.context.casingsGenerator.generateName(this.schemaId),properties:n.properties.map(a=>{let o=r.encoding?.[a.name.wireValue];return this.convertRequestBodyProperty({property:a,contentType:t,encoding:o})}),v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:i.inlinedTypes}),examples:i.examples}}handleBinaryContent({contentType:t}){let r=this.mediaType;if(r==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,contentType:t});return{requestBody:zm.bytes({contentType:t,isOptional:this.required===!1,docs:this.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:i?.inlinedTypes??{}}}convertRequestBodyProperty({property:t,contentType:r,encoding:i}){let{isFile:n,isOptional:a,isArray:o}=this.recursivelyCheckTypeReferenceIsFile({typeReference:t.valueType});return n?o?D1.file(fY.fileArray({key:t.name,isOptional:a,contentType:r,docs:t.docs})):D1.file(fY.file({key:t.name,isOptional:a,contentType:r,docs:t.docs})):D1.bodyProperty({...t,contentType:i?.contentType??r,style:bAB({encoding:i}),name:t.name})}handleStreamConditionJsonOrFormContent({contentType:t}){if(this.streamingExtension?.type!=="streamCondition")return;let r=this.mediaType;if(r==null||r.schema==null)return;let i=this.context.resolveMaybeReference({schemaOrReference:r.schema,breadcrumbs:[...this.breadcrumbs,"content",t,"schema"]});if(i==null)return;let n=i.properties?.[this.streamingExtension.streamConditionProperty];if(n==null||this.context.isReferenceObject(n))return;let a=this.buildStreamConditionInlinedRequestBody({streamConditionProperty:n,resolvedMediaTypeSchema:i,isStreaming:!0,contentType:t,mediaTypeObject:r}),o=this.buildStreamConditionInlinedRequestBody({streamConditionProperty:n,resolvedMediaTypeSchema:i,isStreaming:!1,contentType:t,mediaTypeObject:r});if(!(a==null||o==null))return{requestBody:o.requestBody,streamRequestBody:a.requestBody,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:{...a.inlinedTypes,...o.inlinedTypes}})}}buildStreamConditionInlinedRequestBody({streamConditionProperty:t,resolvedMediaTypeSchema:r,isStreaming:i,contentType:n,mediaTypeObject:a}){if(this.streamingExtension==null||this.streamingExtension.type!=="streamCondition")return;let o={...r,properties:{...r.properties,[this.streamingExtension.streamConditionProperty]:{type:"boolean",const:i,...t}},required:[...r.required??[],this.streamingExtension.streamConditionProperty]},c={...a,schema:o},d=this.parseMediaTypeObject({mediaTypeObject:c,schemaId:this.schemaId,contentType:n});if(d==null)return;let s=d.schema?.typeDeclaration.shape;if(s?.type==="object")return{requestBody:zm.inlinedRequestBody({contentType:n,docs:void 0,name:this.context.casingsGenerator.generateName(i?`${this.schemaId}_streaming`:this.schemaId),extendedProperties:s.extendedProperties,extends:s.extends,properties:s.properties,extraProperties:s.extraProperties,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:c,exampleGenerationStrategy:"request"})}),inlinedTypes:d.inlinedTypes}}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}}hasBodyQueryParameterOverlap(t){if(this.queryParameters.length===0)return!1;let r=new Set(this.queryParameters.map(i=>i.name.wireValue.toLowerCase()));return t.some(i=>r.has(i.name.wireValue.toLowerCase()))}},yAB={"application/json":"json"};function bAB({encoding:e}){if(e){if(e.explode)return"exploded";if(e.style==="form")return"form";if(e.contentType)return yAB[e.contentType]}}var vAB=/{([^}]+)}/g,gAB=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]),Cca=class extends Oa{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 uw.Get;case"post":return uw.Post;case"put":return uw.Put;case"delete":return uw.Delete;case"patch":return uw.Patch;case"head":return uw.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 o=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:t});if(o==null)continue;let d=new WPu({context:this.context,breadcrumbs:t,parameter:o}).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,u=d.parameter.name.wireValue,l=!1,p=this.context.authOverrides?.["auth-schemes"];if(p!=null){for(let h of Object.values(p))if(PAB(h)&&h.header.toLowerCase()===u.toLowerCase()){l=!0;break}}let _=this.context.globalHeaderNames;if(_!=null){for(let h of _)if(h.toLowerCase()===u.toLowerCase()){l=!0;break}}!gAB.has(s.toLowerCase())&&!l&&n.push(d.parameter);break}}}return this.checkMissingPathParameters(r),{pathParameters:r,queryParameters:i,headers:n}}checkMissingPathParameters(t){let i=[...this.path.matchAll(vAB)].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:Oa.STRING,docs:void 0,location:"ENDPOINT",variable:void 0,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{[a]:this.generateStringParameterExample({example:n})}},explode:void 0})}}convertRequestBody({breadcrumbs:t,group:r,method:i,streamingExtension:n,queryParameters:a}){if(this.operation.requestBody==null)return;let o=this.context.resolveMaybeReference({schemaOrReference:this.operation.requestBody,breadcrumbs:t});if(o==null)return null;let c=[];for(let[d,s]of Object.entries(o.content)){let l=new GPu({context:this.context,breadcrumbs:t,contentType:d,mediaType:s,description:o.description,required:o.required,group:r??[],method:i,streamingExtension:n,queryParameters:a}).convert();l!=null&&(this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes},c.push({requestBody:l.requestBody,streamRequestBody:l.streamRequestBody,examples:l.examples}))}return c}computeGroupNameAndLocationFromExtensions(){let r=new NR.SdkMethodNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert()?.methodName,n=new NR.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?ou(this.operation.summary):ou(`${this.method}_${this.path.split("/").join("_")}`))}computeGroupNameFromTagAndOperationId(){let t=this.operation.tags?.[0],r=this.evaluateMethodNameFromOperation();if(t==null)return{method:r};let i=ozh(t),n=ozh(r);return rR(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((c,d)=>c!==n[d]))return{group:[t],method:i};let o=n.slice(r.length);return{group:[t],method:ou(o.join("_"))}}generateStringParameterExample({example:t}){let r=new Nm.ExampleConverter({breadcrumbs:this.breadcrumbs,context:this.context,schema:{type:"string"},example:t}),{validExample:i}=r.convert();return i}};function ozh(e){let t=OAB(e)?mAB(e):AAB(e);return t=t.map(r=>r.toLowerCase()),t=u0e(t),t}function OAB(e){return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)}function mAB(e){return e.split(/(?=[A-Z])/)}function AAB(e){return e.split(/[^a-zA-Z0-9]+/)}function PAB(e){return e?.header!=null}var qca=class extends Cca{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,queryParameters:o}=this.convertParameters({breadcrumbs:n}),c=this.convertRequestBody({breadcrumbs:n,group:r,method:i,streamingExtension:void 0,queryParameters:o});if(c==null)return;let d=c[0]?.requestBody;if(d==null)return;let s,u;if(d.type==="inlinedRequestBody")s=dF.inlinedPayload({name:d.name,extends:d.extends,properties:d.properties});else if(d.type==="reference")s=dF.reference({payloadType:d.requestBodyType,docs:d.docs});else if(d.type==="fileUpload")u={name:d.name,properties:d.properties,docs:d.docs,v2Examples:d.v2Examples,contentType:d.contentType},s=dF.inlinedPayload({name:d.name,extends:[],properties:[]});else return;let l=this.convertWebhookResponses();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:s,fileUploadPayload:u,responses:l.length>0?l:void 0,examples:[],availability:this.context.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs}),docs:this.operation.description,v2Examples:{autogeneratedExamples:this.getWebhookV2ExamplesFromRequestBodyV2Examples(d.v2Examples?.autogeneratedExamples??{}),userSpecifiedExamples:this.getWebhookV2ExamplesFromRequestBodyV2Examples(d.v2Examples?.userSpecifiedExamples??{})}},inlinedTypes:this.inlinedTypes}}convertWebhookResponses(){let t=[];if(this.operation.responses==null)return t;for(let[r,i]of Object.entries(this.operation.responses)){let n=/^\d[Xx]{2}$/.test(r),a;if(n)a=parseInt(r.charAt(0))*100;else if(a=parseInt(r),isNaN(a))continue;let c=this.context.resolveMaybeReference({schemaOrReference:i,breadcrumbs:[...this.breadcrumbs,"responses",r]})?.description;t.push({statusCode:a,isWildcardStatusCode:n?!0:void 0,body:void 0,docs:c})}return t}getWebhookV2ExamplesFromRequestBodyV2Examples(t){return Object.fromEntries(Object.entries(t).map(([r,i])=>[r,{name:r,payload:i}]))}};var jel=ce(UPu(),1);var uzh=["get","post","put","delete","patch","head"];var xPu=class extends fl{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 jAB=Qt.object({cursor:Qt.string(),next_cursor:Qt.string(),results:Qt.string()}),wAB=Qt.object({offset:Qt.string(),results:Qt.string(),step:Qt.string().optional(),"has-next-page":Qt.string().optional()}),Ael=Qt.union([Qt.boolean(),jAB,wAB]);var Pel="$request.",HPu="$response.",KPu=class extends fl{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=Ael.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=Ael.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:bC.maybeTrimPrefix(r.cursor,Pel),nextCursor:bC.maybeTrimPrefix(r.next_cursor,HPu),results:bC.maybeTrimPrefix(r.results,HPu)};let i=t;return{type:"offset",offset:bC.maybeTrimPrefix(i.offset,Pel),results:bC.maybeTrimPrefix(i.results,HPu),step:i.step!=null?bC.maybeTrimPrefix(i.step,Pel):void 0,hasNextPage:i["has-next-page"]!=null?bC.maybeTrimPrefix(i["has-next-page"],HPu):void 0}}};var EAB="$request.",SAB=Qt.object({"stream-condition":Qt.string().optional(),format:Qt.enum(["sse","json"]).optional(),"stream-description":Qt.string().optional(),"response-stream":Qt.any(),response:Qt.any()}),MAB=Qt.union([Qt.boolean(),SAB]),JPu=class extends fl{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=MAB.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:bC.maybeTrimPrefix(r.data["stream-condition"],EAB),responseStream:r.data["response-stream"],response:r.data.response}}};var $Pu=class extends fl{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 XPu=require("fs"),szh=require("path");function DAB(e){return yl(e)&&typeof e.$ref=="string"}function BAB(e,t){if(e!=null){if(typeof e=="string")return e;if(DAB(e)){let r=(0,szh.resolve)(t??process.cwd(),e.$ref);if((0,XPu.existsSync)(r))try{return(0,XPu.readFileSync)(r,"utf-8")}catch{return}}}}var YPu=class extends fl{operation;baseDir;key="x-codeSamples";constructor({context:t,breadcrumbs:r,operation:i,baseDir:n}){super({breadcrumbs:r,context:t}),this.operation=i,this.baseDir=n}convert(){let t=yl(this.operation)?this.operation:{},r=t["x-codeSamples"],i=t["x-code-samples"],n=Array.isArray(r)?r:[],a=Array.isArray(i)?i:[],o=[...n,...a];if(o.length===0)return;let c=[];for(let d of o){if(!yl(d))continue;let s=d,u=s.lang,l=s.label,p=s.source;if(typeof u!="string")continue;let _=BAB(p,this.baseDir);_!=null&&c.push({name:typeof l=="string"?l:u,language:u,code:_,install:void 0,docs:void 0})}if(c.length!==0)return[{"code-samples":c}]}};var kPu=require("fs"),czh=require("path");function IAB(e){return yl(e)&&typeof e.$ref=="string"}function CAB(e,t){if(e!=null){if(typeof e=="string")return e;if(IAB(e)){let r=(0,czh.resolve)(t??process.cwd(),e.$ref);if((0,kPu.existsSync)(r))try{return(0,kPu.readFileSync)(r,"utf-8")}catch{return}}}}function qAB(e,t){if(!Array.isArray(e))return[];let r=[];for(let i of e){if(!yl(i))continue;let a=CAB(i.code,t);a!=null&&r.push({...i,code:a})}return r}var ZPu=class extends fl{operation;baseDir;key="x-fern-examples";constructor({context:t,breadcrumbs:r,operation:i,baseDir:n}){super({breadcrumbs:r,context:t}),this.operation=i,this.baseDir=n}convert(){let t=this.getExtensionValue(this.operation);return t==null?void 0:(Array.isArray(t)?t:[]).map(a=>{if(!yl(a))return a;let c=a["code-samples"];if(c!=null){let d=qAB(c,this.baseDir);return{...a,"code-samples":d}}return a}).filter(a=>{let o=cI.serialization.ExampleEndpointCallSchema.parse(a);return o.ok||this.context.errorCollector.collect({message:`Failed to parse x-fern-example in ${this.breadcrumbs.join(".")}`,path:this.breadcrumbs}),o.ok})}};var OYa=class extends fl{document;key="x-fern-explorer";constructor({breadcrumbs:t,document:r,context:i}){super({breadcrumbs:t,context:i}),this.document=r}convert(){let t=this.getExtensionValue(this.document);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-explorer",path:this.breadcrumbs});return}return t}}};var mYa=class extends Nm.AbstractConverters.AbstractMediaTypeObjectConverter{responseBody;statusCode;streamingExtension;constructor({context:t,breadcrumbs:r,responseBody:i,group:n,method:a,statusCode:o,streamingExtension:c}){super({context:t,breadcrumbs:r,group:n,method:a}),this.responseBody=i,this.statusCode=o,this.streamingExtension=c}convert(){return this.shouldConvertAsStreaming()?this.convertStreamingResponseBody():this.convertNonStreamingResponseBody()}convertStreamingResponseBody(){if(this.streamingExtension!=null){if(this.streamingExtension.type=="streamCondition"){let t=this.streamingExtension.responseStream,r=this.streamingExtension.response,i=[...this.group,this.method,"Response",this.statusCode].join("_"),n=`${i}_streaming`,a=this.parseMediaTypeSchemaOrReference({schemaOrReference:t,schemaId:n}),o=this.parseMediaTypeSchemaOrReference({schemaOrReference:r,schemaId:i});return this.convertStreamConditionResponse({convertedStreamingSchema:a,convertedNonStreamingSchema:o})}if(this.streamingExtension.type==="stream"){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})}}}}convertNonStreamingResponseBody(){let t=[...this.group,this.method,"Response",this.statusCode].join("_"),r=Object.keys(this.responseBody.content??{}).filter(a=>a.includes("json"));for(let a of r){let o=this.responseBody.content?.[a];if(o==null)continue;let c=this.parseMediaTypeObject({mediaTypeObject:o,schemaId:t,contentType:a});if(c!=null&&this.shouldReturnJsonResponse(a))return this.returnJsonResponse({mediaTypeObject:o,convertedSchema:c})}let i=Object.keys(this.responseBody.content??{}).filter(a=>!a.includes("json"));for(let a of i){let o=this.responseBody.content?.[a];if(o==null)continue;let c=this.parseMediaTypeObject({mediaTypeObject:o,schemaId:t,contentType:a});if(c!=null){if(this.isBinarySchema(c))return this.shouldReturnBytesResponse()?this.returnBytesResponse({mediaTypeObject:o}):this.returnFileDownloadResponse({mediaTypeObject:o});if(this.shouldReturnTextResponse(a))return this.returnTextResponse({mediaTypeObject:o})}}let n=parseInt(this.statusCode);if(!isNaN(n)&&n>=200&&n<300){let a={schema:{type:"object",description:"Empty response body"}},o=this.parseMediaTypeObject({mediaTypeObject:a,schemaId:t,contentType:"application/json",resolveSchema:!0});if(o!=null)return this.returnJsonResponse({mediaTypeObject:a,convertedSchema:o})}}convertStreamConditionResponse({convertedStreamingSchema:t,convertedNonStreamingSchema:r}){if(t==null||r==null)return;let i=this.responseBody.description;return this.streamingExtension?.type==="streamCondition"&&this.streamingExtension.streamDescription!=null&&(i=this.streamingExtension.streamDescription),{responseBody:wd.json(dC.response({responseBodyType:r.type,docs:this.responseBody.description,v2Examples:r.schema?.typeDeclaration.v2Examples})),streamResponseBody:wd.streaming(sI.json({docs:i,payload:t.type,terminator:void 0,v2Examples:t.schema?.typeDeclaration.v2Examples})),inlinedTypes:{...t.inlinedTypes,...r.inlinedTypes},headers:this.convertResponseHeaders()}}convertStreamingResponse({mediaTypeObject:t,convertedSchema:r}){if(this.streamingExtension==null)return;switch(this.streamingExtension.format){case"json":return{responseBody:wd.streaming(sI.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,headers:this.convertResponseHeaders()};case"sse":return{responseBody:wd.streaming(sI.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,headers:this.convertResponseHeaders()};default:return}}returnJsonResponse({mediaTypeObject:t,convertedSchema:r}){return{responseBody:wd.json(dC.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,headers:this.convertResponseHeaders()}}returnBytesResponse({mediaTypeObject:t}){return{responseBody:wd.bytes({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{},headers:this.convertResponseHeaders()}}returnFileDownloadResponse({mediaTypeObject:t}){return{responseBody:wd.fileDownload({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{},headers:this.convertResponseHeaders()}}returnTextResponse({mediaTypeObject:t}){return{responseBody:wd.text({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{},headers:this.convertResponseHeaders()}}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&&this.streamingExtension==null}shouldReturnTextResponse(t){return em.parse(t)?.isText()??!1}convertResponseHeaders(){let t=[],r=this.responseBody.headers;if(r==null)return t;for(let[i,n]of Object.entries(r)){let a=this.context.resolveMaybeReference({schemaOrReference:n,breadcrumbs:[...this.breadcrumbs,"headers",i]});if(a==null)continue;let o=a.schema,c=Oa.OPTIONAL_STRING;if(o!=null){let s=this.context.resolveMaybeReference({schemaOrReference:o,breadcrumbs:[...this.breadcrumbs,"headers",i,"schema"]});s!=null&&(s.type==="number"||s.type==="integer"?c=ii.primitive({v1:s.type==="integer"?"INTEGER":"DOUBLE",v2:s.type==="integer"?vn.integer({default:void 0,validation:void 0}):vn.double({default:void 0,validation:void 0})}):s.type==="boolean"&&(c=ii.primitive({v1:"BOOLEAN",v2:vn.boolean({default:void 0})})))}let d=this.convertHeaderExamples({header:a,headerName:i,schema:o});t.push({name:this.context.casingsGenerator.generateNameAndWireValue({name:i,wireValue:i}),docs:a.description,valueType:c,env:void 0,v2Examples:d,availability:void 0})}return t}convertHeaderExamples({header:t,headerName:r,schema:i}){let n={userSpecifiedExamples:{},autogeneratedExamples:{}},a=t.example,o=t.examples;for(let[c,d]of Object.entries(o??{})){let s=this.context.resolveExampleWithValue(d);s!=null&&(n.userSpecifiedExamples[c]=this.generateHeaderExample({schema:i,example:s}))}if(a!=null){let c=this.context.generateUniqueName({prefix:`${r}_example`,existingNames:Object.keys(n.userSpecifiedExamples)});n.userSpecifiedExamples[c]=this.generateHeaderExample({schema:i,example:a})}if(Object.keys(n.userSpecifiedExamples).length===0&&i!=null){let c=`${r}_example`;n.autogeneratedExamples[c]=this.generateHeaderExample({schema:i,example:void 0,ignoreErrors:!0})}return n}generateHeaderExample({schema:t,example:r,ignoreErrors:i}){if(t==null)return r;let n=new OF({breadcrumbs:this.breadcrumbs,context:this.context,schema:t,example:r}),{validExample:a,errors:o}=n.convert();return i||o.forEach(c=>{this.context.errorCollector.collect({message:c.message,path:c.path})}),a}};var eju=class extends Nm.AbstractConverters.AbstractMediaTypeObjectConverter{responseError;statusCode;methodName;isWildcardStatusCode;constructor({context:t,breadcrumbs:r,responseError:i,group:n,method:a,methodName:o,statusCode:c,isWildcardStatusCode:d}){super({context:t,breadcrumbs:r,group:n,method:a}),this.responseError=i,this.statusCode=c,this.methodName=o,this.isWildcardStatusCode=d}convert(){if(!this.responseError.content){let i=this.getErrorNameForStatusCode(this.statusCode,this.isWildcardStatusCode);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:ii.unknown(),displayName:i,statusCode:this.statusCode,isWildcardStatusCode:this.isWildcardStatusCode,inlinedTypes:{},examples:{},headers:this.convertResponseHeaders()}}let t=Object.keys(this.responseError.content).filter(i=>i.includes("json")),r=this.getErrorNameForStatusCode(this.statusCode,this.isWildcardStatusCode);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:lzh(`${this.methodName}Request${r}`),contentType:i});if(a==null)continue;let o=this.getErrorIdFromErrorName(r);if(a.schema!=null)return this.constructErrorConverterOutput({errorName:r,errorId:o,fernFilepath:a.schema.typeDeclaration.name.fernFilepath,convertedSchema:a});if(a.type.type==="named")return this.constructErrorConverterOutput({errorName:r,errorId:o,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,isWildcardStatusCode:this.isWildcardStatusCode,inlinedTypes:n.inlinedTypes,examples:n.examples,headers:this.convertResponseHeaders()}}getErrorNameForStatusCode(t,r){if(r){if(t===400)return"ClientRequestError";if(t===500)return"ServerError"}return Qpu[t]}getErrorIdFromErrorName(t){return this.context.enableUniqueErrorsPerEndpoint?lzh(`${this.methodName}Request${t}`):t}convertResponseHeaders(){let t=[],r=this.responseError.headers;if(r==null)return t;for(let[i,n]of Object.entries(r)){let a=this.context.resolveMaybeReference({schemaOrReference:n,breadcrumbs:[...this.breadcrumbs,"headers",i]});if(a==null)continue;let o=a.schema,c=Oa.OPTIONAL_STRING;if(o!=null){let s=this.context.resolveMaybeReference({schemaOrReference:o,breadcrumbs:[...this.breadcrumbs,"headers",i,"schema"]});s!=null&&(s.type==="number"||s.type==="integer"?c=ii.primitive({v1:s.type==="integer"?"INTEGER":"DOUBLE",v2:s.type==="integer"?vn.integer({default:void 0,validation:void 0}):vn.double({default:void 0,validation:void 0})}):s.type==="boolean"&&(c=ii.primitive({v1:"BOOLEAN",v2:vn.boolean({default:void 0})})))}let d=this.convertHeaderExamples({header:a,headerName:i,schema:o});t.push({name:this.context.casingsGenerator.generateNameAndWireValue({name:i,wireValue:i}),docs:a.description,valueType:c,env:void 0,v2Examples:d,availability:void 0})}return t}convertHeaderExamples({header:t,headerName:r,schema:i}){let n={userSpecifiedExamples:{},autogeneratedExamples:{}},a=t.example,o=t.examples;for(let[c,d]of Object.entries(o??{})){let s=this.context.resolveExampleWithValue(d);s!=null&&(n.userSpecifiedExamples[c]=this.generateHeaderExample({schema:i,example:s}))}if(a!=null){let c=this.context.generateUniqueName({prefix:`${r}_example`,existingNames:Object.keys(n.userSpecifiedExamples)});n.userSpecifiedExamples[c]=this.generateHeaderExample({schema:i,example:a})}if(Object.keys(n.userSpecifiedExamples).length===0&&i!=null){let c=`${r}_example`;n.autogeneratedExamples[c]=this.generateHeaderExample({schema:i,example:void 0,ignoreErrors:!0})}return n}generateHeaderExample({schema:t,example:r,ignoreErrors:i}){if(t==null)return r;let n=new OF({breadcrumbs:this.breadcrumbs,context:this.context,schema:t,example:r}),{validExample:a,errors:o}=n.convert();return i||o.forEach(c=>{this.context.errorCollector.collect({message:c.message,path:c.path})}),a}};function lzh(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}var tju=class e extends Cca{idempotent;idToAuthScheme;topLevelServers;streamingExtension;static AUTHORIZATION_HEADER="Authorization";constructor({context:t,breadcrumbs:r,operation:i,method:n,path:a,idempotent:o,idToAuthScheme:c,topLevelServers:d,streamingExtension:s}){super({context:t,breadcrumbs:r,operation:i,method:n,path:a}),this.idempotent=o,this.idToAuthScheme=c,this.topLevelServers=d,this.streamingExtension=s}convert(){let t=this.convertHttpMethod();if(t==null)return;let{group:r,method:i}=this.computeGroupNameAndLocationFromExtensions()??this.computeGroupNameFromTagAndOperationId(),n=this.getGroupDisplayName(r),{headers:a,pathParameters:o,queryParameters:c}=this.convertParameters({breadcrumbs:[...this.breadcrumbs,"parameters"]}),d=this.convertRequestBody({breadcrumbs:[...this.breadcrumbs,"requestBody"],group:r,method:i,streamingExtension:this.streamingExtension,queryParameters:c}),s=d?.[0]?.requestBody,u=d?.[0]?.streamRequestBody,l={requestBodies:d?.map(Y=>Y.requestBody)},p=this.convertResponseBody({breadcrumbs:[...this.breadcrumbs,"responses"],group:r,method:i,streamingExtension:this.streamingExtension}),_=p?.response,h=p?.streamResponse,y=p!=null?p.errors:[],b={},v=y.map(Y=>Y.error),O=DM(this.path),m=this.getEndpointBaseUrl(),g=this.getEndpointBaseUrls(),A=this.convertExamples({httpPath:O,httpMethod:t,baseUrl:m}),j=new Set(this.operation.security?.flatMap(Y=>Object.keys(Y))??[]),M=this.authSchemeToHeaders(Array.from(j));M.length>0&&a.push(...M);for(let Y of y){let he=Y.error,be=Y.errorType,W=he.error.errorId,x=Y.examples;b[W]={name:he.error,displayName:Y.displayName,discriminantValue:{name:he.error.name,wireValue:W},type:be,statusCode:Y.statusCode,isWildcardStatusCode:Y.isWildcardStatusCode,docs:he.docs,examples:[],v2Examples:{userSpecifiedExamples:x??{},autogeneratedExamples:{}},headers:Y.headers}}let w=this.context.getAudiences({operation:this.operation,breadcrumbs:this.breadcrumbs})??[],B=new OYa({context:this.context,breadcrumbs:this.breadcrumbs,document:this.context.spec}).convert(),q=new OYa({context:this.context,breadcrumbs:this.breadcrumbs,document:this.operation}).convert()??B,z={displayName:this.operation.summary,method:t,baseUrl:m,v2BaseUrls:g,path:O,pathParameters:o,queryParameters:c,headers:a.filter((Y,he,be)=>he===be.findIndex(W=>W.name.wireValue===Y.name.wireValue)),responseHeaders:p?.responseHeaders,sdkRequest:void 0,errors:v,auth:this.computeEndpointAuth(),security:this.operation.security??this.context.spec.security??this.getDefaultSecurityFromAuthOverrides(),availability:this.context.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs}),userSpecifiedExamples:[],autogeneratedExamples:[],idempotent:this.idempotent??!1,basePath:void 0,fullPath:O,allPathParameters:o,pagination:void 0,transport:void 0,source:mW.openapi(),audiences:w,retries:void 0,apiPlayground:q},Q=this.context.namespace!=null?[this.context.namespace]:[],H=r?.map(Y=>ou(Y));return Q.push(...H??[]),{audiences:w,group:r,groupDisplayName:n,errors:b,endpoint:{...z,id:`endpoint_${Q.join("/")}.${i}`,name:this.context.casingsGenerator.generateName(i),requestBody:s,v2RequestBodies:l,response:_,docs:this.operation.description,v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:A.examples},v2Responses:{responses:p?.v2Responses}},streamEndpoint:h!=null&&h.body!=null?{...z,id:`endpoint_${Q.join("/")}.${i}_stream`,name:this.context.casingsGenerator.generateName(`${i}_stream`),requestBody:u,v2RequestBodies:void 0,response:h,docs:this.streamingExtension?.type==="streamCondition"?this.streamingExtension.streamDescription??this.operation.description:this.operation.description,v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:A.streamExamples},v2Responses:{responses:[{statusCode:200,isWildcardStatusCode:void 0,body:h.body,docs:h.docs}]}}: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,o=!1;for(let[c,d]of Object.entries(this.operation.responses)){let s=/^[45]XX$/i.test(c),u,l=!1;if(s)u=parseInt(c.charAt(0))*100,l=!0;else{if(u=parseInt(c),isNaN(u)||u<200||u>=300&&u<400)continue;l=u>=400&&u<600}if(a==null&&(a={response:void 0,v2Responses:void 0,streamResponse:void 0,errors:[],examples:{},responseHeaders:[]}),u>=200&&u<300){let p=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:[...t,c]});if(p==null)continue;let h=new mYa({context:this.context,breadcrumbs:[...t,c],responseBody:p,group:r??[],method:i,statusCode:c,streamingExtension:n}).convert();h!=null&&(this.inlinedTypes={...this.inlinedTypes,...h.inlinedTypes},o||(o=!0,a.response={statusCode:u,isWildcardStatusCode:s?!0:void 0,body:h.responseBody,docs:p.description},a.streamResponse={statusCode:u,isWildcardStatusCode:s?!0:void 0,body:h.streamResponseBody,docs:p.description},h.headers!=null&&(a.responseHeaders=h.headers)),a.v2Responses=[...a.v2Responses??[],{statusCode:u,isWildcardStatusCode:s?!0:void 0,body:h.responseBody,docs:p.description}])}if(l){let p=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:[...t,c]});if(p==null)continue;let h=new eju({context:this.context,breadcrumbs:[...t,c],responseError:p,group:r??[],method:i,methodName:this.evaluateMethodNameFromOperation(),statusCode:u,isWildcardStatusCode:s?!0:void 0}).convert();h!=null&&(this.inlinedTypes={...this.inlinedTypes,...h.inlinedTypes},a.errors.push(h))}}if(this.streamingExtension!=null){a==null&&(a={response:void 0,v2Responses:void 0,streamResponse:void 0,errors:[],examples:{},responseHeaders:[]});let d=new mYa({context:this.context,breadcrumbs:[...t,"stream"],responseBody:{description:""},group:r??[],method:i,statusCode:"stream",streamingExtension:n}).convert();d!=null&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},a.response={statusCode:200,isWildcardStatusCode:void 0,body:d.responseBody,docs:void 0},a.streamResponse={statusCode:200,isWildcardStatusCode:void 0,body:d.streamResponseBody,docs:void 0},a.v2Responses=[{statusCode:200,isWildcardStatusCode:void 0,body:d.responseBody,docs:void 0}])}return a}computeEndpointAuth(){return this.operation.security!=null&&this.operation.security.length===0?!1:this.operation.security!=null&&this.operation.security.length>0?!0:this.context.spec.security!=null&&this.context.spec.security.length>0||this.shouldApplyDefaultAuthOverrides()}shouldApplyDefaultAuthOverrides(){if(!this.context.authOverrides?.auth)return!1;let t=this.context.spec.security!=null&&this.context.spec.security.length>0,r=this.operation.security!=null&&this.operation.security.length>0;return!(t||r)}getDefaultSecurityFromAuthOverrides(){if(!this.context.authOverrides?.auth)return;let t=this.context.authOverrides.auth;if(typeof t!="string")return;let r={};return r[t]=[],[r]}authSchemeToHeaders(t){let r=[];for(let i of t){let n=this.idToAuthScheme?.[i];if(n==null)continue;let a={valueType:Oa.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 ZPu({context:this.context,breadcrumbs:this.breadcrumbs,operation:this.operation,baseDir:this.context.documentBaseDir}).convert()??[],c=new YPu({context:this.context,breadcrumbs:this.breadcrumbs,operation:this.operation,baseDir:this.context.documentBaseDir}).convert()??[],s=a.some(u=>Array.isArray(u["code-samples"])&&u["code-samples"].length>0)?a:[...a,...c];return s.length===0?{examples:{},streamExamples:{}}:this.streamingExtension?.type==="streamCondition"?this.convertStreamConditionExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:s}):{examples:this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:s}),streamExamples:{}}}convertStreamConditionExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:n}){let a=n.filter(s=>!(s.response!=null&&"stream"in s.response)),o=n.filter(s=>s.response!=null&&"stream"in s.response),c=this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:a}),d=this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:o});return{examples:c,streamExamples:d}}convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:n}){return Object.fromEntries(n.map((a,o)=>[this.getExampleName({example:a,exampleIndex:o}),{displayName:void 0,request:a.request!=null||a["path-parameters"]!=null||a["query-parameters"]!=null||a.headers!=null?{docs:void 0,endpoint:{method:r,path:this.buildExamplePath(t,a["path-parameters"]??{})},baseUrl:void 0,environment:i,auth:void 0,pathParameters:a["path-parameters"]??{},queryParameters:a["query-parameters"]??{},headers:a.headers??{},requestBody:a.request??void 0}:void 0,response:a.response!=null?{docs:void 0,statusCode:void 0,body:this.getExampleResponseBody({example:a})}:void 0,codeSamples:a["code-samples"]?.map(c=>{let d=("language"in c?c.language:c.sdk)??void 0;return{name:c.name,docs:void 0,language:d,code:c.code}})}]))}getExampleName({example:t,exampleIndex:r}){return t.name??t["code-samples"]?.[0]?.name??`Example_${r}`}getExampleResponseBody({example:t}){if(t.response!=null){if("stream"in t.response)return Ar.V2HttpEndpointResponseBody.stream(t.response.stream);if("body"in t.response)return Ar.V2HttpEndpointResponseBody.json(t.response.body)}}getEndpointBaseUrl(){let r=new NR.ServerFromOperationNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert();if(r!=null)return this.context.logger.debug(`[getEndpointBaseUrl] Endpoint ${this.method.toUpperCase()} ${this.path} specifies a server with "${xi.SERVER_NAME_V2}" extension. Returning server type: ${r}`),r;let i=this.operation.servers?.[0];if(i==null)return;let a=this.topLevelServers?.find(o=>o.url===i.url)??i;return sge.getServerName({server:a,context:this.context})}getEndpointBaseUrls(){let t=this.operation.servers;return t?.map(i=>{let a=this.topLevelServers?.find(o=>o.url===i.url)??i;return sge.getServerName({server:a,context:this.context})})}buildExamplePath(t,r){return t.head+t.parts.map(i=>`${r[i.pathParameter]?.toString()??i.pathParameter}${i.tail}`).join("")}filterOutTopLevelServers(t){return t.filter(r=>!this.topLevelServers?.some(i=>i.url===r.url))}getGroupDisplayName(t){let r=this.operation.tags?.[0];r!=null&&(r=this.context.getDisplayNameForTag(r));let i=t?.[t.length-1];if(i!=null&&r!=null)return r.toLowerCase().replaceAll(" ","")===i?r:void 0}};var rju=class extends Oa{pathItem;path;idToAuthScheme;topLevelServers;constructor({context:t,breadcrumbs:r,pathItem:i,path:n,idToAuthScheme:a,topLevelServers:o}){super({context:t,breadcrumbs:r}),this.pathItem=i,this.path=n,this.idToAuthScheme=a,this.topLevelServers=o}convert(){let t=[],r=[],i={};for(let n of uzh){let a=this.pathItem[n];if(a==null)continue;let o=[...this.breadcrumbs,n],c=this.tryParseAsWebhook({operationBreadcrumbs:o,operation:a,method:n,context:this.context});if(c!=null){r.push(c),Object.assign(i,c.inlinedTypes);continue}let s=new JPu({breadcrumbs:o,operation:a,context:this.context}).convert(),u=this.tryParseAsHttpEndpoint({operationBreadcrumbs:o,operation:a,method:n,streamingExtension:s});u!=null&&(t.push(u),Object.assign(i,u.inlinedTypes))}return{endpoints:t,webhooks:r,inlinedTypes:i}}tryParseAsWebhook({operation:t,method:r,operationBreadcrumbs:i,context:n}){return new $Pu({breadcrumbs:i,operation:t,context:n}).convert()?new qca({context:this.context,breadcrumbs:i,operation:t,method:jel.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path}).convert():void 0}tryParseAsHttpEndpoint({operation:t,method:r,operationBreadcrumbs:i,streamingExtension:n}){new KPu({breadcrumbs:i,operation:t,document:this.context.spec,context:this.context}).convert()!=null;let d=new xPu({breadcrumbs:i,operation:t,context:this.context}).convert();return new tju({context:this.context,breadcrumbs:i,operation:t,method:jel.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path,idempotent:d,idToAuthScheme:this.idToAuthScheme,topLevelServers:this.topLevelServers,streamingExtension:n}).convert()}};var iju=class extends Oa{securityScheme;schemeId;constructor({context:t,breadcrumbs:r,securityScheme:i,schemeId:n}){super({context:t,breadcrumbs:r}),this.securityScheme=i,this.schemeId=n}convert(){switch(this.securityScheme.type){case"http":{if(this.securityScheme.scheme==="bearer")return mA.bearer({key:this.schemeId,token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description});if(this.securityScheme.scheme==="basic")return mA.basic({key:this.schemeId,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 mA.header({key:this.schemeId,name:{name:this.context.casingsGenerator.generateName("apiKey"),wireValue:this.securityScheme.name},valueType:Oa.OPTIONAL_STRING,prefix:void 0,headerEnvVar:void 0,docs:this.securityScheme.description});break}case"oauth2":return mA.bearer({key:this.schemeId,token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description})}}};var AYa=class extends w8t{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}),this.overrideOpenApiAuthWithGeneratorsAuth(),this.convertSecuritySchemes(),this.convertGlobalHeaders(),this.convertBasePath(),this.convertSchemas(),this.convertWebhooks();let{endpointLevelServers:t,errors:r}=this.convertPaths();this.addErrorsToIr(r);let{defaultUrl:i}=this.convertServers({endpointLevelServers:t});this.updateEndpointsWithDefaultUrl(i);let n=this.context.spec.info?.title?.trim();return n&&n!=='""'&&(this.ir.apiDisplayName=n),this.finalizeIr()}convertGlobalHeaders(){this.context.globalHeaderOverrides;let r=new VPu({breadcrumbs:["x-fern-global-headers"],document:this.context.spec,context:this.context}).convert();if(r!=null){let i=azh({globalHeaders:r,context:this.context});this.addGlobalHeadersToIr(i),this.context.setGlobalHeaders(i)}}convertBasePath(){let r=new LPu({breadcrumbs:["x-fern-base-path"],document:this.context.spec,context:this.context}).convert();r!=null&&(this.ir.basePath=DM(r))}convertSecuritySchemes(){if(this.context.authOverrides){let r=Dxc({rawApiFileSchema:this.context.authOverrides,casingsGenerator:this.context.casingsGenerator});this.addAuthToIR({requirement:r.requirement,schemes:r.schemes,docs:r.docs});return}let t=this.convertOpenApiSecuritySchemes();t.length>0&&this.addAuthToIR({requirement:t.length===1?"ALL":"ANY",schemes:t,docs:void 0})}convertOpenApiSecuritySchemes(){let t=[];for(let[r,i]of Object.entries(this.context.spec.components?.securitySchemes??{})){let n=this.context.resolveMaybeReference({schemaOrReference:i,breadcrumbs:["components","securitySchemes",r]});if(n==null)continue;let o=new iju({context:this.context,breadcrumbs:["components","securitySchemes",r],securityScheme:n,schemeId:r}).convert();o!=null&&t.push(o)}return t}convertServers({endpointLevelServers:t}){if(this.context.environmentOverrides){let n=pKa({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 sge({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 Nm.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:["components","schemas",t],schema:r}).convert();n!=null&&this.addSchemaOutputToIr(t,n)}}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 qca({context:this.context,breadcrumbs:["webhooks",r],operation:t.post,method:fzh.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(){let t=[],r={};for(let[i,n]of Object.entries(this.context.spec.paths??{})){if(n==null)continue;let o=new rju({context:this.context,breadcrumbs:["paths",i],topLevelServers:this.context.spec.servers,pathItem:n,path:i}).convert();if(o!=null){for(let c of o.endpoints){if(c.streamEndpoint!=null&&this.addEndpointToIr({endpoint:c.streamEndpoint,audiences:c.audiences,endpointGroup:c.group,endpointGroupDisplayName:c.groupDisplayName}),this.addEndpointToIr({endpoint:c.endpoint,audiences:c.audiences,endpointGroup:c.group,endpointGroupDisplayName:c.groupDisplayName}),c.servers)for(let d of c.servers)this.shouldAddServerToCollectedServers({server:d,currentServers:t})&&t.push(d);if(c.errors)for(let[d,s]of Object.entries(c.errors))r[d]=s}for(let c of o.webhooks){let d=this.context.getGroup({groupParts:c.group,namespace:this.context.namespace});this.addWebhookToIr({webhook:c.webhook,operationId:d.join("."),group:d,audiences:c.audiences})}this.addTypesToIr(o.inlinedTypes)}}return{endpointLevelServers:t,errors:r}}overrideOpenApiAuthWithGeneratorsAuth(){if(!this.context.authOverrides?.["auth-schemes"])return;this.context.spec.components||(this.context.spec.components={}),this.context.spec.components.securitySchemes={};let t={};for(let r of Object.keys(this.context.authOverrides["auth-schemes"]))this.context.spec.components.securitySchemes[r]={type:"http",scheme:"bearer"},t[r]=[];this.context.spec.security=[t],this.removeEndpointSpecificAuth()}removeEndpointSpecificAuth(){if(this.context.spec.paths)for(let t of Object.values(this.context.spec.paths)){if(!t)continue;let r=["get","post","put","patch","delete","options","head","trace"];for(let i of r){let n=t[i];n?.security&&delete n.security}}}};var nju=class extends fl{tag;key="x-displayName";constructor({breadcrumbs:t,tag:r,context:i}){super({breadcrumbs:t,context:i}),this.tag=r}convert(){if(typeof this.tag!="object"||this.tag==null)return;let t=this.tag[this.key];if(t!=null){if(typeof t!="string"){this.context.errorCollector.collect({message:"x-displayName extension must be a string",path:this.breadcrumbs});return}if(t.trim().length!==0)return{displayName:t}}}};var h4i=class extends bC{globalHeaderNames;tagToDisplayName={};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 o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;n==="reference_identifier"?c=i??o.value.title:n==="discriminator_key"?c=o.value.title??i:n==="schema_identifier"&&(c=o.value.title);let d;if(a.includes("/")){let u=new Nm.SchemaConverters.SchemaConverter({context:this,breadcrumbs:r??[],schema:o.value,id:a}).convert();u!=null&&(d={[a]:u.convertedSchema})}return{ok:!0,reference:ii.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,default:void 0,inline:!1,displayName:c}),inlinedTypes:d}}setGlobalHeaders(t){this.globalHeaderNames=t.map(r=>r.name.wireValue)}getDisplayNameForTag(t){if(Object.keys(this.tagToDisplayName).length===0)for(let r of this.spec.tags??[]){let n=new nju({breadcrumbs:["tags",r.name],tag:r,context:this}).convert()?.displayName??r.name;this.tagToDisplayName[r.name]=n}return this.tagToDisplayName[t]??t}};var TAB=Qt.object({description:Qt.string().optional(),required:Qt.boolean().optional(),deprecated:Qt.boolean().optional(),allowEmptyValue:Qt.boolean().optional(),style:Qt.string().optional(),explode:Qt.boolean().optional(),allowReserved:Qt.boolean().optional(),schema:Qt.any().optional(),example:Qt.any().optional(),examples:Qt.record(Qt.string(),Qt.any()).optional(),content:Qt.record(Qt.string(),Qt.any()).optional()}),RAB=TAB.extend({name:Qt.string(),in:Qt.string()}),zAB=Qt.array(RAB),aju=class extends fl{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 zAB.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 oju=class extends Oa{method;pathParameters;queryParameters;headers;topLevelServers;constructor({context:t,breadcrumbs:r,method:i,pathParameters:n=[],queryParameters:a=[],headers:o=[],topLevelServers:c=[]}){super({context:t,breadcrumbs:r}),this.method=i,this.pathParameters=n,this.queryParameters=a,this.headers=o,this.topLevelServers=c}convert(){let t={},r="";for(let s of this.pathParameters)r+=`/{${s.name.originalName}}`;let i=DM(r),n=[];for(let[s,u]of this.method.params.entries()){let l;if(this.context.isReferenceObject(u)){let y=this.context.resolveReference({reference:u});if(y.resolved)l=y.value;else continue}else l=u;let p=[this.method.name,"Param",l.name].join("_"),h=new Nm.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[this.method.name,"Param",l.name],schemaIdOverride:p,context:this.context,schemaOrReference:l.schema,wrapAsOptional:!l.required}).convert();h!=null&&(n.push({docs:l.description,availability:this.context.getAvailability({node:u,breadcrumbs:[...this.breadcrumbs,"parameters"]}),name:this.context.casingsGenerator.generateNameAndWireValue({name:l.name,wireValue:l.name}),valueType:h.type,v2Examples:h.schema?.typeDeclaration.v2Examples,propertyAccess:void 0}),t={...h.inlinedTypes,...t,...h.schema!=null?{[p]:h.schema}:{}})}let a;if(this.method.result!=null){let s=this.context.resolveMaybeReference({schemaOrReference:this.method.result,breadcrumbs:[...this.breadcrumbs,"result"]});if(s!=null){let u=new Nm.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[this.method.name,"result"],context:this.context,schemaOrReference:s.schema}),l=[this.method.name,"Result"].join("_"),p=u.convert();p!=null&&(a={docs:s.description,v2Examples:p.schema?.typeDeclaration.v2Examples,responseBodyType:p.type},t={...p.inlinedTypes,...t,...p.schema!=null?{[l]:p.schema}:{}})}}let o=this.getEndpointBaseUrls(),c=this.context.getAudiences({operation:this.method,breadcrumbs:this.breadcrumbs})??[];return{endpoint:{baseUrl:void 0,v2BaseUrls:o,basePath:void 0,auth:!1,security:void 0,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?zm.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,v2RequestBodies:void 0,sdkRequest:void 0,response:a!=null?{body:wd.json(dC.response(a)),statusCode:void 0,isWildcardStatusCode:void 0,docs:a.docs}:void 0,v2Responses:void 0,errors:[],idempotent:!1,pagination:void 0,userSpecifiedExamples:[],autogeneratedExamples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples()},transport:void 0,availability:void 0,source:mW.openrpc(),audiences:c,retries:void 0,apiPlayground:void 0,responseHeaders:[]},audiences:c,inlinedTypes:t,servers:this.filterOutTopLevelServers(this.method.servers??[])}}filterOutTopLevelServers(t){return t.filter(r=>!this.topLevelServers.some(i=>i.url===r.url))}getEndpointBaseUrls(){let t=this.method.servers;return t?.map(i=>{if(this.topLevelServers.find(c=>c.name===i.name&&c.url!==i.url)!=null)return i.url;let o=this.topLevelServers.find(c=>c.url===i.url)??i;return sge.getServerName({server:o,context:this.context})})}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 o=n.name??`Example ${r+1}`,c=[];if(n.params&&Array.isArray(n.params)){c=[];for(let d of n.params)if(this.context.isReferenceObject(d)){let s=this.context.resolveReference({reference:d});if(s.resolved)c.push(s.value);else continue}else c.push(d)}t[o]={displayName:void 0,request:{docs:void 0,endpoint:{method:"POST",path:"/{apiKey}"},baseUrl:void 0,environment:void 0,auth:void 0,pathParameters:{},queryParameters:{},headers:{},requestBody:c.map(d=>d.value)??void 0},response:{docs:void 0,statusCode:void 0,body:a?.value?Ar.V2HttpEndpointResponseBody.json({jsonrpc:"2.0",id:n.examplePairedRequest?.id||"1",result:a.value}):void 0},codeSamples:[]}}++r}return t}};var uju=class extends Nm.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 Nm.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 PYa=class extends w8t{constructor({context:t,breadcrumbs:r,audiences:i}){super({context:t,breadcrumbs:r,audiences:i})}async convert(){this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.convertSchemas();let{endpointLevelServers:t}=this.convertMethods(),{defaultUrl:r}=this.convertServers({endpointLevelServers:t});return this.updateEndpointsWithDefaultUrl(r),this.finalizeIr()}convertServers({endpointLevelServers:t}){let i=new sge({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 Nm.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:["components","schemas",t],schema:r}).convert();n!=null&&this.addSchemaOutputToIr(t,n)}}convertMethods(){let t=[],i=new aju({context:this.context,breadcrumbs:["methods"],operation:this.context.spec}).convert(),n=[],a=[],o=[];if(i&&i.length>0)for(let[d,s]of i.entries()){let l=new uju({context:this.context,breadcrumbs:[...this.breadcrumbs,`x-fern-parameters[${d}]`],parameter:s}).convert();if(l!=null)switch(l.type){case"path":{n.push(l.parameter);break}case"query":{a.push(l.parameter);break}case"header":{o.push(l.parameter);break}}}let c=this.context.getGroup({groupParts:[],namespace:this.context.namespace});for(let d of this.context.spec.methods??[]){let s=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:["methods"]});if(s==null)continue;let l=new oju({context:this.context,breadcrumbs:["methods"],method:s,pathParameters:n,queryParameters:a,headers:o,topLevelServers:this.context.spec.servers}).convert();if(l!=null&&(this.addEndpointToIr({endpoint:l.endpoint,audiences:l.audiences,endpointGroup:c,serviceName:"service_root"}),this.addTypesToIr(l.inlinedTypes),l.servers))for(let p of l.servers)this.shouldAddServerToCollectedServers({server:p,currentServers:t,specType:"openrpc"})&&t.push(this.maybeDeduplicateServerName(p))}return{endpointLevelServers:t}}maybeDeduplicateServerName(t){return this.context.spec.servers?.find(i=>i.name===t.name&&i.url!==t.url)?{...t,name:t.url}:t}};var jYa=class extends bC{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 o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return n==="reference_identifier"?c=i??o.value.title:(n==="discriminator_key"||n==="schema_identifier")&&(c=o.value.title??i),{ok:!0,reference:ii.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}};var tFh=require("fs/promises");var dzh={[an.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,X0(e)])),[an.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"]),[an.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"]),[an.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","kwargs"]),[an.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","vendor","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[an.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","object_id","hash","eql?","equal?","method","send","respond_to?","respond_to_missing?","instance_of?","kind_of?","is_a?","extend","singleton_class","instance_variables","instance_variable_get","instance_variable_set","instance_variable_defined?","remove_instance_variable","public_methods","private_methods","protected_methods","singleton_methods"]),[an.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"]),[an.GenerationLanguage.RUST]:new Set(["as","async","await","break","const","continue","crate","dyn","else","enum","extern","false","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","true","type","union","unsafe","use","where","while","abstract","become","box","do","final","macro","override","priv","try","typeof","unsized","virtual","yield","bool","char","f32","f64","i8","i16","i32","i64","i128","isize","str","u8","u16","u32","u64","u128","usize","String","Vec","Option","Result","Box","Rc","Arc","Cell","RefCell","HashMap","HashSet","BTreeMap","BTreeSet"]),[an.GenerationLanguage.SWIFT]:new Set([])};var NAB=["go","ruby"];function lju({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let o=HAB(n),c=p=>({unsafeName:p,safeName:FAB({name:p,keywords:QAB({generationLanguage:e,keywords:t})})}),d=ou(o),s=X0(d),u=Kfn(o),l=Wfn(d);return r&&(!VAB(l)&&(e==null||NAB.includes(e))&&(d=l.map((p,_)=>{if(_>0){let h=sju(p);if(h!=null)return h;if(cju(p))return p.toUpperCase()}return p}).join(""),s=X0(l.map((p,_)=>{let h=sju(p);return h??(cju(p)?p.toUpperCase():_===0?X0(p):p)}).join(""))),u=o.split(" ").map(p=>p.split(/(\d+)/).map(Kfn).join("")).join("_")),{originalName:n,camelCase:c(a?.casingOverrides?.camel??d),snakeCase:c(a?.casingOverrides?.snake??u),screamingSnakeCase:c(a?.casingOverrides?.["screaming-snake"]??u.toUpperCase()),pascalCase:c(a?.casingOverrides?.pascal??s)}},generateNameAndWireValue:({name:n,wireValue:a,opts:o})=>({name:i.generateName(n,o),wireValue:a})};return i}function FAB({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":LAB(e)?"_"+e:e}function QAB({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return dzh[e]}var UAB=/^[0-9]/;function LAB(e){return UAB.test(e)}function VAB(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=sju(i)!=null||cju(i),a=sju(t)!=null||cju(t);return n&&a})}function sju(e){return GAB.get(e.toUpperCase())}function cju(e){return WAB.has(e.toUpperCase())}var WAB=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"]),GAB=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]),xAB=[[/\[\]/g,"Array"]];function HAB(e){return xAB.reduce((t,[r,i])=>t.replace(r,i),e)}var pzh=require("fs/promises");async function wel({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,pzh.readFile)(t)).toString(),n;try{n=JSON.parse(i)}catch{n=qi.load(i)}return r!=null?await Mca({absoluteFilePathToOverrides:r,context:e,data:n}):n}var LNh=ce(UNh(),1);function gYi(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...o}={}){let c=n.reduce((s,u)=>({...s,[u]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[s,u]of Object.entries(c))d=d.replaceAll(s,u);return e?.debug(`+ ${d}`),(0,LNh.default)(t,r,o)}async function yy(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...o}={}){let c=gYi(e,t,r,{doNotPipeOutput:i,secrets:n,substitutions:a,...o});i||(c.stdout?.pipe(process.stdout),c.stderr?.pipe(process.stderr));let d=await c;return d.stdout==null&&(d.stdout=""),d.stderr==null&&(d.stderr=""),d}function OYi(e,{logger:t,...r}={}){return(i,n)=>yy(t,e,i,{...r,...n})}var Cx=require("fs/promises"),XNh=ce(require("path"),1),Wel=ce(M4(),1);var QjB=ce(M4(),1);function VNh(e){return e.includes("server hosted at that remote is unavailable")||e.includes("fetch failed")||e.includes("failed to connect")||e.includes("network")||e.includes("ENOTFOUND")||e.includes("ETIMEDOUT")||e.includes("TIMEDOUT")||e.includes("timed out")||e.includes("ECONNREFUSED")||e.includes("ECONNRESET")||e.includes("socket hang up")}var DYa,Vel;async function xgn(e,t,r=5e3){return DYa!==void 0?DYa:(Vel==null&&(Vel=UjB(e,t,r)),Vel)}async function UjB(e,t,r){t.debug(`Detecting air-gapped mode by checking connectivity to ${e}`);try{return await fetch(e,{method:"GET",signal:AbortSignal.timeout(r)}),DYa=!1,t.debug("Network check succeeded - not in air-gapped mode"),!1}catch(i){let n=i instanceof Error?i.message:String(i);return VNh(n)?(DYa=!0,t.debug(`Network check failed - entering air-gapped mode: ${n}`),!0):(DYa=!1,!1)}}var WNh="buf.gen.yaml",LjB="output",GNh=`${LjB}/ir.json`,xNh="protoc-gen-fern",HNh=`version: v1
|
|
1528
|
+
`).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:uAu.conjure.DefinitionFile.parseOrThrow(qi.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}function tCh(e,t){if(fbB(e))return t.alias(e);if(dbB(e))return t.enum(e);if(pbB(e))return t.object(e);if(_bB(e))return t.union(e);vt(e)}function fbB(e){return e?.alias!=null}function dbB(e){return e?.values!=null}function pbB(e){return e?.fields!=null}function _bB(e){return e?.union!=null}var M$a=class extends cJa{fernDefinitionBuilder=new Kvn(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:i,globalHeaderOverrides:n}){if(r!=null){for(let[a,o]of Object.entries(r["auth-schemes"]??{}))this.fernDefinitionBuilder.addAuthScheme({name:a,schema:o});r.auth!=null&&this.fernDefinitionBuilder.setAuth(r.auth)}if(i!=null){for(let[a,o]of Object.entries(i.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:o});i["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(i["default-environment"]),i["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(i["default-url"])}return await rCh(t,(a,o,c)=>{for(let[u,l]of Object.entries(c.services??{})){let p=MRo({value:u,suffix:"Service"});this.conjureFilepathToFernFilepath[o]=Je.of(`${p}/__package__.yml`);return}let s=lNi(o)?.split(".")[0];s!=null&&(this.conjureFilepathToFernFilepath[o]=Je.of(`${s}/__package__.yml`))}),await rCh(t,(a,o,c)=>{if(c.services==null||Object.keys(c.services??{}).length===0){let d=this.conjureFilepathToFernFilepath[o];if(d==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${o}`);for(let[s,u]of Object.entries(c.types?.conjureImports??{})){let l=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Je.of(u)});this.fernDefinitionBuilder.addImport({file:d,fileToImport:Je.of(l),alias:s})}this.importAllTypes({conjureFile:c,fernFilePath:d});return}for(let[d,s]of Object.entries(c.services)){let u=MRo({value:d,suffix:"Service"}),l=Je.of(`${u}/__package__.yml`),p={};s.basePath!=null&&(p["base-path"]=s.basePath),s.docs!=null&&(p.docs=s.docs),this.fernDefinitionBuilder.setServiceInfo(l,p),this.importAllTypes({conjureFile:c,fernFilePath:l});for(let[_,h]of Object.entries(c.types?.conjureImports??{})){let y=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Je.of(h)});this.fernDefinitionBuilder.addImport({file:l,fileToImport:Je.of(y),alias:_})}for(let[_,h]of Object.entries(s.endpoints??{})){let y=Znc(h.http);if(y.type==="failure"){this.context?.logger.error(`Failed to parse ${h.http}. Skipping.`);continue}let v={auth:(h.auth??s.defaultAuth)!==jIh.None,path:y.path,method:y.method,response:h.returns==="binary"?"file":h.returns};h.docs!=null&&(v.docs=h.docs);let O={};if(h.args!=null)for(let m of y.pathParameters){let g=h.args[m];if(g==null)throw new Error(`Failed to find path parameter ${m} in ${h.http}`);O[m]=typeof g=="string"?g:{type:g.type}}Object.entries(O).length>0&&(v["path-parameters"]=O);for(let[m,g]of Object.entries(h.args??{}))if(O[m]==null)if(typeof g=="string")v.request?typeof v.request=="string"&&(v.request={body:v.request}):v.request={},v.request.body=g==="binary"?"bytes":g;else switch(g.paramType){case"body":v.request={body:g.type==="binary"?"bytes":g.type};break;case"query":v.request==null?v.request={"query-parameters":{[m]:g.type}}:typeof v.request!="string"&&v.request?.["query-parameters"]==null?v.request["query-parameters"]={[m]:g.type}:typeof v.request!="string"&&v.request?.["query-parameters"]!=null&&(v.request["query-parameters"][m]=g.type)}v.request!=null&&typeof v.request!="string"&&v.request?.["query-parameters"]!=null&&(v.request.name=`${_}Request`),this.fernDefinitionBuilder.addEndpoint(l,{name:_,schema:v,source:void 0})}}}),this.fernDefinitionBuilder.build()}convertBinaryType(t){return typeof t=="string"?t==="binary"?{type:"string",validation:{format:"binary"}}:t:t.type==="binary"?{...t,type:"string",validation:{format:"binary"}}:t}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[i,n]of Object.entries(t.types?.definitions?.objects??{}))tCh(n,{alias:a=>{let o=a.alias==="binary"?{type:"string",validation:{format:"binary"}}:a.alias;this.fernDefinitionBuilder.addType(r,{name:i,schema:typeof o=="string"?{type:o,docs:a.docs}:{...o,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{properties:Object.fromEntries(Object.entries(a.fields).map(([o,c])=>[o,this.convertBinaryType(c)]))}})},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(([o,c])=>{let d=this.convertBinaryType(c);return[o,{type:typeof d=="string"?d:d.type,docs:typeof d=="string"?void 0:d.docs,key:o}]}))}})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:i}){let n=Tt(nn(t),Je.of(r)),a=FJ(i,n),o=this.conjureFilepathToFernFilepath[a];if(o==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return o}};async function rCh(e,t){for(let r of await eCh(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}function iCh(e,t){return rn(e,t)}var sAu=class extends B8t{type="conjure";absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=Tt(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new gY({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 M$a(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:Sr.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:n.rootApiFile["default-url"],contents:n.rootApiFile,rawContents:qi.dump(n.rootApiFile)},namedDefinitionFiles:{...iCh(n.definitionFiles,a=>({absoluteFilepath:Sr.of("/DUMMY_PATH"),rawContents:qi.dump(a),contents:a})),[Je.of(Yb)]:{absoluteFilepath:Sr.of("/DUMMY_PATH"),rawContents:qi.dump(n.packageMarkerFile),contents:n.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};var PTh=ce(cCh(),1);var Wp;(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"})(Wp||(Wp={}));function lCh(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function cAu(e,t){for(let[r,i]of UI(e))ybB({relativeFilepath:r,failure:i,logger:t})}function ybB({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case Wp.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 Wp.FILE_READ:r.error("Failed to open file: "+e);break;case Wp.FILE_MISSING:r.error("Missing file: "+e);break;case Wp.FILE_PARSE:t.error instanceof L3a?r.error(b0e({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case Wp.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of bbB(i))r.error(b0e({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case Wp.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case Wp.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${vUo}: `+t.dependencyName);break;case Wp.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case Wp.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case Wp.JSONSCHEMA_VALIDATION:if(t.error.error!=null){let i=t.error.error.instancePath.split("/").filter(n=>n!=="").map(lCh);t.error.error.keyword==="required"&&t.error.error.params?.missingProperty?i.push(t.error.error.params.missingProperty):t.error.error.keyword==="additionalProperties"&&t.error.error.params?.additionalProperty&&i.push(t.error.error.params.additionalProperty),r.error(b0e({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...i]}))}for(let i of t.error.allErrors)if(i!==t.error.error){let n=i.instancePath.split("/").filter(a=>a!=="").map(lCh);i.keyword==="required"&&i.params?.missingProperty?n.push(i.params.missingProperty):i.keyword==="additionalProperties"&&i.params?.additionalProperty&&n.push(i.params.additionalProperty),r.debug(b0e({title:i.message??"Unknown error",breadcrumbs:[e,...n]}))}break;default:vt(t)}}function bbB(e){switch(e.code){case wi.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${Rt.underline(e.expected)} but received ${Rt.underline(e.received)}`}];case wi.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${Rt.underline(t)}`}));case wi.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>Rt.underline(t)).join(", ")}`}];case wi.invalid_union:case wi.invalid_arguments:case wi.invalid_return_type:case wi.invalid_date:case wi.invalid_string:case wi.too_small:case wi.too_big:case wi.invalid_intersection_types:case wi.not_multiple_of:case wi.custom:default:return[{title:e.message}]}}var fCh=require("fs/promises");async function dCh(e,t){let r=[];for(let i of await w4(e,t))r.push(await vbB({relativeFilepath:pp(e,i),absoluteFilepath:i}));return r}async function vbB({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,fCh.readFile)(t)).toString()}}async function pCh(e){let t={},r={};function i(n){try{t[n.relativeFilepath]={defaultUrl:void 0,contents:qi.load(n.fileContents,{schema:qi.CORE_SCHEMA}),rawContents:n.fileContents}}catch(a){r[n.relativeFilepath]={type:Wp.FILE_PARSE,error:a}}}return await Promise.all(e.map(i)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}var Hkc=ce(O7i(),1);var dTh=require("fs"),Oca=require("fs/promises");var pTh=require("os"),_Th=ce(require("path"),1),hTh=require("stream/promises"),yTh=ce(xkc(),1),bTh=ce(M4(),1);var JgB=dQi();async function vTh({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:i,cliVersion:n,settings:a,loadAPIWorkspace:o}){let c,d={type:Wp.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},s=t.dependencies[e];return s==null?d={type:Wp.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${tOB(s)}`},async u=>{switch(s.type){case"version":c=await kgB({context:u,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:o});return;case"local":c=await ZgB({context:u,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:o});return;default:vt(s)}}),c!=null?{didSucceed:!0,definition:c}:{didSucceed:!1,failure:d}}var gTh="dependencies";var $gB="metadata.json",YgB=".fern";function XgB(e){return Tt(Sr.of((0,pTh.homedir)()),Je.of(YgB),Je.of(gTh),Je.of(e.organization),Je.of(e.apiName),Je.of(e.version))}async function ZgB({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 o=await a.workspace.getDefinition({context:t,relativePathToDependency:Je.of(e.path)},i);return t.logger.info("Loaded..."),o}async function kgB({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){let a=XgB(e),o=Tt(a,Je.of(gTh)),c=Tt(a,Je.of($gB)),d;if(!await Ai(o)||!await Ai(c)){t.logger.info("Downloading manifest...");let l=await JgB.definitionRegistry.get(Hkc.FernFiddle.OrganizationId(e.organization),Hkc.FernFiddle.ApiId(e.apiName),e.version);if(!l.ok){l.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:y=>{t.failWithoutThrowing("Failed to download API manifest",y)}});return}let p=l.body.yamlSchemaVersion!=null?parseInt(l.body.yamlSchemaVersion):void 0,_=Avn(r),h=Avn(l.body.cliVersion);if(p!=null){if(p>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${l.body.cliVersion}`);return}else if(p<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(_.major!==h.major||_.minor!==h.minor){t.failWithoutThrowing(`CLI version is ${l.body.cliVersion}. Expected ${_.major}.${_.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+l.body.definitionS3DownloadUrl),await(0,Oca.mkdir)(o,{recursive:!0});try{await eOB({s3PreSignedReadUrl:l.body.definitionS3DownloadUrl,absolutePathToLocalOutput:o})}catch(y){t.failWithoutThrowing("Failed to download API",y);return}d=l.body,await(0,Oca.writeFile)(c,JSON.stringify(d))}else d=JSON.parse((await(0,Oca.readFile)(c)).toString());if(t.logger.info("Parsing..."),n==null){t.failWithoutThrowing("Failed to load API");return}let s=await n({absolutePathToWorkspace:o,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 eOB({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await eI.get(e,{responseType:"stream"}),i=await bTh.default.dir(),n=_Th.default.join(i.path,"api.tgz");await(0,hTh.pipeline)(r.data,(0,dTh.createWriteStream)(n)),await(0,yTh.extract)({file:n,cwd:t})}function tOB(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:vt(e)}}async function OTh({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:i,settings:n,loadAPIWorkspace:a}){let o={},c={},d={};return await Promise.all(UI(t.packageMarkers).map(async([s,u])=>{if(u.contents.export==null)o[s]=u;else{let{export:l,...p}=u.contents;if(QA(p)>0)d[s]={type:Wp.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:s};else{let _=nn(s);if(_Vt(t.namedDefinitionFiles).some(y=>y!==s&&y.startsWith(_)))d[s]={type:Wp.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:_};else{let y=await vTh({dependencyName:typeof u.contents.export=="string"?u.contents.export:u.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:i,settings:n,loadAPIWorkspace:a});y.didSucceed?c[nn(s)]={definition:y.definition,url:typeof u.contents.export=="object"?u.contents.export.url:void 0}:d[s]=y.failure}}}})),QA(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:o,importedDefinitions:c}}var mTh=ce(require("path"),1);var Kkc={};Yt(Kkc,{additionalProperties:()=>aOB,default:()=>uOB,definitions:()=>oOB,properties:()=>iOB,required:()=>nOB,type:()=>rOB});var rOB="object",iOB={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"}]}},nOB=["name"],aOB=!1,oOB={"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.EndpointSecuritySchemaDetails":{type:"object",additionalProperties:!1},"auth.EndpointSecuritySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"endpoint-security":{$ref:"#/definitions/auth.EndpointSecuritySchemaDetails"}},required:["endpoint-security"],additionalProperties:!1},"auth.ApiAuthSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"},{$ref:"#/definitions/auth.AnyAuthSchemesSchema"},{$ref:"#/definitions/auth.EndpointSecuritySchema"}]},"auth.AuthScope":{type:"string"},"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:{$ref:"#/definitions/auth.AuthScope"}},{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.TokenBearerAuthSchema":{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.InferredAuthenticatedRequestHeader":{type:"object",properties:{"response-property":{type:"string"},"header-name":{type:"string"},"value-prefix":{oneOf:[{type:"string"},{type:"null"}]}},required:["response-property","header-name"],additionalProperties:!1},"auth.InferredGetTokenEndpointSchemaObject":{type:"object",properties:{endpoint:{type:"string"},"expiry-response-property":{oneOf:[{type:"string"},{type:"null"}]},"authenticated-request-headers":{oneOf:[{type:"array",items:{$ref:"#/definitions/auth.InferredAuthenticatedRequestHeader"}},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.InferredGetTokenEndpointSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.InferredGetTokenEndpointSchemaObject"}]},"auth.InferredBearerAuthSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},"get-token":{$ref:"#/definitions/auth.InferredGetTokenEndpointSchema"}},required:["scheme","get-token"],additionalProperties:!1},"auth.BearerAuthSchemeSchema":{anyOf:[{$ref:"#/definitions/auth.TokenBearerAuthSchema"},{$ref:"#/definitions/auth.InferredBearerAuthSchema"}]},"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}},uOB={type:rOB,properties:iOB,required:nOB,additionalProperties:aOB,definitions:oOB};var Jkc={};Yt(Jkc,{additionalProperties:()=>lOB,default:()=>dOB,definitions:()=>fOB,properties:()=>cOB,type:()=>sOB});var sOB="object",cOB={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"}]}},lOB=!1,fOB={"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"}]},"auth.AuthScope":{type:"string"},"service.HttpEndpointSecurityItem":{type:"object",additionalProperties:{type:"array",items:{$ref:"#/definitions/auth.AuthScope"}}},"service.HttpEndpointSecurity":{type:"array",items:{$ref:"#/definitions/service.HttpEndpointSecurityItem"}},"service.HttpEndpointAuth":{anyOf:[{type:"boolean"},{$ref:"#/definitions/service.HttpEndpointSecurity"}]},"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.RetriesDisabledSchema":{type:"object",properties:{disabled:{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"service.RetriesConfiguration":{anyOf:[{$ref:"#/definitions/service.RetriesDisabledSchema"}]},"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:[{$ref:"#/definitions/service.HttpEndpointAuth"},{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"}]},retries:{oneOf:[{$ref:"#/definitions/service.RetriesConfiguration"},{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"},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},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"}]},"method-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}},dOB={type:sOB,properties:cOB,additionalProperties:lOB,definitions:fOB};var $kc={};Yt($kc,{additionalProperties:()=>hOB,default:()=>bOB,definitions:()=>yOB,properties:()=>_OB,type:()=>pOB});var pOB="object",_OB={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"}]}},hOB=!1,yOB={"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"}]},"auth.AuthScope":{type:"string"},"service.HttpEndpointSecurityItem":{type:"object",additionalProperties:{type:"array",items:{$ref:"#/definitions/auth.AuthScope"}}},"service.HttpEndpointSecurity":{type:"array",items:{$ref:"#/definitions/service.HttpEndpointSecurityItem"}},"service.HttpEndpointAuth":{anyOf:[{type:"boolean"},{$ref:"#/definitions/service.HttpEndpointSecurity"}]},"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.RetriesDisabledSchema":{type:"object",properties:{disabled:{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"service.RetriesConfiguration":{anyOf:[{$ref:"#/definitions/service.RetriesDisabledSchema"}]},"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:[{$ref:"#/definitions/service.HttpEndpointAuth"},{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"}]},retries:{oneOf:[{$ref:"#/definitions/service.RetriesConfiguration"},{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"},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},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"}]},"method-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"}]}},bOB={type:pOB,properties:_OB,additionalProperties:hOB,definitions:yOB};function ATh({files:e,absolutePathToDefinition:t}){let r,i={},n={},a={};for(let[o,c]of UI(e)){let d=c.contents,s=u=>{a[o]={type:Wp.JSONSCHEMA_VALIDATION,error:u}};if(o===GB){let u=OVt(d,Kkc);if(u.success){let l=cI.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:l["default-url"],contents:l,rawContents:c.rawContents}}else s(u)}else if(mTh.default.basename(o)===Yb){let u=OVt(d,$kc);if(u.success){let l=cI.serialization.PackageMarkerFileSchema.parseOrThrow(d);n[o]={defaultUrl:typeof l.export=="object"?l.export.url:void 0,contents:l,rawContents:c.rawContents}}else s(u)}else{let u=OVt(d,Jkc);if(u.success){let l=cI.serialization.DefinitionFileSchema.parseOrThrow(d);i[o]={defaultUrl:void 0,contents:l,rawContents:c.rawContents,absoluteFilePath:Tt(t,o)}}else s(u)}}return r==null?{didSucceed:!1,failures:{[Je.of(GB)]:{type:Wp.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:i,rootApiFile:r,packageMarkers:n}}var ESe=class extends B8t{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,PTh.default)(r??{}),n=this.fernWorkspaces[i];if(n==null){let a=t||this.context,o=Tt(this.absoluteFilePath,Je.of(e1)),c=await wbc({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await dCh(o,"{yml,yaml}"),s=await pCh(d);if(!s.didSucceed)return cAu(s.failures,a.logger),a.failAndThrow();let u=ATh({files:s.files,absolutePathToDefinition:o});if(!u.didSucceed)return cAu(u.failures,a.logger),a.failAndThrow();let l=await OTh({dependenciesConfiguration:c,structuralValidationResult:u,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!l.didSucceed)return cAu(l.failures,a.logger),a.failAndThrow();let p={absoluteFilePath:o,rootApiFile:u.rootApiFile,namedDefinitionFiles:u.namedDefinitionFiles,packageMarkers:l.packageMarkers,importedDefinitions:l.importedDefinitions};r?.auth!=null&&(p={...p,rootApiFile:{...p.rootApiFile,contents:{...p.rootApiFile.contents,auth:r?.auth}}}),n=new gY({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:c,workspaceName:this.workspaceName,definition:p,cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[i]=n}return n}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var tzh=require("fs/promises");var JRh=ce(KRh(),1);async function pYa(e){return(await(0,JRh.convertObj)(e,{})).openapi}var YRh=require("fs/promises");var $Rh=require("fs/promises");async function Mca({absoluteFilePathToOverrides:e,data:t,context:r,allowNullKeys:i}){let n=null;try{let a=(await(0,$Rh.readFile)(e,"utf8")).toString();try{n=JSON.parse(a)}catch{n=qi.load(a,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return Jnc({data:t,overrides:n,allowNullKeys:i})}async function vel({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,YRh.readFile)(t)).toString(),n=await qi.load(i);return r!=null?await Mca({absoluteFilePathToOverrides:r,context:e,data:n}):n}var ezh=require("fs/promises");var qPu=require("fs/promises");var CPu=ce(require("path"),1),XRh=ce(M4(),1),gel;async function oAB(){return gel===void 0&&(gel=(await XRh.default.dir({prefix:"fern-overlay-"})).path),gel}async function ZRh({absoluteFilePathToOverlay:e,absoluteFilePathToOpenAPI:t,data:r,context:i}){let n=await uAB(e,i);if(!sAB(n,i))return r;i.logger.debug(`Applying overlay "${n.info.title}" v${n.info.version}`);let a=Lnc({data:r,overlay:n}),o=await oAB(),c=CPu.default.basename(t),d=`${CPu.default.parse(c).name}.overlaid.json`,s=CPu.default.join(o,d);return await(0,qPu.writeFile)(s,JSON.stringify(a,null,2),"utf8"),i.logger.info(`Wrote overlaid OpenAPI spec to: ${s}`),a}async function uAB(e,t){let r;try{r=await(0,qPu.readFile)(e,"utf8")}catch(i){return t.failAndThrow(`Failed to read overlay file at ${e}: ${i}`)}try{try{return JSON.parse(r)}catch{return qi.load(r,{json:!0})}}catch(i){return t.failAndThrow(`Failed to parse overlay file at ${e}: ${i}`)}}function sAB(e,t){if(!e.overlay)return t.logger.error("Overlay file missing required 'overlay' version field"),!1;if(!e.info?.title||!e.info?.version)return t.logger.error("Overlay file missing required 'info.title' or 'info.version' field"),!1;if(!Array.isArray(e.actions)||e.actions.length===0)return t.logger.error("Overlay file must have at least one action"),!1;for(let r=0;r<e.actions.length;r++){let i=e.actions[r];if(!i?.target)return t.logger.error(`Overlay action at index ${r} missing required 'target' field`),!1;if(i.update===void 0&&!i.remove)return t.logger.error(`Overlay action at index ${r} must have either 'update' or 'remove'`),!1}return!0}var yYa=ce(zmu(),1);var kRh=ce(zmu(),1),_Ya=ce(require("path"),1),hYa=class extends kRh.BaseResolver{absolutePathToOpenAPIOverrides;absolutePathToOpenAPIOverlays;constructor({absolutePathToOpenAPIOverrides:t,absolutePathToOpenAPIOverlays:r}){super(),this.absolutePathToOpenAPIOverrides=t,this.absolutePathToOpenAPIOverlays=r}resolveExternalRef(t,r){let i=super.resolveExternalRef(t,r);if(i.startsWith("http://")||i.startsWith("https://")||E0e(Sr.of(i)))return i;if(this.absolutePathToOpenAPIOverlays!=null){let n=_Ya.default.resolve(_Ya.default.dirname(this.absolutePathToOpenAPIOverlays),r);if(E0e(Sr.of(n)))return n}return this.absolutePathToOpenAPIOverrides!=null?_Ya.default.resolve(_Ya.default.dirname(this.absolutePathToOpenAPIOverrides),r):i}};async function Oel({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,absolutePathToOpenAPIOverlays:r,parsed:i}){return(i!=null?await(0,yYa.bundle)({...Nmu,doc:{source:new yYa.Source(e,"<openapi>"),parsed:i},externalRefResolver:new hYa({absolutePathToOpenAPIOverrides:t,absolutePathToOpenAPIOverlays:r})}):await(0,yYa.bundle)({...Nmu,ref:e,externalRefResolver:new hYa({absolutePathToOpenAPIOverrides:t,absolutePathToOpenAPIOverlays:r})})).bundle.parsed}function cAB(e,t){if(t.includes(e))return e;for(let r of t){let i=r.replace(/\{[^}]+\}/g,"([^/]+)");if(new RegExp(`^${i}$`).test(e))return r}}var lAB=["examples","example",xi.EXAMPLES,PL.REDOCLY_CODE_SAMPLES_CAMEL,PL.REDOCLY_CODE_SAMPLES_KEBAB];async function bYa({context:e,absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r,absolutePathToOpenAPIOverlays:i,loadAiExamples:n=!1}){let a=await Oel({absolutePathToOpenAPI:t}),o;r!=null?o=r:typeof a=="object"&&a[xi.OPENAPI_OVERIDES_FILEPATH]!=null&&(o=Tt(nn(t),Je.of(a[xi.OPENAPI_OVERIDES_FILEPATH])));let c=a;if(o!=null&&(c=await Mca({absoluteFilePathToOverrides:o,context:e,data:c,allowNullKeys:lAB})),i!=null&&(c=await ZRh({absoluteFilePathToOverlay:i,absoluteFilePathToOpenAPI:t,context:e,data:c})),n){let d=Tt(nn(t),Je.of("ai_examples_override.yml"));try{let s=await(0,ezh.readFile)(d,"utf-8"),u=qi.load(s);if(u?.paths&&c.paths){for(let[l,p]of Object.entries(u.paths))if(p&&typeof p=="object")for(let[_,h]of Object.entries(p)){let y=_.toLowerCase(),b=c.paths[l];if(!b&&c.paths){let v=cAB(l,Object.keys(c.paths));v&&(b=c.paths[v],e.logger.debug(`Matched override path "${l}" to OpenAPI path "${v}" using pattern matching`))}if(b&&typeof b=="object"){let O=b[y];if(O&&typeof O=="object"){let m=O;!m["x-fern-examples"]&&h["x-fern-examples"]&&(m["x-fern-examples"]=h["x-fern-examples"],e.logger.debug(`Added AI examples for ${_.toUpperCase()} ${l} from override file`))}}}}e.logger.debug(`Processed AI examples from ${d}`)}catch{}}return o!=null||i!=null||c!==a?await Oel({absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:o,absolutePathToOpenAPIOverlays:i,parsed:c}):c}var Y8t=class{absoluteFilePath;constructor(t){this.absoluteFilePath=t}async loadDocuments({context:t,specs:r,loadAiExamples:i=!1}){let n=[];for(let a of r)try{let o=(await(0,tzh.readFile)(a.absoluteFilepath)).toString(),c=pp(this.absoluteFilePath,a.source.file);a.source.relativePathToDependency!=null&&(c=Tt(a.source.relativePathToDependency,c));let d=a.source.type==="protobuf"?CW.protobuf({file:c}):CW.openapi({file:c});if(o.includes("openapi")||o.includes("swagger"))try{let s=await bYa({absolutePathToOpenAPI:a.absoluteFilepath,context:t,absolutePathToOpenAPIOverrides:a.absoluteFilepathToOverrides,absolutePathToOpenAPIOverlays:a.absoluteFilepathToOverlays,loadAiExamples:i});if(KZc(s)){n.push({type:"openapi",value:s,source:d,namespace:a.namespace,settings:lSe({options:a.settings})});continue}else if(P$a(s)){(!s.schemes||s.schemes.length===0)&&(s.schemes=["https"]);let u=await pYa(s);n.push({type:"openapi",value:u,source:d,namespace:a.namespace,settings:lSe({options:a.settings})});continue}}catch(s){t.logger.debug(`Failed to parse OpenAPI document at ${a.absoluteFilepath}: ${s}. Skipping...`);continue}if(o.includes("asyncapi"))try{let s=await vel({context:t,absoluteFilePath:a.absoluteFilepath,absoluteFilePathToOverrides:a.absoluteFilepathToOverrides});n.push({type:"asyncapi",value:s,source:d,namespace:a.namespace,settings:lSe({options:a.settings})});continue}catch(s){t.logger.error(`Failed to parse AsyncAPI document at ${a.absoluteFilepath}: ${s}. Skipping...`);continue}if(o.includes("openrpc"))try{let s=await vel({context:t,absoluteFilePath:a.absoluteFilepath,absoluteFilePathToOverrides:a.absoluteFilepathToOverrides});n.push({type:"asyncapi",value:s,source:d,namespace:a.namespace,settings:lSe({options:a.settings})});continue}catch(s){t.logger.error(`Failed to parse OpenRPC document at ${a.absoluteFilepath}: ${s}. Skipping...`);continue}t.logger.warn(`${a.absoluteFilepath} is not a valid OpenAPI, AsyncAPI, or OpenRPC file. Skipping...`)}catch(o){t.logger.error(`Failed to read or process file ${a.absoluteFilepath}: ${o}. Skipping...`);continue}return n}};var fAB=Qt.object({type:Qt.string(),channelId:Qt.string().optional(),messageId:Qt.string(),value:Qt.any()}),dAB=Qt.object({summary:Qt.string().optional(),description:Qt.string().optional(),"query-parameters":Qt.record(Qt.string()).optional(),headers:Qt.record(Qt.string()).optional(),messages:Qt.array(fAB)}),rzh=Qt.array(dAB);var TPu=class extends fl{channel;baseDir;key="x-fern-examples";constructor({breadcrumbs:t,channel:r,context:i,baseDir:n}){super({breadcrumbs:t??[],context:i}),this.channel=r,this.baseDir=n}convert(){let t=this.getExtensionValue(this.channel);if(t==null)return;let r=rzh.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 Dca=class extends Oa{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 TPu({context:this.context,breadcrumbs:this.breadcrumbs,channel:this.channel,baseDir:this.context.documentBaseDir}).convert();return a==null?{}:Object.fromEntries(a.map((o,c)=>[c.toString(),{channel:{method:"GET",path:t},baseUrl:t,environment:r,auth:void 0,pathParameters:{},queryParameters:o.queryParameters,headers:o.headers,messages:o.messages.map(d=>({type:i==="v2"?d.type:d.messageId,body:d.value}))}]))}transformToValidPath(t){return t.startsWith("/")?t:"/"+t}};var bYi=class extends Nm.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 NR.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},c=new Nm.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 c!=null&&(t=c.type,r=c.inlinedTypes??{}),this.convertToOutput({schema:a,typeReference:t,inlinedTypes:r})}};var RPu=class extends fl{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 Bca=class extends fl{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 zPu=class extends Dca{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 Bca({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 o;this.channel.subscribe!=null&&(o=this.convertMessage({context:this.context,operation:this.channel.subscribe,origin:"server"}));let c;this.channel.publish!=null&&(c=this.convertMessage({context:this.context,operation:this.channel.publish,origin:"client"}));let d=[];o!=null&&d.push(o),c!=null&&d.push(c);let u=new RPu({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert(),l=this.transformToValidPath(u??this.channelPath),p=this.channel.servers?.[0]??Object.keys(this.context.spec.servers??{})[0],_=DM(l),h=ou(this.channelPath),y=this.context.getAudiences({operation:this.channel,breadcrumbs:this.breadcrumbs})??[];return{channel:{name:this.context.casingsGenerator.generateName(h),displayName:a,baseUrl:p,path:_,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:l,baseUrl:p,asyncApiVersion:"v2"})}},audiences:y,inlinedTypes:this.inlinedTypes}}convertMessage({context:t,operation:r,origin:i}){let n,a=i==="server"?"subscribe":"publish",o=[...this.breadcrumbs,a],c=t.resolveMaybeReference({schemaOrReference:r.message,breadcrumbs:o});c!=null&&(r.message=c);let d=Jfn(ou(`${this.channelPath}_${a}`)).replace(/ /g,"");if("oneOf"in r.message){let u=new Nm.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:o,schemaOrReference:r.message,schemaIdOverride:d}).convert();u!=null&&u.schema!=null&&(n=u.schema,this.inlinedTypes={...this.inlinedTypes,...u.inlinedTypes})}else if(t.isMessageWithPayload(r.message)){let s=t.resolveMaybeReference({schemaOrReference:r.message.payload,breadcrumbs:o});if(s!=null){let l=new Nm.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:o,schemaOrReference:s,schemaIdOverride:d}).convert();l!=null&&l.schema!=null&&(n=l.schema,this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes})}}if(n!=null){let s=n,u=ii.named({fernFilepath:t.createFernFilepath(),name:s.typeDeclaration.name.name,typeId:s.typeDeclaration.name.typeId,displayName:void 0,default:void 0,inline:!1}),l=bL.reference({bodyType:u,docs:r.description}),p=i==="server"?"subscribe":"publish";return{type:p,displayName:p,origin:i,body:l,availability:t.getAvailability({node:r,breadcrumbs:this.breadcrumbs}),docs:r.description,methodName:void 0}}}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 c=new bYi({context:this.context,breadcrumbs:this.breadcrumbs,parameter:{...a,name:i,in:"path",description:a.description,required:a.required??!0}}).convert();c!=null&&(this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes},c.type==="path"&&r.push(c.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 o=t.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,n]});if(o==null)continue;let d=new bYi({context:this.context,breadcrumbs:[...this.breadcrumbs,n],parameter:{name:n,in:"header",required:i.includes(n),schema:o,description:"description"in o?o.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 o=t.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,n]});if(o==null)continue;let d=new bYi({context:this.context,breadcrumbs:[...this.breadcrumbs,n],parameter:{name:n,in:"query",required:i.includes(n),schema:o,description:"description"in o?o.description:void 0,deprecated:o.deprecated??!1}}).convert();d!=null&&d.type==="query"&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},r.push(d.parameter))}}}};var Ica=class extends Oa{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:SM.singleBaseUrl({environments:t})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var NPu=class extends Ica{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 mel="$message.",izh="#/channels/",nzh="#/servers/",FPu=class extends Dca{operations;inlinedTypes={};constructor({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a,operations:o}){super({context:t,breadcrumbs:r,websocketGroup:i,channel:n,channelPath:a}),this.operations=o}convert(){let t=[],r=[],i=[],a=new Bca({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 o=Object.entries(this.operations).reduce((p,[_,h])=>{try{this.getChannelPathFromOperation(h)===this.channelPath&&(p[_]=h)}catch{}return p},{}),c=[];for(let[p,_]of Object.entries(o))for(let h of _.messages){let y=this.context.convertReferenceToTypeReference({reference:h});if(y.ok){let b=bL.reference({bodyType:y.reference,docs:_.description});c.push({type:p,displayName:p,origin:_.action==="send"?"client":"server",body:b,availability:this.context.getAvailability({node:_,breadcrumbs:this.breadcrumbs}),docs:_.description,methodName:void 0})}}let d=this.resolveChannelServersFromReference(this.channel.servers??[])??Object.keys(this.context.spec.servers??{})[0],s=this.transformToValidPath(this.channel.address??this.channelPath),u=DM(s),l=this.context.getAudiences({operation:this.channel,breadcrumbs:this.breadcrumbs})??[];return{channel:{name:this.context.casingsGenerator.generateName(a),displayName:a,baseUrl:d,path:u,auth:!1,headers:i,queryParameters:r,pathParameters:t,messages:c,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:l,inlinedTypes:this.inlinedTypes}}convertChannelParameters({pathParameters:t,queryParameters:r,headers:i,channelPath:n}){for(let a of Object.values(this.channel.parameters??{})){let o=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,"parameters"]});if(o==null)continue;let c=this.convertChannelParameterLocation(o.location);if(c==null)continue;let{type:d,parameterKey:s}=c,l=new bYi({context:this.context,breadcrumbs:this.breadcrumbs,parameter:{...o,name:s,in:d},parameterNamePrefix:this.channelPath}).convert();if(l!=null)switch(this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes},l.type){case"path":t.push(l.parameter);break;case"query":r.push(l.parameter);break;case"header":i.push(l.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(mel)){this.context.errorCollector.collect({message:`Invalid location format: ${t}; expected ${mel} prefix`,path:this.breadcrumbs});return}let n=r.substring(mel.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(nzh)){this.context.errorCollector.collect({message:`Failed to resolve server name from server ref ${r.$ref}`,path:this.breadcrumbs});return}let i=r.$ref.substring(nzh.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(izh))throw new Error(`Failed to resolve channel path from operation ${t.channel.$ref}`);return t.channel.$ref.substring(izh.length)}};var QPu=class extends Ica{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 vYa=class extends w8t{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 o=["channels",r,"messages",n],c=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:o});if(!this.context.isMessageWithPayload(c))continue;let d=this.context.resolveMaybeReference({schemaOrReference:c.payload,breadcrumbs:o});if(d==null)continue;let s=`${r}_${n}`;this.convertSchema({id:s,breadcrumbs:o,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 Nm.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:r,schema:i}).convert();a!=null&&this.addSchemaOutputToIr(t,a)}convertServers(){let t;if(this.isAsyncAPIV3(this.context)){let r=this.context.spec.servers;t=new QPu({context:this.context,breadcrumbs:["servers"],servers:r}).convert()}else{let r=this.context.spec.servers;t=new NPu({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 NR.SdkGroupNameExtension({breadcrumbs:["channels",t],operation:r,context:this.context}).convert()?.groups,a;if(this.isAsyncAPIV3(this.context)){let c=this.context.spec.operations??{};a=new FPu({context:this.context,breadcrumbs:["channels",t],websocketGroup:n,channel:r,channelPath:t,operations:c}).convert()}else a=new zPu({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 gYa=class extends bC{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,o=t.$ref.match(/^.*\/schemas\/(.+)$/),c=t.$ref.match(/^.*\/channels\/([^/]+)\/messages\/(.+)$/),d=t.$ref.match(/^.*\/messages\/(.+)$/);if(o&&o[1])return a=o[1],this.convertSchemaReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a});if(c&&c[2]){let s=c[1],u=c[2];return a=`${s}_${u}`,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 o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return n==="reference_identifier"?c=i??o.value.title:(n==="discriminator_key"||n==="schema_identifier")&&(c=o.value.title??i),{ok:!0,reference:ii.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}convertV3MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a}){let o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return n==="reference_identifier"?c=i??o.value.name:(n==="discriminator_key"||n==="schema_identifier")&&(c=o.value.name??i),{ok:!0,reference:ii.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}convertV2MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:i,displayNameOverrideSource:n,typeId:a}){let o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return n==="reference_identifier"?c=i??o.value.messageId??o.value.name:(n==="discriminator_key"||n==="schema_identifier")&&(c=o.value.messageId??o.value.name??i),{ok:!0,reference:ii.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}};var fzh=ce(UPu(),1);var LPu=class extends fl{document;key="x-fern-base-path";constructor({breadcrumbs:t,document:r,context:i}){super({breadcrumbs:t,context:i}),this.document=r}convert(){let t=this.getExtensionValue(this.document);if(t!=null){if(typeof t!="string"){this.context.errorCollector.collect({message:"Received unexpected non-string value for x-fern-base-path",path:this.breadcrumbs});return}return t}}};var VPu=class extends fl{document;key="x-fern-global-headers";constructor({breadcrumbs:t,document:r,context:i}){super({breadcrumbs:t,context:i}),this.document=r}convert(){let t=this.getExtensionValue(this.document);if(t!=null){if(!Array.isArray(t)){this.context.errorCollector.collect({message:"Received unexpected non-array value for x-fern-global-headers",path:this.breadcrumbs});return}return t}}};function azh({globalHeaders:e,context:t}){return e.map(r=>({name:t.casingsGenerator.generateNameAndWireValue({name:r.name??"",wireValue:r.header}),valueType:r.optional?Oa.OPTIONAL_STRING:Oa.STRING,env:r.env,v2Examples:r.optional?void 0:hAB({header:r,context:t}),availability:void 0,docs:void 0}))}function hAB({header:e,context:t}){let r=new OF({breadcrumbs:[],context:t,schema:{type:"string"},example:e.header}),{validExample:i}=r.convert();return{userSpecifiedExamples:{},autogeneratedExamples:{globalHeaderExample:i}}}var WPu=class extends Nm.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 Nm.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,this.parameter.name,"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 GPu=class extends Nm.AbstractConverters.AbstractMediaTypeObjectConverter{contentType;mediaType;description;required;schemaId;streamingExtension;queryParameters;constructor({context:t,breadcrumbs:r,contentType:i,mediaType:n,description:a,required:o,group:c,method:d,streamingExtension:s,queryParameters:u}){super({context:t,breadcrumbs:r,group:c,method:d}),this.contentType=i,this.mediaType=n,this.description=a,this.required=o,this.schemaId=[...this.group,this.method,"Request"].join("_"),this.streamingExtension=s,this.queryParameters=u??[]}convert(){return this.streamingExtension?.type=="streamCondition"?this.convertStreamConditionRequestBody():this.convertNonStreamConditionRequestBody()}convertStreamConditionRequestBody(){if(this.isOrderedJsonOrFormContentType())return this.handleStreamConditionJsonOrFormContent({contentType:this.contentType})}convertNonStreamConditionRequestBody(){if(this.isOrderedJsonOrFormContentType())return this.handleJsonOrFormContent({contentType:this.contentType});if(em.parse(this.contentType)?.isMultipart())return this.handleMultipartContent({contentType:this.contentType});if(this.isBinaryContentType())return this.handleBinaryContent({contentType:this.contentType})}isOrderedJsonOrFormContentType(){let t=em.parse(this.contentType);return t?t.isJSON()||t.isURLEncoded()||t.isPlainText()||t.isCSV()||t.isHTML()||t.isXML()||t.isDNS()||t.isApplicationText():!1}isBinaryContentType(){let t=em.parse(this.contentType);return t?t.isBinary():!1}handleJsonOrFormContent({contentType:t}){let r=this.mediaType;if(r==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,contentType:t});if(i==null)return;let n=i.schema?.typeDeclaration.shape;return n?.type==="object"?this.hasBodyQueryParameterOverlap(n.properties)?{requestBody:zm.reference({contentType:t,docs:this.description,requestBodyType:i.type,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:i.inlinedTypes??{}}:{requestBody:zm.inlinedRequestBody({contentType:t,docs:this.description,name:this.context.casingsGenerator.generateName(this.schemaId),extendedProperties:n.extendedProperties,extends:n.extends,properties:n.properties,extraProperties:n.extraProperties,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:i.inlinedTypes})}:{requestBody:zm.reference({contentType:t,docs:this.description,requestBodyType:i.type,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:i.inlinedTypes??{}}}handleMultipartContent({contentType:t}){let r=this.mediaType;if(r==null||r.schema==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,resolveSchema:!0,contentType:t});if(i==null)return;let n=i.schema?.typeDeclaration.shape;if(n?.type==="object")return{requestBody:zm.fileUpload({contentType:t,docs:this.description,name:this.context.casingsGenerator.generateName(this.schemaId),properties:n.properties.map(a=>{let o=r.encoding?.[a.name.wireValue];return this.convertRequestBodyProperty({property:a,contentType:t,encoding:o})}),v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:i.inlinedTypes}),examples:i.examples}}handleBinaryContent({contentType:t}){let r=this.mediaType;if(r==null)return;let i=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,contentType:t});return{requestBody:zm.bytes({contentType:t,isOptional:this.required===!1,docs:this.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:i?.inlinedTypes??{}}}convertRequestBodyProperty({property:t,contentType:r,encoding:i}){let{isFile:n,isOptional:a,isArray:o}=this.recursivelyCheckTypeReferenceIsFile({typeReference:t.valueType});return n?o?D1.file(fY.fileArray({key:t.name,isOptional:a,contentType:r,docs:t.docs})):D1.file(fY.file({key:t.name,isOptional:a,contentType:r,docs:t.docs})):D1.bodyProperty({...t,contentType:i?.contentType??r,style:bAB({encoding:i}),name:t.name})}handleStreamConditionJsonOrFormContent({contentType:t}){if(this.streamingExtension?.type!=="streamCondition")return;let r=this.mediaType;if(r==null||r.schema==null)return;let i=this.context.resolveMaybeReference({schemaOrReference:r.schema,breadcrumbs:[...this.breadcrumbs,"content",t,"schema"]});if(i==null)return;let n=i.properties?.[this.streamingExtension.streamConditionProperty];if(n==null||this.context.isReferenceObject(n))return;let a=this.buildStreamConditionInlinedRequestBody({streamConditionProperty:n,resolvedMediaTypeSchema:i,isStreaming:!0,contentType:t,mediaTypeObject:r}),o=this.buildStreamConditionInlinedRequestBody({streamConditionProperty:n,resolvedMediaTypeSchema:i,isStreaming:!1,contentType:t,mediaTypeObject:r});if(!(a==null||o==null))return{requestBody:o.requestBody,streamRequestBody:a.requestBody,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:{...a.inlinedTypes,...o.inlinedTypes}})}}buildStreamConditionInlinedRequestBody({streamConditionProperty:t,resolvedMediaTypeSchema:r,isStreaming:i,contentType:n,mediaTypeObject:a}){if(this.streamingExtension==null||this.streamingExtension.type!=="streamCondition")return;let o={...r,properties:{...r.properties,[this.streamingExtension.streamConditionProperty]:{type:"boolean",const:i,...t}},required:[...r.required??[],this.streamingExtension.streamConditionProperty]},c={...a,schema:o},d=this.parseMediaTypeObject({mediaTypeObject:c,schemaId:this.schemaId,contentType:n});if(d==null)return;let s=d.schema?.typeDeclaration.shape;if(s?.type==="object")return{requestBody:zm.inlinedRequestBody({contentType:n,docs:void 0,name:this.context.casingsGenerator.generateName(i?`${this.schemaId}_streaming`:this.schemaId),extendedProperties:s.extendedProperties,extends:s.extends,properties:s.properties,extraProperties:s.extraProperties,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:c,exampleGenerationStrategy:"request"})}),inlinedTypes:d.inlinedTypes}}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}}hasBodyQueryParameterOverlap(t){if(this.queryParameters.length===0)return!1;let r=new Set(this.queryParameters.map(i=>i.name.wireValue.toLowerCase()));return t.some(i=>r.has(i.name.wireValue.toLowerCase()))}},yAB={"application/json":"json"};function bAB({encoding:e}){if(e){if(e.explode)return"exploded";if(e.style==="form")return"form";if(e.contentType)return yAB[e.contentType]}}var vAB=/{([^}]+)}/g,gAB=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]),Cca=class extends Oa{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 uw.Get;case"post":return uw.Post;case"put":return uw.Put;case"delete":return uw.Delete;case"patch":return uw.Patch;case"head":return uw.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 o=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:t});if(o==null)continue;let d=new WPu({context:this.context,breadcrumbs:t,parameter:o}).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,u=d.parameter.name.wireValue,l=!1,p=this.context.authOverrides?.["auth-schemes"];if(p!=null){for(let h of Object.values(p))if(PAB(h)&&h.header.toLowerCase()===u.toLowerCase()){l=!0;break}}let _=this.context.globalHeaderNames;if(_!=null){for(let h of _)if(h.toLowerCase()===u.toLowerCase()){l=!0;break}}!gAB.has(s.toLowerCase())&&!l&&n.push(d.parameter);break}}}return this.checkMissingPathParameters(r),{pathParameters:r,queryParameters:i,headers:n}}checkMissingPathParameters(t){let i=[...this.path.matchAll(vAB)].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:Oa.STRING,docs:void 0,location:"ENDPOINT",variable:void 0,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{[a]:this.generateStringParameterExample({example:n})}},explode:void 0})}}convertRequestBody({breadcrumbs:t,group:r,method:i,streamingExtension:n,queryParameters:a}){if(this.operation.requestBody==null)return;let o=this.context.resolveMaybeReference({schemaOrReference:this.operation.requestBody,breadcrumbs:t});if(o==null)return null;let c=[];for(let[d,s]of Object.entries(o.content)){let l=new GPu({context:this.context,breadcrumbs:t,contentType:d,mediaType:s,description:o.description,required:o.required,group:r??[],method:i,streamingExtension:n,queryParameters:a}).convert();l!=null&&(this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes},c.push({requestBody:l.requestBody,streamRequestBody:l.streamRequestBody,examples:l.examples}))}return c}computeGroupNameAndLocationFromExtensions(){let r=new NR.SdkMethodNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert()?.methodName,n=new NR.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?ou(this.operation.summary):ou(`${this.method}_${this.path.split("/").join("_")}`))}computeGroupNameFromTagAndOperationId(){let t=this.operation.tags?.[0],r=this.evaluateMethodNameFromOperation();if(t==null)return{method:r};let i=ozh(t),n=ozh(r);return rR(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((c,d)=>c!==n[d]))return{group:[t],method:i};let o=n.slice(r.length);return{group:[t],method:ou(o.join("_"))}}generateStringParameterExample({example:t}){let r=new Nm.ExampleConverter({breadcrumbs:this.breadcrumbs,context:this.context,schema:{type:"string"},example:t}),{validExample:i}=r.convert();return i}};function ozh(e){let t=OAB(e)?mAB(e):AAB(e);return t=t.map(r=>r.toLowerCase()),t=u0e(t),t}function OAB(e){return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)}function mAB(e){return e.split(/(?=[A-Z])/)}function AAB(e){return e.split(/[^a-zA-Z0-9]+/)}function PAB(e){return e?.header!=null}var qca=class extends Cca{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,queryParameters:o}=this.convertParameters({breadcrumbs:n}),c=this.convertRequestBody({breadcrumbs:n,group:r,method:i,streamingExtension:void 0,queryParameters:o});if(c==null)return;let d=c[0]?.requestBody;if(d==null)return;let s,u;if(d.type==="inlinedRequestBody")s=dF.inlinedPayload({name:d.name,extends:d.extends,properties:d.properties});else if(d.type==="reference")s=dF.reference({payloadType:d.requestBodyType,docs:d.docs});else if(d.type==="fileUpload")u={name:d.name,properties:d.properties,docs:d.docs,v2Examples:d.v2Examples,contentType:d.contentType},s=dF.inlinedPayload({name:d.name,extends:[],properties:[]});else return;let l=this.convertWebhookResponses();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:s,fileUploadPayload:u,responses:l.length>0?l:void 0,examples:[],availability:this.context.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs}),docs:this.operation.description,v2Examples:{autogeneratedExamples:this.getWebhookV2ExamplesFromRequestBodyV2Examples(d.v2Examples?.autogeneratedExamples??{}),userSpecifiedExamples:this.getWebhookV2ExamplesFromRequestBodyV2Examples(d.v2Examples?.userSpecifiedExamples??{})}},inlinedTypes:this.inlinedTypes}}convertWebhookResponses(){let t=[];if(this.operation.responses==null)return t;for(let[r,i]of Object.entries(this.operation.responses)){let n=/^\d[Xx]{2}$/.test(r),a;if(n)a=parseInt(r.charAt(0))*100;else if(a=parseInt(r),isNaN(a))continue;let c=this.context.resolveMaybeReference({schemaOrReference:i,breadcrumbs:[...this.breadcrumbs,"responses",r]})?.description;t.push({statusCode:a,isWildcardStatusCode:n?!0:void 0,body:void 0,docs:c})}return t}getWebhookV2ExamplesFromRequestBodyV2Examples(t){return Object.fromEntries(Object.entries(t).map(([r,i])=>[r,{name:r,payload:i}]))}};var jel=ce(UPu(),1);var uzh=["get","post","put","delete","patch","head"];var xPu=class extends fl{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 jAB=Qt.object({cursor:Qt.string(),next_cursor:Qt.string(),results:Qt.string()}),wAB=Qt.object({offset:Qt.string(),results:Qt.string(),step:Qt.string().optional(),"has-next-page":Qt.string().optional()}),Ael=Qt.union([Qt.boolean(),jAB,wAB]);var Pel="$request.",HPu="$response.",KPu=class extends fl{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=Ael.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=Ael.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:bC.maybeTrimPrefix(r.cursor,Pel),nextCursor:bC.maybeTrimPrefix(r.next_cursor,HPu),results:bC.maybeTrimPrefix(r.results,HPu)};let i=t;return{type:"offset",offset:bC.maybeTrimPrefix(i.offset,Pel),results:bC.maybeTrimPrefix(i.results,HPu),step:i.step!=null?bC.maybeTrimPrefix(i.step,Pel):void 0,hasNextPage:i["has-next-page"]!=null?bC.maybeTrimPrefix(i["has-next-page"],HPu):void 0}}};var EAB="$request.",SAB=Qt.object({"stream-condition":Qt.string().optional(),format:Qt.enum(["sse","json"]).optional(),"stream-description":Qt.string().optional(),"response-stream":Qt.any(),response:Qt.any()}),MAB=Qt.union([Qt.boolean(),SAB]),JPu=class extends fl{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=MAB.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:bC.maybeTrimPrefix(r.data["stream-condition"],EAB),responseStream:r.data["response-stream"],response:r.data.response}}};var $Pu=class extends fl{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 XPu=require("fs"),szh=require("path");function DAB(e){return yl(e)&&typeof e.$ref=="string"}function BAB(e,t){if(e!=null){if(typeof e=="string")return e;if(DAB(e)){let r=(0,szh.resolve)(t??process.cwd(),e.$ref);if((0,XPu.existsSync)(r))try{return(0,XPu.readFileSync)(r,"utf-8")}catch{return}}}}var YPu=class extends fl{operation;baseDir;key="x-codeSamples";constructor({context:t,breadcrumbs:r,operation:i,baseDir:n}){super({breadcrumbs:r,context:t}),this.operation=i,this.baseDir=n}convert(){let t=yl(this.operation)?this.operation:{},r=t["x-codeSamples"],i=t["x-code-samples"],n=Array.isArray(r)?r:[],a=Array.isArray(i)?i:[],o=[...n,...a];if(o.length===0)return;let c=[];for(let d of o){if(!yl(d))continue;let s=d,u=s.lang,l=s.label,p=s.source;if(typeof u!="string")continue;let _=BAB(p,this.baseDir);_!=null&&c.push({name:typeof l=="string"?l:u,language:u,code:_,install:void 0,docs:void 0})}if(c.length!==0)return[{"code-samples":c}]}};var kPu=require("fs"),czh=require("path");function IAB(e){return yl(e)&&typeof e.$ref=="string"}function CAB(e,t){if(e!=null){if(typeof e=="string")return e;if(IAB(e)){let r=(0,czh.resolve)(t??process.cwd(),e.$ref);if((0,kPu.existsSync)(r))try{return(0,kPu.readFileSync)(r,"utf-8")}catch{return}}}}function qAB(e,t){if(!Array.isArray(e))return[];let r=[];for(let i of e){if(!yl(i))continue;let a=CAB(i.code,t);a!=null&&r.push({...i,code:a})}return r}var ZPu=class extends fl{operation;baseDir;key="x-fern-examples";constructor({context:t,breadcrumbs:r,operation:i,baseDir:n}){super({breadcrumbs:r,context:t}),this.operation=i,this.baseDir=n}convert(){let t=this.getExtensionValue(this.operation);return t==null?void 0:(Array.isArray(t)?t:[]).map(a=>{if(!yl(a))return a;let c=a["code-samples"];if(c!=null){let d=qAB(c,this.baseDir);return{...a,"code-samples":d}}return a}).filter(a=>{let o=cI.serialization.ExampleEndpointCallSchema.parse(a);return o.ok||this.context.errorCollector.collect({message:`Failed to parse x-fern-example in ${this.breadcrumbs.join(".")}`,path:this.breadcrumbs}),o.ok})}};var OYa=class extends fl{document;key="x-fern-explorer";constructor({breadcrumbs:t,document:r,context:i}){super({breadcrumbs:t,context:i}),this.document=r}convert(){let t=this.getExtensionValue(this.document);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-explorer",path:this.breadcrumbs});return}return t}}};var mYa=class extends Nm.AbstractConverters.AbstractMediaTypeObjectConverter{responseBody;statusCode;streamingExtension;constructor({context:t,breadcrumbs:r,responseBody:i,group:n,method:a,statusCode:o,streamingExtension:c}){super({context:t,breadcrumbs:r,group:n,method:a}),this.responseBody=i,this.statusCode=o,this.streamingExtension=c}convert(){return this.shouldConvertAsStreaming()?this.convertStreamingResponseBody():this.convertNonStreamingResponseBody()}convertStreamingResponseBody(){if(this.streamingExtension!=null){if(this.streamingExtension.type=="streamCondition"){let t=this.streamingExtension.responseStream,r=this.streamingExtension.response,i=[...this.group,this.method,"Response",this.statusCode].join("_"),n=`${i}_streaming`,a=this.parseMediaTypeSchemaOrReference({schemaOrReference:t,schemaId:n}),o=this.parseMediaTypeSchemaOrReference({schemaOrReference:r,schemaId:i});return this.convertStreamConditionResponse({convertedStreamingSchema:a,convertedNonStreamingSchema:o})}if(this.streamingExtension.type==="stream"){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})}}}}convertNonStreamingResponseBody(){let t=[...this.group,this.method,"Response",this.statusCode].join("_"),r=Object.keys(this.responseBody.content??{}).filter(a=>a.includes("json"));for(let a of r){let o=this.responseBody.content?.[a];if(o==null)continue;let c=this.parseMediaTypeObject({mediaTypeObject:o,schemaId:t,contentType:a});if(c!=null&&this.shouldReturnJsonResponse(a))return this.returnJsonResponse({mediaTypeObject:o,convertedSchema:c})}let i=Object.keys(this.responseBody.content??{}).filter(a=>!a.includes("json"));for(let a of i){let o=this.responseBody.content?.[a];if(o==null)continue;let c=this.parseMediaTypeObject({mediaTypeObject:o,schemaId:t,contentType:a});if(c!=null){if(this.isBinarySchema(c))return this.shouldReturnBytesResponse()?this.returnBytesResponse({mediaTypeObject:o}):this.returnFileDownloadResponse({mediaTypeObject:o});if(this.shouldReturnTextResponse(a))return this.returnTextResponse({mediaTypeObject:o})}}let n=parseInt(this.statusCode);if(!isNaN(n)&&n>=200&&n<300){let a={schema:{type:"object",description:"Empty response body"}},o=this.parseMediaTypeObject({mediaTypeObject:a,schemaId:t,contentType:"application/json",resolveSchema:!0});if(o!=null)return this.returnJsonResponse({mediaTypeObject:a,convertedSchema:o})}}convertStreamConditionResponse({convertedStreamingSchema:t,convertedNonStreamingSchema:r}){if(t==null||r==null)return;let i=this.responseBody.description;return this.streamingExtension?.type==="streamCondition"&&this.streamingExtension.streamDescription!=null&&(i=this.streamingExtension.streamDescription),{responseBody:wd.json(dC.response({responseBodyType:r.type,docs:this.responseBody.description,v2Examples:r.schema?.typeDeclaration.v2Examples})),streamResponseBody:wd.streaming(sI.json({docs:i,payload:t.type,terminator:void 0,v2Examples:t.schema?.typeDeclaration.v2Examples})),inlinedTypes:{...t.inlinedTypes,...r.inlinedTypes},headers:this.convertResponseHeaders()}}convertStreamingResponse({mediaTypeObject:t,convertedSchema:r}){if(this.streamingExtension==null)return;switch(this.streamingExtension.format){case"json":return{responseBody:wd.streaming(sI.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,headers:this.convertResponseHeaders()};case"sse":return{responseBody:wd.streaming(sI.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,headers:this.convertResponseHeaders()};default:return}}returnJsonResponse({mediaTypeObject:t,convertedSchema:r}){return{responseBody:wd.json(dC.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,headers:this.convertResponseHeaders()}}returnBytesResponse({mediaTypeObject:t}){return{responseBody:wd.bytes({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{},headers:this.convertResponseHeaders()}}returnFileDownloadResponse({mediaTypeObject:t}){return{responseBody:wd.fileDownload({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{},headers:this.convertResponseHeaders()}}returnTextResponse({mediaTypeObject:t}){return{responseBody:wd.text({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{},headers:this.convertResponseHeaders()}}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&&this.streamingExtension==null}shouldReturnTextResponse(t){return em.parse(t)?.isText()??!1}convertResponseHeaders(){let t=[],r=this.responseBody.headers;if(r==null)return t;for(let[i,n]of Object.entries(r)){let a=this.context.resolveMaybeReference({schemaOrReference:n,breadcrumbs:[...this.breadcrumbs,"headers",i]});if(a==null)continue;let o=a.schema,c=Oa.OPTIONAL_STRING;if(o!=null){let s=this.context.resolveMaybeReference({schemaOrReference:o,breadcrumbs:[...this.breadcrumbs,"headers",i,"schema"]});s!=null&&(s.type==="number"||s.type==="integer"?c=ii.primitive({v1:s.type==="integer"?"INTEGER":"DOUBLE",v2:s.type==="integer"?vn.integer({default:void 0,validation:void 0}):vn.double({default:void 0,validation:void 0})}):s.type==="boolean"&&(c=ii.primitive({v1:"BOOLEAN",v2:vn.boolean({default:void 0})})))}let d=this.convertHeaderExamples({header:a,headerName:i,schema:o});t.push({name:this.context.casingsGenerator.generateNameAndWireValue({name:i,wireValue:i}),docs:a.description,valueType:c,env:void 0,v2Examples:d,availability:void 0})}return t}convertHeaderExamples({header:t,headerName:r,schema:i}){let n={userSpecifiedExamples:{},autogeneratedExamples:{}},a=t.example,o=t.examples;for(let[c,d]of Object.entries(o??{})){let s=this.context.resolveExampleWithValue(d);s!=null&&(n.userSpecifiedExamples[c]=this.generateHeaderExample({schema:i,example:s}))}if(a!=null){let c=this.context.generateUniqueName({prefix:`${r}_example`,existingNames:Object.keys(n.userSpecifiedExamples)});n.userSpecifiedExamples[c]=this.generateHeaderExample({schema:i,example:a})}if(Object.keys(n.userSpecifiedExamples).length===0&&i!=null){let c=`${r}_example`;n.autogeneratedExamples[c]=this.generateHeaderExample({schema:i,example:void 0,ignoreErrors:!0})}return n}generateHeaderExample({schema:t,example:r,ignoreErrors:i}){if(t==null)return r;let n=new OF({breadcrumbs:this.breadcrumbs,context:this.context,schema:t,example:r}),{validExample:a,errors:o}=n.convert();return i||o.forEach(c=>{this.context.errorCollector.collect({message:c.message,path:c.path})}),a}};var eju=class extends Nm.AbstractConverters.AbstractMediaTypeObjectConverter{responseError;statusCode;methodName;isWildcardStatusCode;constructor({context:t,breadcrumbs:r,responseError:i,group:n,method:a,methodName:o,statusCode:c,isWildcardStatusCode:d}){super({context:t,breadcrumbs:r,group:n,method:a}),this.responseError=i,this.statusCode=c,this.methodName=o,this.isWildcardStatusCode=d}convert(){if(!this.responseError.content){let i=this.getErrorNameForStatusCode(this.statusCode,this.isWildcardStatusCode);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:ii.unknown(),displayName:i,statusCode:this.statusCode,isWildcardStatusCode:this.isWildcardStatusCode,inlinedTypes:{},examples:{},headers:this.convertResponseHeaders()}}let t=Object.keys(this.responseError.content).filter(i=>i.includes("json")),r=this.getErrorNameForStatusCode(this.statusCode,this.isWildcardStatusCode);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:lzh(`${this.methodName}Request${r}`),contentType:i});if(a==null)continue;let o=this.getErrorIdFromErrorName(r);if(a.schema!=null)return this.constructErrorConverterOutput({errorName:r,errorId:o,fernFilepath:a.schema.typeDeclaration.name.fernFilepath,convertedSchema:a});if(a.type.type==="named")return this.constructErrorConverterOutput({errorName:r,errorId:o,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,isWildcardStatusCode:this.isWildcardStatusCode,inlinedTypes:n.inlinedTypes,examples:n.examples,headers:this.convertResponseHeaders()}}getErrorNameForStatusCode(t,r){if(r){if(t===400)return"ClientRequestError";if(t===500)return"ServerError"}return Qpu[t]}getErrorIdFromErrorName(t){return this.context.enableUniqueErrorsPerEndpoint?lzh(`${this.methodName}Request${t}`):t}convertResponseHeaders(){let t=[],r=this.responseError.headers;if(r==null)return t;for(let[i,n]of Object.entries(r)){let a=this.context.resolveMaybeReference({schemaOrReference:n,breadcrumbs:[...this.breadcrumbs,"headers",i]});if(a==null)continue;let o=a.schema,c=Oa.OPTIONAL_STRING;if(o!=null){let s=this.context.resolveMaybeReference({schemaOrReference:o,breadcrumbs:[...this.breadcrumbs,"headers",i,"schema"]});s!=null&&(s.type==="number"||s.type==="integer"?c=ii.primitive({v1:s.type==="integer"?"INTEGER":"DOUBLE",v2:s.type==="integer"?vn.integer({default:void 0,validation:void 0}):vn.double({default:void 0,validation:void 0})}):s.type==="boolean"&&(c=ii.primitive({v1:"BOOLEAN",v2:vn.boolean({default:void 0})})))}let d=this.convertHeaderExamples({header:a,headerName:i,schema:o});t.push({name:this.context.casingsGenerator.generateNameAndWireValue({name:i,wireValue:i}),docs:a.description,valueType:c,env:void 0,v2Examples:d,availability:void 0})}return t}convertHeaderExamples({header:t,headerName:r,schema:i}){let n={userSpecifiedExamples:{},autogeneratedExamples:{}},a=t.example,o=t.examples;for(let[c,d]of Object.entries(o??{})){let s=this.context.resolveExampleWithValue(d);s!=null&&(n.userSpecifiedExamples[c]=this.generateHeaderExample({schema:i,example:s}))}if(a!=null){let c=this.context.generateUniqueName({prefix:`${r}_example`,existingNames:Object.keys(n.userSpecifiedExamples)});n.userSpecifiedExamples[c]=this.generateHeaderExample({schema:i,example:a})}if(Object.keys(n.userSpecifiedExamples).length===0&&i!=null){let c=`${r}_example`;n.autogeneratedExamples[c]=this.generateHeaderExample({schema:i,example:void 0,ignoreErrors:!0})}return n}generateHeaderExample({schema:t,example:r,ignoreErrors:i}){if(t==null)return r;let n=new OF({breadcrumbs:this.breadcrumbs,context:this.context,schema:t,example:r}),{validExample:a,errors:o}=n.convert();return i||o.forEach(c=>{this.context.errorCollector.collect({message:c.message,path:c.path})}),a}};function lzh(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}var tju=class e extends Cca{idempotent;idToAuthScheme;topLevelServers;streamingExtension;static AUTHORIZATION_HEADER="Authorization";constructor({context:t,breadcrumbs:r,operation:i,method:n,path:a,idempotent:o,idToAuthScheme:c,topLevelServers:d,streamingExtension:s}){super({context:t,breadcrumbs:r,operation:i,method:n,path:a}),this.idempotent=o,this.idToAuthScheme=c,this.topLevelServers=d,this.streamingExtension=s}convert(){let t=this.convertHttpMethod();if(t==null)return;let{group:r,method:i}=this.computeGroupNameAndLocationFromExtensions()??this.computeGroupNameFromTagAndOperationId(),n=this.getGroupDisplayName(r),{headers:a,pathParameters:o,queryParameters:c}=this.convertParameters({breadcrumbs:[...this.breadcrumbs,"parameters"]}),d=this.convertRequestBody({breadcrumbs:[...this.breadcrumbs,"requestBody"],group:r,method:i,streamingExtension:this.streamingExtension,queryParameters:c}),s=d?.[0]?.requestBody,u=d?.[0]?.streamRequestBody,l={requestBodies:d?.map(Y=>Y.requestBody)},p=this.convertResponseBody({breadcrumbs:[...this.breadcrumbs,"responses"],group:r,method:i,streamingExtension:this.streamingExtension}),_=p?.response,h=p?.streamResponse,y=p!=null?p.errors:[],b={},v=y.map(Y=>Y.error),O=DM(this.path),m=this.getEndpointBaseUrl(),g=this.getEndpointBaseUrls(),A=this.convertExamples({httpPath:O,httpMethod:t,baseUrl:m}),j=new Set(this.operation.security?.flatMap(Y=>Object.keys(Y))??[]),M=this.authSchemeToHeaders(Array.from(j));M.length>0&&a.push(...M);for(let Y of y){let he=Y.error,be=Y.errorType,W=he.error.errorId,x=Y.examples;b[W]={name:he.error,displayName:Y.displayName,discriminantValue:{name:he.error.name,wireValue:W},type:be,statusCode:Y.statusCode,isWildcardStatusCode:Y.isWildcardStatusCode,docs:he.docs,examples:[],v2Examples:{userSpecifiedExamples:x??{},autogeneratedExamples:{}},headers:Y.headers}}let w=this.context.getAudiences({operation:this.operation,breadcrumbs:this.breadcrumbs})??[],B=new OYa({context:this.context,breadcrumbs:this.breadcrumbs,document:this.context.spec}).convert(),q=new OYa({context:this.context,breadcrumbs:this.breadcrumbs,document:this.operation}).convert()??B,z={displayName:this.operation.summary,method:t,baseUrl:m,v2BaseUrls:g,path:O,pathParameters:o,queryParameters:c,headers:a.filter((Y,he,be)=>he===be.findIndex(W=>W.name.wireValue===Y.name.wireValue)),responseHeaders:p?.responseHeaders,sdkRequest:void 0,errors:v,auth:this.computeEndpointAuth(),security:this.operation.security??this.context.spec.security??this.getDefaultSecurityFromAuthOverrides(),availability:this.context.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs}),userSpecifiedExamples:[],autogeneratedExamples:[],idempotent:this.idempotent??!1,basePath:void 0,fullPath:O,allPathParameters:o,pagination:void 0,transport:void 0,source:mW.openapi(),audiences:w,retries:void 0,apiPlayground:q},Q=this.context.namespace!=null?[this.context.namespace]:[],H=r?.map(Y=>ou(Y));return Q.push(...H??[]),{audiences:w,group:r,groupDisplayName:n,errors:b,endpoint:{...z,id:`endpoint_${Q.join("/")}.${i}`,name:this.context.casingsGenerator.generateName(i),requestBody:s,v2RequestBodies:l,response:_,docs:this.operation.description,v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:A.examples},v2Responses:{responses:p?.v2Responses}},streamEndpoint:h!=null&&h.body!=null?{...z,id:`endpoint_${Q.join("/")}.${i}_stream`,name:this.context.casingsGenerator.generateName(`${i}_stream`),requestBody:u,v2RequestBodies:void 0,response:h,docs:this.streamingExtension?.type==="streamCondition"?this.streamingExtension.streamDescription??this.operation.description:this.operation.description,v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:A.streamExamples},v2Responses:{responses:[{statusCode:200,isWildcardStatusCode:void 0,body:h.body,docs:h.docs}]}}: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,o=!1;for(let[c,d]of Object.entries(this.operation.responses)){let s=/^[45]XX$/i.test(c),u,l=!1;if(s)u=parseInt(c.charAt(0))*100,l=!0;else{if(u=parseInt(c),isNaN(u)||u<200||u>=300&&u<400)continue;l=u>=400&&u<600}if(a==null&&(a={response:void 0,v2Responses:void 0,streamResponse:void 0,errors:[],examples:{},responseHeaders:[]}),u>=200&&u<300){let p=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:[...t,c]});if(p==null)continue;let h=new mYa({context:this.context,breadcrumbs:[...t,c],responseBody:p,group:r??[],method:i,statusCode:c,streamingExtension:n}).convert();h!=null&&(this.inlinedTypes={...this.inlinedTypes,...h.inlinedTypes},o||(o=!0,a.response={statusCode:u,isWildcardStatusCode:s?!0:void 0,body:h.responseBody,docs:p.description},a.streamResponse={statusCode:u,isWildcardStatusCode:s?!0:void 0,body:h.streamResponseBody,docs:p.description},h.headers!=null&&(a.responseHeaders=h.headers)),a.v2Responses=[...a.v2Responses??[],{statusCode:u,isWildcardStatusCode:s?!0:void 0,body:h.responseBody,docs:p.description}])}if(l){let p=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:[...t,c]});if(p==null)continue;let h=new eju({context:this.context,breadcrumbs:[...t,c],responseError:p,group:r??[],method:i,methodName:this.evaluateMethodNameFromOperation(),statusCode:u,isWildcardStatusCode:s?!0:void 0}).convert();h!=null&&(this.inlinedTypes={...this.inlinedTypes,...h.inlinedTypes},a.errors.push(h))}}if(this.streamingExtension!=null){a==null&&(a={response:void 0,v2Responses:void 0,streamResponse:void 0,errors:[],examples:{},responseHeaders:[]});let d=new mYa({context:this.context,breadcrumbs:[...t,"stream"],responseBody:{description:""},group:r??[],method:i,statusCode:"stream",streamingExtension:n}).convert();d!=null&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},a.response={statusCode:200,isWildcardStatusCode:void 0,body:d.responseBody,docs:void 0},a.streamResponse={statusCode:200,isWildcardStatusCode:void 0,body:d.streamResponseBody,docs:void 0},a.v2Responses=[{statusCode:200,isWildcardStatusCode:void 0,body:d.responseBody,docs:void 0}])}return a}computeEndpointAuth(){return this.operation.security!=null&&this.operation.security.length===0?!1:this.operation.security!=null&&this.operation.security.length>0?!0:this.context.spec.security!=null&&this.context.spec.security.length>0||this.shouldApplyDefaultAuthOverrides()}shouldApplyDefaultAuthOverrides(){if(!this.context.authOverrides?.auth)return!1;let t=this.context.spec.security!=null&&this.context.spec.security.length>0,r=this.operation.security!=null&&this.operation.security.length>0;return!(t||r)}getDefaultSecurityFromAuthOverrides(){if(!this.context.authOverrides?.auth)return;let t=this.context.authOverrides.auth;if(typeof t!="string")return;let r={};return r[t]=[],[r]}authSchemeToHeaders(t){let r=[];for(let i of t){let n=this.idToAuthScheme?.[i];if(n==null)continue;let a={valueType:Oa.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 ZPu({context:this.context,breadcrumbs:this.breadcrumbs,operation:this.operation,baseDir:this.context.documentBaseDir}).convert()??[],c=new YPu({context:this.context,breadcrumbs:this.breadcrumbs,operation:this.operation,baseDir:this.context.documentBaseDir}).convert()??[],s=a.some(u=>Array.isArray(u["code-samples"])&&u["code-samples"].length>0)?a:[...a,...c];return s.length===0?{examples:{},streamExamples:{}}:this.streamingExtension?.type==="streamCondition"?this.convertStreamConditionExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:s}):{examples:this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:s}),streamExamples:{}}}convertStreamConditionExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:n}){let a=n.filter(s=>!(s.response!=null&&"stream"in s.response)),o=n.filter(s=>s.response!=null&&"stream"in s.response),c=this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:a}),d=this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:o});return{examples:c,streamExamples:d}}convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:i,fernExamples:n}){return Object.fromEntries(n.map((a,o)=>[this.getExampleName({example:a,exampleIndex:o}),{displayName:void 0,request:a.request!=null||a["path-parameters"]!=null||a["query-parameters"]!=null||a.headers!=null?{docs:void 0,endpoint:{method:r,path:this.buildExamplePath(t,a["path-parameters"]??{})},baseUrl:void 0,environment:i,auth:void 0,pathParameters:a["path-parameters"]??{},queryParameters:a["query-parameters"]??{},headers:a.headers??{},requestBody:a.request??void 0}:void 0,response:a.response!=null?{docs:void 0,statusCode:void 0,body:this.getExampleResponseBody({example:a})}:void 0,codeSamples:a["code-samples"]?.map(c=>{let d=("language"in c?c.language:c.sdk)??void 0;return{name:c.name,docs:void 0,language:d,code:c.code}})}]))}getExampleName({example:t,exampleIndex:r}){return t.name??t["code-samples"]?.[0]?.name??`Example_${r}`}getExampleResponseBody({example:t}){if(t.response!=null){if("stream"in t.response)return Ar.V2HttpEndpointResponseBody.stream(t.response.stream);if("body"in t.response)return Ar.V2HttpEndpointResponseBody.json(t.response.body)}}getEndpointBaseUrl(){let r=new NR.ServerFromOperationNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert();if(r!=null)return this.context.logger.debug(`[getEndpointBaseUrl] Endpoint ${this.method.toUpperCase()} ${this.path} specifies a server with "${xi.SERVER_NAME_V2}" extension. Returning server type: ${r}`),r;let i=this.operation.servers?.[0];if(i==null)return;let a=this.topLevelServers?.find(o=>o.url===i.url)??i;return sge.getServerName({server:a,context:this.context})}getEndpointBaseUrls(){let t=this.operation.servers;return t?.map(i=>{let a=this.topLevelServers?.find(o=>o.url===i.url)??i;return sge.getServerName({server:a,context:this.context})})}buildExamplePath(t,r){return t.head+t.parts.map(i=>`${r[i.pathParameter]?.toString()??i.pathParameter}${i.tail}`).join("")}filterOutTopLevelServers(t){return t.filter(r=>!this.topLevelServers?.some(i=>i.url===r.url))}getGroupDisplayName(t){let r=this.operation.tags?.[0];r!=null&&(r=this.context.getDisplayNameForTag(r));let i=t?.[t.length-1];if(i!=null&&r!=null)return r.toLowerCase().replaceAll(" ","")===i?r:void 0}};var rju=class extends Oa{pathItem;path;idToAuthScheme;topLevelServers;constructor({context:t,breadcrumbs:r,pathItem:i,path:n,idToAuthScheme:a,topLevelServers:o}){super({context:t,breadcrumbs:r}),this.pathItem=i,this.path=n,this.idToAuthScheme=a,this.topLevelServers=o}convert(){let t=[],r=[],i={};for(let n of uzh){let a=this.pathItem[n];if(a==null)continue;let o=[...this.breadcrumbs,n],c=this.tryParseAsWebhook({operationBreadcrumbs:o,operation:a,method:n,context:this.context});if(c!=null){r.push(c),Object.assign(i,c.inlinedTypes);continue}let s=new JPu({breadcrumbs:o,operation:a,context:this.context}).convert(),u=this.tryParseAsHttpEndpoint({operationBreadcrumbs:o,operation:a,method:n,streamingExtension:s});u!=null&&(t.push(u),Object.assign(i,u.inlinedTypes))}return{endpoints:t,webhooks:r,inlinedTypes:i}}tryParseAsWebhook({operation:t,method:r,operationBreadcrumbs:i,context:n}){return new $Pu({breadcrumbs:i,operation:t,context:n}).convert()?new qca({context:this.context,breadcrumbs:i,operation:t,method:jel.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path}).convert():void 0}tryParseAsHttpEndpoint({operation:t,method:r,operationBreadcrumbs:i,streamingExtension:n}){new KPu({breadcrumbs:i,operation:t,document:this.context.spec,context:this.context}).convert()!=null;let d=new xPu({breadcrumbs:i,operation:t,context:this.context}).convert();return new tju({context:this.context,breadcrumbs:i,operation:t,method:jel.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path,idempotent:d,idToAuthScheme:this.idToAuthScheme,topLevelServers:this.topLevelServers,streamingExtension:n}).convert()}};var iju=class extends Oa{securityScheme;schemeId;constructor({context:t,breadcrumbs:r,securityScheme:i,schemeId:n}){super({context:t,breadcrumbs:r}),this.securityScheme=i,this.schemeId=n}convert(){switch(this.securityScheme.type){case"http":{if(this.securityScheme.scheme==="bearer")return mA.bearer({key:this.schemeId,token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description});if(this.securityScheme.scheme==="basic")return mA.basic({key:this.schemeId,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 mA.header({key:this.schemeId,name:{name:this.context.casingsGenerator.generateName("apiKey"),wireValue:this.securityScheme.name},valueType:Oa.OPTIONAL_STRING,prefix:void 0,headerEnvVar:void 0,docs:this.securityScheme.description});break}case"oauth2":return mA.bearer({key:this.schemeId,token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description})}}};var AYa=class extends w8t{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}),this.overrideOpenApiAuthWithGeneratorsAuth(),this.convertSecuritySchemes(),this.convertGlobalHeaders(),this.convertBasePath(),this.convertSchemas(),this.convertWebhooks();let{endpointLevelServers:t,errors:r}=this.convertPaths();this.addErrorsToIr(r);let{defaultUrl:i}=this.convertServers({endpointLevelServers:t});this.updateEndpointsWithDefaultUrl(i);let n=this.context.spec.info?.title?.trim();return n&&n!=='""'&&(this.ir.apiDisplayName=n),this.finalizeIr()}convertGlobalHeaders(){this.context.globalHeaderOverrides;let r=new VPu({breadcrumbs:["x-fern-global-headers"],document:this.context.spec,context:this.context}).convert();if(r!=null){let i=azh({globalHeaders:r,context:this.context});this.addGlobalHeadersToIr(i),this.context.setGlobalHeaders(i)}}convertBasePath(){let r=new LPu({breadcrumbs:["x-fern-base-path"],document:this.context.spec,context:this.context}).convert();r!=null&&(this.ir.basePath=DM(r))}convertSecuritySchemes(){if(this.context.authOverrides){let r=Dxc({rawApiFileSchema:this.context.authOverrides,casingsGenerator:this.context.casingsGenerator});this.addAuthToIR({requirement:r.requirement,schemes:r.schemes,docs:r.docs});return}let t=this.convertOpenApiSecuritySchemes();t.length>0&&this.addAuthToIR({requirement:t.length===1?"ALL":"ANY",schemes:t,docs:void 0})}convertOpenApiSecuritySchemes(){let t=[];for(let[r,i]of Object.entries(this.context.spec.components?.securitySchemes??{})){let n=this.context.resolveMaybeReference({schemaOrReference:i,breadcrumbs:["components","securitySchemes",r]});if(n==null)continue;let o=new iju({context:this.context,breadcrumbs:["components","securitySchemes",r],securityScheme:n,schemeId:r}).convert();o!=null&&t.push(o)}return t}convertServers({endpointLevelServers:t}){if(this.context.environmentOverrides){let n=pKa({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 sge({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 Nm.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:["components","schemas",t],schema:r}).convert();n!=null&&this.addSchemaOutputToIr(t,n)}}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 qca({context:this.context,breadcrumbs:["webhooks",r],operation:t.post,method:fzh.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(){let t=[],r={};for(let[i,n]of Object.entries(this.context.spec.paths??{})){if(n==null)continue;let o=new rju({context:this.context,breadcrumbs:["paths",i],topLevelServers:this.context.spec.servers,pathItem:n,path:i}).convert();if(o!=null){for(let c of o.endpoints){if(c.streamEndpoint!=null&&this.addEndpointToIr({endpoint:c.streamEndpoint,audiences:c.audiences,endpointGroup:c.group,endpointGroupDisplayName:c.groupDisplayName}),this.addEndpointToIr({endpoint:c.endpoint,audiences:c.audiences,endpointGroup:c.group,endpointGroupDisplayName:c.groupDisplayName}),c.servers)for(let d of c.servers)this.shouldAddServerToCollectedServers({server:d,currentServers:t})&&t.push(d);if(c.errors)for(let[d,s]of Object.entries(c.errors))r[d]=s}for(let c of o.webhooks){let d=this.context.getGroup({groupParts:c.group,namespace:this.context.namespace});this.addWebhookToIr({webhook:c.webhook,operationId:d.join("."),group:d,audiences:c.audiences})}this.addTypesToIr(o.inlinedTypes)}}return{endpointLevelServers:t,errors:r}}overrideOpenApiAuthWithGeneratorsAuth(){if(!this.context.authOverrides?.["auth-schemes"])return;this.context.spec.components||(this.context.spec.components={}),this.context.spec.components.securitySchemes={};let t={};for(let r of Object.keys(this.context.authOverrides["auth-schemes"]))this.context.spec.components.securitySchemes[r]={type:"http",scheme:"bearer"},t[r]=[];this.context.spec.security=[t],this.removeEndpointSpecificAuth()}removeEndpointSpecificAuth(){if(this.context.spec.paths)for(let t of Object.values(this.context.spec.paths)){if(!t)continue;let r=["get","post","put","patch","delete","options","head","trace"];for(let i of r){let n=t[i];n?.security&&delete n.security}}}};var nju=class extends fl{tag;key="x-displayName";constructor({breadcrumbs:t,tag:r,context:i}){super({breadcrumbs:t,context:i}),this.tag=r}convert(){if(typeof this.tag!="object"||this.tag==null)return;let t=this.tag[this.key];if(t!=null){if(typeof t!="string"){this.context.errorCollector.collect({message:"x-displayName extension must be a string",path:this.breadcrumbs});return}if(t.trim().length!==0)return{displayName:t}}}};var h4i=class extends bC{globalHeaderNames;tagToDisplayName={};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 o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;n==="reference_identifier"?c=i??o.value.title:n==="discriminator_key"?c=o.value.title??i:n==="schema_identifier"&&(c=o.value.title);let d;if(a.includes("/")){let u=new Nm.SchemaConverters.SchemaConverter({context:this,breadcrumbs:r??[],schema:o.value,id:a}).convert();u!=null&&(d={[a]:u.convertedSchema})}return{ok:!0,reference:ii.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,default:void 0,inline:!1,displayName:c}),inlinedTypes:d}}setGlobalHeaders(t){this.globalHeaderNames=t.map(r=>r.name.wireValue)}getDisplayNameForTag(t){if(Object.keys(this.tagToDisplayName).length===0)for(let r of this.spec.tags??[]){let n=new nju({breadcrumbs:["tags",r.name],tag:r,context:this}).convert()?.displayName??r.name;this.tagToDisplayName[r.name]=n}return this.tagToDisplayName[t]??t}};var TAB=Qt.object({description:Qt.string().optional(),required:Qt.boolean().optional(),deprecated:Qt.boolean().optional(),allowEmptyValue:Qt.boolean().optional(),style:Qt.string().optional(),explode:Qt.boolean().optional(),allowReserved:Qt.boolean().optional(),schema:Qt.any().optional(),example:Qt.any().optional(),examples:Qt.record(Qt.string(),Qt.any()).optional(),content:Qt.record(Qt.string(),Qt.any()).optional()}),RAB=TAB.extend({name:Qt.string(),in:Qt.string()}),zAB=Qt.array(RAB),aju=class extends fl{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 zAB.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 oju=class extends Oa{method;pathParameters;queryParameters;headers;topLevelServers;constructor({context:t,breadcrumbs:r,method:i,pathParameters:n=[],queryParameters:a=[],headers:o=[],topLevelServers:c=[]}){super({context:t,breadcrumbs:r}),this.method=i,this.pathParameters=n,this.queryParameters=a,this.headers=o,this.topLevelServers=c}convert(){let t={},r="";for(let s of this.pathParameters)r+=`/{${s.name.originalName}}`;let i=DM(r),n=[];for(let[s,u]of this.method.params.entries()){let l;if(this.context.isReferenceObject(u)){let y=this.context.resolveReference({reference:u});if(y.resolved)l=y.value;else continue}else l=u;let p=[this.method.name,"Param",l.name].join("_"),h=new Nm.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[this.method.name,"Param",l.name],schemaIdOverride:p,context:this.context,schemaOrReference:l.schema,wrapAsOptional:!l.required}).convert();h!=null&&(n.push({docs:l.description,availability:this.context.getAvailability({node:u,breadcrumbs:[...this.breadcrumbs,"parameters"]}),name:this.context.casingsGenerator.generateNameAndWireValue({name:l.name,wireValue:l.name}),valueType:h.type,v2Examples:h.schema?.typeDeclaration.v2Examples,propertyAccess:void 0}),t={...h.inlinedTypes,...t,...h.schema!=null?{[p]:h.schema}:{}})}let a;if(this.method.result!=null){let s=this.context.resolveMaybeReference({schemaOrReference:this.method.result,breadcrumbs:[...this.breadcrumbs,"result"]});if(s!=null){let u=new Nm.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[this.method.name,"result"],context:this.context,schemaOrReference:s.schema}),l=[this.method.name,"Result"].join("_"),p=u.convert();p!=null&&(a={docs:s.description,v2Examples:p.schema?.typeDeclaration.v2Examples,responseBodyType:p.type},t={...p.inlinedTypes,...t,...p.schema!=null?{[l]:p.schema}:{}})}}let o=this.getEndpointBaseUrls(),c=this.context.getAudiences({operation:this.method,breadcrumbs:this.breadcrumbs})??[];return{endpoint:{baseUrl:void 0,v2BaseUrls:o,basePath:void 0,auth:!1,security:void 0,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?zm.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,v2RequestBodies:void 0,sdkRequest:void 0,response:a!=null?{body:wd.json(dC.response(a)),statusCode:void 0,isWildcardStatusCode:void 0,docs:a.docs}:void 0,v2Responses:void 0,errors:[],idempotent:!1,pagination:void 0,userSpecifiedExamples:[],autogeneratedExamples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples()},transport:void 0,availability:void 0,source:mW.openrpc(),audiences:c,retries:void 0,apiPlayground:void 0,responseHeaders:[]},audiences:c,inlinedTypes:t,servers:this.filterOutTopLevelServers(this.method.servers??[])}}filterOutTopLevelServers(t){return t.filter(r=>!this.topLevelServers.some(i=>i.url===r.url))}getEndpointBaseUrls(){let t=this.method.servers;return t?.map(i=>{if(this.topLevelServers.find(c=>c.name===i.name&&c.url!==i.url)!=null)return i.url;let o=this.topLevelServers.find(c=>c.url===i.url)??i;return sge.getServerName({server:o,context:this.context})})}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 o=n.name??`Example ${r+1}`,c=[];if(n.params&&Array.isArray(n.params)){c=[];for(let d of n.params)if(this.context.isReferenceObject(d)){let s=this.context.resolveReference({reference:d});if(s.resolved)c.push(s.value);else continue}else c.push(d)}t[o]={displayName:void 0,request:{docs:void 0,endpoint:{method:"POST",path:"/{apiKey}"},baseUrl:void 0,environment:void 0,auth:void 0,pathParameters:{},queryParameters:{},headers:{},requestBody:c.map(d=>d.value)??void 0},response:{docs:void 0,statusCode:void 0,body:a?.value?Ar.V2HttpEndpointResponseBody.json({jsonrpc:"2.0",id:n.examplePairedRequest?.id||"1",result:a.value}):void 0},codeSamples:[]}}++r}return t}};var uju=class extends Nm.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 Nm.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 PYa=class extends w8t{constructor({context:t,breadcrumbs:r,audiences:i}){super({context:t,breadcrumbs:r,audiences:i})}async convert(){this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.convertSchemas();let{endpointLevelServers:t}=this.convertMethods(),{defaultUrl:r}=this.convertServers({endpointLevelServers:t});return this.updateEndpointsWithDefaultUrl(r),this.finalizeIr()}convertServers({endpointLevelServers:t}){let i=new sge({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 Nm.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:["components","schemas",t],schema:r}).convert();n!=null&&this.addSchemaOutputToIr(t,n)}}convertMethods(){let t=[],i=new aju({context:this.context,breadcrumbs:["methods"],operation:this.context.spec}).convert(),n=[],a=[],o=[];if(i&&i.length>0)for(let[d,s]of i.entries()){let l=new uju({context:this.context,breadcrumbs:[...this.breadcrumbs,`x-fern-parameters[${d}]`],parameter:s}).convert();if(l!=null)switch(l.type){case"path":{n.push(l.parameter);break}case"query":{a.push(l.parameter);break}case"header":{o.push(l.parameter);break}}}let c=this.context.getGroup({groupParts:[],namespace:this.context.namespace});for(let d of this.context.spec.methods??[]){let s=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:["methods"]});if(s==null)continue;let l=new oju({context:this.context,breadcrumbs:["methods"],method:s,pathParameters:n,queryParameters:a,headers:o,topLevelServers:this.context.spec.servers}).convert();if(l!=null&&(this.addEndpointToIr({endpoint:l.endpoint,audiences:l.audiences,endpointGroup:c,serviceName:"service_root"}),this.addTypesToIr(l.inlinedTypes),l.servers))for(let p of l.servers)this.shouldAddServerToCollectedServers({server:p,currentServers:t,specType:"openrpc"})&&t.push(this.maybeDeduplicateServerName(p))}return{endpointLevelServers:t}}maybeDeduplicateServerName(t){return this.context.spec.servers?.find(i=>i.name===t.name&&i.url!==t.url)?{...t,name:t.url}:t}};var jYa=class extends bC{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 o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return n==="reference_identifier"?c=i??o.value.title:(n==="discriminator_key"||n==="schema_identifier")&&(c=o.value.title??i),{ok:!0,reference:ii.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}};var tFh=require("fs/promises");var dzh={[an.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,X0(e)])),[an.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"]),[an.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"]),[an.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","kwargs"]),[an.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","vendor","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[an.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","object_id","hash","eql?","equal?","method","send","respond_to?","respond_to_missing?","instance_of?","kind_of?","is_a?","extend","singleton_class","instance_variables","instance_variable_get","instance_variable_set","instance_variable_defined?","remove_instance_variable","public_methods","private_methods","protected_methods","singleton_methods"]),[an.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"]),[an.GenerationLanguage.RUST]:new Set(["as","async","await","break","const","continue","crate","dyn","else","enum","extern","false","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","true","type","union","unsafe","use","where","while","abstract","become","box","do","final","macro","override","priv","try","typeof","unsized","virtual","yield","bool","char","f32","f64","i8","i16","i32","i64","i128","isize","str","u8","u16","u32","u64","u128","usize","String","Vec","Option","Result","Box","Rc","Arc","Cell","RefCell","HashMap","HashSet","BTreeMap","BTreeSet"]),[an.GenerationLanguage.SWIFT]:new Set([])};var NAB=["go","ruby"];function lju({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let o=HAB(n),c=p=>({unsafeName:p,safeName:FAB({name:p,keywords:QAB({generationLanguage:e,keywords:t})})}),d=ou(o),s=X0(d),u=Kfn(o),l=Wfn(d);return r&&(!VAB(l)&&(e==null||NAB.includes(e))&&(d=l.map((p,_)=>{if(_>0){let h=sju(p);if(h!=null)return h;if(cju(p))return p.toUpperCase()}return p}).join(""),s=X0(l.map((p,_)=>{let h=sju(p);return h??(cju(p)?p.toUpperCase():_===0?X0(p):p)}).join(""))),u=o.split(" ").map(p=>p.split(/(\d+)/).map(Kfn).join("")).join("_")),{originalName:n,camelCase:c(a?.casingOverrides?.camel??d),snakeCase:c(a?.casingOverrides?.snake??u),screamingSnakeCase:c(a?.casingOverrides?.["screaming-snake"]??u.toUpperCase()),pascalCase:c(a?.casingOverrides?.pascal??s)}},generateNameAndWireValue:({name:n,wireValue:a,opts:o})=>({name:i.generateName(n,o),wireValue:a})};return i}function FAB({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":LAB(e)?"_"+e:e}function QAB({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return dzh[e]}var UAB=/^[0-9]/;function LAB(e){return UAB.test(e)}function VAB(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=sju(i)!=null||cju(i),a=sju(t)!=null||cju(t);return n&&a})}function sju(e){return GAB.get(e.toUpperCase())}function cju(e){return WAB.has(e.toUpperCase())}var WAB=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"]),GAB=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]),xAB=[[/\[\]/g,"Array"]];function HAB(e){return xAB.reduce((t,[r,i])=>t.replace(r,i),e)}var pzh=require("fs/promises");async function wel({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,pzh.readFile)(t)).toString(),n;try{n=JSON.parse(i)}catch{n=qi.load(i)}return r!=null?await Mca({absoluteFilePathToOverrides:r,context:e,data:n}):n}var LNh=ce(UNh(),1);function gYi(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...o}={}){let c=n.reduce((s,u)=>({...s,[u]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[s,u]of Object.entries(c))d=d.replaceAll(s,u);return e?.debug(`+ ${d}`),(0,LNh.default)(t,r,o)}async function yy(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...o}={}){let c=gYi(e,t,r,{doNotPipeOutput:i,secrets:n,substitutions:a,...o});i||(c.stdout?.pipe(process.stdout),c.stderr?.pipe(process.stderr));let d=await c;return d.stdout==null&&(d.stdout=""),d.stderr==null&&(d.stderr=""),d}function OYi(e,{logger:t,...r}={}){return(i,n)=>yy(t,e,i,{...r,...n})}var Cx=require("fs/promises"),XNh=ce(require("path"),1),Wel=ce(M4(),1);var QjB=ce(M4(),1);function VNh(e){return e.includes("server hosted at that remote is unavailable")||e.includes("fetch failed")||e.includes("failed to connect")||e.includes("network")||e.includes("ENOTFOUND")||e.includes("ETIMEDOUT")||e.includes("TIMEDOUT")||e.includes("timed out")||e.includes("ECONNREFUSED")||e.includes("ECONNRESET")||e.includes("socket hang up")}var DYa,Vel;async function xgn(e,t,r=5e3){return DYa!==void 0?DYa:(Vel==null&&(Vel=UjB(e,t,r)),Vel)}async function UjB(e,t,r){t.debug(`Detecting air-gapped mode by checking connectivity to ${e}`);try{return await fetch(e,{method:"GET",signal:AbortSignal.timeout(r)}),DYa=!1,t.debug("Network check succeeded - not in air-gapped mode"),!1}catch(i){let n=i instanceof Error?i.message:String(i);return VNh(n)?(DYa=!0,t.debug(`Network check failed - entering air-gapped mode: ${n}`),!0):(DYa=!1,!1)}}var WNh="buf.gen.yaml",LjB="output",GNh=`${LjB}/ir.json`,xNh="protoc-gen-fern",HNh=`version: v1
|
|
1529
1529
|
`,KNh=`version: v2
|
|
1530
1530
|
`,vju=e=>{let t=`version: v1
|
|
1531
1531
|
`;if(e.length>0){t+=`deps:
|
|
@@ -1558,7 +1558,7 @@ plugins:
|
|
|
1558
1558
|
- enum_type=string
|
|
1559
1559
|
- default_response=false
|
|
1560
1560
|
- source_root=${e}
|
|
1561
|
-
`}async function MSe({context:e,specs:t,relativePathToDependency:r}){let i=new Oju({context:e}),n=t.filter(d=>d.type==="openapi").map(d=>({...d,relativePathToDependency:r})),a=t.filter(d=>d.type==="protobuf"),c=(await Promise.all(a.map(async d=>{if(d.absoluteFilepathToProtobufTarget!=null){let p=await eFh({generator:i,protobufSpec:d,relativePathToDependency:r});return p?[p.openApiSpec]:[]}let s=await w4(d.absoluteFilepathToProtobufRoot,"proto"),u,l=[];for(let p of s){let _=await eFh({generator:i,protobufSpec:{...d,absoluteFilepathToProtobufTarget:p},relativePathToDependency:r,existingBufLockContents:u});_!=null&&(l.push(_.openApiSpec),_.bufLockContents!=null&&(u=_.bufLockContents))}return l}))).flat().filter(d=>us(d));return[...n,...c]}async function eFh({generator:e,protobufSpec:t,relativePathToDependency:r,existingBufLockContents:i}){if(t.absoluteFilepathToProtobufTarget==null)return;let n=await e.generate({absoluteFilepathToProtobufRoot:t.absoluteFilepathToProtobufRoot,absoluteFilepathToProtobufTarget:t.absoluteFilepathToProtobufTarget,relativeFilepathToProtobufRoot:t.relativeFilepathToProtobufRoot,local:t.generateLocally,deps:t.dependencies,existingBufLockContents:i});return{bufLockContents:n.bufLockContents,openApiSpec:{type:"openapi",absoluteFilepath:n.absoluteFilepath,absoluteFilepathToOverrides:t.absoluteFilepathToOverrides,absoluteFilepathToOverlays:void 0,settings:t.settings,source:{type:"protobuf",relativePathToDependency:r,root:t.absoluteFilepathToProtobufRoot,file:t.absoluteFilepathToProtobufTarget}}}}function xjB(e){return e.every(t=>t.settings?.removeDiscriminantsFromSchemas===an.RemoveDiscriminantsFromSchemas.Never)?an.RemoveDiscriminantsFromSchemas.Never:an.RemoveDiscriminantsFromSchemas.Always}var jS=class e extends lJa{type="oss";allSpecs;specs;sources;loader;parseOptions;groupMultiApiEnvironments;constructor({allSpecs:t,specs:r,...i}){super({...i,respectReadonlySchemas:r.every(n=>n.settings?.respectReadonlySchemas),respectNullableSchemas:r.every(n=>n.settings?.respectNullableSchemas),wrapReferencesToNullableInOptional:r.every(n=>n.settings?.wrapReferencesToNullableInOptional),removeDiscriminantsFromSchemas:xjB(r),coerceOptionalSchemasToNullable:r.every(n=>n.settings?.coerceOptionalSchemasToNullable),coerceEnumsToLiterals:r.every(n=>n.settings?.coerceEnumsToLiterals),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),inlineAllOfSchemas:r.every(n=>n.settings?.inlineAllOfSchemas),resolveAliases:r.every(o=>o.settings?.resolveAliases)?{except:r.flatMap(o=>typeof o.settings?.resolveAliases=="object"?o.settings.resolveAliases.except??[]:[])}:!1,exampleGeneration:r[0]?.settings?.exampleGeneration,groupEnvironmentsByHost:r.some(n=>n.settings?.groupEnvironmentsByHost),defaultIntegerFormat:r[0]?.settings?.defaultIntegerFormat,pathParameterOrder:r[0]?.settings?.pathParameterOrder}),this.specs=r,this.allSpecs=t,this.sources=this.convertSpecsToIdentifiableSources(r),this.loader=new Y8t(this.absoluteFilePath),this.groupMultiApiEnvironments=this.specs.some(n=>n.settings?.groupMultiApiEnvironments),this.parseOptions={onlyIncludeReferencedSchemas:this.onlyIncludeReferencedSchemas,respectReadonlySchemas:this.respectReadonlySchemas,respectNullableSchemas:this.respectNullableSchemas,wrapReferencesToNullableInOptional:this.wrapReferencesToNullableInOptional,coerceOptionalSchemasToNullable:this.coerceOptionalSchemasToNullable,coerceEnumsToLiterals:this.coerceEnumsToLiterals,inlinePathParameters:this.inlinePathParameters,objectQueryParameters:this.objectQueryParameters,exampleGeneration:this.exampleGeneration,useBytesForBinaryResponse:this.useBytesForBinaryResponse,respectForwardCompatibleEnums:this.respectForwardCompatibleEnums,inlineAllOfSchemas:this.inlineAllOfSchemas,resolveAliases:this.resolveAliases,removeDiscriminantsFromSchemas:this.removeDiscriminantsFromSchemas,groupMultiApiEnvironments:this.groupMultiApiEnvironments,groupEnvironmentsByHost:this.groupEnvironmentsByHost,defaultIntegerFormat:this.defaultIntegerFormat,pathParameterOrder:this.pathParameterOrder}}async getOpenAPIIr({context:t,relativePathToDependency:r},i){let n=await MSe({context:t,specs:this.specs,relativePathToDependency:r});return kvn({context:t,documents:await this.loader.loadDocuments({context:t,specs:n}),options:{...i,...this.parseOptions}})}async getIntermediateRepresentation({context:t,audiences:r,enableUniqueErrorsPerEndpoint:i,generateV1Examples:n,logWarnings:a}){let o=await MSe({context:t,specs:this.specs}),c=await this.loader.loadDocuments({context:t,specs:o}),d=this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0;d&&t.logger.trace("Using auth overrides from generators configuration");let s=this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0;s&&t.logger.trace("Using environment overrides from generators configuration");let u=this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0;u&&t.logger.trace("Using global header overrides from generators configuration");let l,p=[];for(let _ of c){let h=Tt(this.absoluteFilePath,Je.of(_.source?.file??"")),y=FJ(iA(),h),b=new ZEe({logger:t.logger,relativeFilepathToSpec:y});p.push(b);let v;switch(_.type){case"openapi":{let m=new h4i({namespace:_.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:_.value,exampleGenerationArgs:{disabled:!1},errorCollector:b,authOverrides:d,environmentOverrides:s,globalHeaderOverrides:u,enableUniqueErrorsPerEndpoint:i,generateV1Examples:n,settings:x8t({options:_.settings}),documentBaseDir:nn(h)});v=await new AYa({context:m,audiences:r}).convert();break}case"asyncapi":{let m=new gYa({namespace:_.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:_.value,exampleGenerationArgs:{disabled:!1},errorCollector:b,enableUniqueErrorsPerEndpoint:i,settings:x8t({options:_.settings}),generateV1Examples:n});v=await new vYa({context:m,audiences:r}).convert();break}default:b.collect({message:`Unsupported document type: ${_}`,path:[]});break}let O=lju({generationLanguage:"typescript",keywords:void 0,smartCasing:!1});v!=null&&(l=l===void 0?v:svn(l,v,O))}for(let _ of this.allSpecs)if(_.type==="openrpc"){let h=_.absoluteFilepath,y=FJ(iA(),h),b=new ZEe({logger:t.logger,relativeFilepathToSpec:y});p.push(b);let v=new jYa({namespace:_.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:await wel({context:t,absoluteFilePath:_.absoluteFilepath,absoluteFilePathToOverrides:_.absoluteFilepathToOverrides}),exampleGenerationArgs:{disabled:!1},errorCollector:b,enableUniqueErrorsPerEndpoint:i,generateV1Examples:n,settings:x8t()}),m=await new PYa({context:v,audiences:r}).convert(),g=lju({generationLanguage:"typescript",keywords:void 0,smartCasing:!1});m!=null&&(l=l===void 0?m:svn(l,m,g))}else if(_.type==="protobuf")try{let y=await new gju({context:t}).generate({absoluteFilepathToProtobufRoot:_.absoluteFilepathToProtobufRoot,absoluteFilepathToProtobufTarget:_.absoluteFilepathToProtobufTarget,local:!0,deps:_.dependencies}),b=await(0,tFh.readFile)(y,"utf-8"),v=lju({generationLanguage:"typescript",keywords:void 0,smartCasing:!1});if(b!=null){let O;try{if(O=$n.IntermediateRepresentation.parse(JSON.parse(b),{allowUnrecognizedEnumValues:!0,skipValidation:!0}),O.ok)l=l===void 0?O.value:svn(l,O.value,v);else throw new Error}catch{t.logger.log("error","Failed to parse protobuf IR: ")}}}catch(h){t.logger.log("warn","Failed to parse protobuf IR: "+h)}for(let _ of p)if(_.hasErrors()){let h=_.getErrorStats(),y=_.relativeFilepathToSpec?` for ${_.relativeFilepathToSpec}`:"";h.numErrors>0?t.logger.log("error",`API validation${y} completed with ${h.numErrors} errors and ${h.numWarnings} warnings.`):h.numWarnings>0?t.logger.log("warn",`API validation${y} completed with ${h.numWarnings} warnings.`):t.logger.log("info",`All checks passed when parsing OpenAPI${y}.`),t.logger.log("info",""),await _.logErrors({logWarnings:a})}if(l===void 0)throw new Error("Failed to generate intermediate representation");return l}async toFernWorkspace({context:t},r,i){if(i!=null)return this.createWorkspaceWithSpecsOverride({context:t},i,r);let n=await this.getDefinition({context:t},r);return new gY({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:this.sources})}async createWorkspaceWithSpecsOverride({context:t},r,i){let n=await this.convertSpecsOverrideToSpecs(r),a=n.filter(d=>d.type!=="protobuf"||!d.fromOpenAPI),o=new e({allSpecs:a,specs:n.filter(d=>d.type==="openapi"||d.type==="protobuf"),generatorsConfiguration:this.generatorsConfiguration,workspaceName:this.workspaceName,cliVersion:this.cliVersion,absoluteFilePath:this.absoluteFilePath,changelog:this.changelog}),c=await o.getDefinition({context:t},i);return new gY({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:c,cliVersion:this.cliVersion,sources:o.sources})}async convertSpecsOverrideToSpecs(t){if(!Array.isArray(t))throw new Error("Conjure specs override is not yet supported");let r=[];for(let i of t)if(an.isOpenApiSpecSchema(i)){let n=Tt(this.absoluteFilePath,Je.of(i.openapi)),a=i.overrides?Tt(this.absoluteFilePath,Je.of(i.overrides)):void 0,o=i.overlays?Tt(this.absoluteFilePath,Je.of(i.overlays)):void 0,c={type:"openapi",absoluteFilepath:n,absoluteFilepathToOverrides:a,absoluteFilepathToOverlays:o,settings:this.specs.length>0?this.specs[0]?.settings:void 0,source:{type:"openapi",file:n},namespace:i.namespace??this.workspaceName};r.push(c)}else throw new Error("Spec type override not yet supported. Only OpenAPI specs are currently supported in specs override.");return r}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.allSpecs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(us)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,i=[];return t.reduce((n,a)=>{let o=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(o)||(r.add(o),n.push({type:a.type,id:Lve(),absoluteFilePath:o})),n},i)}};function HjB(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Gel(e,t){for(let[r,i]of UI(e.failures))KjB({relativeFilepath:r,failure:i,logger:t})}function KjB({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case Wp.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 Wp.FILE_READ:r.error("Failed to open file: "+e);break;case Wp.FILE_MISSING:r.error("Missing file: "+e);break;case Wp.FILE_PARSE:t.error instanceof L3a?r.error(b0e({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case Wp.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of JjB(i))r.error(b0e({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case Wp.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case Wp.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${vUo}: `+t.dependencyName);break;case Wp.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case Wp.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case Wp.JSONSCHEMA_VALIDATION:if(t.error.error!=null){let i=t.error.error.instancePath.split("/").filter(n=>n!=="").map(HjB);t.error.error.keyword==="required"&&t.error.error.params?.missingProperty?i.push(t.error.error.params.missingProperty):t.error.error.keyword==="additionalProperties"&&t.error.error.params?.additionalProperty&&i.push(t.error.error.params.additionalProperty),r.error(b0e({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...i]}))}break;default:vt(t)}}function JjB(e){switch(e.code){case wi.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${Rt.underline(e.expected)} but received ${Rt.underline(e.received)}`}];case wi.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${Rt.underline(t)}`}));case wi.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>Rt.underline(t)).join(", ")}`}];case wi.invalid_union:case wi.invalid_arguments:case wi.invalid_return_type:case wi.invalid_date:case wi.invalid_string:case wi.too_small:case wi.too_big:case wi.invalid_intersection_types:case wi.not_multiple_of:case wi.custom:default:return[{title:e.message}]}}var rFh=require("fs/promises");async function iFh(e,t){let r=[];for(let i of await w4(e,t))r.push(await $jB({relativeFilepath:pp(e,i),absoluteFilepath:i}));return r}async function $jB({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,rFh.readFile)(t)).toString()}}async function nFh({absolutePathToWorkspace:e}){let t=Tt(e,Je.of(AVp));if(!await Ai(t))return;let i=await iFh(t,"{md,mdx}");return{files:await Promise.all(i.map(n=>({absoluteFilepath:n.absoluteFilepath,contents:n.fileContents})))}}async function xel({absolutePathToWorkspace:e,namespace:t,definitions:r}){let i=[];for(let n of r){let a=n.overrides!=null?Tt(e,Je.of(n.overrides)):void 0,o=n.overlays!=null?Tt(e,Je.of(n.overlays)):void 0;if(n.schema.type==="protobuf"){let s=Je.of(n.schema.root),u=Tt(e,s);if(!await Ai(u))return{didSucceed:!1,failures:{[Je.of(n.schema.root)]:{type:Wp.FILE_MISSING}}};let l=n.schema.target.length===0?void 0:Tt(e,Je.of(n.schema.target));if(l!=null&&!await Ai(l))return{didSucceed:!1,failures:{[Je.of(n.schema.target)]:{type:Wp.FILE_MISSING}}};let p=Fmu(n.settings);i.push({type:"protobuf",absoluteFilepathToProtobufRoot:u,absoluteFilepathToProtobufTarget:l,absoluteFilepathToOverrides:a,relativeFilepathToProtobufRoot:s,dependencies:n.schema.dependencies,generateLocally:n.schema.localGeneration,fromOpenAPI:n.schema.fromOpenAPI,settings:{...p,audiences:n.audiences??[]}});continue}if(n.schema.type==="openrpc"){let s=Je.of(n.schema.path),u=Tt(e,s);i.push({type:"openrpc",absoluteFilepath:u,absoluteFilepathToOverrides:a,namespace:t});continue}let c=Tt(e,Je.of(n.schema.path));if(!await Ai(c))return{didSucceed:!1,failures:{[Je.of(n.schema.path)]:{type:Wp.FILE_MISSING}}};if(n.overrides!=null&&a!=null&&!await Ai(a))return{didSucceed:!1,failures:{[Je.of(n.overrides)]:{type:Wp.FILE_MISSING}}};if(n.overlays!=null&&o!=null&&!await Ai(o))return{didSucceed:!1,failures:{[Je.of(n.overlays)]:{type:Wp.FILE_MISSING}}};let d=Fmu(n.settings);i.push({type:"openapi",absoluteFilepath:c,absoluteFilepathToOverrides:a,absoluteFilepathToOverlays:o,settings:{...d,audiences:n.audiences??[]},source:{type:"openapi",file:c},namespace:t})}return i}async function BYa({absolutePathToWorkspace:e,context:t,cliVersion:r,workspaceName:i}){let n=await zve({absolutePathToWorkspace:e,context:t}),a;try{a=await nFh({absolutePathToWorkspace:e})}catch{}if(n?.api!=null&&n?.api.type==="conjure")return{didSucceed:!0,workspace:new sAu({workspaceName:i,absoluteFilePath:e,generatorsConfiguration:n,changelog:a,cliVersion:r,context:t,relativePathToConjureDirectory:Je.of(n.api.pathToConjureDefinition)})};if(n?.api!=null&&(n.api.type==="singleNamespace"&&n.api.definitions.length>0||n.api.type==="multiNamespace")){let o=[];if(n.api.type==="singleNamespace"){let c=await xel({absolutePathToWorkspace:e,namespace:void 0,definitions:n.api.definitions});if(!Array.isArray(c))return c;o.push(...c)}else{for(let[c,d]of Object.entries(n.api.definitions)){let s=await xel({absolutePathToWorkspace:e,namespace:c,definitions:d});if(!Array.isArray(s))return s;o.push(...s)}if(n.api.rootDefinitions!=null){let c=await xel({absolutePathToWorkspace:e,namespace:void 0,definitions:n.api.rootDefinitions});if(!Array.isArray(c))return c;o.push(...c)}}return{didSucceed:!0,workspace:new jS({specs:o.filter(c=>!(c.type==="openrpc"||c.type==="protobuf"&&!c.fromOpenAPI)),allSpecs:o.filter(c=>!(c.type==="protobuf"&&c.fromOpenAPI)),workspaceName:i,absoluteFilePath:e,generatorsConfiguration:n,changelog:a,cliVersion:r})}}if(await Ai(Tt(e,Je.of(e1))))return{didSucceed:!0,workspace:new ESe({absoluteFilePath:e,generatorsConfiguration:n,workspaceName:i,changelog:a,context:t,cliVersion:r,loadAPIWorkspace:BYa})};if(await apc(Tt(e,Je.of(e1)))){let o=e.split("/").pop();t.logger.warn(`Detected empty API definiton: ${o}. Remove to resolve error.`)}return{didSucceed:!1,failures:{[Je.of(i3a)]:{type:Wp.MISCONFIGURED_DIRECTORY}}}}var aFh=require("fs/promises");var Hel={};Yt(Hel,{additionalProperties:()=>kjB,default:()=>t0B,definitions:()=>e0B,properties:()=>XjB,required:()=>ZjB,type:()=>YjB});var YjB="object",XjB={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"}]},"page-actions":{oneOf:[{$ref:"#/definitions/docs.PageActionsConfig"},{type:"null"}]},experimental:{oneOf:[{$ref:"#/definitions/docs.ExperimentalConfig"},{type:"null"}]},"default-language":{oneOf:[{$ref:"#/definitions/docs.ProgrammingLanguage"},{type:"null"}]},languages:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.Language"}},{type:"null"}]},"ai-chat":{oneOf:[{$ref:"#/definitions/docs.AIChatConfig"},{type:"null"}]},"ai-search":{oneOf:[{$ref:"#/definitions/docs.AIChatConfig"},{type:"null"}]},"ai-examples":{oneOf:[{$ref:"#/definitions/docs.AiExamplesConfig"},{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"}]},settings:{oneOf:[{$ref:"#/definitions/docs.DocsSettingsConfig"},{type:"null"}]},theme:{oneOf:[{$ref:"#/definitions/docs.ThemeConfig"},{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"}]}},ZjB=["instances"],kjB=!1,e0B={"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.EditThisPageLaunch":{type:"string",enum:["github","dashboard"]},"docs.EditThisPageConfig":{type:"object",properties:{github:{oneOf:[{$ref:"#/definitions/docs.GithubEditThisPageConfig"},{type:"null"}]},launch:{oneOf:[{$ref:"#/definitions/docs.EditThisPageLaunch"},{type:"null"}]}},additionalProperties:!1},"docs.AudienceId":{type:"string"},"docs.Audience":{anyOf:[{$ref:"#/definitions/docs.AudienceId"},{type:"array",items:{$ref:"#/definitions/docs.AudienceId"}}]},"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"}]},audiences:{oneOf:[{$ref:"#/definitions/docs.Audience"},{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.Target":{type:"string",enum:["_blank","_self","_parent","_top"]},"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"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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"}]},audiences:{oneOf:[{$ref:"#/definitions/docs.Audience"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},announcement:{oneOf:[{$ref:"#/definitions/docs.AnnouncementConfig"},{type:"null"}]}},required:["display-name","path"],additionalProperties:!1},"docs.InternalProduct":{type:"object",properties:{"display-name":{type:"string"},subtitle:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},image:{oneOf:[{type:"string"},{type:"null"}]},versions:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.VersionConfig"}},{type:"null"}]},audiences:{oneOf:[{$ref:"#/definitions/docs.Audience"},{type:"null"}]},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},path:{type:"string"},slug:{oneOf:[{type:"string"},{type:"null"}]},announcement:{oneOf:[{$ref:"#/definitions/docs.AnnouncementConfig"},{type:"null"}]}},required:["display-name","path"],additionalProperties:!1},"docs.ExternalProduct":{type:"object",properties:{"display-name":{type:"string"},subtitle:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},image:{oneOf:[{type:"string"},{type:"null"}]},versions:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.VersionConfig"}},{type:"null"}]},audiences:{oneOf:[{$ref:"#/definitions/docs.Audience"},{type:"null"}]},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},href:{type:"string"},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{type:"null"}]}},required:["display-name","href"],additionalProperties:!1},"docs.ProductConfig":{anyOf:[{$ref:"#/definitions/docs.InternalProduct"},{$ref:"#/definitions/docs.ExternalProduct"}]},"docs.Availability":{type:"string",enum:["stable","generally-available","in-development","pre-release","deprecated","beta"]},"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"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{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"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]}},required:["section","contents"],additionalProperties:!1},"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"}]},php:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},swift:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},rust:{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:{hidden:{oneOf:[{type:"boolean"},{type:"null"}]},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"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{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"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{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"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{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"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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:[{$ref:"#/definitions/docs.Audience"},{type:"null"}]},"display-errors":{oneOf:[{type:"boolean"},{type:"null"}]},"tag-description-pages":{oneOf:[{type:"boolean"},{type:"null"}]},snippets:{oneOf:[{$ref:"#/definitions/docs.SnippetsConfiguration"},{type:"null"}]},postman:{oneOf:[{type:"string"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{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.PythonDocsConfiguration":{type:"object",properties:{"python-docs":{type:"string"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]}},required:["python-docs"],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.FolderConfiguration":{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"}]},folder:{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"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]}},required:["folder"],additionalProperties:!1},"docs.NavigationItem":{anyOf:[{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.SectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceConfiguration"},{$ref:"#/definitions/docs.PythonDocsConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"},{$ref:"#/definitions/docs.ChangelogConfiguration"},{$ref:"#/definitions/docs.FolderConfiguration"}]},"docs.UntabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},"docs.TabId":{type:"string"},"docs.TabbedNavigationItemWithLayout":{type:"object",properties:{tab:{$ref:"#/definitions/docs.TabId"},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},{type:"null"}]}},required:["tab"],additionalProperties:!1},"docs.TabVariant":{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:{type:"string"},subtitle:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},layout:{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},slug:{oneOf:[{type:"string"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},default:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["title","layout"],additionalProperties:!1},"docs.TabbedNavigationItemWithVariants":{type:"object",properties:{tab:{$ref:"#/definitions/docs.TabId"},variants:{type:"array",items:{$ref:"#/definitions/docs.TabVariant"}}},required:["tab","variants"],additionalProperties:!1},"docs.TabbedNavigationItem":{anyOf:[{$ref:"#/definitions/docs.TabbedNavigationItemWithLayout"},{$ref:"#/definitions/docs.TabbedNavigationItemWithVariants"}]},"docs.TabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.TabbedNavigationItem"}},"docs.NavigationConfig":{anyOf:[{$ref:"#/definitions/docs.UntabbedNavigationConfig"},{$ref:"#/definitions/docs.TabbedNavigationConfig"}]},"docs.NavbarGithubConfigWithOptions":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},url:{type:"string"},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{type:"null"}]}},required:["url"],additionalProperties:!1},"docs.NavbarGithubConfig":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.NavbarGithubConfigWithOptions"}]},"docs.NavbarLinkConfig":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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"}]}},additionalProperties:!1},"docs.NavbarLink":{type:"object",properties:{type:{type:"string",enum:["filled","outlined","minimal","github","dropdown","primary","secondary"]}},oneOf:[{properties:{type:{const:"filled"},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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"},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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"},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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:"dropdown"},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},links:{type:"array",items:{$ref:"#/definitions/docs.NavbarLinkConfig"}},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","links"]},{properties:{type:{const:"primary"},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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"},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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.PageActionOption":{type:"string",enum:["copy-page","view-as-markdown","ask-ai","chatgpt","claude","cursor","vscode"]},"docs.CustomPageAction":{type:"object",properties:{title:{type:"string"},subtitle:{oneOf:[{type:"string"},{type:"null"}]},url:{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]},default:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["title","url"],additionalProperties:!1},"docs.PageActionOptions":{type:"object",properties:{"copy-page":{oneOf:[{type:"boolean"},{type:"null"}]},"view-as-markdown":{oneOf:[{type:"boolean"},{type:"null"}]},"ask-ai":{oneOf:[{type:"boolean"},{type:"null"}]},chatgpt:{oneOf:[{type:"boolean"},{type:"null"}]},claude:{oneOf:[{type:"boolean"},{type:"null"}]},cursor:{oneOf:[{type:"boolean"},{type:"null"}]},vscode:{oneOf:[{type:"boolean"},{type:"null"}]},custom:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.CustomPageAction"}},{type:"null"}]}},additionalProperties:!1},"docs.PageActionsConfig":{type:"object",properties:{default:{oneOf:[{$ref:"#/definitions/docs.PageActionOption"},{type:"null"}]},options:{oneOf:[{$ref:"#/definitions/docs.PageActionOptions"},{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"}]},"dynamic-snippets":{oneOf:[{type:"boolean"},{type:"null"}]},"ai-examples":{oneOf:[{type:"boolean"},{type:"null"}]},"ai-example-style-instructions":{oneOf:[{type:"string"},{type:"null"}]},"exclude-apis":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"docs.ProgrammingLanguage":{type:"string",enum:["typescript","javascript","python","java","go","ruby","csharp","php","swift","rust","nodets","nodejs","dotnet","curl","jvm","ts","js"]},"docs.Language":{type:"string",enum:["en","es","fr","de","it","pt","ja","zh","ko","el","no","pl","ru","sv","tr"]},"docs.AIChatModel":{type:"string",enum:["claude-3.7","claude-4","command-a"]},"docs.AIChatLocation":{type:"string",enum:["docs","slack","discord"]},"docs.AIChatWebsiteDatasource":{type:"object",properties:{url:{type:"string"},title:{oneOf:[{type:"string"},{type:"null"}]}},required:["url"],additionalProperties:!1},"docs.AIChatDatasource":{anyOf:[{$ref:"#/definitions/docs.AIChatWebsiteDatasource"}]},"docs.AIChatConfig":{type:"object",properties:{model:{oneOf:[{$ref:"#/definitions/docs.AIChatModel"},{type:"null"}]},"system-prompt":{oneOf:[{type:"string"},{type:"null"}]},location:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.AIChatLocation"}},{type:"null"}]},datasources:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.AIChatDatasource"}},{type:"null"}]}},additionalProperties:!1},"docs.AiExamplesConfig":{type:"object",properties:{enabled:{oneOf:[{type:"boolean"},{type:"null"}]},style:{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"}]},"canonical-host":{oneOf:[{type:"string"},{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"}]},"right-text":{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"}]},"hide-nav-links":{oneOf:[{type:"boolean"},{type:"null"}]},"hide-feedback":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"docs.HttpSnippetLanguage":{type:"string",enum:["curl","csharp","go","java","javascript","php","python","ruby","swift","typescript"]},"docs.HttpSnippetsConfig":{anyOf:[{type:"boolean"},{type:"array",items:{$ref:"#/definitions/docs.HttpSnippetLanguage"}}]},"docs.DocsSettingsConfig":{type:"object",properties:{"search-text":{oneOf:[{type:"string"},{type:"null"}]},"disable-search":{oneOf:[{type:"boolean"},{type:"null"}]},"dark-mode-code":{oneOf:[{type:"boolean"},{type:"null"}]},"default-search-filters":{oneOf:[{type:"boolean"},{type:"null"}]},"http-snippets":{oneOf:[{$ref:"#/definitions/docs.HttpSnippetsConfig"},{type:"null"}]},"hide-404-page":{oneOf:[{type:"boolean"},{type:"null"}]},"use-javascript-as-typescript":{oneOf:[{type:"boolean"},{type:"null"}]},"disable-explorer-proxy":{oneOf:[{type:"boolean"},{type:"null"}]},"disable-analytics":{oneOf:[{type:"boolean"},{type:"null"}]},language:{oneOf:[{$ref:"#/definitions/docs.Language"},{type:"null"}]},"substitute-env-vars":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"docs.SidebarThemeConfig":{type:"string",enum:["default","minimal"]},"docs.BodyThemeConfig":{type:"string",enum:["default","canvas"]},"docs.TabsThemeConfig":{type:"string",enum:["default","bubble"]},"docs.PageActionsThemeConfig":{type:"string",enum:["default","toolbar"]},"docs.FooterNavThemeConfig":{type:"string",enum:["default","minimal"]},"docs.LanguageSwitcherThemeConfig":{type:"string",enum:["default","minimal"]},"docs.ProductSwitcherThemeConfig":{type:"string",enum:["default","toggle"]},"docs.ThemeConfig":{type:"object",properties:{sidebar:{oneOf:[{$ref:"#/definitions/docs.SidebarThemeConfig"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/docs.BodyThemeConfig"},{type:"null"}]},tabs:{oneOf:[{$ref:"#/definitions/docs.TabsThemeConfig"},{type:"null"}]},"page-actions":{oneOf:[{$ref:"#/definitions/docs.PageActionsThemeConfig"},{type:"null"}]},"footer-nav":{oneOf:[{$ref:"#/definitions/docs.FooterNavThemeConfig"},{type:"null"}]},"language-switcher":{oneOf:[{$ref:"#/definitions/docs.LanguageSwitcherThemeConfig"},{type:"null"}]},"product-switcher":{oneOf:[{$ref:"#/definitions/docs.ProductSwitcherThemeConfig"},{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"}}]}},t0B={type:YjB,properties:XjB,required:ZjB,additionalProperties:kjB,definitions:e0B};async function Kel({fernDirectory:e,context:t}){let r=Tt(e,Je.of(P0));if(!await Ai(r))return;let i=await r0B({absolutePathToDocsDefinition:e,context:t});if(i!=null)return{type:"docs",absoluteFilePath:e,config:i,workspaceName:void 0,absoluteFilepathToDocsConfig:Tt(e,Je.of(P0))}}async function r0B({absolutePathToDocsDefinition:e,context:t}){if(!await Ai(e))return;let r=Tt(e,Je.of(P0));return await i0B({absolutePathOfConfiguration:r,context:t})}async function i0B({absolutePathOfConfiguration:e,context:t}){let r=await(0,aFh.readFile)(e),i=qi.load(r.toString()),n=OVt(i,Hel,{filePath:e});if(n.success){let a=[];t.logger.debug("About to sanitize docs configuration JSON structure");let o=c0e(i,[],a);a.length>0?t.logger.warn(`docs.yml contained null/undefined sections that were ignored: ${a.map(c=>c.join(".")).join(", ")}`):t.logger.debug("No null/undefined values found during sanitization");try{return t.logger.debug("Attempting to parse sanitized docs configuration"),GJ.RawSchemas.Serializer.DocsConfiguration.parseOrThrow(o)}catch(c){throw t.logger.error(`Parsing failed even after sanitization: ${c instanceof Error?c.message:String(c)}`),t.logger.debug(`Sanitized JSON structure: ${JSON.stringify(o,null,2)}`),new Error(`Failed to parse ${e}: ${c instanceof Error?c.message:String(c)}`)}}else throw new Error(`Failed to parse docs.yml:
|
|
1561
|
+
`}async function MSe({context:e,specs:t,relativePathToDependency:r}){let i=new Oju({context:e}),n=t.filter(d=>d.type==="openapi").map(d=>({...d,relativePathToDependency:r})),a=t.filter(d=>d.type==="protobuf"),c=(await Promise.all(a.map(async d=>{if(d.absoluteFilepathToProtobufTarget!=null){let p=await eFh({generator:i,protobufSpec:d,relativePathToDependency:r});return p?[p.openApiSpec]:[]}let s=await w4(d.absoluteFilepathToProtobufRoot,"proto"),u,l=[];for(let p of s){let _=await eFh({generator:i,protobufSpec:{...d,absoluteFilepathToProtobufTarget:p},relativePathToDependency:r,existingBufLockContents:u});_!=null&&(l.push(_.openApiSpec),_.bufLockContents!=null&&(u=_.bufLockContents))}return l}))).flat().filter(d=>us(d));return[...n,...c]}async function eFh({generator:e,protobufSpec:t,relativePathToDependency:r,existingBufLockContents:i}){if(t.absoluteFilepathToProtobufTarget==null)return;let n=await e.generate({absoluteFilepathToProtobufRoot:t.absoluteFilepathToProtobufRoot,absoluteFilepathToProtobufTarget:t.absoluteFilepathToProtobufTarget,relativeFilepathToProtobufRoot:t.relativeFilepathToProtobufRoot,local:t.generateLocally,deps:t.dependencies,existingBufLockContents:i});return{bufLockContents:n.bufLockContents,openApiSpec:{type:"openapi",absoluteFilepath:n.absoluteFilepath,absoluteFilepathToOverrides:t.absoluteFilepathToOverrides,absoluteFilepathToOverlays:void 0,settings:t.settings,source:{type:"protobuf",relativePathToDependency:r,root:t.absoluteFilepathToProtobufRoot,file:t.absoluteFilepathToProtobufTarget}}}}function xjB(e){return e.every(t=>t.settings?.removeDiscriminantsFromSchemas===an.RemoveDiscriminantsFromSchemas.Never)?an.RemoveDiscriminantsFromSchemas.Never:an.RemoveDiscriminantsFromSchemas.Always}var jS=class e extends lJa{type="oss";allSpecs;specs;sources;loader;parseOptions;groupMultiApiEnvironments;constructor({allSpecs:t,specs:r,...i}){super({...i,respectReadonlySchemas:r.every(n=>n.settings?.respectReadonlySchemas),respectNullableSchemas:r.every(n=>n.settings?.respectNullableSchemas),wrapReferencesToNullableInOptional:r.every(n=>n.settings?.wrapReferencesToNullableInOptional),removeDiscriminantsFromSchemas:xjB(r),coerceOptionalSchemasToNullable:r.every(n=>n.settings?.coerceOptionalSchemasToNullable),coerceEnumsToLiterals:r.every(n=>n.settings?.coerceEnumsToLiterals),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),inlineAllOfSchemas:r.every(n=>n.settings?.inlineAllOfSchemas),resolveAliases:r.every(o=>o.settings?.resolveAliases)?{except:r.flatMap(o=>typeof o.settings?.resolveAliases=="object"?o.settings.resolveAliases.except??[]:[])}:!1,exampleGeneration:r[0]?.settings?.exampleGeneration,groupEnvironmentsByHost:r.some(n=>n.settings?.groupEnvironmentsByHost),defaultIntegerFormat:r[0]?.settings?.defaultIntegerFormat,pathParameterOrder:r[0]?.settings?.pathParameterOrder}),this.specs=r,this.allSpecs=t,this.sources=this.convertSpecsToIdentifiableSources(r),this.loader=new Y8t(this.absoluteFilePath),this.groupMultiApiEnvironments=this.specs.some(n=>n.settings?.groupMultiApiEnvironments),this.parseOptions={onlyIncludeReferencedSchemas:this.onlyIncludeReferencedSchemas,respectReadonlySchemas:this.respectReadonlySchemas,respectNullableSchemas:this.respectNullableSchemas,wrapReferencesToNullableInOptional:this.wrapReferencesToNullableInOptional,coerceOptionalSchemasToNullable:this.coerceOptionalSchemasToNullable,coerceEnumsToLiterals:this.coerceEnumsToLiterals,inlinePathParameters:this.inlinePathParameters,objectQueryParameters:this.objectQueryParameters,exampleGeneration:this.exampleGeneration,useBytesForBinaryResponse:this.useBytesForBinaryResponse,respectForwardCompatibleEnums:this.respectForwardCompatibleEnums,inlineAllOfSchemas:this.inlineAllOfSchemas,resolveAliases:this.resolveAliases,removeDiscriminantsFromSchemas:this.removeDiscriminantsFromSchemas,groupMultiApiEnvironments:this.groupMultiApiEnvironments,groupEnvironmentsByHost:this.groupEnvironmentsByHost,defaultIntegerFormat:this.defaultIntegerFormat,pathParameterOrder:this.pathParameterOrder}}async getOpenAPIIr({context:t,relativePathToDependency:r,loadAiExamples:i=!1},n){let a=await MSe({context:t,specs:this.specs,relativePathToDependency:r});return kvn({context:t,documents:await this.loader.loadDocuments({context:t,specs:a,loadAiExamples:i}),options:{...n,...this.parseOptions}})}async getIntermediateRepresentation({context:t,audiences:r,enableUniqueErrorsPerEndpoint:i,generateV1Examples:n,logWarnings:a}){let o=await MSe({context:t,specs:this.specs}),c=await this.loader.loadDocuments({context:t,specs:o}),d=this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0;d&&t.logger.trace("Using auth overrides from generators configuration");let s=this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0;s&&t.logger.trace("Using environment overrides from generators configuration");let u=this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0;u&&t.logger.trace("Using global header overrides from generators configuration");let l,p=[];for(let _ of c){let h=Tt(this.absoluteFilePath,Je.of(_.source?.file??"")),y=FJ(iA(),h),b=new ZEe({logger:t.logger,relativeFilepathToSpec:y});p.push(b);let v;switch(_.type){case"openapi":{let m=new h4i({namespace:_.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:_.value,exampleGenerationArgs:{disabled:!1},errorCollector:b,authOverrides:d,environmentOverrides:s,globalHeaderOverrides:u,enableUniqueErrorsPerEndpoint:i,generateV1Examples:n,settings:x8t({options:_.settings}),documentBaseDir:nn(h)});v=await new AYa({context:m,audiences:r}).convert();break}case"asyncapi":{let m=new gYa({namespace:_.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:_.value,exampleGenerationArgs:{disabled:!1},errorCollector:b,enableUniqueErrorsPerEndpoint:i,settings:x8t({options:_.settings}),generateV1Examples:n});v=await new vYa({context:m,audiences:r}).convert();break}default:b.collect({message:`Unsupported document type: ${_}`,path:[]});break}let O=lju({generationLanguage:"typescript",keywords:void 0,smartCasing:!1});v!=null&&(l=l===void 0?v:svn(l,v,O))}for(let _ of this.allSpecs)if(_.type==="openrpc"){let h=_.absoluteFilepath,y=FJ(iA(),h),b=new ZEe({logger:t.logger,relativeFilepathToSpec:y});p.push(b);let v=new jYa({namespace:_.namespace,generationLanguage:"typescript",logger:t.logger,smartCasing:!1,spec:await wel({context:t,absoluteFilePath:_.absoluteFilepath,absoluteFilePathToOverrides:_.absoluteFilepathToOverrides}),exampleGenerationArgs:{disabled:!1},errorCollector:b,enableUniqueErrorsPerEndpoint:i,generateV1Examples:n,settings:x8t()}),m=await new PYa({context:v,audiences:r}).convert(),g=lju({generationLanguage:"typescript",keywords:void 0,smartCasing:!1});m!=null&&(l=l===void 0?m:svn(l,m,g))}else if(_.type==="protobuf")try{let y=await new gju({context:t}).generate({absoluteFilepathToProtobufRoot:_.absoluteFilepathToProtobufRoot,absoluteFilepathToProtobufTarget:_.absoluteFilepathToProtobufTarget,local:!0,deps:_.dependencies}),b=await(0,tFh.readFile)(y,"utf-8"),v=lju({generationLanguage:"typescript",keywords:void 0,smartCasing:!1});if(b!=null){let O;try{if(O=$n.IntermediateRepresentation.parse(JSON.parse(b),{allowUnrecognizedEnumValues:!0,skipValidation:!0}),O.ok)l=l===void 0?O.value:svn(l,O.value,v);else throw new Error}catch{t.logger.log("error","Failed to parse protobuf IR: ")}}}catch(h){t.logger.log("warn","Failed to parse protobuf IR: "+h)}for(let _ of p)if(_.hasErrors()){let h=_.getErrorStats(),y=_.relativeFilepathToSpec?` for ${_.relativeFilepathToSpec}`:"";h.numErrors>0?t.logger.log("error",`API validation${y} completed with ${h.numErrors} errors and ${h.numWarnings} warnings.`):h.numWarnings>0?t.logger.log("warn",`API validation${y} completed with ${h.numWarnings} warnings.`):t.logger.log("info",`All checks passed when parsing OpenAPI${y}.`),t.logger.log("info",""),await _.logErrors({logWarnings:a})}if(l===void 0)throw new Error("Failed to generate intermediate representation");return l}async toFernWorkspace({context:t},r,i){if(i!=null)return this.createWorkspaceWithSpecsOverride({context:t},i,r);let n=await this.getDefinition({context:t},r);return new gY({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:this.sources})}async createWorkspaceWithSpecsOverride({context:t},r,i){let n=await this.convertSpecsOverrideToSpecs(r),a=n.filter(d=>d.type!=="protobuf"||!d.fromOpenAPI),o=new e({allSpecs:a,specs:n.filter(d=>d.type==="openapi"||d.type==="protobuf"),generatorsConfiguration:this.generatorsConfiguration,workspaceName:this.workspaceName,cliVersion:this.cliVersion,absoluteFilePath:this.absoluteFilePath,changelog:this.changelog}),c=await o.getDefinition({context:t},i);return new gY({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:c,cliVersion:this.cliVersion,sources:o.sources})}async convertSpecsOverrideToSpecs(t){if(!Array.isArray(t))throw new Error("Conjure specs override is not yet supported");let r=[];for(let i of t)if(an.isOpenApiSpecSchema(i)){let n=Tt(this.absoluteFilePath,Je.of(i.openapi)),a=i.overrides?Tt(this.absoluteFilePath,Je.of(i.overrides)):void 0,o=i.overlays?Tt(this.absoluteFilePath,Je.of(i.overlays)):void 0,c={type:"openapi",absoluteFilepath:n,absoluteFilepathToOverrides:a,absoluteFilepathToOverlays:o,settings:this.specs.length>0?this.specs[0]?.settings:void 0,source:{type:"openapi",file:n},namespace:i.namespace??this.workspaceName};r.push(c)}else throw new Error("Spec type override not yet supported. Only OpenAPI specs are currently supported in specs override.");return r}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.allSpecs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(us)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,i=[];return t.reduce((n,a)=>{let o=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(o)||(r.add(o),n.push({type:a.type,id:Lve(),absoluteFilePath:o})),n},i)}};function HjB(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Gel(e,t){for(let[r,i]of UI(e.failures))KjB({relativeFilepath:r,failure:i,logger:t})}function KjB({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case Wp.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 Wp.FILE_READ:r.error("Failed to open file: "+e);break;case Wp.FILE_MISSING:r.error("Missing file: "+e);break;case Wp.FILE_PARSE:t.error instanceof L3a?r.error(b0e({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case Wp.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of JjB(i))r.error(b0e({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case Wp.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case Wp.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${vUo}: `+t.dependencyName);break;case Wp.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case Wp.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case Wp.JSONSCHEMA_VALIDATION:if(t.error.error!=null){let i=t.error.error.instancePath.split("/").filter(n=>n!=="").map(HjB);t.error.error.keyword==="required"&&t.error.error.params?.missingProperty?i.push(t.error.error.params.missingProperty):t.error.error.keyword==="additionalProperties"&&t.error.error.params?.additionalProperty&&i.push(t.error.error.params.additionalProperty),r.error(b0e({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...i]}))}break;default:vt(t)}}function JjB(e){switch(e.code){case wi.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${Rt.underline(e.expected)} but received ${Rt.underline(e.received)}`}];case wi.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${Rt.underline(t)}`}));case wi.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>Rt.underline(t)).join(", ")}`}];case wi.invalid_union:case wi.invalid_arguments:case wi.invalid_return_type:case wi.invalid_date:case wi.invalid_string:case wi.too_small:case wi.too_big:case wi.invalid_intersection_types:case wi.not_multiple_of:case wi.custom:default:return[{title:e.message}]}}var rFh=require("fs/promises");async function iFh(e,t){let r=[];for(let i of await w4(e,t))r.push(await $jB({relativeFilepath:pp(e,i),absoluteFilepath:i}));return r}async function $jB({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,rFh.readFile)(t)).toString()}}async function nFh({absolutePathToWorkspace:e}){let t=Tt(e,Je.of(AVp));if(!await Ai(t))return;let i=await iFh(t,"{md,mdx}");return{files:await Promise.all(i.map(n=>({absoluteFilepath:n.absoluteFilepath,contents:n.fileContents})))}}async function xel({absolutePathToWorkspace:e,namespace:t,definitions:r}){let i=[];for(let n of r){let a=n.overrides!=null?Tt(e,Je.of(n.overrides)):void 0,o=n.overlays!=null?Tt(e,Je.of(n.overlays)):void 0;if(n.schema.type==="protobuf"){let s=Je.of(n.schema.root),u=Tt(e,s);if(!await Ai(u))return{didSucceed:!1,failures:{[Je.of(n.schema.root)]:{type:Wp.FILE_MISSING}}};let l=n.schema.target.length===0?void 0:Tt(e,Je.of(n.schema.target));if(l!=null&&!await Ai(l))return{didSucceed:!1,failures:{[Je.of(n.schema.target)]:{type:Wp.FILE_MISSING}}};let p=Fmu(n.settings);i.push({type:"protobuf",absoluteFilepathToProtobufRoot:u,absoluteFilepathToProtobufTarget:l,absoluteFilepathToOverrides:a,relativeFilepathToProtobufRoot:s,dependencies:n.schema.dependencies,generateLocally:n.schema.localGeneration,fromOpenAPI:n.schema.fromOpenAPI,settings:{...p,audiences:n.audiences??[]}});continue}if(n.schema.type==="openrpc"){let s=Je.of(n.schema.path),u=Tt(e,s);i.push({type:"openrpc",absoluteFilepath:u,absoluteFilepathToOverrides:a,namespace:t});continue}let c=Tt(e,Je.of(n.schema.path));if(!await Ai(c))return{didSucceed:!1,failures:{[Je.of(n.schema.path)]:{type:Wp.FILE_MISSING}}};if(n.overrides!=null&&a!=null&&!await Ai(a))return{didSucceed:!1,failures:{[Je.of(n.overrides)]:{type:Wp.FILE_MISSING}}};if(n.overlays!=null&&o!=null&&!await Ai(o))return{didSucceed:!1,failures:{[Je.of(n.overlays)]:{type:Wp.FILE_MISSING}}};let d=Fmu(n.settings);i.push({type:"openapi",absoluteFilepath:c,absoluteFilepathToOverrides:a,absoluteFilepathToOverlays:o,settings:{...d,audiences:n.audiences??[]},source:{type:"openapi",file:c},namespace:t})}return i}async function BYa({absolutePathToWorkspace:e,context:t,cliVersion:r,workspaceName:i}){let n=await zve({absolutePathToWorkspace:e,context:t}),a;try{a=await nFh({absolutePathToWorkspace:e})}catch{}if(n?.api!=null&&n?.api.type==="conjure")return{didSucceed:!0,workspace:new sAu({workspaceName:i,absoluteFilePath:e,generatorsConfiguration:n,changelog:a,cliVersion:r,context:t,relativePathToConjureDirectory:Je.of(n.api.pathToConjureDefinition)})};if(n?.api!=null&&(n.api.type==="singleNamespace"&&n.api.definitions.length>0||n.api.type==="multiNamespace")){let o=[];if(n.api.type==="singleNamespace"){let c=await xel({absolutePathToWorkspace:e,namespace:void 0,definitions:n.api.definitions});if(!Array.isArray(c))return c;o.push(...c)}else{for(let[c,d]of Object.entries(n.api.definitions)){let s=await xel({absolutePathToWorkspace:e,namespace:c,definitions:d});if(!Array.isArray(s))return s;o.push(...s)}if(n.api.rootDefinitions!=null){let c=await xel({absolutePathToWorkspace:e,namespace:void 0,definitions:n.api.rootDefinitions});if(!Array.isArray(c))return c;o.push(...c)}}return{didSucceed:!0,workspace:new jS({specs:o.filter(c=>!(c.type==="openrpc"||c.type==="protobuf"&&!c.fromOpenAPI)),allSpecs:o.filter(c=>!(c.type==="protobuf"&&c.fromOpenAPI)),workspaceName:i,absoluteFilePath:e,generatorsConfiguration:n,changelog:a,cliVersion:r})}}if(await Ai(Tt(e,Je.of(e1))))return{didSucceed:!0,workspace:new ESe({absoluteFilePath:e,generatorsConfiguration:n,workspaceName:i,changelog:a,context:t,cliVersion:r,loadAPIWorkspace:BYa})};if(await apc(Tt(e,Je.of(e1)))){let o=e.split("/").pop();t.logger.warn(`Detected empty API definiton: ${o}. Remove to resolve error.`)}return{didSucceed:!1,failures:{[Je.of(i3a)]:{type:Wp.MISCONFIGURED_DIRECTORY}}}}var aFh=require("fs/promises");var Hel={};Yt(Hel,{additionalProperties:()=>kjB,default:()=>t0B,definitions:()=>e0B,properties:()=>XjB,required:()=>ZjB,type:()=>YjB});var YjB="object",XjB={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"}]},"page-actions":{oneOf:[{$ref:"#/definitions/docs.PageActionsConfig"},{type:"null"}]},experimental:{oneOf:[{$ref:"#/definitions/docs.ExperimentalConfig"},{type:"null"}]},"default-language":{oneOf:[{$ref:"#/definitions/docs.ProgrammingLanguage"},{type:"null"}]},languages:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.Language"}},{type:"null"}]},"ai-chat":{oneOf:[{$ref:"#/definitions/docs.AIChatConfig"},{type:"null"}]},"ai-search":{oneOf:[{$ref:"#/definitions/docs.AIChatConfig"},{type:"null"}]},"ai-examples":{oneOf:[{$ref:"#/definitions/docs.AiExamplesConfig"},{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"}]},settings:{oneOf:[{$ref:"#/definitions/docs.DocsSettingsConfig"},{type:"null"}]},theme:{oneOf:[{$ref:"#/definitions/docs.ThemeConfig"},{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"}]}},ZjB=["instances"],kjB=!1,e0B={"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.EditThisPageLaunch":{type:"string",enum:["github","dashboard"]},"docs.EditThisPageConfig":{type:"object",properties:{github:{oneOf:[{$ref:"#/definitions/docs.GithubEditThisPageConfig"},{type:"null"}]},launch:{oneOf:[{$ref:"#/definitions/docs.EditThisPageLaunch"},{type:"null"}]}},additionalProperties:!1},"docs.AudienceId":{type:"string"},"docs.Audience":{anyOf:[{$ref:"#/definitions/docs.AudienceId"},{type:"array",items:{$ref:"#/definitions/docs.AudienceId"}}]},"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"}]},audiences:{oneOf:[{$ref:"#/definitions/docs.Audience"},{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.Target":{type:"string",enum:["_blank","_self","_parent","_top"]},"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"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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"}]},audiences:{oneOf:[{$ref:"#/definitions/docs.Audience"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},announcement:{oneOf:[{$ref:"#/definitions/docs.AnnouncementConfig"},{type:"null"}]}},required:["display-name","path"],additionalProperties:!1},"docs.InternalProduct":{type:"object",properties:{"display-name":{type:"string"},subtitle:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},image:{oneOf:[{type:"string"},{type:"null"}]},versions:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.VersionConfig"}},{type:"null"}]},audiences:{oneOf:[{$ref:"#/definitions/docs.Audience"},{type:"null"}]},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},path:{type:"string"},slug:{oneOf:[{type:"string"},{type:"null"}]},announcement:{oneOf:[{$ref:"#/definitions/docs.AnnouncementConfig"},{type:"null"}]}},required:["display-name","path"],additionalProperties:!1},"docs.ExternalProduct":{type:"object",properties:{"display-name":{type:"string"},subtitle:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},image:{oneOf:[{type:"string"},{type:"null"}]},versions:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.VersionConfig"}},{type:"null"}]},audiences:{oneOf:[{$ref:"#/definitions/docs.Audience"},{type:"null"}]},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},href:{type:"string"},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{type:"null"}]}},required:["display-name","href"],additionalProperties:!1},"docs.ProductConfig":{anyOf:[{$ref:"#/definitions/docs.InternalProduct"},{$ref:"#/definitions/docs.ExternalProduct"}]},"docs.Availability":{type:"string",enum:["stable","generally-available","in-development","pre-release","deprecated","beta"]},"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"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{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"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]}},required:["section","contents"],additionalProperties:!1},"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"}]},php:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},swift:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},rust:{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:{hidden:{oneOf:[{type:"boolean"},{type:"null"}]},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"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{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"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{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"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{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"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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:[{$ref:"#/definitions/docs.Audience"},{type:"null"}]},"display-errors":{oneOf:[{type:"boolean"},{type:"null"}]},"tag-description-pages":{oneOf:[{type:"boolean"},{type:"null"}]},snippets:{oneOf:[{$ref:"#/definitions/docs.SnippetsConfiguration"},{type:"null"}]},postman:{oneOf:[{type:"string"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{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.PythonDocsConfiguration":{type:"object",properties:{"python-docs":{type:"string"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]}},required:["python-docs"],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.FolderConfiguration":{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"}]},folder:{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"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]}},required:["folder"],additionalProperties:!1},"docs.NavigationItem":{anyOf:[{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.SectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceConfiguration"},{$ref:"#/definitions/docs.PythonDocsConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"},{$ref:"#/definitions/docs.ChangelogConfiguration"},{$ref:"#/definitions/docs.FolderConfiguration"}]},"docs.UntabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},"docs.TabId":{type:"string"},"docs.TabbedNavigationItemWithLayout":{type:"object",properties:{tab:{$ref:"#/definitions/docs.TabId"},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},{type:"null"}]}},required:["tab"],additionalProperties:!1},"docs.TabVariant":{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:{type:"string"},subtitle:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},layout:{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},slug:{oneOf:[{type:"string"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},default:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["title","layout"],additionalProperties:!1},"docs.TabbedNavigationItemWithVariants":{type:"object",properties:{tab:{$ref:"#/definitions/docs.TabId"},variants:{type:"array",items:{$ref:"#/definitions/docs.TabVariant"}}},required:["tab","variants"],additionalProperties:!1},"docs.TabbedNavigationItem":{anyOf:[{$ref:"#/definitions/docs.TabbedNavigationItemWithLayout"},{$ref:"#/definitions/docs.TabbedNavigationItemWithVariants"}]},"docs.TabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.TabbedNavigationItem"}},"docs.NavigationConfig":{anyOf:[{$ref:"#/definitions/docs.UntabbedNavigationConfig"},{$ref:"#/definitions/docs.TabbedNavigationConfig"}]},"docs.NavbarGithubConfigWithOptions":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},url:{type:"string"},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{type:"null"}]}},required:["url"],additionalProperties:!1},"docs.NavbarGithubConfig":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.NavbarGithubConfigWithOptions"}]},"docs.NavbarLinkConfig":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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"}]}},additionalProperties:!1},"docs.NavbarLink":{type:"object",properties:{type:{type:"string",enum:["filled","outlined","minimal","github","dropdown","primary","secondary"]}},oneOf:[{properties:{type:{const:"filled"},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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"},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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"},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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:"dropdown"},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},links:{type:"array",items:{$ref:"#/definitions/docs.NavbarLinkConfig"}},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","links"]},{properties:{type:{const:"primary"},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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"},viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},target:{oneOf:[{$ref:"#/definitions/docs.Target"},{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.PageActionOption":{type:"string",enum:["copy-page","view-as-markdown","ask-ai","chatgpt","claude","cursor","vscode"]},"docs.CustomPageAction":{type:"object",properties:{title:{type:"string"},subtitle:{oneOf:[{type:"string"},{type:"null"}]},url:{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]},default:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["title","url"],additionalProperties:!1},"docs.PageActionOptions":{type:"object",properties:{"copy-page":{oneOf:[{type:"boolean"},{type:"null"}]},"view-as-markdown":{oneOf:[{type:"boolean"},{type:"null"}]},"ask-ai":{oneOf:[{type:"boolean"},{type:"null"}]},chatgpt:{oneOf:[{type:"boolean"},{type:"null"}]},claude:{oneOf:[{type:"boolean"},{type:"null"}]},cursor:{oneOf:[{type:"boolean"},{type:"null"}]},vscode:{oneOf:[{type:"boolean"},{type:"null"}]},custom:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.CustomPageAction"}},{type:"null"}]}},additionalProperties:!1},"docs.PageActionsConfig":{type:"object",properties:{default:{oneOf:[{$ref:"#/definitions/docs.PageActionOption"},{type:"null"}]},options:{oneOf:[{$ref:"#/definitions/docs.PageActionOptions"},{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"}]},"dynamic-snippets":{oneOf:[{type:"boolean"},{type:"null"}]},"ai-examples":{oneOf:[{type:"boolean"},{type:"null"}]},"ai-example-style-instructions":{oneOf:[{type:"string"},{type:"null"}]},"exclude-apis":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"docs.ProgrammingLanguage":{type:"string",enum:["typescript","javascript","python","java","go","ruby","csharp","php","swift","rust","nodets","nodejs","dotnet","curl","jvm","ts","js"]},"docs.Language":{type:"string",enum:["en","es","fr","de","it","pt","ja","zh","ko","el","no","pl","ru","sv","tr"]},"docs.AIChatModel":{type:"string",enum:["claude-3.7","claude-4","command-a"]},"docs.AIChatLocation":{type:"string",enum:["docs","slack","discord"]},"docs.AIChatWebsiteDatasource":{type:"object",properties:{url:{type:"string"},title:{oneOf:[{type:"string"},{type:"null"}]}},required:["url"],additionalProperties:!1},"docs.AIChatDatasource":{anyOf:[{$ref:"#/definitions/docs.AIChatWebsiteDatasource"}]},"docs.AIChatConfig":{type:"object",properties:{model:{oneOf:[{$ref:"#/definitions/docs.AIChatModel"},{type:"null"}]},"system-prompt":{oneOf:[{type:"string"},{type:"null"}]},location:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.AIChatLocation"}},{type:"null"}]},datasources:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.AIChatDatasource"}},{type:"null"}]}},additionalProperties:!1},"docs.AiExamplesConfig":{type:"object",properties:{enabled:{oneOf:[{type:"boolean"},{type:"null"}]},style:{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"}]},"canonical-host":{oneOf:[{type:"string"},{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"}]},"right-text":{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"}]},"hide-nav-links":{oneOf:[{type:"boolean"},{type:"null"}]},"hide-feedback":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"docs.HttpSnippetLanguage":{type:"string",enum:["curl","csharp","go","java","javascript","php","python","ruby","swift","typescript"]},"docs.HttpSnippetsConfig":{anyOf:[{type:"boolean"},{type:"array",items:{$ref:"#/definitions/docs.HttpSnippetLanguage"}}]},"docs.DocsSettingsConfig":{type:"object",properties:{"search-text":{oneOf:[{type:"string"},{type:"null"}]},"disable-search":{oneOf:[{type:"boolean"},{type:"null"}]},"dark-mode-code":{oneOf:[{type:"boolean"},{type:"null"}]},"default-search-filters":{oneOf:[{type:"boolean"},{type:"null"}]},"http-snippets":{oneOf:[{$ref:"#/definitions/docs.HttpSnippetsConfig"},{type:"null"}]},"hide-404-page":{oneOf:[{type:"boolean"},{type:"null"}]},"use-javascript-as-typescript":{oneOf:[{type:"boolean"},{type:"null"}]},"disable-explorer-proxy":{oneOf:[{type:"boolean"},{type:"null"}]},"disable-analytics":{oneOf:[{type:"boolean"},{type:"null"}]},language:{oneOf:[{$ref:"#/definitions/docs.Language"},{type:"null"}]},"substitute-env-vars":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"docs.SidebarThemeConfig":{type:"string",enum:["default","minimal"]},"docs.BodyThemeConfig":{type:"string",enum:["default","canvas"]},"docs.TabsThemeConfig":{type:"string",enum:["default","bubble"]},"docs.PageActionsThemeConfig":{type:"string",enum:["default","toolbar"]},"docs.FooterNavThemeConfig":{type:"string",enum:["default","minimal"]},"docs.LanguageSwitcherThemeConfig":{type:"string",enum:["default","minimal"]},"docs.ProductSwitcherThemeConfig":{type:"string",enum:["default","toggle"]},"docs.ThemeConfig":{type:"object",properties:{sidebar:{oneOf:[{$ref:"#/definitions/docs.SidebarThemeConfig"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/docs.BodyThemeConfig"},{type:"null"}]},tabs:{oneOf:[{$ref:"#/definitions/docs.TabsThemeConfig"},{type:"null"}]},"page-actions":{oneOf:[{$ref:"#/definitions/docs.PageActionsThemeConfig"},{type:"null"}]},"footer-nav":{oneOf:[{$ref:"#/definitions/docs.FooterNavThemeConfig"},{type:"null"}]},"language-switcher":{oneOf:[{$ref:"#/definitions/docs.LanguageSwitcherThemeConfig"},{type:"null"}]},"product-switcher":{oneOf:[{$ref:"#/definitions/docs.ProductSwitcherThemeConfig"},{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"}}]}},t0B={type:YjB,properties:XjB,required:ZjB,additionalProperties:kjB,definitions:e0B};async function Kel({fernDirectory:e,context:t}){let r=Tt(e,Je.of(P0));if(!await Ai(r))return;let i=await r0B({absolutePathToDocsDefinition:e,context:t});if(i!=null)return{type:"docs",absoluteFilePath:e,config:i,workspaceName:void 0,absoluteFilepathToDocsConfig:Tt(e,Je.of(P0))}}async function r0B({absolutePathToDocsDefinition:e,context:t}){if(!await Ai(e))return;let r=Tt(e,Je.of(P0));return await i0B({absolutePathOfConfiguration:r,context:t})}async function i0B({absolutePathOfConfiguration:e,context:t}){let r=await(0,aFh.readFile)(e),i=qi.load(r.toString()),n=OVt(i,Hel,{filePath:e});if(n.success){let a=[];t.logger.debug("About to sanitize docs configuration JSON structure");let o=c0e(i,[],a);a.length>0?t.logger.warn(`docs.yml contained null/undefined sections that were ignored: ${a.map(c=>c.join(".")).join(", ")}`):t.logger.debug("No null/undefined values found during sanitization");try{return t.logger.debug("Attempting to parse sanitized docs configuration"),GJ.RawSchemas.Serializer.DocsConfiguration.parseOrThrow(o)}catch(c){throw t.logger.error(`Parsing failed even after sanitization: ${c instanceof Error?c.message:String(c)}`),t.logger.debug(`Sanitized JSON structure: ${JSON.stringify(o,null,2)}`),new Error(`Failed to parse ${e}: ${c instanceof Error?c.message:String(c)}`)}}else throw new Error(`Failed to parse docs.yml:
|
|
1562
1562
|
${n.error?.message??"Unknown error"}`)}var oFh=require("fs/promises");async function Jel({context:e,nameOverride:t,...r}){let i=await vS(t);return i==null?e.failAndThrow(`Directory "${t??uR}" not found.`):await uFh({absolutePathToFernDirectory:i,context:e,nameOverride:t,...r})}async function uFh({absolutePathToFernDirectory:e,cliName:t,cliVersion:r,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:n,context:a}){let o=[];(await Ai(Tt(e,Je.of(hNi)))||await Ai(Tt(e,Je.of(e1)))||await Ai(Tt(e,Je.of(_D)))||await Ai(Tt(e,Je.of(gUo)))||await Ai(Tt(e,Je.of(i3a)))||await Ai(Tt(e,Je.of(whc))))&&(o=await sFh({cliName:t,fernDirectory:e,cliVersion:r,context:a,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:n}));let c=await Kel({fernDirectory:e,context:a});return o.length===0&&c==null?a.failAndThrow(`No SDK specifications or docs specifications found. Please ensure one of the following .yml (not .yaml) files is present:
|
|
1563
1563
|
\u203A ${_D}
|
|
1564
1564
|
\u203A ${P0}
|
|
@@ -1903,7 +1903,7 @@ A valid API configuration was not found at the path: fern/apis/${t.apiName}.
|
|
|
1903
1903
|
Learn more about project structure:
|
|
1904
1904
|
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions`:`Failed to load API Definition referenced in docs.
|
|
1905
1905
|
Learn more about project structure:
|
|
1906
|
-
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions`;throw new Error(r)}async toRootNode(){let t=Ft.V1.SlugGenerator.init(Ft.slugjoin(this.getDocsBasePath())),r=this.#e.get("root"),i=await this.toRootChild(t);return{type:"root",version:"v1",id:r,child:i,slug:t.get(),title:this.parsedDocsConfig.title??"Documentation",hidden:!1,icon:void 0,pointsTo:void 0,authed:void 0,viewers:void 0,orphaned:void 0,roles:this.parsedDocsConfig.roles?.map(n=>Ft.RoleId(n)),featureFlags:void 0}}async toRootChild(t){return odn(this.parsedDocsConfig.navigation)._visit({untabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),tabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),versioned:r=>this.toVersionedNode(r,t),productgroup:r=>this.toProductGroupNode({landingPageConfig:this.parsedDocsConfig.landingPage,productGroup:r,parentSlug:t})})}toLandingPageNode(t,r){let i=Ft.PageId(this.toRelativeFilepath(t.absolutePath)),n=r.apply({urlSlug:t.slug??cS(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{type:"landingPage",id:this.#e.get(i),title:t.title,slug:n.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:i,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags}}async toUnversionedNode({landingPage:t,navigationConfig:r,parentSlug:i}){let n=this.#e.get("unversioned"),a=t!=null?this.toLandingPageNode(t,i):void 0,o=r.type==="tabbed"?await this.convertTabbedNavigation(n,r.items,i):await this.toSidebarRootNode(n,r.items,i);return{type:"unversioned",id:n,landingPage:a,child:o}}async toVersionedNode(t,r){let i=this.#e.get("versioned"),n=t.versions[0];if(n?.hidden===!0)throw new Error(`The default version "${n.version}" cannot be hidden. Please set a non-hidden version as the first version in your versions list, or remove the hidden flag from the default version.`);return{id:i,type:"versioned",children:await Promise.all(t.versions.map((a,o)=>this.toVersionNode(a,r,o===0)))}}async toProductGroupNode({productGroup:t,landingPageConfig:r,parentSlug:i}){let n=this.#e.get("productgroup"),a=r!=null?this.toLandingPageNode(r,i):void 0;return{id:n,type:"productgroup",landingPage:a,children:await Promise.all(t.products.map(o=>this.toProductNode(o,i)))}}async toProductNode(t,r){if(t.type==="internal"){let i=r.setProductSlug(t.slug??cS(t.product)),n;switch(t.navigation.type){case"tabbed":n={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.convertTabbedNavigation(this.#e.get(t.product),t.navigation.items,i)};break;case"untabbed":n={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.toSidebarRootNode(this.#e.get(t.product),t.navigation.items,i)};break;case"versioned":n=await this.toVersionedNode(t.navigation,i);break;default:vt(t.navigation)}return{type:"product",id:this.#e.get(t.product),productId:Ft.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",slug:i.get(),child:n,default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,pointsTo:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,announcement:t.announcement!=null?{text:t.announcement.message}:void 0}}else return{type:"productLink",id:this.#e.get(t.product),productId:Ft.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",href:UG.Url(t.href??""),target:t.target,default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,viewers:t.viewers,orphaned:t.orphaned}}async toVersionNode(t,r,i){let n=this.#e.get(t.version),a=r.setVersionSlug(t.slug??cS(t.version)),o=t.navigation.type==="tabbed"?await this.convertTabbedNavigation(n,t.navigation.items,a):await this.toSidebarRootNode(n,t.navigation.items,a);return{type:"version",id:n,versionId:Ft.VersionId(t.version),title:t.version,slug:a.get(),child:o,default:i,availability:t.availability!=null?SDB(t.availability):void 0,landingPage:t.landingPage?this.toLandingPageNode(t.landingPage,a):void 0,hidden:t.hidden,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,icon:void 0,pointsTo:void 0,featureFlags:t.featureFlags,announcement:t.announcement!=null?{text:t.announcement.message}:void 0}}async toSidebarRootNode(t,r,i){let n=this.#e.get(`${t}/root`),a=await Promise.all(r.map(c=>this.toNavigationChild({prefix:n,item:c,parentSlug:i}))),o=[];return a.forEach(c=>{if(c.type==="apiReference"){o.push(c);return}if(c.type==="section"&&!c.collapsed){o.push(c);return}let d=o.length>0?o[o.length-1]:void 0,s;d?.type==="sidebarGroup"?s=d:(s={id:this.#e.get(`${n}/group`),type:"sidebarGroup",children:[]},o.push(s)),s.children.push(c)}),{type:"sidebarRoot",id:n,children:o}}async toSidebarRootNodeWithVariants(t,r,i){let n=this.#e.get(`${t}/root`);return{type:"sidebarRoot",id:n,children:[{type:"varianted",id:n,children:await Promise.all(r.map(a=>this.toVariantNode(a,n,i)))}]}}async toVariantNode(t,r,i){let n=this.#e.get(`${r}/variant/${t.slug??cS(t.title)}`),a=i.apply({urlSlug:t.slug??cS(t.title),skipUrlSlug:t.skipUrlSlug}),o=await Promise.all(t.layout.map(c=>this.toVariantChild(c,n,a)));return{type:"variant",id:n,variantId:Ft.V1.VariantId(t.title),subtitle:t.subtitle??"",default:t.default??!1,image:void 0,children:o,title:t.title,slug:a.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,pointsTo:void 0}}async toVariantChild(t,r,i){return odn(t)._visit({page:async n=>this.toPageNode({item:n,parentSlug:i}),apiSection:async n=>this.toApiSectionNode({item:n,parentSlug:i}),section:async n=>this.toSectionNode({prefix:r,item:n,parentSlug:i}),link:async n=>this.toLinkNode(n),changelog:async n=>this.toChangelogNode(n,i),pythonDocsSection:async n=>this.toPythonDocsSectionPlaceholder(n,i)})}async toNavigationChild({prefix:t,item:r,parentSlug:i,hideChildren:n,parentAvailability:a}){return odn(r)._visit({page:async o=>this.toPageNode({item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),apiSection:async o=>this.toApiSectionNode({item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),section:async o=>this.toSectionNode({prefix:t,item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),link:async o=>this.toLinkNode(o),changelog:async o=>this.toChangelogNode(o,i,n),pythonDocsSection:async o=>this.toPythonDocsSectionPlaceholder(o,i)})}async toApiSectionNode({item:t,parentSlug:r,hideChildren:i,parentAvailability:n}){let a=SLh(t.snippetsConfiguration),o,c=await this.getFernWorkspaceForApiSection(t).toFernWorkspace({context:this.taskContext},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1,objectQueryParameters:!0,preserveSchemaIds:!0}),d=this.parsedDocsConfig.experimental?.openapiParserV3,s=d==null||d;if(s)try{o=await this.getOpenApiWorkspaceForApiSection(t).getIntermediateRepresentation({context:this.taskContext,audiences:t.audiences,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1})}catch{}let u;if(t.tagDescriptionPages&&s)try{let b=await this.getOpenApiWorkspaceForApiSection(t).getOpenAPIIr({context:this.taskContext});b.tags.tagsById&&(u=Object.fromEntries(Object.entries(b.tags.tagsById).filter(([v,O])=>O.description&&O.description.trim().length>0).map(([v,O])=>[v,{id:String(O.id),description:O.description}])))}catch(y){this.taskContext.logger.warn("Failed to extract OpenAPI tags for tag description pages",String(y))}o==null&&(o=ES({workspace:c,audiences:t.audiences,generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!0},readme:void 0,version:void 0,packageName:void 0,context:this.taskContext,sourceResolver:new wS(this.taskContext,c)})),this.docsWorkspace.config.settings?.substituteEnvVars&&(o=iR(o,{onError:y=>this.taskContext.failAndThrow(`Error substituting environment variables in API spec: ${y}`)},{substituteAsEmpty:!1}));let l=await this.registerApi({ir:o,snippetsConfig:a,playgroundConfig:{oauth:t.playground?.oauth},apiName:t.apiName,workspace:c}),p=iXa({ir:o,apiDefinitionId:l,playgroundConfig:{oauth:t.playground?.oauth},context:this.taskContext}),_=new B0u(t,p,r,this.docsWorkspace,this.taskContext,this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,this.#e,this.collectedFileIds,c,i,n??t.availability,u),h=_.getTagDescriptionContent();for(let[y,b]of h.entries()){let v=y.split("/").pop()||y,O=Je.of(v),m=b;this.docsWorkspace.config.settings?.substituteEnvVars&&(m=iR(b,{onError:g=>this.taskContext.logger.error(`Error in tag description environment variable substitution: ${g}`)},{substituteAsEmpty:!1})),this.rawMarkdownFiles[O]=m,this.parsedDocsConfig.pages[O]=m}return _.get()}async toChangelogNode(t,r,i){return new cOn(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,t.changelog,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:r,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:i||t.hidden,slug:t.slug})}async toLinkNode(t){return{type:"link",id:this.#e.get(t.url),title:t.text,url:Ft.V1.Url(t.url),icon:this.resolveIconFileId(t.icon),target:t.target}}toPythonDocsSectionPlaceholder(t,r){let i=t.title??"Python Reference",n=t.slug??"python-docs",a=r.apply({urlSlug:n}),o=`__python-docs-placeholder-${n}__.mdx`,c=Ft.PageId(o),d=`---
|
|
1906
|
+
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions`;throw new Error(r)}async toRootNode(){let t=Ft.V1.SlugGenerator.init(Ft.slugjoin(this.getDocsBasePath())),r=this.#e.get("root"),i=await this.toRootChild(t);return{type:"root",version:"v1",id:r,child:i,slug:t.get(),title:this.parsedDocsConfig.title??"Documentation",hidden:!1,icon:void 0,pointsTo:void 0,authed:void 0,viewers:void 0,orphaned:void 0,roles:this.parsedDocsConfig.roles?.map(n=>Ft.RoleId(n)),featureFlags:void 0}}async toRootChild(t){return odn(this.parsedDocsConfig.navigation)._visit({untabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),tabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),versioned:r=>this.toVersionedNode(r,t),productgroup:r=>this.toProductGroupNode({landingPageConfig:this.parsedDocsConfig.landingPage,productGroup:r,parentSlug:t})})}toLandingPageNode(t,r){let i=Ft.PageId(this.toRelativeFilepath(t.absolutePath)),n=r.apply({urlSlug:t.slug??cS(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{type:"landingPage",id:this.#e.get(i),title:t.title,slug:n.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:i,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags}}async toUnversionedNode({landingPage:t,navigationConfig:r,parentSlug:i}){let n=this.#e.get("unversioned"),a=t!=null?this.toLandingPageNode(t,i):void 0,o=r.type==="tabbed"?await this.convertTabbedNavigation(n,r.items,i):await this.toSidebarRootNode(n,r.items,i);return{type:"unversioned",id:n,landingPage:a,child:o}}async toVersionedNode(t,r){let i=this.#e.get("versioned"),n=t.versions[0];if(n?.hidden===!0)throw new Error(`The default version "${n.version}" cannot be hidden. Please set a non-hidden version as the first version in your versions list, or remove the hidden flag from the default version.`);return{id:i,type:"versioned",children:await Promise.all(t.versions.map((a,o)=>this.toVersionNode(a,r,o===0)))}}async toProductGroupNode({productGroup:t,landingPageConfig:r,parentSlug:i}){let n=this.#e.get("productgroup"),a=r!=null?this.toLandingPageNode(r,i):void 0;return{id:n,type:"productgroup",landingPage:a,children:await Promise.all(t.products.map(o=>this.toProductNode(o,i)))}}async toProductNode(t,r){if(t.type==="internal"){let i=r.setProductSlug(t.slug??cS(t.product)),n;switch(t.navigation.type){case"tabbed":n={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.convertTabbedNavigation(this.#e.get(t.product),t.navigation.items,i)};break;case"untabbed":n={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.toSidebarRootNode(this.#e.get(t.product),t.navigation.items,i)};break;case"versioned":n=await this.toVersionedNode(t.navigation,i);break;default:vt(t.navigation)}return{type:"product",id:this.#e.get(t.product),productId:Ft.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",slug:i.get(),child:n,default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,pointsTo:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,announcement:t.announcement!=null?{text:t.announcement.message}:void 0}}else return{type:"productLink",id:this.#e.get(t.product),productId:Ft.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",href:UG.Url(t.href??""),target:t.target,default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,viewers:t.viewers,orphaned:t.orphaned}}async toVersionNode(t,r,i){let n=this.#e.get(t.version),a=r.setVersionSlug(t.slug??cS(t.version)),o=t.navigation.type==="tabbed"?await this.convertTabbedNavigation(n,t.navigation.items,a):await this.toSidebarRootNode(n,t.navigation.items,a);return{type:"version",id:n,versionId:Ft.VersionId(t.version),title:t.version,slug:a.get(),child:o,default:i,availability:t.availability!=null?SDB(t.availability):void 0,landingPage:t.landingPage?this.toLandingPageNode(t.landingPage,a):void 0,hidden:t.hidden,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,icon:void 0,pointsTo:void 0,featureFlags:t.featureFlags,announcement:t.announcement!=null?{text:t.announcement.message}:void 0}}async toSidebarRootNode(t,r,i){let n=this.#e.get(`${t}/root`),a=await Promise.all(r.map(c=>this.toNavigationChild({prefix:n,item:c,parentSlug:i}))),o=[];return a.forEach(c=>{if(c.type==="apiReference"){o.push(c);return}if(c.type==="section"&&!c.collapsed){o.push(c);return}let d=o.length>0?o[o.length-1]:void 0,s;d?.type==="sidebarGroup"?s=d:(s={id:this.#e.get(`${n}/group`),type:"sidebarGroup",children:[]},o.push(s)),s.children.push(c)}),{type:"sidebarRoot",id:n,children:o}}async toSidebarRootNodeWithVariants(t,r,i){let n=this.#e.get(`${t}/root`);return{type:"sidebarRoot",id:n,children:[{type:"varianted",id:n,children:await Promise.all(r.map(a=>this.toVariantNode(a,n,i)))}]}}async toVariantNode(t,r,i){let n=this.#e.get(`${r}/variant/${t.slug??cS(t.title)}`),a=i.apply({urlSlug:t.slug??cS(t.title),skipUrlSlug:t.skipUrlSlug}),o=await Promise.all(t.layout.map(c=>this.toVariantChild(c,n,a)));return{type:"variant",id:n,variantId:Ft.V1.VariantId(t.title),subtitle:t.subtitle??"",default:t.default??!1,image:void 0,children:o,title:t.title,slug:a.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,pointsTo:void 0}}async toVariantChild(t,r,i){return odn(t)._visit({page:async n=>this.toPageNode({item:n,parentSlug:i}),apiSection:async n=>this.toApiSectionNode({item:n,parentSlug:i}),section:async n=>this.toSectionNode({prefix:r,item:n,parentSlug:i}),link:async n=>this.toLinkNode(n),changelog:async n=>this.toChangelogNode(n,i),pythonDocsSection:async n=>this.toPythonDocsSectionPlaceholder(n,i)})}async toNavigationChild({prefix:t,item:r,parentSlug:i,hideChildren:n,parentAvailability:a}){return odn(r)._visit({page:async o=>this.toPageNode({item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),apiSection:async o=>this.toApiSectionNode({item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),section:async o=>this.toSectionNode({prefix:t,item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),link:async o=>this.toLinkNode(o),changelog:async o=>this.toChangelogNode(o,i,n),pythonDocsSection:async o=>this.toPythonDocsSectionPlaceholder(o,i)})}async toApiSectionNode({item:t,parentSlug:r,hideChildren:i,parentAvailability:n}){let a=SLh(t.snippetsConfiguration),o,c=await this.getFernWorkspaceForApiSection(t).toFernWorkspace({context:this.taskContext},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1,objectQueryParameters:!0,preserveSchemaIds:!0}),d=this.parsedDocsConfig.experimental?.openapiParserV3,s=d==null||d;if(s)try{o=await this.getOpenApiWorkspaceForApiSection(t).getIntermediateRepresentation({context:this.taskContext,audiences:t.audiences,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1})}catch{}let u;if(t.tagDescriptionPages&&s)try{let b=await this.getOpenApiWorkspaceForApiSection(t).getOpenAPIIr({context:this.taskContext,loadAiExamples:!0});b.tags.tagsById&&(u=Object.fromEntries(Object.entries(b.tags.tagsById).filter(([v,O])=>O.description&&O.description.trim().length>0).map(([v,O])=>[v,{id:String(O.id),description:O.description}])))}catch(y){this.taskContext.logger.warn("Failed to extract OpenAPI tags for tag description pages",String(y))}o==null&&(o=ES({workspace:c,audiences:t.audiences,generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!0},readme:void 0,version:void 0,packageName:void 0,context:this.taskContext,sourceResolver:new wS(this.taskContext,c)})),this.docsWorkspace.config.settings?.substituteEnvVars&&(o=iR(o,{onError:y=>this.taskContext.failAndThrow(`Error substituting environment variables in API spec: ${y}`)},{substituteAsEmpty:!1}));let l=await this.registerApi({ir:o,snippetsConfig:a,playgroundConfig:{oauth:t.playground?.oauth},apiName:t.apiName,workspace:c}),p=iXa({ir:o,apiDefinitionId:l,playgroundConfig:{oauth:t.playground?.oauth},context:this.taskContext}),_=new B0u(t,p,r,this.docsWorkspace,this.taskContext,this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,this.#e,this.collectedFileIds,c,i,n??t.availability,u),h=_.getTagDescriptionContent();for(let[y,b]of h.entries()){let v=y.split("/").pop()||y,O=Je.of(v),m=b;this.docsWorkspace.config.settings?.substituteEnvVars&&(m=iR(b,{onError:g=>this.taskContext.logger.error(`Error in tag description environment variable substitution: ${g}`)},{substituteAsEmpty:!1})),this.rawMarkdownFiles[O]=m,this.parsedDocsConfig.pages[O]=m}return _.get()}async toChangelogNode(t,r,i){return new cOn(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,t.changelog,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:r,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:i||t.hidden,slug:t.slug})}async toLinkNode(t){return{type:"link",id:this.#e.get(t.url),title:t.text,url:Ft.V1.Url(t.url),icon:this.resolveIconFileId(t.icon),target:t.target}}toPythonDocsSectionPlaceholder(t,r){let i=t.title??"Python Reference",n=t.slug??"python-docs",a=r.apply({urlSlug:n}),o=`__python-docs-placeholder-${n}__.mdx`,c=Ft.PageId(o),d=`---
|
|
1907
1907
|
title: ${i}
|
|
1908
1908
|
---
|
|
1909
1909
|
|
|
@@ -1940,7 +1940,7 @@ The generated documentation will replace this placeholder page with complete API
|
|
|
1940
1940
|
- Class and function references
|
|
1941
1941
|
- Type annotations and signatures
|
|
1942
1942
|
- Docstring content
|
|
1943
|
-
`;return this.parsedDocsConfig.pages[Je.of(o)]=d,{id:this.#e.get(c),type:"page",slug:a.get(),title:i,icon:void 0,hidden:!1,viewers:void 0,orphaned:void 0,pageId:c,authed:void 0,noindex:!0,featureFlags:void 0,availability:void 0}}async toPageNode({item:t,parentSlug:r,hideChildren:i,parentAvailability:n}){let a=Ft.PageId(this.toRelativeFilepath(t.absolutePath)),o=r.apply({urlSlug:t.slug??cS(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{id:this.#e.get(a),type:"page",slug:o.get(),title:this.markdownFilesToSidebarTitle.get(t.absolutePath)??t.title,icon:this.resolveIconFileId(t.icon),hidden:i||t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:a,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags,availability:t.availability??n}}async toSectionNode({prefix:t,item:r,parentSlug:i,hideChildren:n,parentAvailability:a}){let o=this.toRelativeFilepath(r.overviewAbsolutePath),c=o?Ft.PageId(o):void 0,d=this.#e.get(c??`${t}/section`),s=i.apply({urlSlug:r.slug??cS(r.title),fullSlug:r.overviewAbsolutePath?this.markdownFilesToFullSlugs.get(r.overviewAbsolutePath)?.split("/"):void 0,skipUrlSlug:r.skipUrlSlug}),u=r.overviewAbsolutePath!=null?this.markdownFilesToNoIndex.get(r.overviewAbsolutePath):void 0,l=n||r.hidden;return{id:d,type:"section",overviewPageId:c,slug:s.get(),title:r.overviewAbsolutePath!=null?this.markdownFilesToSidebarTitle.get(r.overviewAbsolutePath)??r.title:r.title,icon:this.resolveIconFileId(r.icon),collapsed:r.collapsed,hidden:l,viewers:r.viewers,orphaned:r.orphaned,children:await Promise.all(r.contents.map(p=>this.toNavigationChild({prefix:d,item:p,parentSlug:s,hideChildren:l,parentAvailability:r.availability??a}))),authed:void 0,pointsTo:void 0,noindex:u,featureFlags:r.featureFlags,availability:r.availability??a}}async convertTabbedNavigation(t,r,i){let n=this.#e.get(`${t}/tabbed`);return{type:"tabbed",id:n,children:await Promise.all(r.map(a=>this.toTabChild(n,a,i)))}}async toTabChild(t,r,i){return odn(r.child)._visit({link:({href:n,target:a})=>this.toTabLinkNode(r,n,a),layout:({layout:n})=>this.toTabNode(t,r,n,i),changelog:({changelog:n})=>this.toTabChangelogNode(r,n,i),variants:({variants:n})=>this.toTabNodeWithVariants(t,r,n,i)})}async toTabChangelogNode(t,r,i){return new cOn(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,r,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:i,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:t.hidden,slug:t.slug})}async toTabLinkNode(t,r,i){return{type:"link",id:this.#e.get(r),title:t.title,url:Ft.V1.Url(r),target:i,icon:this.resolveIconFileId(t.icon)}}async toTabNode(t,r,i,n){let a=this.#e.get(`${t}/tab`),o=n.apply({urlSlug:r.slug??cS(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:a,title:r.title,slug:o.get(),icon:this.resolveIconFileId(r.icon),hidden:r.hidden,authed:void 0,viewers:r.viewers,orphaned:r.orphaned,pointsTo:void 0,child:await this.toSidebarRootNode(a,i,o),featureFlags:r.featureFlags}}async toTabNodeWithVariants(t,r,i,n){let a=this.#e.get(`${t}/tab`),o=n.apply({urlSlug:r.slug??cS(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:a,title:r.title,slug:o.get(),icon:this.resolveIconFileId(r.icon),hidden:r.hidden,authed:void 0,viewers:r.viewers,orphaned:r.orphaned,pointsTo:void 0,child:await this.toSidebarRootNodeWithVariants(a,i,o),featureFlags:r.featureFlags}}getFileId(t){if(t==null)return;let r=this.collectedFileIds.get(t);return r==null?this.taskContext.failAndThrow("Failed to locate file after uploading: "+t):UG.FileId(r)}resolveIconFileId(t){if(t!=null)return this.collectedFileIds.has(t)?`file:${this.getFileId(t)}`:t}convertPageActions(){if(this.parsedDocsConfig.pageActions!=null)return{default:this.parsedDocsConfig.pageActions.default,options:{askAi:this.parsedDocsConfig.pageActions.options.askAi,copyPage:this.parsedDocsConfig.pageActions.options.copyPage,viewAsMarkdown:this.parsedDocsConfig.pageActions.options.viewAsMarkdown,openAi:this.parsedDocsConfig.pageActions.options.openAi,claude:this.parsedDocsConfig.pageActions.options.claude,cursor:this.parsedDocsConfig.pageActions.options.cursor,vscode:this.parsedDocsConfig.pageActions.options.vscode,custom:this.parsedDocsConfig.pageActions.options.custom.map(t=>({title:t.title,subtitle:t.subtitle,url:t.url,icon:this.resolveIconFileId(t.icon),default:t.default}))}}}convertColorConfigImageReferences(){let{colors:t}=this.parsedDocsConfig;if(t!=null)return t.type==="dark"?{...t,...this.convertLogoAndBackgroundImage({theme:"dark"})}:t.type==="light"?{...t,...this.convertLogoAndBackgroundImage({theme:"light"}),type:"light"}:{...t,dark:{...t.dark,...this.convertLogoAndBackgroundImage({theme:"dark"})},light:{...t.light,...this.convertLogoAndBackgroundImage({theme:"light"})}}}convertLogoAndBackgroundImage({theme:t}){let{logo:r,backgroundImage:i}=this.parsedDocsConfig,n=r?.[t],a=i?.[t];return{logo:this.getFileId(n),backgroundImage:this.getFileId(a)}}convertDocsTypographyConfiguration(){if(this.parsedDocsConfig.typography!=null)return{headingsFont:this.convertFont(this.parsedDocsConfig.typography.headingsFont,"headings"),bodyFont:this.convertFont(this.parsedDocsConfig.typography.bodyFont,"body"),codeFont:this.convertFont(this.parsedDocsConfig.typography.codeFont,"code")}}convertFont(t,r){if(t==null||t.variants[0]==null)return;let i=this.getFileId(t.variants[0].absolutePath);return{type:"custom",name:t.name??`font:${r}:${i}`,variants:t.variants.map(n=>({fontFile:this.getFileId(n.absolutePath),weight:n.weight,style:n.style!=null?[n.style]:void 0})),display:t.display,fallback:t.fallback,fontVariationSettings:t.fontVariationSettings}}convertJavascriptConfiguration(){if(this.parsedDocsConfig.js!=null)return{files:this.parsedDocsConfig.js.files.map(({absolutePath:t,strategy:r})=>({fileId:this.getFileId(t),strategy:r})).filter(us),remote:this.parsedDocsConfig.js.remote?.map(t=>({...t,url:UG.Url(t.url)})),inline:void 0}}convertMetadata(){if(this.parsedDocsConfig.metadata==null)return;let{"og:image":t,"og:logo":r,"twitter:image":i,...n}=this.parsedDocsConfig.metadata;return{...n,"og:image":this.convertFileIdOrUrl(t),"og:logo":this.convertFileIdOrUrl(r),"twitter:image":this.convertFileIdOrUrl(i)}}convertFileIdOrUrl(t){if(t!=null)return odn(t,"type")._visit({filepath:({value:r})=>({type:"fileId",value:this.getFileId(r)}),url:({value:r})=>({type:"url",value:UG.Url(r)}),_other:()=>this.taskContext.failAndThrow("Invalid metadata configuration")})}};function EDB(e,t){let r=e?.launch??"github";if(e?.github==null)return{url:void 0,launch:r};let{owner:i,repo:n,branch:a="main",host:o="https://github.com"}=e.github;return{url:`${Qx(o)}/${i}/${n}/blob/${a}/fern/${t}?plain=1`,launch:r}}function SDB(e){switch(e){case"beta":return Ft.V1.NavigationV1Availability.Beta;case"deprecated":return Ft.V1.NavigationV1Availability.Deprecated;case"ga":return Ft.V1.NavigationV1Availability.GenerallyAvailable;case"stable":return Ft.V1.NavigationV1Availability.Stable;default:vt(e)}}async function RL(e){return(await Promise.all(e.apiWorkspaces.map(async t=>t instanceof jS?t:null))).filter(us)}async function Srl(e,t,r){if(e instanceof ESe){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof jS))return;let i=await e.getIntermediateRepresentation({context:t,audiences:r,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1});return Fx({ir:i,snippetsConfig:{typescriptSdk:void 0,pythonSdk:void 0,javaSdk:void 0,rubySdk:void 0,goSdk:void 0,csharpSdk:void 0,phpSdk:void 0,swiftSdk:void 0,rustSdk:void 0},playgroundConfig:{oauth:!0},context:t})}var uc={};Yt(uc,{AlgoliaSearchIndex:()=>JLh,ApiDefinitionId:()=>hVh,ApiId:()=>gVh,Availability:()=>TVh,DocsConfigId:()=>OVh,EndpointId:()=>AVh,EndpointPathLiteral:()=>CVh,EnvironmentId:()=>mVh,FileId:()=>SVh,HttpMethod:()=>qVh,IndexSegmentId:()=>$Lh,JqString:()=>DVh,OrgId:()=>bVh,PageId:()=>EVh,PayloadLocation:()=>u3h,PropertyKey:()=>BVh,PullRequestState:()=>r3h,RoleId:()=>IVh,TokenId:()=>vVh,TypeId:()=>wVh,Url:()=>MVh,VersionId:()=>yVh,WebSocketId:()=>PVh,WebhookId:()=>jVh,algolia:()=>Mrl,api:()=>Frl,commons:()=>Qrl,diff:()=>RVh,docs:()=>Jrl,generators:()=>Yrl,git:()=>Xrl,navigation:()=>eil,sdks:()=>ril,snippets:()=>a3h,snippetsFactory:()=>o3h,templates:()=>iil,tokens:()=>s3h});var Mrl={};Yt(Mrl,{AlgoliaSearchIndex:()=>JLh,IndexSegmentId:()=>$Lh});function JLh(e){return e}function $Lh(e){return e}var Frl={};Yt(Frl,{latest:()=>Irl,v1:()=>Nrl});var Irl={};Yt(Irl,{AuthSchemeId:()=>YLh,WebhookHttpMethod:()=>eVh,auth:()=>Drl,commons:()=>XLh,endpoint:()=>ZLh,type_:()=>kLh,webhook:()=>Brl,websocket:()=>tVh});var Drl={};Yt(Drl,{AuthSchemeId:()=>YLh});function YLh(e){return e}var XLh={};var ZLh={};var kLh={};var Brl={};Yt(Brl,{WebhookHttpMethod:()=>eVh});var eVh={Get:"GET",Post:"POST"};var tVh={};var Nrl={};Yt(Nrl,{SubpackageId:()=>fVh,WebSocketMessageId:()=>dVh,WebSocketMessageOrigin:()=>pVh,WebhookHttpMethod:()=>_Vh,commons:()=>zrl,db:()=>Crl,read:()=>Trl,register:()=>Rrl});var Crl={};Yt(Crl,{endpoint:()=>rVh});var rVh={};var Trl={};Yt(Trl,{SupportedLanguage:()=>iVh,endpoint:()=>qrl,type_:()=>nVh,webhook:()=>aVh,websocket:()=>oVh});var qrl={};Yt(qrl,{SupportedLanguage:()=>iVh});var iVh={Curl:"curl",Python:"python",Javascript:"javascript",Js:"js",Node:"node",Typescript:"typescript",Ts:"ts",Go:"go",Ruby:"ruby",Csharp:"csharp"};var nVh={};var aVh={};var oVh={};var Rrl={};Yt(Rrl,{SourceId:()=>MDB,endpoint:()=>uVh,type_:()=>sVh,webhook:()=>cVh,websocket:()=>lVh});var uVh={};var sVh={};var cVh={};var lVh={};function MDB(e){return e}var zrl={};Yt(zrl,{SubpackageId:()=>fVh,WebSocketMessageId:()=>dVh,WebSocketMessageOrigin:()=>pVh,WebhookHttpMethod:()=>_Vh});function fVh(e){return e}function dVh(e){return e}var pVh={Client:"client",Server:"server"};var _Vh={Get:"GET",Post:"POST"};var Qrl={};Yt(Qrl,{ApiDefinitionId:()=>hVh,ApiId:()=>gVh,Availability:()=>TVh,DocsConfigId:()=>OVh,EndpointId:()=>AVh,EndpointPathLiteral:()=>CVh,EnvironmentId:()=>mVh,FileId:()=>SVh,HttpMethod:()=>qVh,JqString:()=>DVh,OrgId:()=>bVh,PageId:()=>EVh,PropertyKey:()=>BVh,RoleId:()=>IVh,TokenId:()=>vVh,TypeId:()=>wVh,Url:()=>MVh,VersionId:()=>yVh,WebSocketId:()=>PVh,WebhookId:()=>jVh});function hVh(e){return e}function yVh(e){return e}function bVh(e){return e}function vVh(e){return e}function gVh(e){return e}function OVh(e){return e}function mVh(e){return e}function AVh(e){return e}function PVh(e){return e}function jVh(e){return e}function wVh(e){return e}function EVh(e){return e}function SVh(e){return e}function MVh(e){return e}function DVh(e){return e}function BVh(e){return e}function IVh(e){return e}function CVh(e){return e}var qVh={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE"};var TVh={Stable:"Stable",GenerallyAvailable:"GenerallyAvailable",InDevelopment:"InDevelopment",PreRelease:"PreRelease",Deprecated:"Deprecated",Beta:"Beta"};var RVh={};var Jrl={};Yt(Jrl,{latest:()=>Vrl,v1:()=>Hrl,v2:()=>Krl});var Vrl={};Yt(Vrl,{Layout:()=>NVh,MdxEngine:()=>DDB,TwitterCardSetting:()=>FVh,commons:()=>zVh,frontmatter:()=>Url,seo:()=>Lrl});var DDB={NextMdxRemote:"next-mdx-remote",MdxBundler:"mdx-bundler"};var zVh={};var Url={};Yt(Url,{Layout:()=>NVh});var NVh={Guide:"guide",Overview:"overview",Reference:"reference",Page:"page",Custom:"custom"};var Lrl={};Yt(Lrl,{TwitterCardSetting:()=>FVh});var FVh={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var Hrl={};Yt(Hrl,{commons:()=>xrl,db:()=>QVh,read:()=>UVh,write:()=>Wrl});var QVh={};var UVh={};var Wrl={};Yt(Wrl,{DocsRegistrationId:()=>IDB,FilePath:()=>BDB});function BDB(e){return e}function IDB(e){return e}var xrl={};Yt(xrl,{ContentAlignment:()=>GVh,FontDisplay:()=>$Vh,FontStyle:()=>JVh,HeaderPosition:()=>xVh,JsScriptStrategy:()=>KVh,ProgrammingLanguage:()=>LVh,SearchbarPlacement:()=>VVh,TabsPlacement:()=>WVh,TwitterCardSetting:()=>HVh,commons:()=>Grl});var Grl={};Yt(Grl,{ContentAlignment:()=>GVh,FontDisplay:()=>$Vh,FontStyle:()=>JVh,HeaderPosition:()=>xVh,JsScriptStrategy:()=>KVh,ProgrammingLanguage:()=>LVh,SearchbarPlacement:()=>VVh,TabsPlacement:()=>WVh,TwitterCardSetting:()=>HVh});var LVh={Typescript:"typescript",Javascript:"javascript",Python:"python",Java:"java",Go:"go",Ruby:"ruby",Csharp:"csharp",Nodets:"nodets",Nodejs:"nodejs",Dotnet:"dotnet",Curl:"curl",Jvm:"jvm",Ts:"ts",Js:"js"};var VVh={Header:"HEADER",HeaderTabs:"HEADER_TABS",Sidebar:"SIDEBAR"};var WVh={Header:"HEADER",Sidebar:"SIDEBAR"};var GVh={Center:"CENTER",Left:"LEFT"};var xVh={Fixed:"FIXED",Absolute:"ABSOLUTE"};var HVh={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var KVh={BeforeInteractive:"beforeInteractive",AfterInteractive:"afterInteractive",LazyOnload:"lazyOnload"};var JVh={Normal:"normal",Italic:"italic"};var $Vh={Auto:"auto",Block:"block",Swap:"swap",Fallback:"fallback",Optional:"optional"};var Krl={};Yt(Krl,{read:()=>YVh,write:()=>XVh});var YVh={};var XVh={};var Yrl={};Yt(Yrl,{ChangelogEntryType:()=>kVh,GeneratorId:()=>CDB,GeneratorLanguage:()=>qDB,ReleaseType:()=>e3h,cli:()=>ZVh,commons:()=>$rl,versions:()=>t3h});var ZVh={};var $rl={};Yt($rl,{ChangelogEntryType:()=>kVh,ReleaseType:()=>e3h});var kVh={Fix:"fix",Feat:"feat",Chore:"chore",Break:"break",Internal:"internal"};var e3h={Ga:"GA",Rc:"RC"};var t3h={};function CDB(e){return e}var qDB={Python:"python",Go:"go",Java:"java",Typescript:"typescript",Ruby:"ruby",Csharp:"csharp",Php:"php",Swift:"swift",Rust:"rust"};var Xrl={};Yt(Xrl,{PullRequestState:()=>r3h});var r3h={Open:"open",Closed:"closed",Merged:"merged"};var eil={};Yt(eil,{latest:()=>Zrl,v1:()=>krl});var Zrl={};Yt(Zrl,{NodeId:()=>zDB,ProductId:()=>NDB,Slug:()=>TDB,TabId:()=>RDB});function TDB(e){return e}function RDB(e){return e}function zDB(e){return e}function NDB(e){return e}var krl={};Yt(krl,{NavigationV1Availability:()=>VDB,NodeId:()=>UDB,ProductId:()=>LDB,Slug:()=>FDB,TabId:()=>QDB});function FDB(e){return e}function QDB(e){return e}function UDB(e){return e}function LDB(e){return e}var VDB={Stable:"stable",GenerallyAvailable:"generally-available",InDevelopment:"in-development",PreRelease:"pre-release",Beta:"beta",Deprecated:"deprecated"};var ril={};Yt(ril,{Language:()=>i3h,VersionBump:()=>n3h,versions:()=>til});var til={};Yt(til,{Language:()=>i3h,VersionBump:()=>n3h});var i3h={Go:"Go",TypeScript:"TypeScript",Java:"Java",Python:"Python",Csharp:"Csharp",Ruby:"Ruby"};var n3h={Major:"MAJOR",Minor:"MINOR",Patch:"PATCH"};var a3h={};var o3h={};var iil={};Yt(iil,{PayloadLocation:()=>u3h});var u3h={Body:"BODY",Query:"QUERY",Path:"PATH",Headers:"HEADERS",Relative:"RELATIVE",Auth:"AUTH"};var s3h={};var U0u=class{warnings=[];errors=[];error(t){this.errors.push(t)}warning(t){this.warnings.push(t)}};function Ho(e){return e!=null}var l3h=ce(I4a(),1);var c3h=["PII","PHI","PCI","GDPR","CCPA","HIPAA","COPPA","FERPA","GLBA","SOX","FISMA","NIST","CIS","ISO","IEC","ITAR","EAR","CMMC","CUI","CDI","FTC","FCC","SEC","FINRA","XSS","CSRF","SSRF","XSRF","TLS","SSL","SSH","API","OAuth","OAuth1","OAuth1.0","OAuth2","OAuth2.0","SAML","OpenID","OpenID Connect","CAPTCHA","reCAPTCHA","2FA","MFA","OTP","TOTP","HOTP","U2F","FIDO","FIDO2","PKI","HMAC","AES","RSA","SHA","MD5","BCrypt","PBKDF2","Argon2","SCrypt","JWT","JWE","JWS","JWK","JWA","JOSE","SKU","SKUs","UPC","EAN","ISBN","ASIN","MPN","MSRP","MAP","RRP","MSRP","AM","PM","UTC","GMT","PST","PDT","EST","EDT","CST","CDT","MST","MDT","USA","UK","EU","UAE","APAC","EMEA","LATAM","ANZ","SEA","MEA","MENA","NATO","NA","SA","CA","EU","AU","NZ","JP","KR","CN","HK","TW","SG","MY","TH","ID","PH","VN","IN","PK","BD","LK","NP","MM","KH","LA","MM","BT","MV","USD","EUR","GBP","JPY","CNY","RUB","INR","AUD","CAD","CHF","SGD","MYR","THB","IDR","KRW","PHP","VND","HKD","TWD","MXN","BRL","ARS","CLP","COP","PEN","ZAR","NGN","EGP","AED","SAR","ILS","TRY","SEK","NOK","DKK","ISK","HUF","PLN","CZK","RON","BGN","API","APIs","SDK","SDKs","AI","OCR","REST","SOAP","JSON","XML","HTTP","HTTPS","URI","URL","CRUD","RESTful","KYB","KYC","AML","HTML","CSS","JS","SQL","DB","UI","UX","SaaS","PaaS","IaaS","IP","TCP","UDP","DNS","FTP","SMTP","IMAP","POP3","CSV","MVC","MVP","MVVM","DOM","SPA","SSR","CSR","DDoS","CDN","IoT","ML","DL","NLP","CLI","GUI","BI","ETL","RDBMS","NoSQL","IDE","CMS","CCPA","POSIX","ABI","API","AST","COBOL","DDL","DML","NN","CNN","RNN","LSTM","GRU","ANN","GAN","RL","DL","ML","NLP","NLG","NLU","BERT","GPT","SVM","PCA","AI","CV","TF","TTS","ASR","HMM","DNN","MLP","RBM","CRF","PDF","PDFs","RTF","TXT","XLS","XLSX","PPT","JPG","JPEG","PNG","GIF","GIFs","SVG","TIFF","BMP","ICO","PSD","WebP","AVIF","HEIF","HEIC","EPS","MP3","WAV","AIFF","FLAC","WMA","AAC","OGG","AVI","WMV","MOV","M4V","MP4","MPG","MPEG","FLV","SWF","MKV","WebM","GCP","AWS","VM","VPC","S3","EC2","DynamoDB","CosmosDB","BigQuery","CI/CD","SOC1","SOC2","SOC3","PCI DSS","WAF","IAM","SDN","MPLS","BGP","Vue.js","Node.js",".NET"];function TXt(e){return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e=e.replace(/_/g," "),e=e.replace(/-/g," "),(0,l3h.default)(e,{special:c3h}).replace(/V\s(\d)/g,"V$1")}function f3h({endpoints:e,webhookEndpoints:t}){let r={};return Object.values({...e,...t}).forEach(i=>{let n=[];i.namespace?.forEach(a=>{let o=[...n,a],c=uc.api.v1.SubpackageId(o.join("."));r[c]={id:c,name:a,displayName:TXt(a)},n.push(a)})}),r}var L0u=class{input;context;constructor(t,r){this.input=t,this.context=r}errors(){return this.context.errors.errors}warnings(){return this.context.errors.warnings}};function d3h(e){return`#/${e.map(t=>t.replaceAll(/~/g,"~0").replaceAll(/\//g,"~1")).join("/")}`}var mo=class extends L0u{context;accessPath;pathId;constructor({input:t,context:r,accessPath:i,pathId:n}){if(super(t,r),this.context=r,this.accessPath=[...i],this.pathId=n,n!=null){let a=Array.isArray(this.pathId)?this.pathId:[this.pathId];a.every((o,c)=>o===this.accessPath[this.accessPath.length-a.length+c])||this.accessPath.push(...a)}r.logger.debug(`Processing ${d3h(this.accessPath)}`)}safeParse(...t){try{this.parse(...t)}catch{this.context.errors.error({message:"Error converting node. Please contact support if the error persists",path:this.accessPath})}}},qC=class extends mo{},zY=class extends qC{seenSchemas;constructor(t){super(t),this.seenSchemas=new Set(t.seenSchemas)}};var p3h="x-fern-base-path",_3h="x-fern-availability",V0u="x-fern-sdk-group-name",h3h="x-fern-global-headers",y3h="x-fern-sdk-method-name";var b3h="x-fern-webhook",v3h="x-fern-access-token-locator",g3h="x-fern-basic",O3h="x-fern-username-variable-name",m3h="x-fern-password-variable-name",A3h="x-fern-bearer",P3h="x-fern-token-variable-name",j3h="x-fern-header",w3h="x-fern-header-variable-name",E3h="x-fern-server-name",S3h="x-fern-examples";var W0u=class extends mo{serverName;constructor(t){super(t),this.safeParse()}parse(){this.serverName=this.input[E3h]}convert(){if(this.serverName!=null)return this.serverName}};var G0u=class extends mo{url;serverName;constructor(t){super(t),this.safeParse()}parse(){this.url=Object.entries(this.input.variables??{}).reduce((t,[r,i])=>t.replace(`{${r}}`,i.default),this.input.url)??this.input.url,this.serverName=new W0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})}convert(){let t=this.serverName?.convert()??this.url;if(!(this.url==null||t==null))return{id:uc.EnvironmentId(t),baseUrl:this.url}}};function CYi(e,t,r,i){let n=e??[],a=new Set(n.map(c=>c.url)),o=(t??[]).filter(c=>!a.has(c.url)).map((c,d)=>new G0u({input:c,context:r,accessPath:i,pathId:["servers",`${d}`]}));return[...n,...o]}function eg(e){return typeof e=="object"&&Ho(e)&&"$ref"in e&&typeof e.$ref=="string"}function zL(e,t,r){let i=e.$ref.substring(2).split("/").map(a=>a.replace(/~1/g,"/")),n=t;for(let a of i){if(typeof n!="object"||n==null)return r;n=n[a]}return n==null?r:(eg(n)&&(n=zL(n,t,r)),n)}function x0u(e,t){let r=t.components?.securitySchemes?.[e];if(r!=null)return eg(r)?zL(r,t,void 0):r}var v8h=ce(bM());var H0u=class extends mo{username;password;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[g3h];this.username=t?.username,this.password=t?.password}convert(){return{username:this.username,password:this.password}}};var K0u=class extends mo{passwordVariableName;constructor(t){super(t),this.safeParse()}parse(){this.passwordVariableName=this.input[m3h]}convert(){return this.passwordVariableName}};var J0u=class extends mo{usernameVariableName;constructor(t){super(t),this.safeParse()}parse(){this.usernameVariableName=this.input[O3h]}convert(){return this.usernameVariableName}};var $0u=class extends mo{bearerTokenVariableName;bearerTokenEnvVar;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[A3h];this.bearerTokenVariableName=t?.name,this.bearerTokenEnvVar=t?.env}convert(){return{tokenVariableName:this.bearerTokenVariableName,tokenEnvVar:this.bearerTokenEnvVar}}};var Y0u=class extends mo{tokenVariableName;constructor(t){super(t),this.safeParse()}parse(){this.tokenVariableName=this.input[P3h]}convert(){return this.tokenVariableName}};function M3h(e){return typeof e=="object"&&e!=null&&"in"in e&&e.in==="header"}var D3h="x-bearer-format",B3h="x-code-samples",I3h="x-codeSamples";var X0u=class extends mo{bearerFormat;constructor(t){super(t),this.safeParse()}parse(){this.bearerFormat=this.input[D3h]}convert(){return this.bearerFormat}};var Z0u=class extends mo{headerVariableName;headerEnvVar;headerPrefix;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[j3h];this.headerVariableName=t?.name,this.headerEnvVar=t?.env,this.headerPrefix=t?.prefix}convert(){return{name:this.headerVariableName,env:this.headerEnvVar,prefix:this.headerPrefix}}};var k0u=class extends mo{headerVariableName;constructor(t){super(t),this.safeParse()}parse(){this.headerVariableName=this.input[w3h]}convert(){return this.headerVariableName}};function C3h(e){return e.type==="apiKey"}var fla=class extends mo{headerName;headerBearerFormatNode;headerAuthNode;headerVariableNameNode;constructor(t){super(t),this.safeParse()}parse(){C3h(this.input)&&(this.headerName=this.input.name),this.headerAuthNode=new Z0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerVariableNameNode=new k0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerBearerFormatNode=new X0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})}convert(){let t=this.headerAuthNode?.convert();if(t!=null)return{type:"header",nameOverride:t?.name,headerWireValue:this.headerName??"Authorization",prefix:t?.prefix??this.headerBearerFormatNode?.convert()}}};function ewu(e){return e}function twu(e){return e==="__proto__"}function rwu(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function dla(e){return typeof e=="string"||typeof e=="symbol"?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function nXa(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(nXa).join(",");let t=String(e);return t==="0"&&Object.is(Number(e),-0)?"-0":t}function iwu(e){if(Array.isArray(e))return e.map(dla);if(typeof e=="symbol")return[e];e=nXa(e);let t=[],r=e.length;if(r===0)return t;let i=0,n="",a="",o=!1;for(e.charCodeAt(0)===46&&(t.push(""),i++);i<r;){let c=e[i];a?c==="\\"&&i+1<r?(i++,n+=e[i]):c===a?a="":n+=c:o?c==='"'||c==="'"?a=c:c==="]"?(o=!1,t.push(n),n=""):n+=c:c==="["?(o=!0,n&&(t.push(n),n="")):c==="."?n&&(t.push(n),n=""):n+=c,i++}return n&&t.push(n),t}function aXa(e,t,r){if(e==null)return r;switch(typeof t){case"string":{if(twu(t))return r;let i=e[t];return i===void 0?rwu(t)?aXa(e,iwu(t),r):r:i}case"number":case"symbol":{typeof t=="number"&&(t=dla(t));let i=e[t];return i===void 0?r:i}default:{if(Array.isArray(t))return WDB(e,t,r);if(Object.is(t?.valueOf(),-0)?t="-0":t=String(t),twu(t))return r;let i=e[t];return i===void 0?r:i}}}function WDB(e,t,r){if(t.length===0)return r;let i=e;for(let n=0;n<t.length;n++){if(i==null||twu(t[n]))return r;i=i[t[n]]}return i===void 0?r:i}function q3h(e){return function(t){return aXa(t,e)}}function T3h(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function nwu(e){return e==null||typeof e!="object"&&typeof e!="function"}function nil(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function oil(e,t,r){return typeof r!="function"?oil(e,t,()=>{}):ail(e,t,function i(n,a,o,c,d,s){let u=r(n,a,o,c,d,s);return u!==void 0?!!u:ail(n,a,i,s)},new Map)}function ail(e,t,r,i){if(t===e)return!0;switch(typeof t){case"object":return GDB(e,t,r,i);case"function":return Object.keys(t).length>0?ail(e,{...t},r,i):nil(e,t);default:return T3h(e)?typeof t=="string"?t==="":!0:nil(e,t)}}function GDB(e,t,r,i){if(t==null)return!0;if(Array.isArray(t))return R3h(e,t,r,i);if(t instanceof Map)return xDB(e,t,r,i);if(t instanceof Set)return HDB(e,t,r,i);let n=Object.keys(t);if(e==null)return n.length===0;if(n.length===0)return!0;if(i?.has(t))return i.get(t)===e;i?.set(t,e);try{for(let a=0;a<n.length;a++){let o=n[a];if(!nwu(e)&&!(o in e)||t[o]===void 0&&e[o]!==void 0||t[o]===null&&e[o]!==null||!r(e[o],t[o],o,e,t,i))return!1}return!0}finally{i?.delete(t)}}function xDB(e,t,r,i){if(t.size===0)return!0;if(!(e instanceof Map))return!1;for(let[n,a]of t.entries()){let o=e.get(n);if(r(o,a,n,e,t,i)===!1)return!1}return!0}function R3h(e,t,r,i){if(t.length===0)return!0;if(!Array.isArray(e))return!1;let n=new Set;for(let a=0;a<t.length;a++){let o=t[a],c=!1;for(let d=0;d<e.length;d++){if(n.has(d))continue;let s=e[d],u=!1;if(r(s,o,a,e,t,i)&&(u=!0),u){n.add(d),c=!0;break}}if(!c)return!1}return!0}function HDB(e,t,r,i){return t.size===0?!0:e instanceof Set?R3h([...e],[...t],r,i):!1}function awu(e,t){return oil(e,t,()=>{})}function z3h(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function owu(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var N3h="[object RegExp]",uwu="[object String]",swu="[object Number]",cwu="[object Boolean]",lwu="[object Arguments]",F3h="[object Symbol]",Q3h="[object Date]",U3h="[object Map]",L3h="[object Set]",V3h="[object Array]";var W3h="[object ArrayBuffer]",G3h="[object Object]";var x3h="[object DataView]",H3h="[object Uint8Array]",K3h="[object Uint8ClampedArray]",J3h="[object Uint16Array]",$3h="[object Uint32Array]";var Y3h="[object Int8Array]",X3h="[object Int16Array]",Z3h="[object Int32Array]";var k3h="[object Float32Array]",e8h="[object Float64Array]";function t8h(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function r8h(e,t){return qYi(e,void 0,e,new Map,t)}function qYi(e,t,r,i=new Map,n=void 0){let a=n?.(e,t,r,i);if(a!==void 0)return a;if(nwu(e))return e;if(i.has(e))return i.get(e);if(Array.isArray(e)){let o=new Array(e.length);i.set(e,o);for(let c=0;c<e.length;c++)o[c]=qYi(e[c],c,r,i,n);return Object.hasOwn(e,"index")&&(o.index=e.index),Object.hasOwn(e,"input")&&(o.input=e.input),o}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let o=new RegExp(e.source,e.flags);return o.lastIndex=e.lastIndex,o}if(e instanceof Map){let o=new Map;i.set(e,o);for(let[c,d]of e)o.set(c,qYi(d,c,r,i,n));return o}if(e instanceof Set){let o=new Set;i.set(e,o);for(let c of e)o.add(qYi(c,void 0,r,i,n));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(e))return e.subarray();if(t8h(e)){let o=new(Object.getPrototypeOf(e)).constructor(e.length);i.set(e,o);for(let c=0;c<e.length;c++)o[c]=qYi(e[c],c,r,i,n);return o}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){let o=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return i.set(e,o),uWt(o,e,r,i,n),o}if(typeof File<"u"&&e instanceof File){let o=new File([e],e.name,{type:e.type});return i.set(e,o),uWt(o,e,r,i,n),o}if(typeof Blob<"u"&&e instanceof Blob){let o=new Blob([e],{type:e.type});return i.set(e,o),uWt(o,e,r,i,n),o}if(e instanceof Error){let o=new e.constructor;return i.set(e,o),o.message=e.message,o.name=e.name,o.stack=e.stack,o.cause=e.cause,uWt(o,e,r,i,n),o}if(e instanceof Boolean){let o=new Boolean(e.valueOf());return i.set(e,o),uWt(o,e,r,i,n),o}if(e instanceof Number){let o=new Number(e.valueOf());return i.set(e,o),uWt(o,e,r,i,n),o}if(e instanceof String){let o=new String(e.valueOf());return i.set(e,o),uWt(o,e,r,i,n),o}if(typeof e=="object"&&KDB(e)){let o=Object.create(Object.getPrototypeOf(e));return i.set(e,o),uWt(o,e,r,i,n),o}return e}function uWt(e,t,r=e,i,n){let a=[...Object.keys(t),...z3h(t)];for(let o=0;o<a.length;o++){let c=a[o],d=Object.getOwnPropertyDescriptor(e,c);(d==null||d.writable)&&(e[c]=qYi(t[c],c,r,i,n))}}function KDB(e){switch(owu(e)){case lwu:case V3h:case W3h:case x3h:case cwu:case Q3h:case k3h:case e8h:case Y3h:case X3h:case Z3h:case U3h:case swu:case G3h:case N3h:case L3h:case uwu:case F3h:case H3h:case K3h:case J3h:case $3h:return!0;default:return!1}}function i8h(e){return qYi(e,void 0,e,new Map,void 0)}function n8h(e){return e=i8h(e),t=>awu(t,e)}function a8h(e,t){return r8h(e,(r,i,n,a)=>{let o=t?.(r,i,n,a);if(o!==void 0)return o;if(typeof e=="object")switch(Object.prototype.toString.call(e)){case swu:case uwu:case cwu:{let c=new e.constructor(e?.valueOf());return uWt(c,e),c}case lwu:{let c={};return uWt(c,e),c.length=e.length,c[Symbol.iterator]=e[Symbol.iterator],c}default:return}})}function o8h(e){return a8h(e)}var JDB=/^(?:0|[1-9]\d*)$/;function u8h(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e<t;case"symbol":return!1;case"string":return JDB.test(e)}}function s8h(e){return e!==null&&typeof e=="object"&&owu(e)==="[object Arguments]"}function c8h(e,t){let r;if(Array.isArray(t)?r=t:typeof t=="string"&&rwu(t)&&e?.[t]==null?r=iwu(t):r=[t],r.length===0)return!1;let i=e;for(let n=0;n<r.length;n++){let a=r[n];if((i==null||!Object.hasOwn(i,a))&&!((Array.isArray(i)||s8h(i))&&u8h(a)&&a<i.length))return!1;i=i[a]}return!0}function l8h(e,t){switch(typeof e){case"object":{Object.is(e?.valueOf(),-0)&&(e="-0");break}case"number":{e=dla(e);break}}return t=o8h(t),function(r){let i=aXa(r,e);return i===void 0?c8h(r,e):t===void 0?i===void 0:awu(i,t)}}function f8h(e){if(e==null)return ewu;switch(typeof e){case"function":return e;case"object":return Array.isArray(e)&&e.length===2?l8h(e[0],e[1]):n8h(e);case"string":case"symbol":case"number":return q3h(e)}}function d8h(e,t){let r={},i=Object.keys(e);for(let n=0;n<i.length;n++){let a=i[n],o=e[a];r[a]=t(o,a,e)}return r}function fwu(e,t=ewu){return e==null?{}:d8h(e,f8h(t))}function p8h(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}var $DB=new RegExp("\\p{Lu}?\\p{Ll}+|[0-9]+|\\p{Lu}+(?!\\p{Ll})|\\p{Emoji_Presentation}|\\p{Extended_Pictographic}|\\p{L}+","gu");function _8h(e){return Array.from(e.match($DB)??[])}function h8h(e){let t=_8h(e);if(t.length===0)return"";let[r,...i]=t;return`${r.toLowerCase()}${i.map(n=>p8h(n)).join("")}`}function y8h(e){return typeof e!="string"&&(e=nXa(e)),e.replace(/['\u2019]/g,"")}function sWt(e){return h8h(y8h(e))}function tj(e){if(e!=null)return Array.isArray(e)?e:[e]}function dwu({namespace:e,path:t,method:r,sdkMethodName:i,operationId:n,displayName:a,isWebhook:o}){if(t==null)return;let c=r!=null&&t!=null?`${r}_${t.split("/").join("_")}`:r??t.split("/").join("_");if(!(i==null&&n==null&&a==null&&c==null))return`${YDB(o)}${XDB(e)}.${ZDB(i,n,a,c)}`}function YDB(e){return e?"webhook_":"endpoint_"}function XDB(e){return e!=null?tj(e)?.map(t=>sWt(t)).join("/"):""}function ZDB(e,t,r,i){return e||t||sWt(r??"")||sWt(i??"")}function b8h(e){return e.length===0?!1:/^\$?(\.[\w*]+|\[['"][\w*]+['"]?\]|\[['"]?[\d*]+['"]?\]|\[[\d:]+\])*$/.test(e)}var pwu=class extends mo{accessTokenLocator;constructor(t){super(t),this.safeParse()}parse(){this.accessTokenLocator=this.input[v3h],this.accessTokenLocator!=null&&(b8h(this.accessTokenLocator)||(this.context.errors.error({message:"Invalid access token locator, must be a valid jq path",path:this.accessPath}),this.accessTokenLocator=void 0))}convert(){return this.accessTokenLocator}};var _wu=class extends mo{authorizationUrl;headerAuthNode;accessTokenLocatorNode;constructor(t){super(t),this.safeParse()}parse(){if(this.input.flows.clientCredentials!=null){let t=this.input.flows.clientCredentials;this.authorizationUrl=t.tokenUrl,this.authorizationUrl==null&&this.context.errors.error({message:"Expected 'tokenUrl' property to be specified",path:this.accessPath}),this.headerAuthNode=new fla({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.accessTokenLocatorNode=new pwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.authorizationUrl==null&&this.context.errors.error({message:"Expected 'tokenUrl' property to be specified",path:this.accessPath}),this.accessTokenLocatorNode?.accessTokenLocator==null&&this.context.errors.error({message:"Expected 'x-fern-access-token-locator' property to be specified",path:this.accessPath})}}convert(){let t=this.accessTokenLocatorNode?.convert();if(t==null||this.authorizationUrl==null)return{type:"bearerAuth",tokenName:void 0};let r=dwu({namespace:void 0,path:this.authorizationUrl,method:"POST",sdkMethodName:void 0,operationId:void 0,displayName:void 0,isWebhook:void 0});if(r!=null)return{type:"oAuth",value:{type:"clientCredentials",value:{type:"referencedEndpoint",endpointId:uc.EndpointId(r),accessTokenLocator:uc.JqString(t),headerName:this.headerAuthNode?.convert()?.headerWireValue,tokenPrefix:this.headerAuthNode?.convert()?.prefix}}}}};var pla=class extends mo{authScheme;headerAuthNode;bearerTokenNode;bearerTokenVariableNameNode;basicAuthNode;basicUsernameVariableNameNode;basicPasswordVariableNameNode;oauth2Node;constructor(t){super(t),this.safeParse()}parse(){switch(this.input.type){case"http":switch(this.input.scheme){case"basic":{this.authScheme="basic",this.basicAuthNode=new H0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicUsernameVariableNameNode=new J0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicPasswordVariableNameNode=new K0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),(this.basicAuthNode==null||this.basicAuthNode.username==null&&this.basicUsernameVariableNameNode?.usernameVariableName==null||this.basicAuthNode.password==null&&this.basicPasswordVariableNameNode?.passwordVariableName==null)&&this.context.errors.warning({message:"Basic auth should specify either a username or a username variable name",path:this.accessPath});break}case"bearer":{this.authScheme="bearer",this.bearerTokenNode=new $0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.bearerTokenVariableNameNode=new Y0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});break}default:{this.context.errors.warning({message:`Unsupported HTTP auth scheme: ${this.input.scheme}`,path:this.accessPath});break}}break;case"apiKey":{M3h(this.input)?(this.authScheme="header",this.headerAuthNode=new fla({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})):this.context.errors.error({message:`Unsupported API key location: ${this.input.in}`,path:this.accessPath});break}case"oauth2":{this.authScheme="oauth",this.oauth2Node=new _wu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});break}case"openIdConnect":{this.authScheme="bearer";break}}}convert(){switch(this.authScheme){case"basic":{let t=this.basicAuthNode?.convert();return{type:"basicAuth",usernameName:t?.username?.name??this.basicUsernameVariableNameNode?.convert(),passwordName:t?.password?.name??this.basicPasswordVariableNameNode?.convert()}}case"bearer":return{type:"bearerAuth",tokenName:this.bearerTokenNode?.convert()?.tokenVariableName??this.bearerTokenVariableNameNode?.convert()};case"header":return this.headerAuthNode?.convert();case"oauth":return this.oauth2Node?.convert();case void 0:return;default:new v8h.UnreachableCaseError(this.authScheme);return}}};var _la=class extends mo{authNodesMap;constructor(t){super(t),this.safeParse()}parse(){this.input.map((t,r)=>Object.keys(t).map(i=>{let n=x0u(i,this.context.document);if(n==null){this.context.errors.warning({message:`No auth scheme found for ${i}. Inline security schemes are not supported.`,path:this.accessPath});return}let a=new pla({input:n,context:this.context,accessPath:this.accessPath,pathId:["security",`${r}`]});a.convert()!=null?(this.authNodesMap??={},this.authNodesMap[i]=a):this.context.errors.warning({message:`No auth scheme found for ${i}`,path:this.accessPath})}))}convert(){return Object.fromEntries(Object.entries(this.authNodesMap??{}).map(([t,r])=>{let i=r.convert();if(i!=null)return[t,i]}).filter(Ho))}};var hwu=class extends mo{basePath;constructor(t){super(t),this.safeParse()}parse(){this.basePath=this.input[p3h],this.basePath!=null?(this.basePath.startsWith("/")&&(this.basePath=this.basePath.slice(1)),this.basePath.endsWith("/")&&(this.basePath=this.basePath.slice(0,-1))):this.basePath=void 0}convert(){return this.basePath}};function g8h(e){return"required"in e&&typeof e.required=="boolean"?e.required:!1}function O8h(e,t){return{type:"alias",value:{type:"optional",shape:e,default:t}}}function hla(e,t){return e==null?void 0:Object.entries(e).map(([i,n])=>tj(n.convert())?.map(o=>((t!=null&&!t.includes(i)||t==null&&!g8h(n))&&(o=O8h(o,o.type==="enum"?o.default:void 0)),{key:uc.PropertyKey(i),valueShape:o,description:n.description,availability:n.availability?.convert()})).filter(Ho)).filter(Ho).reduce((i,n)=>i.flatMap(a=>n.length>0?n.map(o=>[...a,o]):[[...a]]),[[]])}function ywu(e,t){return eg(e)?zL(e,t,void 0):e}function TYi(e,t){return e!=null&&e!==""?e:t!=null&&t!==""?t:void 0}function m8h(e,t){let r={...e};for(let[i,n]of Object.entries(t??{}))r[i]=[...r[i]??[],...n];return Object.keys(r).length>0?r:void 0}function A8h(e,t){if(e==null)return t;if(t==null)return e;let r=[];for(let i of e)for(let n of t)r.push({path:i.path??n.path,responseStatusCode:i.responseStatusCode??n.responseStatusCode,name:i.name??n.name,description:i.description??n.description,pathParameters:i.pathParameters??n.pathParameters,queryParameters:i.queryParameters??n.queryParameters,headers:i.headers??n.headers,requestBody:i.requestBody??n.requestBody,responseBody:i.responseBody??n.responseBody,snippets:{...n.snippets,...i.snippets}});return r}var P8h=ce(bM());var uil=["decimal","decimal128","double-int","double","float","sf-decimal"],sil=["int16","int32","int64","int8","sf-integer","uint8"],cil=["base64url","binary","byte","char","commonmark","date-time","date","decimal","decimal128","duration","email","hostname","html","http-date","idn-email","idn-hostname","int64","ipv4","ipv6","iri-reference","iri","json-pointer","media-range","password","regex","relative-json-pointer","sf-binary","sf-boolean","sf-string","sf-token","time","uri-reference","uri-template","uri","uuid"],lil=["beta","pre-release","in-development","generally-available","deprecated"];function TC(e,t){return eg(e)?zL(e,t,{type:"unknown","x-fern-type":"unknown",additionalProperties:!1}):e}var NSe=class extends mo{availability;constructor(t){super(t),this.safeParse()}parse(){if(TC(this.input,this.context.document)?.deprecated)this.availability="deprecated";else{let r=this.input[_3h];r!=null&&(lil.includes(r)?this.availability=r:(this.context.errors.warning({message:`Expected one of: ${lil.join(", ")}. Received: ${r}`,path:this.accessPath}),this.availability=void 0))}}convert(){switch(this.availability){case"beta":case"pre-release":return uc.Availability.Beta;case"in-development":return uc.Availability.InDevelopment;case"generally-available":return uc.Availability.GenerallyAvailable;case"deprecated":return uc.Availability.Deprecated;case void 0:return;default:new P8h.UnreachableCaseError(this.availability);return}}};var vwu=ce(bM());function j8h(e){return typeof e=="object"&&e!=null&&"language"in e}function w8h(e){return typeof e=="object"&&e!=null&&"sdk"in e}function E8h(e){return typeof e=="object"&&e!=null&&("error"in e||"body"in e)}function S8h(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)}function bwu(e){return typeof e=="object"&&e!=null&&"event"in e}function fil(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)&&e.stream.every(bwu)}function RYi(e){return typeof e=="object"&&e!=null&&"filename"in e&&"data"in e&&typeof e.filename=="string"&&typeof e.data=="string"}function M8h(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}var gwu=class extends mo{path;successResponseStatusCode;requestBodyByContentType;responseBodies;examples;constructor(t,r,i,n,a){super(t),this.path=r,this.successResponseStatusCode=i,this.requestBodyByContentType=n,this.responseBodies=a,this.safeParse()}parse(){this.examples=this.input[S3h]}convertFormDataExampleRequest(t,r){if(t.fields!=null)switch(t.contentType){case"form-data":return{type:"form",value:Object.fromEntries(Object.entries(t.fields).map(([n,a])=>{let o=typeof r=="object"?r[n]:void 0;switch(a.multipartType){case"file":return RYi(o)?[n,{type:"filenameWithData",filename:o.filename,data:uc.FileId(o.data)}]:o!=null?[n,{type:"filename",value:o}]:void 0;case"files":{if(Array.isArray(o)){if(o.every(c=>RYi(c)))return[n,{type:"filenamesWithData",value:o.map(c=>({filename:c.filename,data:uc.FileId(c.data)}))}];if(o.every(c=>typeof c=="string"))return[n,{type:"filenames",value:o}]}return}case"property":return[n,{type:"json",value:o}];case void 0:return;default:new vwu.UnreachableCaseError(a.multipartType);return}}).filter(Ho))};case"json":return{type:"json",value:r};case"bytes":return typeof r=="string"?{type:"bytes",value:{type:"base64",value:r}}:void 0;default:return}}convert(){if(this.examples==null)return;this.requestBodyByContentType!=null&&Object.keys(this.requestBodyByContentType).length>1&&this.context.logger.warn(`Multiple request bodies found for #/${[this.accessPath,this.pathId,"x-fern-examples"].join("/")}. Coercing to first request body until supported.`);let t=Object.keys(this.requestBodyByContentType??{})[0];return this.examples.flatMap(r=>(this.responseBodies??[]).map(i=>{let n=t!=null?this.requestBodyByContentType?.[t]:void 0,a;if(n!=null)switch(n.contentType){case"form-data":a=M8h(r.request)?this.convertFormDataExampleRequest(n,r.request):void 0;break;case"json":a=r.request!=null?{type:"json",value:r.request}:void 0;break;case"bytes":a=typeof r.request=="string"&&r.request!=null?{type:"bytes",value:{type:"base64",value:r.request}}:void 0;break;case void 0:break;default:new vwu.UnreachableCaseError(n.contentType);break}let o;switch(i.contentType){case"application/json":{E8h(r.response)&&(o={type:"json",value:r.response.body});break}case"text/event-stream":{fil(r.response)&&(o={type:"sse",value:r.response.stream.map(l=>({event:l.event,data:l.data}))});break}case"application/octet-stream":!fil(r.response)&&S8h(r.response)&&(o={type:"stream",value:r.response.stream});break;case void 0:break;default:new vwu.UnreachableCaseError(i.contentType);break}let c={};r["code-samples"]?.forEach(l=>{j8h(l)?l.language!=null&&(c[l.language]??=[],c[l.language]?.push({name:l.name,language:l.language,install:l.install,code:l.code,generated:!1,description:l.docs})):w8h(l)&&l.sdk!=null&&(c[l.sdk]??=[],c[l.sdk]?.push({name:l.name,language:l.sdk,install:void 0,code:l.code,generated:!1,description:l.docs}))});let d=Object.fromEntries(Object.entries(r["path-parameters"]??{}).map(([l,p])=>[uc.PropertyKey(l),p])),s=Object.fromEntries(Object.entries(r["query-parameters"]??{}).map(([l,p])=>[uc.PropertyKey(l),p])),u=Object.fromEntries(Object.entries(r.headers??{}).map(([l,p])=>[uc.PropertyKey(l),p]));return{path:this.path,responseStatusCode:this.successResponseStatusCode,name:r.name,description:r.docs,pathParameters:Object.keys(d).length>0?d:void 0,queryParameters:Object.keys(s).length>0?s:void 0,headers:Object.keys(u).length>0?u:void 0,requestBody:a,responseBody:o,snippets:c}}))}};var oXa=class extends mo{groupName;constructor(t){super(t),this.safeParse()}parse(){this.groupName=this.input[V0u]}convert(){if(this.groupName==null)return;let t;return Array.isArray(this.groupName)?t=this.groupName:t=[this.groupName],t.map(r=>uc.api.v1.SubpackageId(sWt(r)))}};var Owu=class extends mo{sdkMethodName;constructor(t){super(t),this.safeParse()}parse(){this.sdkMethodName=this.input[y3h]}convert(){return this.sdkMethodName}};var mwu=class extends mo{isWebhook;constructor(t){super(t),this.safeParse()}parse(){this.isWebhook=this.input[b3h]}convert(){return this.isWebhook}};var Awu=class extends mo{codeSamples;constructor(t){super(t),this.safeParse()}parse(){this.codeSamples=[...this.input[B3h]??[],...this.input[I3h]??[]],this.codeSamples.forEach(t=>{[...Object.values(uc.api.v1.read.SupportedLanguage),"Kotlin","Swift","PHP"].map(r=>r.toLowerCase()).includes(t.lang.toLowerCase())||this.context.errors.warning({message:`Unsupported language: ${t.lang}. This may not render correctly.`,path:this.accessPath})})}convert(){let t={};if(this.codeSamples?.forEach(r=>{t[r.lang.toLowerCase()]??=[],t[r.lang.toLowerCase()]?.push({name:r.label,language:r.lang,code:r.source,install:void 0,generated:!1,description:void 0})}),Object.keys(t).length!==0)return t}};var lOn=ce(bM());function dil(e,t){return eg(e)?zL(e,t,void 0):e}function D8h(e,t){return e.replace(/{(\w+)}/g,(r,i)=>t[i]!=null&&typeof t[i]=="string"||typeof t[i]=="number"||typeof t[i]=="boolean"?`${t[i]}`:r)}var FF="",RXt=class extends mo{path;responseStatusCode;name;shapes;resolvedRequestInput;resolvedResponseInput;summary;constructor(t,r,i,n,a){super(t),this.path=r,this.responseStatusCode=i,this.name=n,this.shapes=a,this.safeParse()}validateFormDataRequestExample(){return typeof this.resolvedRequestInput?.value!="object"?!1:Object.entries(this.shapes.requestBody?.fields??{}).reduce((t,[r,i])=>{let n=this.resolvedRequestInput?.value[r];switch(i.multipartType){case"file":return t&&(RYi(n)||typeof n=="string");case"files":return t&&Array.isArray(n)&&n.every(a=>RYi(a)||typeof a=="string");case"property":return t;case void 0:return t&&!1;default:return new lOn.UnreachableCaseError(i.multipartType),t}},!0)}parse(){let t=this.shapes.requestBody?.schema?.example({includeOptionals:!1,override:void 0});this.resolvedRequestInput=dil(this.input?.requestExample,this.context.document)??(t!=null?{value:t}:void 0);let r=this.shapes.responseBody?.schema?.example({includeOptionals:!1,override:void 0});if(this.resolvedResponseInput=dil(this.input?.responseExample,this.context.document)??(r!=null?{value:r}:void 0),this.summary=this.input?.requestExample?.summary??this.input?.responseExample?.summary,this.shapes.requestBody!=null&&this.resolvedRequestInput!=null)switch(this.shapes.requestBody?.contentType){case"json":{if(typeof this.resolvedRequestInput.value!="object"){this.context.errors.error({message:"Invalid example, expected object for json",path:this.accessPath});return}break}case"bytes":{if(typeof this.resolvedRequestInput.value!="string"){this.context.errors.error({message:"Invalid example, expected string for bytes",path:this.accessPath});return}break}case"form-data":{if(!this.validateFormDataRequestExample()){this.context.errors.error({message:"Invalid example, expected valid form-data",path:this.accessPath});return}break}case void 0:break;default:new lOn.UnreachableCaseError(this.shapes.requestBody?.contentType),this.context.errors.error({message:"Invalid example, unsupported content type",path:this.accessPath});return}if(this.shapes.responseBody!=null&&this.resolvedResponseInput!=null)switch(this.shapes.responseBody?.contentType){case"application/json":if(this.resolvedResponseInput!=null&&typeof this.resolvedResponseInput!="object"||this.resolvedResponseInput.value!=null&&typeof this.resolvedResponseInput.value!="object"){this.context.errors.error({message:"Invalid example, expected object for json",path:this.accessPath});return}break;case"text/event-stream":if(this.resolvedResponseInput.value!=null&&!Array.isArray(this.resolvedResponseInput.value)&&!this.resolvedResponseInput.value.every(bwu)){this.context.errors.error({message:"Invalid example, expected array of SSE events for event-stream",path:this.accessPath});return}break;case"application/octet-stream":if(this.resolvedResponseInput.value!=null&&typeof this.resolvedResponseInput.value!="string"&&!Array.isArray(this.resolvedResponseInput.value)){this.context.errors.error({message:"Invalid example, expected string or array for octet-stream",path:this.accessPath});return}break;case void 0:break;default:new lOn.UnreachableCaseError(this.shapes.responseBody?.contentType);return}}convertFormDataExampleRequest(){if(!(this.resolvedRequestInput==null||this.shapes.requestBody?.fields==null))switch(this.shapes.requestBody?.contentType){case"form-data":return{type:"form",value:Object.fromEntries(Object.entries(this.shapes.requestBody.fields).map(([r,i])=>{let n=this.resolvedRequestInput?.value?.[r];switch(i.multipartType){case"file":return RYi(n)?[r,{type:"filenameWithData",filename:n.filename,data:uc.FileId(n.data)}]:[r,{type:"filename",value:n}];case"files":{if(Array.isArray(n)){if(n.every(a=>RYi(a)))return[r,{type:"filenamesWithData",value:n.map(a=>({filename:a.filename,data:uc.FileId(a.data)}))}];if(n.every(a=>typeof a=="string"))return[r,{type:"filenames",value:n}]}return}case"property":return[r,{type:"json",value:n}];case void 0:return;default:new lOn.UnreachableCaseError(i.multipartType);return}}).filter(Ho))};case"json":return{type:"json",value:this.resolvedRequestInput.value};case"bytes":return typeof this.resolvedRequestInput.value=="string"?{type:"bytes",value:{type:"base64",value:this.resolvedRequestInput.value}}:void 0;default:return}}convertDescription(){if(this.resolvedRequestInput!=null&&this.resolvedResponseInput!=null)return this.resolvedResponseInput.description;if(this.resolvedRequestInput!=null)return this.resolvedRequestInput.description;if(this.resolvedResponseInput!=null)return this.resolvedResponseInput.description}convert(){let t;if(this.shapes.requestBody!=null&&this.resolvedRequestInput!=null)switch(this.shapes.requestBody.contentType){case"form-data":t=this.convertFormDataExampleRequest();break;case"json":t={type:"json",value:this.resolvedRequestInput.value};break;case"bytes":t={type:"bytes",value:{type:"base64",value:this.resolvedRequestInput.value}};break;case void 0:break;default:new lOn.UnreachableCaseError(this.shapes.requestBody?.contentType);break}let r;if(this.shapes.responseBody!=null&&this.resolvedResponseInput!=null)switch(this.shapes.responseBody.contentType){case"application/json":{r={type:"json",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break}case"text/event-stream":r={type:"sse",value:this.resolvedResponseInput?.value};break;case"application/octet-stream":r={type:typeof this.resolvedResponseInput?.value=="string"?"filename":"stream",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break;case void 0:r={type:"json",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break;default:new lOn.UnreachableCaseError(this.shapes.responseBody?.contentType);break}let i=Object.fromEntries(Object.entries(this.shapes.pathParameters??{}).map(([o,c])=>[o,c.example({includeOptionals:!1,override:o})]));i=Object.keys(i).length>0?i:void 0;let n=Object.fromEntries(Object.entries(this.shapes.queryParameters??{}).map(([o,c])=>c.required||c.inputExample!=null?[o,c.example({includeOptionals:!1,override:o})]:void 0).filter(Ho));n=Object.keys(n).length>0?n:void 0;let a=Object.fromEntries(Object.entries(this.shapes.requestHeaders??{}).map(([o,c])=>c.required||c.inputExample!=null?[o,c.example({includeOptionals:!1,override:o})]:void 0).filter(Ho));if(a=Object.keys(a).length>0?a:void 0,!(this.path==null&&t==null&&r==null&&a==null&&n==null&&i==null))return{path:D8h(this.path,i??{}),responseStatusCode:this.responseStatusCode,name:this.name!=null?TXt(this.name):this.summary!=null?TXt(this.summary):void 0,description:this.convertDescription(),pathParameters:i,queryParameters:n,headers:a,requestBody:t,responseBody:r,snippets:void 0}}};function B8h(e,t){return eg(e)?zL(e,t,void 0):e}var W8h=ce(bM());var I8h="#/components/schemas/";function yla(e){if(e.$ref.startsWith(I8h))return e.$ref.replace(I8h,"")}function D4i(e){if(e!=null)return{type:"alias",value:{type:"nullable",shape:e}}}function zYi(e){return typeof e.type=="string"&&e.type==="array"}function C8h(e){return e.type==="boolean"}function q8h(e){return e.type==="integer"}function NYi(e){return!Array.isArray(e.type)&&!zYi(e)}function T8h(e){return e!=null&&Array.isArray(e)&&e.every(t=>t.type==="null"||NYi(t)||zYi(t))}function R8h(e){return"nullable"in e&&typeof e.nullable=="boolean"}function z8h(e){return e.type==="null"}function N8h(e){return e.type==="number"}function pil(e){return e.type==null||typeof e.type=="string"&&e.type==="object"}function F8h(e){return e.type==="string"}var Pwu=class extends zY{item;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.item=new _w({input:this.input.items,context:this.context,accessPath:this.accessPath,pathId:"items",seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}),this.input.items==null&&this.context.errors.error({message:"Expected 'items' property to be specified",path:this.accessPath})}convert(){return tj(this.item?.convert())?.map(r=>({type:"alias",value:{type:"list",itemShape:r}}))}example(t){return this.input.example??this.input.examples?.[0]??[this.item?.example(t)]}};var jwu=class extends qC{constValue;description;availability;constructor(t){super(t),this.safeParse()}parse(){this.input.const!=null&&(typeof this.input.const=="string"||typeof this.input.const=="number"||typeof this.input.const=="boolean")?this.constValue=this.input.const.toString():this.context.errors.warning({message:`Unsupported const type: ${typeof this.input}`,path:this.accessPath}),this.description=this.input.description,this.availability=new NSe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"})}convert(){if(this.constValue!=null)return{type:"enum",default:this.constValue,values:[{value:this.constValue,description:this.description,availability:this.availability?.convert()}]}}example(){return this.input.example??this.input.examples?.[0]??this.constValue}};var wwu=class extends zY{typeNodes;nullable;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.parse()}parse(){this.typeNodes=this.input.map(t=>{if(t.type==="null")this.nullable=!0;else return new _w({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName})}).filter(Ho)}convert(){if(this.typeNodes==null)return;let i=this.typeNodes.map(n=>tj(n.convert())?.map(o=>({displayName:n.name,shape:o,description:n.description,availability:n.availability?.convert()}))).filter(Ho).reduce((n,a)=>n.flatMap(o=>a.length>0?a.map(c=>[...o,c]):[[...o]]),[[]]).map(n=>({type:"undiscriminatedUnion",variants:n}));return this.nullable?i.map(D4i).filter(Ho):i}example(t){return this.nullable?null:this.typeNodes?.[0]?.example(t)}};function Ewu(e){return e!=null&&e.length>0?e:[void 0]}var bla=class extends zY{description;extends=[];properties;extraProperties;requiredProperties;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.extends=[],this.requiredProperties=this.input.required,this.properties=Object.fromEntries(Object.entries(this.input.properties??{}).map(([t,r])=>[t,new _w({input:r,context:this.context,accessPath:this.accessPath,pathId:["properties",t],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})])),this.extraProperties=this.input.additionalProperties!=null?typeof this.input.additionalProperties=="boolean"?this.input.additionalProperties?this.input.title:void 0:new _w({input:this.input.additionalProperties,context:this.context,accessPath:this.accessPath,pathId:["additionalProperties"],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0,this.input.allOf!=null&&(this.extends=this.extends.concat(this.input.allOf.map((t,r)=>{if(eg(t))return yla(t);this.properties={...this.properties,...Object.fromEntries(Object.entries(t.properties??{}).map(([i,n])=>[i,new _w({input:n,context:this.context,accessPath:this.accessPath,pathId:["allOf",r.toString(),"properties",i],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))}}).filter(Ho))),this.description=this.input.description}convertProperties(){if(this.properties!=null)return hla(this.properties,this.requiredProperties)}convertExtraProperties(){return this.extraProperties==null?void 0:typeof this.extraProperties=="string"?[{type:"map",keyShape:{type:"alias",value:{type:"primitive",value:{type:"string",format:void 0,regex:void 0,minLength:void 0,maxLength:void 0,default:void 0}}},valueShape:{type:"alias",value:{type:"unknown",displayName:this.extraProperties}}}]:tj(this.extraProperties.convert())?.map(r=>({type:"map",keyShape:{type:"alias",value:{type:"primitive",value:{type:"string",format:void 0,regex:void 0,minLength:void 0,maxLength:void 0,default:void 0}}},valueShape:r})).filter(Ho)}convert(){let t=this.convertProperties();if(t==null)return;let r=this.convertExtraProperties();return t.flatMap(i=>Ewu(r).map(n=>(this.extends==null||this.extends.length===0)&&i.length===0&&n!=null?{type:"alias",value:n}:{type:"object",extends:this.extends.map(a=>uc.TypeId(a)),properties:i,extraProperties:n}))}example({includeOptionals:t}){let r={...this.properties};return this.input.allOf?.forEach(i=>{let n=TC(i,this.context.document);n!=null&&(r={...r,...Object.fromEntries(Object.entries(n.properties??{}).map(([a,o])=>[a,new _w({input:o,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))})}),this.input.example??this.input.examples?.[0]??(!t&&this.requiredProperties!=null&&this.requiredProperties.length>0?this.requiredProperties?.reduce((i,n)=>{let a=r?.[n];return i[n]=a?.example({includeOptionals:t,override:n}),i},{}):Object.entries(r).reduce((i,[n,a])=>(i[n]=a?.example({includeOptionals:t,override:n}),i),{}))}};var Swu=class extends zY{isNullable;discriminated;discriminant;discriminatedMapping;undiscriminatedMapping;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){if(this.input.oneOf!=null||this.input.anyOf!=null)if(this.isNullable=(this.input.oneOf??this.input.anyOf)?.some(t=>TC(t,this.context.document)?.type==="null"),this.input.discriminator==null)this.discriminated=!1,this.undiscriminatedMapping=(this.input.oneOf??this.input.anyOf)?.map(t=>TC(t,this.context.document)?.type!=="null"?new _w({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0).filter(Ho);else{let t=this.input.discriminator.mapping;if(t!=null){this.discriminated=!0,this.discriminant=this.input.discriminator.propertyName,this.discriminatedMapping={};let r=this.discriminatedMapping;Object.entries(t).map(([i,n])=>{let a=TC({$ref:n},this.context.document);if(a==null){this.context.errors.warning({message:`Expected schema reference. Received undefined reference: ${n}`,path:[...this.accessPath,"discriminator","mapping",i]});return}r[i]=new _w({input:a,context:this.context,accessPath:[...this.accessPath,"discriminator","mapping",i],pathId:i,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})})}}}convert(){if(!this.discriminated&&this.undiscriminatedMapping?.length===1){let n=this.undiscriminatedMapping?.flatMap(a=>a.convert()).filter(Ho);return this.isNullable&&n!=null?n.map(D4i).filter(Ho):n}let t=0,r=this.discriminated&&this.discriminant!=null&&this.discriminatedMapping!=null?{type:"discriminatedUnion",discriminant:uc.PropertyKey(this.discriminant),variants:Object.entries(this.discriminatedMapping).flatMap(([n,a])=>tj(a.convert())?.map(c=>{if(!(c==null||c.type!=="object"))return{discriminantValue:n,displayName:a.name??TXt(n),availability:a.availability?.convert(),description:a.description,...c}}).filter(Ho)).filter(Ho)}:this.undiscriminatedMapping!=null?{type:"undiscriminatedUnion",variants:this.undiscriminatedMapping.flatMap(n=>tj(n.convert())?.map(o=>{if(o==null)return;t+=1;let c=o.type==="object"?TXt(`${this.schemaName??"Variant"} ${t}`):void 0;return{displayName:n.name??(o.type==="alias"&&o.value.type==="id"?TXt(o.value.id):c),shape:o,description:n.description,availability:n.availability?.convert()}}).filter(Ho)).filter(Ho)}:void 0,i=this.isNullable?D4i(r):r;return i!=null?[i]:void 0}example(t){return this.input.example??this.input.examples?.[0]??this.undiscriminatedMapping?.[0]?.example(t)??Object.values(this.discriminatedMapping??{})[0]?.example(t)}};var Mwu=class extends qC{default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.input.default!=null&&typeof this.input.default!="boolean"&&this.context.errors.warning({message:`Expected default value to be a boolean. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default}convert(){return{type:"alias",value:{type:"primitive",value:{type:"boolean",default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:!1)}};var FYi=class extends qC{default;values=[];nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){if(this.input.enum!=null){let t=!0;this.values=this.input.enum.map((r,i)=>{if(t){if(eg(r)){let n=TC(r,this.context.document);r=typeof n=="string"?n:typeof n?.default=="string"?n?.default:typeof n?.example=="string"?n.example:void 0}if(typeof r!="string"){this.context.errors.error({message:`Expected enum values to be strings. Received ${r}`,path:[...this.accessPath,`enum[${i}]`]}),t=!1;return}return r}}).filter(Ho),this.values=Array.from(new Set(this.values))}this.default=this.input.default}convert(){return{type:"enum",values:this.values.map(t=>({value:t,description:void 0,availability:void 0})),default:this.default}}example(){return this.input.example??this.input.examples?.[0]??this.default??this.values[0]??(this.nullable?null:void 0)}};var Q8h=ce(bM());function kDB(e){return sil.includes(e)}var Dwu=class extends qC{format;minimum;maximum;default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.minimum=this.input.minimum,this.maximum=this.input.maximum,this.input.default!=null&&typeof this.input.default!="number"&&this.context.errors.warning({message:`Expected default value to be an integer. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(kDB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${sil.join(", ")}. Received ${this.input.format}`,path:this.accessPath}))}convert(){let t="integer";if(this.format!=null)switch(this.format){case"int64":t="long";break;case"int8":case"int16":case"int32":case"uint8":case"sf-integer":case void 0:t="integer";break;default:new Q8h.UnreachableCaseError(this.format);break}return{type:"alias",value:{type:"primitive",value:{type:t,minimum:this.minimum,maximum:this.maximum,default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:0)}};var Bwu=class extends qC{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){this.displayName=this.input.title}convert(){return D4i({type:"alias",value:{type:"unknown",displayName:this.displayName}})}example(){return null}};var U8h=ce(bM());function eBB(e){return uil.includes(e)}var Iwu=class extends qC{format;minimum;maximum;default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.minimum=this.input.minimum,this.maximum=this.input.maximum,this.input.default!=null&&typeof this.input.default!="number"&&this.context.errors.warning({message:`Expected default value to be a number. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(eBB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${uil.join(", ")}. Received ${this.input.format}`,path:this.accessPath}))}convert(){let t="double";if(this.format!=null)switch(this.format){case"decimal":case"decimal128":case"double-int":case"double":case"float":case"sf-decimal":case void 0:t="double";break;default:new U8h.UnreachableCaseError(this.format);break}return{type:"alias",value:{type:"primitive",value:{type:t,minimum:this.minimum,maximum:this.maximum,default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:0)}};var L8h=ce(bM());function tBB(e){return cil.includes(e)}var Cwu=class extends qC{format;regex;default;minLength;maxLength;enum;mimeType;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}mapToFdrType(t){switch(t){case"base64url":case"binary":case"byte":case"sf-binary":return"base64";case"date-time":return"datetime";case"int64":return"bigInteger";case"date":return"date";case"uuid":return"uuid";case"char":case"commonmark":case"decimal":case"decimal128":case"duration":case"email":case"hostname":case"html":case"http-date":case"idn-email":case"idn-hostname":case"ipv4":case"ipv6":case"iri-reference":case"iri":case"json-pointer":case"media-range":case"password":case"regex":case"relative-json-pointer":case"sf-boolean":case"sf-string":case"sf-token":case"time":case"uri-reference":case"uri-template":case"uri":case void 0:return"string";default:return new L8h.UnreachableCaseError(t),"string"}}parse(){this.regex=this.input.pattern,this.minLength=this.input.minLength,this.maxLength=this.input.maxLength,this.mimeType=this.input.contentMediaType,this.input.default!=null&&typeof this.input.default!="string"&&this.context.errors.warning({message:`Expected default value to be a string. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(tBB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${cil.join(", ")}. Received ${this.input.format}`,path:this.accessPath})),this.input.enum!=null&&(this.enum=new FYi({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"enum",nullable:this.nullable}))}convert(){if(this.enum!=null)return this.enum.convert();let t="string";return this.format!=null&&(t=this.mapToFdrType(this.format)),{type:"alias",value:{type:"primitive",value:t==="base64"?{type:t,mimeType:this.mimeType,default:this.default}:{type:t,format:t==="string"?this.format:void 0,regex:this.regex,minLength:this.minLength,maxLength:this.maxLength,default:this.default}}}}example({override:t}){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:t??"string")}};var V8h=ce(bM());var qwu=class extends qC{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){(0,V8h.noop)()}convert(){return{type:"alias",value:{type:"unknown",displayName:void 0}}}example(){}};var fOn=class extends zY{description;availability;schemaId;maybeEnumConverterNode;nullable;schemaName;constructor(t){super(t),this.nullable=t.nullable,this.schemaName=t.schemaName,this.description=t.description,this.availability=t.availability,this.safeParse()}parse(){this.schemaId=yla(this.input);let t=TC(this.input,this.context.document);t?.enum!=null&&NYi(t)&&(this.maybeEnumConverterNode=new FYi({input:t,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",nullable:this.nullable})),this.schemaId==null&&this.context.errors.error({message:`Unprocessable reference: ${this.input.$ref}`,path:this.accessPath})}convert(){if(this.schemaId!=null)return{type:"alias",value:{type:"id",id:uc.TypeId(this.schemaId),default:this.maybeEnumConverterNode?.default!=null?{type:"enum",value:this.maybeEnumConverterNode.default}:void 0}}}example(t){let r=TC(this.input,this.context.document);if(r!=null)return new _w({input:r,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName}).example(t)}};var _w=class e extends zY{typeShapeNode;description;name;examples;availability;nullable;schemaName;constructor(t){super(t),this.nullable=t.nullable,this.schemaName=t.schemaName,this.safeParse()}parse(){if(this.description=this.input.description,this.availability=new NSe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),NYi(this.input)&&R8h(this.input)&&(this.nullable=this.input.nullable!=null?this.input.nullable:this.nullable),eg(this.input)){let t=yla(this.input);if(t==null){this.context.errors.error({message:"Reference object does not have a valid schema ID",path:this.accessPath});return}if(this.seenSchemas.has(t)){this.context.errors.warning({message:"Circular or deeply nested schema found, terminating",path:this.accessPath});return}this.seenSchemas.add(t),this.typeShapeNode=new fOn({input:this.input,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName,description:this.description,availability:this.availability})}else if(this.name=this.input.title,this.examples=this.input.example,this.input.const!=null)this.typeShapeNode=new jwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});else if(T8h(this.input))this.typeShapeNode=new wwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(NYi(this.input)&&(this.input.oneOf!=null||this.input.anyOf!=null))this.typeShapeNode=new Swu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(pil(this.input)&&this.input.allOf!=null)this.typeShapeNode=new bla({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(NYi(this.input)&&this.input.enum!=null)this.typeShapeNode=new FYi({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable});else if(typeof this.input.type=="string"||Array.isArray(this.input.type)&&this.input.type.length===1){if(this.input.type=Array.isArray(this.input.type)?this.input.type[0]:this.input.type,!Array.isArray(this.input.type))switch(this.input.type){case"object":pil(this.input)&&(this.typeShapeNode=new bla({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"array":zYi(this.input)&&(this.typeShapeNode=new Pwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"boolean":C8h(this.input)&&(this.typeShapeNode=new Mwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"integer":q8h(this.input)&&(this.typeShapeNode=new Dwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"number":N8h(this.input)&&(this.typeShapeNode=new Iwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"string":F8h(this.input)&&(this.typeShapeNode=new Cwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"null":z8h(this.input)&&(this.typeShapeNode=new Bwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}));break;case void 0:break;default:new W8h.UnreachableCaseError(this.input.type);break}}else if(Array.isArray(this.input.type)&&this.input.type.includes("null")&&this.input.type.length===2){let t=this.input.type.filter(r=>r!=="null")[0];t!=="array"&&(this.typeShapeNode=new e({input:{...this.input,type:t},context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:!0,schemaName:this.schemaName}))}else this.input.properties!=null&&(this.typeShapeNode=new bla({input:{...this.input,type:"object"},context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));this.typeShapeNode==null&&(this.typeShapeNode=new qwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),!eg(this.input)&&(!zYi(this.input)&&this.input==null||zYi(this.input)&&this.input.items==null)&&this.context.errors.error({message:"Expected type declaration. Received: null",path:this.accessPath}))}convert(){let t=this.typeShapeNode?.convert();if(t==null)return;let r=tj(t)?.map(i=>this.nullable?D4i(i):i).filter(Ho);return Array.isArray(t)&&t.length>1?r:r?.[0]}example(t){return this.availability?.availability!=="deprecated"?this.typeShapeNode?.example(t):void 0}};function QYi(e){if(e!=null)return hla(e,Object.entries(e??{}).map(([t,r])=>r.required?t:void 0).filter(Ho))}var zXt=class extends qC{availability;required;schema;description;inputExample;constructor(t){super(t),this.safeParse(t.parameterName)}parse(t){this.description=this.input.description;let r;eg(this.input)?r=this.input:this.input.schema!=null?(r=this.input.schema,this.required=this.input.required):(r={type:"string"},this.required=!1),this.availability=new NSe({input:r,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=new _w({input:r,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:t});let i=B8h(this.input,this.context.document);this.inputExample=i?.example??Object.values(i?.examples??{})[0]}convert(){return this.schema?.convert()}example(t){return this.inputExample??this.schema?.example(t)}};function G8h(e,t){return eg(e)?zL(e,t,void 0):e}var _il=ce(bM());function Twu(e){let{uniqueId:t,type:r,contextTypes:i,description:n,availability:a}=e;i[uc.TypeId(t)]={name:t,shape:r,description:n,availability:a}}var x8h=ce(Hnc(),1),vla=class e{type;subtype;essence;parameters;mimeType;input;constructor(t,r,i,n,a,o){this.type=t,this.subtype=r,this.essence=i,this.parameters=n,this.mimeType=a,this.input=o}static APPLICATION_JSON="application/json";static APPLICATION_OCTET_STREAM="application/octet-stream";static MULTIPART_FORM_DATA="multipart/form-data";static parse(t){if(t==null)return null;let r=x8h.default.parse(t);return r==null?null:new e(r.type,r.subtype,r.essence,r.parameters,r,t)}toString(){return this.input}isText(){return this.type==="text"}isImage(){return this.type==="image"}isAudio(){return this.type==="audio"}isVideo(){return this.type==="video"}isFont(){return this.type==="font"}isMultipart(){return this.type==="multipart"}isApplication(){return this.type==="application"}isMessage(){return this.type==="message"}isModel(){return this.type==="model"}isCSS(){return this.isText()&&this.subtype==="css"}isCSV(){return this.isText()&&this.subtype==="csv"}isMarkdown(){return this.isText()&&this.subtype==="markdown"}isPlainText(){return this.isText()&&this.subtype==="plain"}isEventStream(){return this.isText()&&this.subtype==="event-stream"}isMultiPartFormData(){return this.isMultipart()&&this.subtype==="form-data"}isJSON(){return this.isApplication()&&this.subtype==="json"}containsJSON(){return this.isApplication()&&this.subtype.includes("json")}isURLEncoded(){return this.isApplication()&&this.subtype==="x-www-form-urlencoded"}isOctetStream(){return this.isApplication()&&this.subtype==="octet-stream"}isPDF(){return this.isApplication()&&this.subtype==="pdf"}isZip(){return this.isApplication()&&this.subtype==="zip"}isGzip(){return this.isApplication()&&this.subtype==="gzip"}isTar(){return this.isApplication()&&this.subtype==="tar"}isBrotli(){return this.isApplication()&&this.subtype==="br"}isDeflate(){return this.isApplication()&&this.subtype==="deflate"}isProtobuf(){return this.isApplication()&&this.subtype==="protobuf"}isAvif(){return this.isImage()&&this.subtype==="avif"}isWebP(){return this.isImage()&&this.subtype==="webp"}isSVG(){return this.isImage()&&this.subtype==="svg+xml"}isPNG(){return this.isImage()&&this.subtype==="png"}isJPEG(){return this.isImage()&&this.subtype==="jpeg"}isGIF(){return this.isImage()&&this.subtype==="gif"}isMPEG(){return this.isAudio()&&this.subtype==="mpeg"}isWAV(){return this.isAudio()&&this.subtype==="wav"}isHTML(){return this.mimeType.isHTML()}isXML(){return this.mimeType.isXML()}isJavaScript(){return this.mimeType.isJavaScript()}};function rBB(e){return typeof e.securitySchemes=="object"&&e.securitySchemes!=null}var Rwu=class extends mo{typeSchemas;securitySchemes;constructor(t){super(t),this.safeParse()}parse(){this.input.schemas!=null&&(this.typeSchemas=Object.fromEntries(Object.entries(this.input.schemas).map(([t,r])=>[t,new _w({input:r,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:new Set,nullable:void 0,schemaName:t})]))),rBB(this.input)&&this.input.securitySchemes!=null&&(this.securitySchemes=Object.fromEntries(Object.entries(this.input.securitySchemes??{}).map(([t,r],i)=>{let n;if(eg(r)?n=x0u(r.$ref,this.context.document):n=r,n!=null)return[t,new pla({input:n,context:this.context,accessPath:this.accessPath,pathId:["securitySchemes",`${i}`]})]}).filter(Ho)))}convert(){return{auths:this.securitySchemes!=null?Object.fromEntries(Object.entries(this.securitySchemes??{}).map(([t,r])=>{let i=r.convert();if(i!=null)return[uc.api.latest.AuthSchemeId(t),i]}).filter(Ho)):void 0,types:this.typeSchemas!=null?Object.fromEntries(Object.entries(this.typeSchemas).map(([t,r])=>{let i=r.name??t,n=tj(r.convert());return n==null?[t,void 0]:[uc.TypeId(t),{name:i,shape:n[0],description:r.description,availability:void 0}]}).filter(([t,r])=>Ho(r))):void 0}}};var zwu=class extends _w{multipartType;contentType;constructor(t){super(t),this.safeParse()}parse(){super.parse();let t=TC(this.input,this.context.document);if(t==null){this.context.errors.error({message:`Expected multipart form data property definition. ${eg(this.input)?`Received undefined reference: ${this.input.$ref}`:""}`,path:this.accessPath});return}if(t.type==="string"&&t.format==="binary")this.multipartType="file",this.contentType=t.contentMediaType;else if(t.type==="array"){let r=TC(t.items,this.context.document);r?.type==="string"&&r?.format==="binary"?(this.multipartType="files",this.contentType=r?.contentMediaType):(this.context.errors.warning({message:"Expected multipart form data files definition with array type with internal string type and binary format.",path:this.accessPath}),this.multipartType=void 0,this.contentType=void 0)}else this.multipartType="property",this.contentType=t.contentMediaType}};var Nwu=class extends mo{description;method;path;schema;isOptional;contentType;availability;requiredFields;fields;examples;constructor(t){super(t),this.method=t.method,this.path=t.path,this.safeParse(t)}parse({contentType:t}){if(this.input.schema!=null){let i=TC(this.input.schema,this.context.document);this.availability=new NSe({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=eg(this.input.schema)?new fOn({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:!1,schemaName:"Request Body",description:this.input.schema.description,availability:this.availability}):void 0;let n=vla.parse(t);n?.containsJSON()?(this.contentType="json",this.schema=this.schema??new _w({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:"Request Body"})):n?.isOctetStream()?(this.contentType="bytes",this.isOptional=i?.required==null):n?.isMultiPartFormData()?(this.contentType="form-data",this.requiredFields=i?.required,this.fields=Object.fromEntries(Object.entries(i?.properties??{}).map(([a,o])=>{if(o!=null)return[a,new zwu({input:o,context:this.context,accessPath:this.accessPath,pathId:`schema.${a}`,seenSchemas:new Set,nullable:void 0,schemaName:a})]}).filter(Ho))):this.context.errors.warning({message:`Expected request body of reference or object with json, streaming or form-data content types. Received: ${t}`,path:this.accessPath})}let r=this.schema?.example({includeOptionals:!0,override:void 0});this.examples={...this.input.example!=null?{[FF]:{value:this.input.example}}:{},...this.input.examples},r!=null&&Object.keys(this.examples).length===0&&(this.examples={[FF]:{value:r}})}convertJsonLike(){let t=this.schema?.convert();return t==null?void 0:tj(t)?.map(i=>{let n=i.type;switch(n){case"object":case"alias":return i;case"enum":case"undiscriminatedUnion":case"discriminatedUnion":{let a=sWt([this.method,this.path,this.contentType,"request"].join("_"));return Twu({uniqueId:a,type:i,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:uc.TypeId(a),default:i.type==="enum"&&i.default!=null?{type:"enum",value:i.default}:void 0}}}case void 0:return;default:new _il.UnreachableCaseError(n);return}}).filter(Ho)}convert(){if(this.schema instanceof fOn)return this.schema.convert();switch(this.contentType){case"json":return this.convertJsonLike();case"bytes":return{type:"bytes",isOptional:this.isOptional??!1,contentType:this.contentType};case"form-data":return Object.entries(this.fields??{}).map(([i,n])=>{switch(n.multipartType){case"file":return[{type:n.multipartType,key:uc.PropertyKey(i),isOptional:this.requiredFields?.includes(i)==null,contentType:n.contentType,description:n.description,availability:n.availability?.convert()}];case"files":return[{type:n.multipartType,key:uc.PropertyKey(i),isOptional:this.requiredFields?.includes(i)==null,contentType:n.contentType,description:n.description,availability:n.availability?.convert()}];case"property":{let a=tj(n.convert()),o=n.multipartType;return a?.map(c=>({type:o,key:uc.PropertyKey(i),contentType:n.contentType,exploded:void 0,valueShape:c,description:n.description,availability:n.availability?.convert()}))}case void 0:return[];default:return new _il.UnreachableCaseError(n.multipartType),[]}}).filter(Ho).reduce((i,n)=>i.flatMap(a=>n.length>0?n.map(o=>[...a,o]):[[...a]]),[[]]).map(i=>({type:"formData",fields:i,availability:this.availability?.convert(),description:this.description}));case void 0:return this.convertJsonLike();default:return}}};var Fwu=class extends mo{description;requestBodiesByContentType;constructor(t){super(t),this.safeParse(t)}parse({method:t,path:r}){let i=G8h(this.input,this.context.document);if(i==null){this.context.errors.error({message:"Expected request body. Received: null",path:this.accessPath});return}Object.entries(i.content).forEach(([n,a])=>{this.requestBodiesByContentType??={},this.requestBodiesByContentType[n]=new Nwu({input:a,context:this.context,accessPath:this.accessPath,pathId:"content",contentType:n,method:t,path:r})})}convert(){return Object.entries(this.requestBodiesByContentType??{}).flatMap(([t,r])=>tj(r.convert())?.map(n=>({description:this.description,contentType:t,body:n}))).filter(Ho)}convertToWebhookPayload(){return Object.values(this.requestBodiesByContentType??{}).flatMap(t=>tj(t.convert())?.map(i=>{if(!(i.type!=="alias"&&i.type!=="object"))return{description:this.description,shape:i}})).filter(Ho)}webhookExample(){return{payload:this.requestBodiesByContentType?.["application/json"]?.schema?.example({includeOptionals:!0,override:void 0})}}};var H8h={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Switch Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"};function K8h(e,t){if(eg(e)){let r=zL(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var Qwu=ce(bM());var J8h="application/json";var $8h="application/octet-stream";function Y8h(e,t){return e===t||t===FF||e===FF}var uXa=class extends mo{streamingFormat;path;method;statusCode;requests;shapes;schema;contentType;unsupportedContentType;contentSubtype;examples;empty;constructor(t,r,i,n,a,o,c,d){super(t),this.streamingFormat=i,this.path=n,this.method=a,this.statusCode=o,this.requests=c,this.shapes=d,this.safeParse(r)}matchRequestResponseExamplesByName(t,r,i){for(let n of t)for(let[a,o]of Object.entries(n?.examples??{}))for(let[c,d]of Object.entries(r))for(let s of d)Y8h(c,a)&&(i.add(c),this.examples?.push(new RXt({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,TYi(a,c),{requestBody:n,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}matchExamplesByIndex(t,r){let i=0;for(let n of t){let a=0;for(let[o,c]of r){if(a===i){let[d,s,u]=n??[void 0,void 0,void 0];this.examples?.push(...c.map(l=>new RXt({input:{requestExample:u,responseExample:l},context:this.context,accessPath:this.accessPath,pathId:s!=null&&s!==""?["examples",s]:"examples"},this.path,this.statusCode,TYi(s,o),{requestBody:d,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}a++}i++}if(t.length>r.length)for(let n of t.slice(r.length)){let[a,o]=r[r.length-1]??[void 0,void 0],[c,d,s]=n??[void 0,void 0,void 0];this.examples?.push(...(o??[void 0]).map(u=>new RXt({input:{requestExample:s,responseExample:u},context:this.context,accessPath:this.accessPath,pathId:d!=null&&d!==""?["examples",d]:"examples"},this.path,this.statusCode,TYi(d,a),{requestBody:c,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}if(r.length>t.length){let[n,a,o]=t[t.length-1]??[void 0,void 0,void 0];for(let[c,d]of r.slice(t.length))this.examples?.push(...d.map(s=>new RXt({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,TYi(a,c),{requestBody:n,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}}pushResponseExample(t,r,i,n){let a=t[FF];if(a!=null)for(let o of a)this.examples?.push(new RXt({input:{requestExample:n,responseExample:o},context:this.context,accessPath:this.accessPath,pathId:i!=null&&i!==""?["examples",i]:"examples"},this.path,this.statusCode,TYi(i,void 0),{requestBody:r,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders}))}addGlobalFallbackExample(t,r){if(t==null||t.length===0)this.pushResponseExample(r,void 0,void 0,void 0);else for(let i of t)if(Object.keys(i.examples??{}).length===0)this.pushResponseExample(r,i,void 0,void 0);else for(let[n,a]of Object.entries(i.examples??{}))this.pushResponseExample(r,i,n,a)}parse(t){if(t==="empty")this.empty=!0;else{let c=vla.parse(t);if(c?.isJSON()||c?.isEventStream())this.contentType=J8h,this.input.schema==null?(this.streamingFormat==null||this.streamingFormat==="json")&&this.context.errors.error({message:"Expected schema for JSON response body. Received null",path:this.accessPath}):this.schema=new _w({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"type",seenSchemas:new Set,nullable:void 0,schemaName:"Response Body"});else if(c?.isOctetStream())this.contentType=$8h,this.contentSubtype=TC(this.input.schema,this.context.document)?.contentMediaType;else if(this.unsupportedContentType=t,this.input.schema==null){this.context.errors.error({message:"Expected schema for plain text response body. Received null",path:this.accessPath});return}else this.schema=new _w({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:new Set,nullable:void 0,schemaName:"Response Body"})}let r={};this.input.examples!=null&&(r=fwu(this.input.examples,c=>[c])),this.input.example!=null&&Object.keys(r).length===0&&(r[FF]??=[],r[FF]=[{value:this.input.example}]);let i=TC(this.input.schema,this.context.document);if(i!=null&&(i.examples!=null&&Object.keys(r).length===0&&(r=fwu(i.examples,c=>[c])),i.example!=null&&Object.keys(r).length===0&&(r[FF]??=[],r[FF]?.push({value:i.example}))),Object.keys(r).length===0){let c=this.schema?.example({includeOptionals:!0,override:void 0});r[FF]??=[],r[FF]?.push(c!=null?{value:c}:void 0)}this.examples??=[];let n=new Set;this.matchRequestResponseExamplesByName(this.requests,r,n);let a=[];for(let c of this.requests)a.push(...Object.entries(c.examples??{}).filter(([d])=>!n.has(d)&&d!==FF).map(([d,s])=>[c,d,s]));let o=Object.entries(r).filter(([c,d])=>!n.has(c)&&Ho(d)&&c!==FF);Object.keys(r).every(c=>c===FF)||this.matchExamplesByIndex(a,o),!n.has(FF)&&this.examples.length===0&&this.addGlobalFallbackExample(this.requests,r),this.examples.length===0&&(this.examples=void 0)}convertStreamingFormat(){switch(this.streamingFormat){case"json":return tj(this.schema?.convert())?.map(r=>({type:"stream",terminator:"[DATA]",shape:r}));case"sse":return{type:"streamingText"};case void 0:return;default:new Qwu.UnreachableCaseError(this.streamingFormat);return}}convertJsonLike(){return tj(this.schema?.convert())?.map(r=>{let i=r.type;switch(i){case"alias":return r;case"discriminatedUnion":case"undiscriminatedUnion":case"enum":{let n=sWt([this.method,this.path,this.statusCode,"response"].join("_"));return Twu({uniqueId:n,type:r,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:uc.TypeId(n),default:r.type==="enum"&&r.default!=null?{type:"enum",value:r.default}:void 0}}}case"object":return r;default:new Qwu.UnreachableCaseError(i);return}}).filter(Ho)}convert(){if(this.empty)return{type:"empty"};if(this.contentType!=null)switch(this.contentType){case"application/json":return this.streamingFormat==null?this.convertJsonLike():this.convertStreamingFormat();case"application/octet-stream":return{type:"fileDownload",contentType:this.contentSubtype};case"text/event-stream":return this.convertStreamingFormat();case void 0:return;default:new Qwu.UnreachableCaseError(this.contentType);return}else return this.unsupportedContentType!=null?this.convertJsonLike():void 0}};var sXa=class extends mo{path;method;statusCode;requests;shapes;headers;responses;description;constructor(t,r,i,n,a,o){super(t),this.path=r,this.method=i,this.statusCode=n,this.requests=a,this.shapes=o,this.safeParse()}parse(t){this.description=this.input.description;let r=K8h(this.input,this.context.document);if(r==null){this.context.errors.error({message:eg(this.input)?`Undefined reference: ${this.input.$ref}`:"Expected response, received null",path:this.accessPath});return}Object.entries(r.headers??{}).forEach(([i,n])=>{this.headers??={},this.headers[i]=new zXt({input:n,context:this.context,accessPath:this.accessPath,pathId:"headers",parameterName:i})}),r.content==null?(this.responses??=[],this.responses.push(new uXa({input:{},context:this.context,accessPath:this.accessPath,pathId:["content"]},"empty",t,this.path,this.method,this.statusCode,this.requests,this.shapes))):Object.entries(r.content??{}).forEach(([i,n])=>{this.responses??=[],this.responses.push(new uXa({input:n,context:this.context,accessPath:this.accessPath,pathId:["content",i]},i,t,this.path,this.method,this.statusCode,this.requests,this.shapes))})}convert(){return this.responses?.flatMap(t=>t.convert()).filter(Ho)}};var Uwu=class extends mo{path;method;requests;shapes;responsesByStatusCode;errorsByStatusCode;constructor(t,r,i,n,a){super(t),this.path=r,this.method=i,this.requests=n,this.shapes=a,this.safeParse()}parse(){let t=this.input.default;Object.entries(this.input).forEach(([r,i])=>{r!=="default"&&(parseInt(r)>=400?(this.errorsByStatusCode??={},this.errorsByStatusCode[r]=new sXa({input:{...t,...i},context:this.context,accessPath:this.accessPath,pathId:"errors"},this.path,this.method,parseInt(r),[],this.shapes)):(this.responsesByStatusCode??={},this.responsesByStatusCode[r]=new sXa({input:i,context:this.context,accessPath:this.accessPath,pathId:"responses"},this.path,this.method,parseInt(r),this.requests,this.shapes)))})}convertResponseObjectToHttpResponses(){return Object.entries(this.responsesByStatusCode??{}).flatMap(([t,r])=>{let i=r.convert();if(i!=null)return Ewu(QYi(r.headers)).flatMap(n=>i?.map(a=>({headers:n,response:{statusCode:parseInt(t),body:a,description:r.description},examples:(r.responses??[]).flatMap(o=>(o.examples??[]).map(c=>c.convert()).filter(Ho))})))}).filter(Ho)}convertResponseObjectToErrors(){return Object.entries(this.errorsByStatusCode??{}).flatMap(([t,r])=>r.responses?.flatMap(i=>{let n=i.schema,a=tj(n?.convert());if(n!=null)return a?.map(o=>({statusCode:parseInt(t),shape:o,description:r.description??n.description,availability:n.availability?.convert(),name:n.name??H8h[parseInt(t)]??"UNKNOWN ERROR",examples:i.examples?.map(c=>{let d=c.convert();if(d!=null&&d.responseBody?.type==="json")return{name:d.name,description:d.description,responseBody:d.responseBody}}).filter(Ho)})).filter(Ho)})).filter(Ho)}convert(){return{responses:this.convertResponseObjectToHttpResponses(),errors:this.convertResponseObjectToErrors()}}};var UYi=class extends mo{servers;globalAuth;path;method;basePath;isWebhook;endpointIds;description;displayName;operationId;pathParameters;queryParameters;requestHeaders;requests;responses;availability;auth;namespaces;xFernExamplesNode;redocExamplesNode;emptyResponseExamples;constructor(t){super(t),this.servers=t.servers,this.globalAuth=t.globalAuth,this.path=t.path,this.method=t.method,this.basePath=t.basePath,this.isWebhook=t.isWebhook,this.safeParse()}pushEmptyResponseExample(t,r,i){this.emptyResponseExamples??=[],this.emptyResponseExamples.push(new RXt({input:{requestExample:t,responseExample:void 0},context:this.context,accessPath:this.accessPath,pathId:"examples"},this.path,200,TYi(i,void 0),{requestBody:r,pathParameters:this.pathParameters,queryParameters:this.queryParameters,requestHeaders:this.requestHeaders}))}parse(){if(this.isWebhook&&this.method!=="POST"&&this.method!=="GET"){this.context.errors.error({message:`Webhook method must be POST or GET. Received: ${this.method}`,path:this.accessPath});return}this.description=this.input.description,this.displayName=this.input.summary,this.operationId=this.input.operationId,this.availability=new NSe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),this.servers=CYi(this.servers,this.input.servers,this.context,this.accessPath),this.isWebhook=new mwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}).isWebhook||this.isWebhook,this.input.parameters?.map((i,n)=>{if(eg(i)){let a=ywu(i,this.context.document);if(a!=null)i=a;else{this.context.errors.warning({message:`Expected parameter reference to resolve to an object. Received undefined reference: ${i.$ref}`,path:[...this.accessPath,`parameters[${n}]`]});return}}i.in==="path"?i.schema!=null&&(this.pathParameters??={},this.pathParameters[i.name]=new zXt({input:i,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${n}`],parameterName:i.name})):i.in==="query"?i.schema!=null&&(this.queryParameters??={},this.queryParameters[i.name]=new zXt({input:i,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${n}`],parameterName:i.name})):i.in==="header"&&i.schema!=null&&(this.requestHeaders??={},this.requestHeaders[i.name]=new zXt({input:i,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${n}`],parameterName:i.name}))});for(let i of this.extractPathParameterIds()??[])this.pathParameters?.[i]==null&&this.context.errors.warning({message:`Path parameter not defined: ${i}`,path:[...this.accessPath,"parameters"]});if(this.redocExamplesNode=new Awu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-code-samples"}),this.requests=this.input.requestBody!=null?new Fwu({input:this.input.requestBody,context:this.context,accessPath:this.accessPath,pathId:"requestBody",method:this.method,path:this.path}):void 0,this.responses=this.input.responses!=null?new Uwu({input:this.input.responses,context:this.context,accessPath:this.accessPath,pathId:"responses"},this.path,this.method,Object.values(this.requests?.requestBodiesByContentType??{}),{pathParameters:this.pathParameters,queryParameters:this.queryParameters,requestHeaders:this.requestHeaders}):void 0,this.responses==null){let i=this.requests?.requestBodiesByContentType;i==null||Object.keys(i).length===0?this.pushEmptyResponseExample(void 0,void 0,void 0):Object.values(i).forEach(n=>{if(Object.keys(n.examples??{}).length===0){let a=n.schema?.example({includeOptionals:!1,override:void 0});a!=null&&this.pushEmptyResponseExample({value:a},n,void 0)}else Object.entries(n.examples??{}).forEach(([a,o])=>{this.pushEmptyResponseExample(o,n,a)})})}let t=200;this.responses?.responsesByStatusCode!=null&&(t=Number(Object.keys(this.responses.responsesByStatusCode)?.filter(i=>Number(i)>=200&&Number(i)<300)[0])),this.globalAuth!=null&&(this.auth=this.globalAuth),this.input.security!=null&&(this.auth=new _la({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"})),this.namespaces=[new oXa({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-group-name"})],this.namespaces?.every(i=>i.groupName==null)&&this.input.tags!=null&&(this.namespaces=this.input.tags.slice(0,1).map((i,n)=>new oXa({input:{[V0u]:i},context:this.context,accessPath:this.accessPath,pathId:["tags",`${n}`]})));let r=new Owu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-sdk-method-name"});this.endpointIds=this.namespaces.map(i=>dwu({namespace:tj(i?.groupName),path:this.path,method:this.method,sdkMethodName:r.sdkMethodName,operationId:this.input.operationId,displayName:this.displayName,isWebhook:this.isWebhook})).filter(Ho),this.xFernExamplesNode=new gwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-examples"},this.path,t,this.requests?.requestBodiesByContentType,this.responses?.responsesByStatusCode?.[t]?.responses)}extractPathParameterIds(){if(this.path!=null)return this.path.split("/").map(t=>{if(t.startsWith("{")&&t.endsWith("}"))return t.slice(1,-1).trim()}).filter(Ho)}convertPathToPathParts(){if(this.path===void 0)return;let t=this.path.startsWith("/")?this.path.slice(1):this.path,r=this.basePath?.convert();return(r?[r,...t.split("/")]:t.split("/")).reduce((n,a)=>(n.push({type:"literal",value:"/"}),a.startsWith("{")&&a.endsWith("}")?n.push({type:"pathParameter",value:uc.PropertyKey(a.slice(1,-1).trim())}):n.push({type:"literal",value:a}),n),[])}convert(){if(this.path==null||this.endpointIds==null)return;let{responses:t,errors:r}=this.responses?.convert()??{responses:void 0,errors:void 0},i=this.emptyResponseExamples?.map(u=>u.convert()).filter(Ho),n=A8h(this.xFernExamplesNode?.convert(),[...i??[],...t?.flatMap(u=>u.examples)??[]])?.map(u=>({...u,snippets:m8h(u.snippets,this.redocExamplesNode?.convert())}));if(this.isWebhook)return this.endpointIds.map((u,l)=>{if(!(this.method!=="POST"&&this.method!=="GET"))return{id:uc.WebhookId(u),description:this.description,availability:this.availability?.convert(),displayName:this.displayName,operationId:this.operationId,namespace:this.namespaces?.[l]?.convert(),method:this.method,path:this.convertPathToPathParts()?.map(p=>p.value.toString())??[],queryParameters:QYi(this.queryParameters)?.flat(),headers:QYi(this.requestHeaders)?.flat(),payloads:this.requests?.convertToWebhookPayload(),examples:[this.requests?.webhookExample()].filter(Ho)}}).filter(Ho);let a=this.servers?.map(u=>u.convert()).filter(Ho),o=this.convertPathToPathParts();if(o==null)return;let c,d=this.auth?.convert();d!=null&&(c=Object.keys(d));let s=t?.flatMap(u=>u.headers).filter(Ho);return this.endpointIds.map((u,l)=>({id:uc.EndpointId(u),description:this.description,availability:this.availability?.convert(),namespace:this.namespaces?.[l]?.convert()?.map(p=>uc.api.v1.SubpackageId(p)),displayName:this.displayName,operationId:this.operationId,method:this.method,path:o,auth:c?.map(p=>uc.api.latest.AuthSchemeId(p)),defaultEnvironment:a?.[0]?.id,environments:a,pathParameters:QYi(this.pathParameters)?.flat(),queryParameters:QYi(this.queryParameters)?.flat(),requestHeaders:QYi(this.requestHeaders)?.flat(),responseHeaders:s!=null&&s.length>0?s:void 0,requests:this.requests?.convert(),responses:t?.map(p=>p.response),errors:r,examples:n,snippetTemplates:void 0,protocol:{type:"rest"}}))}};var gla=class extends mo{description;get;post;put;patch;delete;path;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:i,isWebhook:n}){this.description=this.input.description;let a=CYi(t,this.input.servers,this.context,this.accessPath),o=Array.isArray(this.pathId)?this.pathId.join("/"):this.pathId;this.input.get!=null&&(this.get=new UYi({input:this.input.get,context:this.context,accessPath:this.accessPath,pathId:"get",servers:a,globalAuth:r,path:o,method:"GET",basePath:i,isWebhook:n})),this.input.post!=null&&(this.post=new UYi({input:this.input.post,context:this.context,accessPath:this.accessPath,pathId:"post",servers:a,globalAuth:r,path:o,method:"POST",basePath:i,isWebhook:n})),this.input.put!=null&&(this.put=new UYi({input:this.input.put,context:this.context,accessPath:this.accessPath,pathId:"put",servers:a,globalAuth:r,path:o,method:"PUT",basePath:i,isWebhook:!1})),this.input.patch!=null&&(this.patch=new UYi({input:this.input.patch,context:this.context,accessPath:this.accessPath,pathId:"patch",servers:a,globalAuth:r,path:o,method:"PATCH",basePath:i,isWebhook:!1})),this.input.delete!=null&&(this.delete=new UYi({input:this.input.delete,context:this.context,accessPath:this.accessPath,pathId:"delete",servers:a,globalAuth:r,path:o,method:"DELETE",basePath:i,isWebhook:!1}))}convert(){return[...this.get?.convert()??[],...this.post?.convert()??[],...this.put?.convert()??[],...this.patch?.convert()??[],...this.delete?.convert()??[]].filter(Ho)}};function Lwu(e){return"payloads"in e}var Vwu=class extends mo{paths;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:i}){this.paths=Object.entries(this.input).map(([n,a])=>{if(a!=null)return new gla({input:a,context:this.context,accessPath:this.accessPath,pathId:n,servers:CYi(t,a.servers,this.context,this.accessPath),globalAuth:r,basePath:i,isWebhook:void 0})}).filter(Ho)}convert(){if(this.paths==null)return;let t={},r={};return this.paths.forEach(i=>{let n=i.convert();n?.forEach(a=>{Lwu(a)?r[uc.WebhookId(a.id)]=a:t[uc.EndpointId(a.id)]=a})}),{endpoints:t,webhookEndpoints:r}}};var Wwu=class extends mo{globalHeaders;requiredProperties;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[h3h]?.map(r=>{let{header:i,...n}=r;return(n.optional!=null&&!n.optional||ywu(n,this.context.document)?.required)&&(this.requiredProperties??=[],this.requiredProperties?.push(i)),[i,new zXt({input:n,context:this.context,accessPath:this.accessPath,pathId:this.pathId,parameterName:i})]});t!=null&&(this.globalHeaders=Object.fromEntries(t))}convert(){return hla(this.globalHeaders,this.requiredProperties)?.flat()}};function X8h(e,t){if(eg(e)){let r=zL(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var Gwu=class extends mo{webhooks;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:i}){this.webhooks=Object.entries(this.input??{}).map(([n,a])=>{let o=X8h(a,this.context.document);if(o!=null)return new gla({input:o,context:this.context,accessPath:this.accessPath,pathId:n,servers:t,globalAuth:r,basePath:i,isWebhook:!0})}).filter(Ho)}convert(){return this.webhooks?.reduce((t,r)=>(r.convert()?.forEach(i=>{Lwu(i)&&(t[uc.WebhookId(i.id)]=i)}),t),{})}};var xwu=class extends mo{paths;webhooks;components;auth;globalHeaders;constructor(t){super(t),this.safeParse()}parse(){let t=CYi(void 0,this.input.servers,this.context,this.accessPath);this.input.security!=null&&(this.auth=new _la({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"}));let r=new hwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});this.input.paths==null&&this.input.webhooks==null&&this.context.errors.warning({message:"Expected 'paths' or 'webhooks' property to be specified",path:this.accessPath}),this.input.paths!=null&&(this.paths=new Vwu({input:this.input.paths,context:this.context,accessPath:this.accessPath,pathId:"paths",basePath:r,servers:t,globalAuth:this.auth})),this.input.webhooks!=null&&(this.webhooks=new Gwu({input:this.input.webhooks,context:this.context,accessPath:this.accessPath,pathId:"webhooks",basePath:r,servers:t,globalAuth:this.auth})),this.input.components!=null&&(this.components=new Rwu({input:this.input.components,context:this.context,accessPath:this.accessPath,pathId:"components"})),this.globalHeaders=new Wwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-global-headers"})}convert(){let t=Lve(),{webhookEndpoints:r,endpoints:i}=this.paths?.convert()??{},n={...this.webhooks?.convert()??{},...r??{}},a=f3h({endpoints:i,webhookEndpoints:n}),{types:o,auths:c}=this.components?.convert()??{};return{id:uc.ApiDefinitionId(t),endpoints:i??{},websockets:{},webhooks:n,types:{...o,...this.context.generatedTypes},subpackages:a,auths:{...c,...this.auth?.convert()??{}},globalHeaders:this.globalHeaders?.convert(),snippetsConfiguration:void 0}}};async function hil(e,t){if(e instanceof ESe){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof jS))return;let r=new Y8t(e.absoluteFilePath),i=await MSe({context:t,specs:e.specs}),n=await r.loadDocuments({context:t,specs:i}),a;for(let o of n){if(o.type!=="openapi")continue;let c={document:o.value,logger:t.logger,errors:new U0u,generatedTypes:{}},d=new xwu({input:o.value,context:c,accessPath:[],pathId:e.workspaceName??"openapi parser"});a=j$n(a,d.convert())}return a}var hYh=ce(vil(),1),yYh=ce(qEu(),1),iMu=require("fs/promises"),bYh=ce(require("http"),1),vYh=ce(require("path"),1);var txh=require("events"),FEu=ce(require("fs"),1),mOn=ce(require("path"),1);var NGh=ce(require("os"),1),FGh=300,KYi=20,IXa=1e7,QGh=NGh.default.platform();var jzB=QGh==="darwin",Fnl=QGh==="win32",JYi=jzB||Fnl,UGh=3e3,LGh=2e4,Qnl=1250;var UXt;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(UXt||(UXt={}));var OOn;(function(e){e.CHANGE="change",e.RENAME="rename"})(OOn||(OOn={}));var CXa;(function(e){e.CHANGE="change",e.ERROR="error"})(CXa||(CXa={}));var rf;(function(e){e.ADD="add",e.ADD_DIR="addDir",e.CHANGE="change",e.RENAME="rename",e.RENAME_DIR="renameDir",e.UNLINK="unlink",e.UNLINK_DIR="unlinkDir"})(rf||(rf={}));var Vx;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(Vx||(Vx={}));var wzB=(e,t=1,r)=>{t=Math.max(1,t);let i=r?.leading??!1,n=r?.trailing??!0,a=Math.max(r?.maxWait??1/0,t),o,c,d=0,s=0,u=()=>{let g=Date.now(),A=g-d,j=g-s,M=A>=t||j>=a;return[g,M]},l=g=>{if(s=g,!o)return;let A=o;o=void 0,e.apply(void 0,A)},p=()=>{O(0)},_=()=>{c&&(p(),l(Date.now()))},h=g=>{if(s=g,i)return l(g)},y=g=>{if(n&&o)return l(g);o=void 0},b=()=>{c=void 0;let[g,A]=u();return A?y(g):v(g)},v=g=>{let A=g-d,j=g-s,M=t-A,w=a-j,D=Math.min(M,w);return O(D)},O=g=>{c&&clearTimeout(c),!(g<=0)&&(c=setTimeout(b,g))},m=(...g)=>{let[A,j]=u(),M=!!c;if(o=g,d=A,(j||!c)&&O(t),j)return M?l(A):h(A)};return m.cancel=p,m.flush=_,m},TEu=wzB;var Wnl=ce(require("fs"),1),zEu=ce(require("path"),1);var fm=ce(require("fs"),1),NL=require("util");var I4i=(e,t)=>function(...i){return e.apply(void 0,i).catch(t)},LXt=(e,t)=>function(...i){try{return e.apply(void 0,i)}catch(n){return t(n)}};var Unl=ce(require("process"),1),VGh=Unl.default.getuid?!Unl.default.getuid():!1,WGh=1e4,UY=()=>{};var qXa={isChangeErrorOk:e=>{if(!qXa.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!VGh&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!qXa.isNodeError(e))return!1;let{code:t}=e;return t==="EMFILE"||t==="ENFILE"||t==="EAGAIN"||t==="EBUSY"||t==="EACCESS"||t==="EACCES"||t==="EACCS"||t==="EPERM"},onChangeError:e=>{if(!qXa.isNodeError(e))throw e;if(!qXa.isChangeErrorOk(e))throw e}},RC=qXa;var Lnl=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=WGh,this.queueActive=new Set,this.queueWaiting=new Set,this.init=()=>{this.intervalId||(this.intervalId=setInterval(this.tick,this.interval))},this.reset=()=>{this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId)},this.add=t=>{this.queueWaiting.add(t),this.queueActive.size<this.limit/2?this.tick():this.init()},this.remove=t=>{this.queueWaiting.delete(t),this.queueActive.delete(t)},this.schedule=()=>new Promise(t=>{let r=()=>this.remove(i),i=()=>t(r);this.add(i)}),this.tick=()=>{if(!(this.queueActive.size>=this.limit)){if(!this.queueWaiting.size)return this.reset();for(let t of this.queueWaiting){if(this.queueActive.size>=this.limit)break;this.queueWaiting.delete(t),this.queueActive.add(t),t()}}}}},GGh=new Lnl;var C4i=(e,t)=>function(i){return function n(...a){return GGh.schedule().then(o=>{let c=s=>(o(),s),d=s=>{if(o(),Date.now()>=i)throw s;if(t(s)){let u=Math.round(100*Math.random());return new Promise(p=>setTimeout(p,u)).then(()=>n.apply(void 0,a))}throw s};return e.apply(void 0,a).then(c,d)})}},q4i=(e,t)=>function(i){return function n(...a){try{return e.apply(void 0,a)}catch(o){if(Date.now()>i)throw o;if(t(o))return n.apply(void 0,a);throw o}}};var EzB={attempt:{chmod:I4i((0,NL.promisify)(fm.default.chmod),RC.onChangeError),chown:I4i((0,NL.promisify)(fm.default.chown),RC.onChangeError),close:I4i((0,NL.promisify)(fm.default.close),UY),fsync:I4i((0,NL.promisify)(fm.default.fsync),UY),mkdir:I4i((0,NL.promisify)(fm.default.mkdir),UY),realpath:I4i((0,NL.promisify)(fm.default.realpath),UY),stat:I4i((0,NL.promisify)(fm.default.stat),UY),unlink:I4i((0,NL.promisify)(fm.default.unlink),UY),chmodSync:LXt(fm.default.chmodSync,RC.onChangeError),chownSync:LXt(fm.default.chownSync,RC.onChangeError),closeSync:LXt(fm.default.closeSync,UY),existsSync:LXt(fm.default.existsSync,UY),fsyncSync:LXt(fm.default.fsync,UY),mkdirSync:LXt(fm.default.mkdirSync,UY),realpathSync:LXt(fm.default.realpathSync,UY),statSync:LXt(fm.default.statSync,UY),unlinkSync:LXt(fm.default.unlinkSync,UY)},retry:{close:C4i((0,NL.promisify)(fm.default.close),RC.isRetriableError),fsync:C4i((0,NL.promisify)(fm.default.fsync),RC.isRetriableError),open:C4i((0,NL.promisify)(fm.default.open),RC.isRetriableError),readFile:C4i((0,NL.promisify)(fm.default.readFile),RC.isRetriableError),rename:C4i((0,NL.promisify)(fm.default.rename),RC.isRetriableError),stat:C4i((0,NL.promisify)(fm.default.stat),RC.isRetriableError),write:C4i((0,NL.promisify)(fm.default.write),RC.isRetriableError),writeFile:C4i((0,NL.promisify)(fm.default.writeFile),RC.isRetriableError),closeSync:q4i(fm.default.closeSync,RC.isRetriableError),fsyncSync:q4i(fm.default.fsyncSync,RC.isRetriableError),openSync:q4i(fm.default.openSync,RC.isRetriableError),readFileSync:q4i(fm.default.readFileSync,RC.isRetriableError),renameSync:q4i(fm.default.renameSync,RC.isRetriableError),statSync:q4i(fm.default.statSync,RC.isRetriableError),writeSync:q4i(fm.default.writeSync,RC.isRetriableError),writeFileSync:q4i(fm.default.writeFileSync,RC.isRetriableError)}},xGh=EzB;var REu=ce(require("fs"),1),TXa=ce(require("path"),1);var Vnl=()=>{};var SzB=()=>{let e=Vnl,t=Vnl,r=!1,i=!1;return{promise:new Promise((d,s)=>{e=u=>(r=!0,d(u)),t=u=>(i=!0,s(u))}),resolve:e,reject:t,isPending:()=>!r&&!i,isResolved:()=>r,isRejected:()=>i}},HGh=SzB;var MzB=()=>{let{promise:e,resolve:t,isPending:r}=HGh(),i=0,n=()=>{i+=1},a=()=>{i-=1,!i&&t()};return(()=>{n(),queueMicrotask(a)})(),{promise:e,isPending:r,increment:n,decrement:a}},KGh=MzB;var JGh={then:e=>{e()}};var $Gh=e=>Array.isArray(e)?e:[e],YGh=e=>typeof e=="function";var DzB=(e,t)=>{let r=t?.followSymlinks??!1,i=t?.depth??1/0,n=t?.limit??1/0,a=t?.ignore??[],o=$Gh(a).map(W=>YGh(W)?W:x=>W.test(x)),c=W=>o.some(x=>x(W)),d=t?.signal??{aborted:!1},s=t?.onDirents||(()=>{}),u=[],l=new Set,p={},_=[],h=new Set,y={},b=[],v=new Set,O={},m={},g=new Set,A={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{},map:{}},j={directories:u,directoriesNames:l,directoriesNamesToPaths:p,files:_,filesNames:h,filesNamesToPaths:y,symlinks:b,symlinksNames:v,symlinksNamesToPaths:O,map:m},{promise:M,increment:w,decrement:D}=KGh(),B=0,T=(W,x,Ee,ue)=>{g.has(x)||B>=n||(B+=1,W.directories.push(x),W.directoriesNames.add(Ee),u.push(x),l.add(Ee),p.propertyIsEnumerable(Ee)||(p[Ee]=[]),p[Ee].push(x),g.add(x),!(ue>=i)&&(B>=n||Y(x,ue+1)))},R=(W,x,Ee)=>{g.has(x)||B>=n||(B+=1,W.files.push(x),W.filesNames.add(Ee),_.push(x),h.add(Ee),y.propertyIsEnumerable(Ee)||(y[Ee]=[]),y[Ee].push(x),g.add(x))},q=(W,x,Ee,ue)=>{g.has(x)||B>=n||(B+=1,W.symlinks.push(x),W.symlinksNames.add(Ee),b.push(x),v.add(Ee),O.propertyIsEnumerable(Ee)||(O[Ee]=[]),O[Ee].push(x),g.add(x),r&&(ue>=i||B>=n||he(x,ue+1)))},z=(W,x,Ee,ue,Oe)=>{d.aborted||c(x)||(ue.isDirectory()?T(W,x,Ee,Oe):ue.isFile()?R(W,x,Ee):ue.isSymbolicLink()&&q(W,x,Ee,Oe))},Q=(W,x,Ee,ue)=>{if(d.aborted)return;let Oe=x===TXa.default.sep?"":TXa.default.sep,Fe=Ee.name,ae=`${x}${Oe}${Fe}`;c(ae)||(Ee.isDirectory()?T(W,ae,Fe,ue):Ee.isFile()?R(W,ae,Fe):Ee.isSymbolicLink()&&q(W,ae,Fe,ue))},H=(W,x,Ee,ue)=>{for(let Oe=0,Fe=Ee.length;Oe<Fe;Oe++)Q(W,x,Ee[Oe],ue)},Y=(W,x)=>{d.aborted||x>i||B>=n||(w(),REu.default.readdir(W,{withFileTypes:!0},(Ee,ue)=>{if(Ee||d.aborted||!ue.length)return D();(s(ue)||JGh).then(()=>{let Fe=m[W]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};H(Fe,W,ue,x),D()})}))},he=(W,x)=>{w(),REu.default.realpath(W,(Ee,ue)=>{if(Ee||d.aborted)return D();REu.default.stat(ue,(Oe,Fe)=>{if(Oe||d.aborted)return D();let ae=TXa.default.basename(ue),re=m[W]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};z(re,ue,ae,Fe,x),D()})})};return(async(W,x=1)=>(W=TXa.default.normalize(W),g.add(W),Y(W,x),await M,d.aborted?A:j))(e)},XGh=DzB;var VXt={lang:{debounce:TEu,attempt:e=>{try{return e()}catch(t){return VXt.lang.castError(t)}},castArray:e=>VXt.lang.isArray(e)?e:[e],castError:e=>VXt.lang.isError(e)?e:VXt.lang.isString(e)?new Error(e):new Error("Unknown error"),defer:e=>setTimeout(e,0),isArray:e=>Array.isArray(e),isError:e=>e instanceof Error,isFunction:e=>typeof e=="function",isNaN:e=>Number.isNaN(e),isNumber:e=>typeof e=="number",isPrimitive:e=>{if(e===null)return!0;let t=typeof e;return t!=="object"&&t!=="function"},isShallowEqual:(e,t)=>{if(e===t)return!0;if(VXt.lang.isNaN(e))return VXt.lang.isNaN(t);if(VXt.lang.isPrimitive(e)||VXt.lang.isPrimitive(t))return e===t;for(let r in e)if(!(r in t))return!1;for(let r in t)if(e[r]!==t[r])return!1;return!0},isSet:e=>e instanceof Set,isString:e=>typeof e=="string",isUndefined:e=>e===void 0,noop:()=>{},uniq:e=>e.length<2?e:Array.from(new Set(e))},fs:{getDepth:e=>Math.max(0,e.split(zEu.default.sep).length-1),getRealPath:(e,t)=>{try{return t?Wnl.default.realpathSync.native(e):Wnl.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===zEu.default.sep&&t.length-e.length>zEu.default.sep.length,poll:(e,t=LGh)=>xGh.retry.stat(t)(e,{bigint:!0}).catch(VXt.lang.noop),readdir:async(e,t,r=1/0,i=1/0,n,a)=>{if(a&&r===1&&e in a){let o=a[e];return[o.directories,o.files]}else{let o=await XGh(e,{depth:r,limit:i,ignore:t,signal:n});return[o.directories,o.files]}}}},Gp=VXt;var NEu=ce(require("path"),1);var Gnl=class{constructor(t,r,i){this.base=i,this.watcher=t,this.handler=r.handler,this.fswatcher=r.watcher,this.options=r.options,this.folderPath=r.folderPath,this.filePath=r.filePath,this.handlerBatched=this.base?this.base.onWatcherEvent.bind(this.base):this._makeHandlerBatched(this.options.debounce)}_isSubRoot(t){return this.filePath?t===this.filePath:t===this.folderPath||Gp.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=FGh){return(()=>{let r=this.watcher._readyWait,i=[],n=new Set,a=async(c,d)=>{let s=this.options.ignoreInitial?[]:c,u=await this.eventsPopulate([...d]),l=this.eventsDeduplicate([...s,...u]);this.onTargetEvents(l)},o=Gp.lang.debounce(()=>{this.watcher.isClosed()||(r=a(i,n),i=[],n=new Set)},t);return async(c,d="",s=!1)=>{s?await this.eventsPopulate([d],i,!0):n.add(d),r.then(o)}})()}eventsDeduplicate(t){if(t.length<2)return t;let r={};return t.reduce((i,n)=>{let[a,o]=n,c=r[o];return a===c||a===rf.CHANGE&&c===rf.ADD||(r[o]=a,i.push(n)),i},[])}async eventsPopulate(t,r=[],i=!1){return await Promise.all(t.map(async n=>{let a=await this.watcher._poller.update(n,this.options.pollingTimeout);await Promise.all(a.map(async o=>{r.push([o,n]),o===rf.ADD_DIR?await this.eventsPopulateAddDir(t,n,r,i):o===rf.UNLINK_DIR&&await this.eventsPopulateUnlinkDir(t,n,r,i)}))})),r}async eventsPopulateAddDir(t,r,i=[],n=!1){if(n)return i;let a=this.options.recursive?this.options.depth??KYi:Math.min(1,this.options.depth??KYi),o=this.options.limit??IXa,[c,d]=await Gp.fs.readdir(r,this.options.ignore,a,o,this.watcher._closeSignal),s=[...c,...d];return await Promise.all(s.map(u=>{if(!this.watcher.isIgnored(u,this.options.ignore)&&!t.includes(u))return this.eventsPopulate([u],i,!0)})),i}async eventsPopulateUnlinkDir(t,r,i=[],n=!1){if(n)return i;for(let a of this.watcher._poller.stats.keys())Gp.fs.isSubPath(r,a)&&(t.includes(a)||await this.eventsPopulate([a],i,!0));return i}onTargetAdd(t){this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAdd(t,this.options.renameTimeout):this.watcher.event(rf.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!JYi&&this.options.native!==!1&&this.watcher.watchDirectory(t,this.options,this.handler,void 0,this.base||this),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAddDir(t,this.options.renameTimeout):this.watcher.event(rf.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(rf.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(NEu.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(rf.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(NEu.default.dirname(t),t,!1),this.watcher.watchersClose(t),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlinkDir(t,this.options.renameTimeout):this.watcher.event(rf.UNLINK_DIR,t))}onTargetEvent(t){let[r,i]=t;r===rf.ADD?this.onTargetAdd(i):r===rf.ADD_DIR?this.onTargetAddDir(i):r===rf.CHANGE?this.onTargetChange(i):r===rf.UNLINK?this.onTargetUnlink(i):r===rf.UNLINK_DIR&&this.onTargetUnlinkDir(i)}onTargetEvents(t){for(let r of t)this.onTargetEvent(r)}onWatcherEvent(t,r,i=!1){return this.handlerBatched(t,r,i)}onWatcherChange(t=OOn.CHANGE,r){if(this.watcher.isClosed())return;let i=NEu.default.resolve(this.folderPath,r||"");this.filePath&&i!==this.folderPath&&i!==this.filePath||this.watcher.isIgnored(i,this.options.ignore)||this.onWatcherEvent(t,i)}onWatcherError(t){Fnl&&t.code==="EPERM"?this.onWatcherChange(OOn.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(CXa.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(CXa.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(OOn.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&JYi&&this.options.native!==!1?this.options.depth??KYi:Math.min(1,this.options.depth??KYi),i=this.options.limit??IXa,[n,a]=await Gp.fs.readdir(this.folderPath,this.options.ignore,r,i,this.watcher._closeSignal,this.options.readdirMap),o=[this.folderPath,...n,...a];await Promise.all(o.map(c=>{if(!this.watcher._poller.stats.has(c)&&!this.watcher.isIgnored(c,this.options.ignore))return this.onWatcherEvent(OOn.CHANGE,c,t)}))}}},ZGh=Gnl;var Wx={interval:100,intervalId:void 0,fns:new Map,init:()=>{Wx.intervalId||(Wx.intervalId=setInterval(Wx.resolve,Wx.interval))},reset:()=>{Wx.intervalId&&(clearInterval(Wx.intervalId),delete Wx.intervalId)},add:(e,t)=>{Wx.fns.set(e,Date.now()+t),Wx.init()},remove:e=>{Wx.fns.delete(e)},resolve:()=>{if(!Wx.fns.size)return Wx.reset();let e=Date.now();for(let[t,r]of Wx.fns)r>=e||(Wx.remove(t),t())}},RXa=Wx;var zXa=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=Qnl){let{ino:i,targetPath:n,events:a,locks:o}=t,c=()=>{let l=this._watcher._poller.paths.find(i||-1,p=>p!==n);if(l&&l!==n){if(Gp.fs.getRealPath(n,!0)===l)return;this._watcher.event(a.rename,l,n)}else this._watcher.event(a.add,n)};if(!i)return c();let d=()=>{o.add.delete(i),RXa.remove(s)},s=()=>{d(),c()};RXa.add(s,r);let u=()=>{let l=o.unlink.get(i);if(!l)return;d();let p=l();n===p?a.change&&this._watcher._poller.stats.has(n)&&this._watcher.event(a.change,n):this._watcher.event(a.rename,p,n)};o.add.set(i,u),u()}getLockUnlink(t,r=Qnl){let{ino:i,targetPath:n,events:a,locks:o}=t,c=()=>{this._watcher.event(a.unlink,n)};if(!i)return c();let d=()=>{o.unlink.delete(i),RXa.remove(s)},s=()=>{d(),c()};RXa.add(s,r);let u=()=>(d(),n);o.unlink.set(i,u),o.add.get(i)?.()}getLockTargetAdd(t,r){let i=this._watcher._poller.getIno(t,rf.ADD,UXt.FILE);return this.getLockAdd({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetAddDir(t,r){let i=this._watcher._poller.getIno(t,rf.ADD_DIR,UXt.DIR);return this.getLockAdd({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}getLockTargetUnlink(t,r){let i=this._watcher._poller.getIno(t,rf.UNLINK,UXt.FILE);return this.getLockUnlink({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetUnlinkDir(t,r){let i=this._watcher._poller.getIno(t,rf.UNLINK_DIR,UXt.DIR);return this.getLockUnlink({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}reset(){this._locksAdd=new Map,this._locksAddDir=new Map,this._locksUnlink=new Map,this._locksUnlinkDir=new Map,this._locksDir={add:this._locksAddDir,unlink:this._locksUnlinkDir},this._locksFile={add:this._locksAdd,unlink:this._locksUnlink}}};zXa.DIR_EVENTS={add:rf.ADD_DIR,rename:rf.RENAME_DIR,unlink:rf.UNLINK_DIR};zXa.FILE_EVENTS={add:rf.ADD,change:rf.CHANGE,rename:rf.RENAME,unlink:rf.UNLINK};var kGh=zXa;var xnl=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(Gp.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let i=this.map.get(t);if(Gp.lang.isSet(i)){let n=i.delete(r);return i.size||this.map.delete(t),n}else if(i===r)return this.map.delete(t),!0}return!1}find(t,r){if(this.map.has(t)){let i=this.map.get(t);if(Gp.lang.isSet(i))return Array.from(i).find(r);if(r(i))return i}}get(t){return this.map.get(t)}has(t,r){if(Gp.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let i=this.map.get(t);return Gp.lang.isSet(i)?i.has(r):i===r}return!1}set(t,r){if(this.map.has(t)){let i=this.map.get(t);Gp.lang.isSet(i)?i.add(r):i!==r&&this.map.set(t,new Set([i,r]))}else this.map.set(t,r);return this}},Hnl=xnl;var Knl=class{constructor(t){this.ino=t.ino<=Number.MAX_SAFE_INTEGER?Number(t.ino):t.ino,this.size=Number(t.size),this.atimeMs=Number(t.atimeMs),this.mtimeMs=Number(t.mtimeMs),this.ctimeMs=Number(t.ctimeMs),this.birthtimeMs=Number(t.birthtimeMs),this._isFile=t.isFile(),this._isDirectory=t.isDirectory(),this._isSymbolicLink=t.isSymbolicLink()}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isSymbolicLink(){return this._isSymbolicLink}},exh=Knl;var Jnl=class{constructor(){this.inos={},this.paths=new Hnl,this.stats=new Map}getIno(t,r,i){let n=this.inos[r];if(!n)return;let a=n[t];if(a&&!(i&&a[1]!==i))return a[0]}getStats(t){return this.stats.get(t)}async poll(t,r){let i=await Gp.fs.poll(t,r);if(!(!i||!(i.isFile()||i.isDirectory())))return new exh(i)}reset(){this.inos={},this.paths=new Hnl,this.stats=new Map}async update(t,r){let i=this.getStats(t),n=await this.poll(t,r);if(this.updateStats(t,n),!i&&n){if(n.isFile())return this.updateIno(t,rf.ADD,n),[rf.ADD];if(n.isDirectory())return this.updateIno(t,rf.ADD_DIR,n),[rf.ADD_DIR]}else if(i&&!n){if(i.isFile())return this.updateIno(t,rf.UNLINK,i),[rf.UNLINK];if(i.isDirectory())return this.updateIno(t,rf.UNLINK_DIR,i),[rf.UNLINK_DIR]}else if(i&&n){if(i.isFile()){if(n.isFile())return i.ino===n.ino&&!i.size&&!n.size?[]:(this.updateIno(t,rf.CHANGE,n),[rf.CHANGE]);if(n.isDirectory())return this.updateIno(t,rf.UNLINK,i),this.updateIno(t,rf.ADD_DIR,n),[rf.UNLINK,rf.ADD_DIR]}else if(i.isDirectory()){if(n.isFile())return this.updateIno(t,rf.UNLINK_DIR,i),this.updateIno(t,rf.ADD,n),[rf.UNLINK_DIR,rf.ADD];if(n.isDirectory())return i.ino===n.ino?[]:(this.updateIno(t,rf.UNLINK_DIR,i),this.updateIno(t,rf.ADD_DIR,n),[rf.UNLINK_DIR,rf.ADD_DIR])}}return[]}updateIno(t,r,i){let n=this.inos[r]=this.inos[r]||(this.inos[r]={}),a=i.isFile()?UXt.FILE:UXt.DIR;n[t]=[i.ino,a]}updateStats(t,r){if(r)this.paths.set(r.ino,t),this.stats.set(t,r);else{let i=this.stats.get(t)?.ino||-1;this.paths.delete(i,t),this.stats.delete(t)}}},$nl=Jnl;var Ynl=class e extends txh.EventEmitter{constructor(t,r,i){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(Vx.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(n=>this.on(Vx.CLOSE,n)),this._readyWait=new Promise(n=>this.on(Vx.READY,n)),this._locker=new kGh(this),this._roots=new Set,this._poller=new $nl,this._pollers=new Set,this._subwatchers=new Set,this._watchers={},this._watchersLock=Promise.resolve(),this._watchersRestorable={},this.watch(t,r,i)}isClosed(){return this._closed}isIgnored(t,r){return!!r&&(Gp.lang.isFunction(r)?!!r(t):r.test(t))}isReady(){return this._ready}close(){return this._locker.reset(),this._poller.reset(),this._roots.clear(),this.watchersClose(),this.isClosed()?!1:(this._closed=!0,this.emit(Vx.CLOSE))}error(t){if(this.isClosed())return!1;let r=Gp.lang.castError(t);return this.emit(Vx.ERROR,r)}event(t,r,i){return this.isClosed()?!1:(this.emit(Vx.ALL,t,r,i),this.emit(t,r,i))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(Vx.READY))}pollerExists(t,r){for(let i of this._pollers)if(i.targetPath===t&&Gp.lang.isShallowEqual(i.options,r))return!0;return!1}subwatcherExists(t,r){for(let i of this._subwatchers)if(i.targetPath===t&&Gp.lang.isShallowEqual(i.options,r))return!0;return!1}watchersClose(t,r,i=!0){if(t){let n=this._watchers[t];if(n)for(let a of[...n])r&&a.filePath!==r||this.watcherClose(a);if(i)for(let a in this._watchers)Gp.fs.isSubPath(t,a)&&this.watchersClose(a,r,!1)}else for(let n in this._watchers)this.watchersClose(n,r,!1)}watchersLock(t){return this._watchersLock.then(()=>this._watchersLock=new Promise(async r=>{await t(),r()}))}watchersRestore(){delete this._watchersRestoreTimeout;let t=Object.entries(this._watchersRestorable);this._watchersRestorable={};for(let[r,i]of t)this.watchPath(r,i.options,i.handler)}async watcherAdd(t,r){let{folderPath:i}=t;(this._watchers[i]=this._watchers[i]||[]).push(t);let a=new ZGh(this,t,r);return await a.init(),a}watcherClose(t){t.watcher.close();let r=this._watchers[t.folderPath];if(r){let a=r.indexOf(t);r.splice(a,1),r.length||delete this._watchers[t.folderPath]}let i=t.filePath||t.folderPath;this._roots.has(i)&&(this._watchersRestorable[i]=t,this._watchersRestoreTimeout||(this._watchersRestoreTimeout=Gp.lang.defer(()=>this.watchersRestore())))}watcherExists(t,r,i,n){if(this._watchers[t]?.find(c=>c.handler===i&&(!c.filePath||c.filePath===n)&&c.options.ignore===r.ignore&&!!c.options.native==!!r.native&&(!r.recursive||c.options.recursive)))return!0;let o=mOn.default.dirname(t);for(let c=1;c<1/0;c++){if(this._watchers[o]?.find(u=>(c===1||u.options.recursive&&c<=(u.options.depth??KYi))&&u.handler===i&&(!u.filePath||u.filePath===n)&&u.options.ignore===r.ignore&&!!u.options.native==!!r.native&&(!r.recursive||u.options.recursive&&JYi&&u.options.native!==!1)))return!0;if(!JYi)break;let s=mOn.default.dirname(t);if(o===s)break;o=s}return!1}async watchDirectories(t,r,i,n,a){if(this.isClosed())return;t=Gp.lang.uniq(t).sort();let o;for(let c of t)if(!this.isIgnored(c,r.ignore)&&!this.watcherExists(c,r,i,n))try{let d=!r.recursive||JYi&&r.native!==!1?r:{...r,recursive:!1},u={watcher:FEu.default.watch(c,d),handler:i,options:r,folderPath:c,filePath:n},l=o=await this.watcherAdd(u,a);if(this._roots.has(n||c)){let _={...r,ignoreInitial:!0,recursive:!1},h=mOn.default.dirname(c),y=c;await this.watchDirectories([h],_,i,y,l)}}catch(d){this.error(d)}return o}async watchDirectory(t,r,i,n,a){if(!this.isClosed()&&!this.isIgnored(t,r.ignore)){if(!r.recursive||JYi&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,i,n,a));{r={...r,recursive:!0};let o=r.depth??KYi,c=r.limit??IXa,[d]=await Gp.fs.readdir(t,r.ignore,o,c,this._closeSignal,r.readdirMap);return this.watchersLock(async()=>{let s=await this.watchDirectories([t],r,i,n,a);if(d.length){let u=Gp.fs.getDepth(t);for(let l of d){let p=Gp.fs.getDepth(l),_=Math.max(0,o-(p-u)),h={...r,depth:_};await this.watchDirectories([l],h,i,n,a||s)}}})}}}async watchFileOnce(t,r,i){if(this.isClosed()||(r={...r,ignoreInitial:!1},this.subwatcherExists(t,r)))return;let n={targetPath:t,options:r},a=(s,u)=>{u===t&&(d(),i())},o=new e(a),c=()=>{this._subwatchers.add(n),this.on(Vx.CLOSE,d),o.watchFile(t,r,a)},d=()=>{this._subwatchers.delete(n),this.removeListener(Vx.CLOSE,d),o.close()};return c()}async watchFile(t,r,i){if(this.isClosed()||this.isIgnored(t,r.ignore))return;r={...r,recursive:!1};let n=mOn.default.dirname(t);return this.watchDirectory(n,r,i,t)}async watchPollingOnce(t,r,i){if(this.isClosed())return;let n=!1,a=new $nl,o=await this.watchPolling(t,r,async()=>{n||!(await a.update(t,r.pollingTimeout)).length||n||(n=!0,o(),i())})}async watchPolling(t,r,i){if(this.isClosed())return Gp.lang.noop;if(this.pollerExists(t,r))return Gp.lang.noop;let n={...r,interval:r.pollingInterval??UGh},a={targetPath:t,options:r},o=()=>{this._pollers.add(a),this.on(Vx.CLOSE,c),FEu.default.watchFile(t,n,i)},c=()=>{this._pollers.delete(a),this.removeListener(Vx.CLOSE,c),FEu.default.unwatchFile(t,i)};return Gp.lang.attempt(o),()=>Gp.lang.attempt(c)}async watchUnknownChild(t,r,i){if(this.isClosed())return;let n=()=>this.watchPath(t,r,i);return this.watchFileOnce(t,r,n)}async watchUnknownTarget(t,r,i){if(this.isClosed())return;let n=()=>this.watchPath(t,r,i);return this.watchPollingOnce(t,r,n)}async watchPaths(t,r,i){if(this.isClosed())return;if(t=Gp.lang.uniq(t).sort(),t.every((a,o)=>t.every((c,d)=>d===o||!Gp.fs.isSubPath(a,c))))await Promise.all(t.map(a=>this.watchPath(a,r,i)));else for(let a of t)await this.watchPath(a,r,i)}async watchPath(t,r,i){if(this.isClosed()||(t=mOn.default.resolve(t),this.isIgnored(t,r.ignore)))return;let n=await Gp.fs.poll(t,r.pollingTimeout);if(n){if(n.isFile())return this.watchFile(t,r,i);if(n.isDirectory())return this.watchDirectory(t,r,i);this.error(`"${t}" is not supported`)}else{let a=mOn.default.dirname(t);return(await Gp.fs.poll(a,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,i):this.watchUnknownTarget(t,r,i)}}async watch(t,r,i=Gp.lang.noop){if(Gp.lang.isFunction(t))return this.watch([],{},t);if(Gp.lang.isUndefined(t))return this.watch([],r,i);if(Gp.lang.isFunction(r))return this.watch(t,{},r);if(Gp.lang.isUndefined(r))return this.watch(t,{},i);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let n=Gp.lang.castArray(t);n.forEach(a=>this._roots.add(a)),await this.watchPaths(n,r,i),!this.isClosed()&&(i!==Gp.lang.noop&&this.on(Vx.ALL,i),r.readdirMap=void 0,this.ready())}},QEu=Ynl;jru();var Rla=require("fs/promises"),rxh=require("os"),ixh=ce(require("path"),1),BzB=".fern",IzB="logs";function CzB(){return"cli@3.47.1"}var NXa=class{logFilePath=null;initialized=!1;sessionStartTime;constructor(){this.sessionStartTime=Date.now()}async initialize(){if(this.initialized)return;let t=Tt(Sr.of((0,rxh.homedir)()),Je.of(BzB)),r=Tt(t,Je.of(IzB));await Ai(r)||await(0,Rla.mkdir)(r,{recursive:!0});let n=`${new Date().toISOString().replace(/[:.]/g,"-")}.debug.log`;this.logFilePath=Tt(r,Je.of(n));let a=["================================================================================","Fern Docs Dev Debug Log",`Session started: ${new Date().toISOString()}`,`Log file: ${ixh.default.basename(this.logFilePath)}`,"================================================================================",""].join(`
|
|
1943
|
+
`;return this.parsedDocsConfig.pages[Je.of(o)]=d,{id:this.#e.get(c),type:"page",slug:a.get(),title:i,icon:void 0,hidden:!1,viewers:void 0,orphaned:void 0,pageId:c,authed:void 0,noindex:!0,featureFlags:void 0,availability:void 0}}async toPageNode({item:t,parentSlug:r,hideChildren:i,parentAvailability:n}){let a=Ft.PageId(this.toRelativeFilepath(t.absolutePath)),o=r.apply({urlSlug:t.slug??cS(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{id:this.#e.get(a),type:"page",slug:o.get(),title:this.markdownFilesToSidebarTitle.get(t.absolutePath)??t.title,icon:this.resolveIconFileId(t.icon),hidden:i||t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:a,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags,availability:t.availability??n}}async toSectionNode({prefix:t,item:r,parentSlug:i,hideChildren:n,parentAvailability:a}){let o=this.toRelativeFilepath(r.overviewAbsolutePath),c=o?Ft.PageId(o):void 0,d=this.#e.get(c??`${t}/section`),s=i.apply({urlSlug:r.slug??cS(r.title),fullSlug:r.overviewAbsolutePath?this.markdownFilesToFullSlugs.get(r.overviewAbsolutePath)?.split("/"):void 0,skipUrlSlug:r.skipUrlSlug}),u=r.overviewAbsolutePath!=null?this.markdownFilesToNoIndex.get(r.overviewAbsolutePath):void 0,l=n||r.hidden;return{id:d,type:"section",overviewPageId:c,slug:s.get(),title:r.overviewAbsolutePath!=null?this.markdownFilesToSidebarTitle.get(r.overviewAbsolutePath)??r.title:r.title,icon:this.resolveIconFileId(r.icon),collapsed:r.collapsed,hidden:l,viewers:r.viewers,orphaned:r.orphaned,children:await Promise.all(r.contents.map(p=>this.toNavigationChild({prefix:d,item:p,parentSlug:s,hideChildren:l,parentAvailability:r.availability??a}))),authed:void 0,pointsTo:void 0,noindex:u,featureFlags:r.featureFlags,availability:r.availability??a}}async convertTabbedNavigation(t,r,i){let n=this.#e.get(`${t}/tabbed`);return{type:"tabbed",id:n,children:await Promise.all(r.map(a=>this.toTabChild(n,a,i)))}}async toTabChild(t,r,i){return odn(r.child)._visit({link:({href:n,target:a})=>this.toTabLinkNode(r,n,a),layout:({layout:n})=>this.toTabNode(t,r,n,i),changelog:({changelog:n})=>this.toTabChangelogNode(r,n,i),variants:({variants:n})=>this.toTabNodeWithVariants(t,r,n,i)})}async toTabChangelogNode(t,r,i){return new cOn(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,r,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:i,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:t.hidden,slug:t.slug})}async toTabLinkNode(t,r,i){return{type:"link",id:this.#e.get(r),title:t.title,url:Ft.V1.Url(r),target:i,icon:this.resolveIconFileId(t.icon)}}async toTabNode(t,r,i,n){let a=this.#e.get(`${t}/tab`),o=n.apply({urlSlug:r.slug??cS(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:a,title:r.title,slug:o.get(),icon:this.resolveIconFileId(r.icon),hidden:r.hidden,authed:void 0,viewers:r.viewers,orphaned:r.orphaned,pointsTo:void 0,child:await this.toSidebarRootNode(a,i,o),featureFlags:r.featureFlags}}async toTabNodeWithVariants(t,r,i,n){let a=this.#e.get(`${t}/tab`),o=n.apply({urlSlug:r.slug??cS(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:a,title:r.title,slug:o.get(),icon:this.resolveIconFileId(r.icon),hidden:r.hidden,authed:void 0,viewers:r.viewers,orphaned:r.orphaned,pointsTo:void 0,child:await this.toSidebarRootNodeWithVariants(a,i,o),featureFlags:r.featureFlags}}getFileId(t){if(t==null)return;let r=this.collectedFileIds.get(t);return r==null?this.taskContext.failAndThrow("Failed to locate file after uploading: "+t):UG.FileId(r)}resolveIconFileId(t){if(t!=null)return this.collectedFileIds.has(t)?`file:${this.getFileId(t)}`:t}convertPageActions(){if(this.parsedDocsConfig.pageActions!=null)return{default:this.parsedDocsConfig.pageActions.default,options:{askAi:this.parsedDocsConfig.pageActions.options.askAi,copyPage:this.parsedDocsConfig.pageActions.options.copyPage,viewAsMarkdown:this.parsedDocsConfig.pageActions.options.viewAsMarkdown,openAi:this.parsedDocsConfig.pageActions.options.openAi,claude:this.parsedDocsConfig.pageActions.options.claude,cursor:this.parsedDocsConfig.pageActions.options.cursor,vscode:this.parsedDocsConfig.pageActions.options.vscode,custom:this.parsedDocsConfig.pageActions.options.custom.map(t=>({title:t.title,subtitle:t.subtitle,url:t.url,icon:this.resolveIconFileId(t.icon),default:t.default}))}}}convertColorConfigImageReferences(){let{colors:t}=this.parsedDocsConfig;if(t!=null)return t.type==="dark"?{...t,...this.convertLogoAndBackgroundImage({theme:"dark"})}:t.type==="light"?{...t,...this.convertLogoAndBackgroundImage({theme:"light"}),type:"light"}:{...t,dark:{...t.dark,...this.convertLogoAndBackgroundImage({theme:"dark"})},light:{...t.light,...this.convertLogoAndBackgroundImage({theme:"light"})}}}convertLogoAndBackgroundImage({theme:t}){let{logo:r,backgroundImage:i}=this.parsedDocsConfig,n=r?.[t],a=i?.[t];return{logo:this.getFileId(n),backgroundImage:this.getFileId(a)}}convertDocsTypographyConfiguration(){if(this.parsedDocsConfig.typography!=null)return{headingsFont:this.convertFont(this.parsedDocsConfig.typography.headingsFont,"headings"),bodyFont:this.convertFont(this.parsedDocsConfig.typography.bodyFont,"body"),codeFont:this.convertFont(this.parsedDocsConfig.typography.codeFont,"code")}}convertFont(t,r){if(t==null||t.variants[0]==null)return;let i=this.getFileId(t.variants[0].absolutePath);return{type:"custom",name:t.name??`font:${r}:${i}`,variants:t.variants.map(n=>({fontFile:this.getFileId(n.absolutePath),weight:n.weight,style:n.style!=null?[n.style]:void 0})),display:t.display,fallback:t.fallback,fontVariationSettings:t.fontVariationSettings}}convertJavascriptConfiguration(){if(this.parsedDocsConfig.js!=null)return{files:this.parsedDocsConfig.js.files.map(({absolutePath:t,strategy:r})=>({fileId:this.getFileId(t),strategy:r})).filter(us),remote:this.parsedDocsConfig.js.remote?.map(t=>({...t,url:UG.Url(t.url)})),inline:void 0}}convertMetadata(){if(this.parsedDocsConfig.metadata==null)return;let{"og:image":t,"og:logo":r,"twitter:image":i,...n}=this.parsedDocsConfig.metadata;return{...n,"og:image":this.convertFileIdOrUrl(t),"og:logo":this.convertFileIdOrUrl(r),"twitter:image":this.convertFileIdOrUrl(i)}}convertFileIdOrUrl(t){if(t!=null)return odn(t,"type")._visit({filepath:({value:r})=>({type:"fileId",value:this.getFileId(r)}),url:({value:r})=>({type:"url",value:UG.Url(r)}),_other:()=>this.taskContext.failAndThrow("Invalid metadata configuration")})}};function EDB(e,t){let r=e?.launch??"github";if(e?.github==null)return{url:void 0,launch:r};let{owner:i,repo:n,branch:a="main",host:o="https://github.com"}=e.github;return{url:`${Qx(o)}/${i}/${n}/blob/${a}/fern/${t}?plain=1`,launch:r}}function SDB(e){switch(e){case"beta":return Ft.V1.NavigationV1Availability.Beta;case"deprecated":return Ft.V1.NavigationV1Availability.Deprecated;case"ga":return Ft.V1.NavigationV1Availability.GenerallyAvailable;case"stable":return Ft.V1.NavigationV1Availability.Stable;default:vt(e)}}async function RL(e){return(await Promise.all(e.apiWorkspaces.map(async t=>t instanceof jS?t:null))).filter(us)}async function Srl(e,t,r){if(e instanceof ESe){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof jS))return;let i=await e.getIntermediateRepresentation({context:t,audiences:r,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1});return Fx({ir:i,snippetsConfig:{typescriptSdk:void 0,pythonSdk:void 0,javaSdk:void 0,rubySdk:void 0,goSdk:void 0,csharpSdk:void 0,phpSdk:void 0,swiftSdk:void 0,rustSdk:void 0},playgroundConfig:{oauth:!0},context:t})}var uc={};Yt(uc,{AlgoliaSearchIndex:()=>JLh,ApiDefinitionId:()=>hVh,ApiId:()=>gVh,Availability:()=>TVh,DocsConfigId:()=>OVh,EndpointId:()=>AVh,EndpointPathLiteral:()=>CVh,EnvironmentId:()=>mVh,FileId:()=>SVh,HttpMethod:()=>qVh,IndexSegmentId:()=>$Lh,JqString:()=>DVh,OrgId:()=>bVh,PageId:()=>EVh,PayloadLocation:()=>u3h,PropertyKey:()=>BVh,PullRequestState:()=>r3h,RoleId:()=>IVh,TokenId:()=>vVh,TypeId:()=>wVh,Url:()=>MVh,VersionId:()=>yVh,WebSocketId:()=>PVh,WebhookId:()=>jVh,algolia:()=>Mrl,api:()=>Frl,commons:()=>Qrl,diff:()=>RVh,docs:()=>Jrl,generators:()=>Yrl,git:()=>Xrl,navigation:()=>eil,sdks:()=>ril,snippets:()=>a3h,snippetsFactory:()=>o3h,templates:()=>iil,tokens:()=>s3h});var Mrl={};Yt(Mrl,{AlgoliaSearchIndex:()=>JLh,IndexSegmentId:()=>$Lh});function JLh(e){return e}function $Lh(e){return e}var Frl={};Yt(Frl,{latest:()=>Irl,v1:()=>Nrl});var Irl={};Yt(Irl,{AuthSchemeId:()=>YLh,WebhookHttpMethod:()=>eVh,auth:()=>Drl,commons:()=>XLh,endpoint:()=>ZLh,type_:()=>kLh,webhook:()=>Brl,websocket:()=>tVh});var Drl={};Yt(Drl,{AuthSchemeId:()=>YLh});function YLh(e){return e}var XLh={};var ZLh={};var kLh={};var Brl={};Yt(Brl,{WebhookHttpMethod:()=>eVh});var eVh={Get:"GET",Post:"POST"};var tVh={};var Nrl={};Yt(Nrl,{SubpackageId:()=>fVh,WebSocketMessageId:()=>dVh,WebSocketMessageOrigin:()=>pVh,WebhookHttpMethod:()=>_Vh,commons:()=>zrl,db:()=>Crl,read:()=>Trl,register:()=>Rrl});var Crl={};Yt(Crl,{endpoint:()=>rVh});var rVh={};var Trl={};Yt(Trl,{SupportedLanguage:()=>iVh,endpoint:()=>qrl,type_:()=>nVh,webhook:()=>aVh,websocket:()=>oVh});var qrl={};Yt(qrl,{SupportedLanguage:()=>iVh});var iVh={Curl:"curl",Python:"python",Javascript:"javascript",Js:"js",Node:"node",Typescript:"typescript",Ts:"ts",Go:"go",Ruby:"ruby",Csharp:"csharp"};var nVh={};var aVh={};var oVh={};var Rrl={};Yt(Rrl,{SourceId:()=>MDB,endpoint:()=>uVh,type_:()=>sVh,webhook:()=>cVh,websocket:()=>lVh});var uVh={};var sVh={};var cVh={};var lVh={};function MDB(e){return e}var zrl={};Yt(zrl,{SubpackageId:()=>fVh,WebSocketMessageId:()=>dVh,WebSocketMessageOrigin:()=>pVh,WebhookHttpMethod:()=>_Vh});function fVh(e){return e}function dVh(e){return e}var pVh={Client:"client",Server:"server"};var _Vh={Get:"GET",Post:"POST"};var Qrl={};Yt(Qrl,{ApiDefinitionId:()=>hVh,ApiId:()=>gVh,Availability:()=>TVh,DocsConfigId:()=>OVh,EndpointId:()=>AVh,EndpointPathLiteral:()=>CVh,EnvironmentId:()=>mVh,FileId:()=>SVh,HttpMethod:()=>qVh,JqString:()=>DVh,OrgId:()=>bVh,PageId:()=>EVh,PropertyKey:()=>BVh,RoleId:()=>IVh,TokenId:()=>vVh,TypeId:()=>wVh,Url:()=>MVh,VersionId:()=>yVh,WebSocketId:()=>PVh,WebhookId:()=>jVh});function hVh(e){return e}function yVh(e){return e}function bVh(e){return e}function vVh(e){return e}function gVh(e){return e}function OVh(e){return e}function mVh(e){return e}function AVh(e){return e}function PVh(e){return e}function jVh(e){return e}function wVh(e){return e}function EVh(e){return e}function SVh(e){return e}function MVh(e){return e}function DVh(e){return e}function BVh(e){return e}function IVh(e){return e}function CVh(e){return e}var qVh={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE"};var TVh={Stable:"Stable",GenerallyAvailable:"GenerallyAvailable",InDevelopment:"InDevelopment",PreRelease:"PreRelease",Deprecated:"Deprecated",Beta:"Beta"};var RVh={};var Jrl={};Yt(Jrl,{latest:()=>Vrl,v1:()=>Hrl,v2:()=>Krl});var Vrl={};Yt(Vrl,{Layout:()=>NVh,MdxEngine:()=>DDB,TwitterCardSetting:()=>FVh,commons:()=>zVh,frontmatter:()=>Url,seo:()=>Lrl});var DDB={NextMdxRemote:"next-mdx-remote",MdxBundler:"mdx-bundler"};var zVh={};var Url={};Yt(Url,{Layout:()=>NVh});var NVh={Guide:"guide",Overview:"overview",Reference:"reference",Page:"page",Custom:"custom"};var Lrl={};Yt(Lrl,{TwitterCardSetting:()=>FVh});var FVh={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var Hrl={};Yt(Hrl,{commons:()=>xrl,db:()=>QVh,read:()=>UVh,write:()=>Wrl});var QVh={};var UVh={};var Wrl={};Yt(Wrl,{DocsRegistrationId:()=>IDB,FilePath:()=>BDB});function BDB(e){return e}function IDB(e){return e}var xrl={};Yt(xrl,{ContentAlignment:()=>GVh,FontDisplay:()=>$Vh,FontStyle:()=>JVh,HeaderPosition:()=>xVh,JsScriptStrategy:()=>KVh,ProgrammingLanguage:()=>LVh,SearchbarPlacement:()=>VVh,TabsPlacement:()=>WVh,TwitterCardSetting:()=>HVh,commons:()=>Grl});var Grl={};Yt(Grl,{ContentAlignment:()=>GVh,FontDisplay:()=>$Vh,FontStyle:()=>JVh,HeaderPosition:()=>xVh,JsScriptStrategy:()=>KVh,ProgrammingLanguage:()=>LVh,SearchbarPlacement:()=>VVh,TabsPlacement:()=>WVh,TwitterCardSetting:()=>HVh});var LVh={Typescript:"typescript",Javascript:"javascript",Python:"python",Java:"java",Go:"go",Ruby:"ruby",Csharp:"csharp",Nodets:"nodets",Nodejs:"nodejs",Dotnet:"dotnet",Curl:"curl",Jvm:"jvm",Ts:"ts",Js:"js"};var VVh={Header:"HEADER",HeaderTabs:"HEADER_TABS",Sidebar:"SIDEBAR"};var WVh={Header:"HEADER",Sidebar:"SIDEBAR"};var GVh={Center:"CENTER",Left:"LEFT"};var xVh={Fixed:"FIXED",Absolute:"ABSOLUTE"};var HVh={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var KVh={BeforeInteractive:"beforeInteractive",AfterInteractive:"afterInteractive",LazyOnload:"lazyOnload"};var JVh={Normal:"normal",Italic:"italic"};var $Vh={Auto:"auto",Block:"block",Swap:"swap",Fallback:"fallback",Optional:"optional"};var Krl={};Yt(Krl,{read:()=>YVh,write:()=>XVh});var YVh={};var XVh={};var Yrl={};Yt(Yrl,{ChangelogEntryType:()=>kVh,GeneratorId:()=>CDB,GeneratorLanguage:()=>qDB,ReleaseType:()=>e3h,cli:()=>ZVh,commons:()=>$rl,versions:()=>t3h});var ZVh={};var $rl={};Yt($rl,{ChangelogEntryType:()=>kVh,ReleaseType:()=>e3h});var kVh={Fix:"fix",Feat:"feat",Chore:"chore",Break:"break",Internal:"internal"};var e3h={Ga:"GA",Rc:"RC"};var t3h={};function CDB(e){return e}var qDB={Python:"python",Go:"go",Java:"java",Typescript:"typescript",Ruby:"ruby",Csharp:"csharp",Php:"php",Swift:"swift",Rust:"rust"};var Xrl={};Yt(Xrl,{PullRequestState:()=>r3h});var r3h={Open:"open",Closed:"closed",Merged:"merged"};var eil={};Yt(eil,{latest:()=>Zrl,v1:()=>krl});var Zrl={};Yt(Zrl,{NodeId:()=>zDB,ProductId:()=>NDB,Slug:()=>TDB,TabId:()=>RDB});function TDB(e){return e}function RDB(e){return e}function zDB(e){return e}function NDB(e){return e}var krl={};Yt(krl,{NavigationV1Availability:()=>VDB,NodeId:()=>UDB,ProductId:()=>LDB,Slug:()=>FDB,TabId:()=>QDB});function FDB(e){return e}function QDB(e){return e}function UDB(e){return e}function LDB(e){return e}var VDB={Stable:"stable",GenerallyAvailable:"generally-available",InDevelopment:"in-development",PreRelease:"pre-release",Beta:"beta",Deprecated:"deprecated"};var ril={};Yt(ril,{Language:()=>i3h,VersionBump:()=>n3h,versions:()=>til});var til={};Yt(til,{Language:()=>i3h,VersionBump:()=>n3h});var i3h={Go:"Go",TypeScript:"TypeScript",Java:"Java",Python:"Python",Csharp:"Csharp",Ruby:"Ruby"};var n3h={Major:"MAJOR",Minor:"MINOR",Patch:"PATCH"};var a3h={};var o3h={};var iil={};Yt(iil,{PayloadLocation:()=>u3h});var u3h={Body:"BODY",Query:"QUERY",Path:"PATH",Headers:"HEADERS",Relative:"RELATIVE",Auth:"AUTH"};var s3h={};var U0u=class{warnings=[];errors=[];error(t){this.errors.push(t)}warning(t){this.warnings.push(t)}};function Ho(e){return e!=null}var l3h=ce(I4a(),1);var c3h=["PII","PHI","PCI","GDPR","CCPA","HIPAA","COPPA","FERPA","GLBA","SOX","FISMA","NIST","CIS","ISO","IEC","ITAR","EAR","CMMC","CUI","CDI","FTC","FCC","SEC","FINRA","XSS","CSRF","SSRF","XSRF","TLS","SSL","SSH","API","OAuth","OAuth1","OAuth1.0","OAuth2","OAuth2.0","SAML","OpenID","OpenID Connect","CAPTCHA","reCAPTCHA","2FA","MFA","OTP","TOTP","HOTP","U2F","FIDO","FIDO2","PKI","HMAC","AES","RSA","SHA","MD5","BCrypt","PBKDF2","Argon2","SCrypt","JWT","JWE","JWS","JWK","JWA","JOSE","SKU","SKUs","UPC","EAN","ISBN","ASIN","MPN","MSRP","MAP","RRP","MSRP","AM","PM","UTC","GMT","PST","PDT","EST","EDT","CST","CDT","MST","MDT","USA","UK","EU","UAE","APAC","EMEA","LATAM","ANZ","SEA","MEA","MENA","NATO","NA","SA","CA","EU","AU","NZ","JP","KR","CN","HK","TW","SG","MY","TH","ID","PH","VN","IN","PK","BD","LK","NP","MM","KH","LA","MM","BT","MV","USD","EUR","GBP","JPY","CNY","RUB","INR","AUD","CAD","CHF","SGD","MYR","THB","IDR","KRW","PHP","VND","HKD","TWD","MXN","BRL","ARS","CLP","COP","PEN","ZAR","NGN","EGP","AED","SAR","ILS","TRY","SEK","NOK","DKK","ISK","HUF","PLN","CZK","RON","BGN","API","APIs","SDK","SDKs","AI","OCR","REST","SOAP","JSON","XML","HTTP","HTTPS","URI","URL","CRUD","RESTful","KYB","KYC","AML","HTML","CSS","JS","SQL","DB","UI","UX","SaaS","PaaS","IaaS","IP","TCP","UDP","DNS","FTP","SMTP","IMAP","POP3","CSV","MVC","MVP","MVVM","DOM","SPA","SSR","CSR","DDoS","CDN","IoT","ML","DL","NLP","CLI","GUI","BI","ETL","RDBMS","NoSQL","IDE","CMS","CCPA","POSIX","ABI","API","AST","COBOL","DDL","DML","NN","CNN","RNN","LSTM","GRU","ANN","GAN","RL","DL","ML","NLP","NLG","NLU","BERT","GPT","SVM","PCA","AI","CV","TF","TTS","ASR","HMM","DNN","MLP","RBM","CRF","PDF","PDFs","RTF","TXT","XLS","XLSX","PPT","JPG","JPEG","PNG","GIF","GIFs","SVG","TIFF","BMP","ICO","PSD","WebP","AVIF","HEIF","HEIC","EPS","MP3","WAV","AIFF","FLAC","WMA","AAC","OGG","AVI","WMV","MOV","M4V","MP4","MPG","MPEG","FLV","SWF","MKV","WebM","GCP","AWS","VM","VPC","S3","EC2","DynamoDB","CosmosDB","BigQuery","CI/CD","SOC1","SOC2","SOC3","PCI DSS","WAF","IAM","SDN","MPLS","BGP","Vue.js","Node.js",".NET"];function TXt(e){return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e=e.replace(/_/g," "),e=e.replace(/-/g," "),(0,l3h.default)(e,{special:c3h}).replace(/V\s(\d)/g,"V$1")}function f3h({endpoints:e,webhookEndpoints:t}){let r={};return Object.values({...e,...t}).forEach(i=>{let n=[];i.namespace?.forEach(a=>{let o=[...n,a],c=uc.api.v1.SubpackageId(o.join("."));r[c]={id:c,name:a,displayName:TXt(a)},n.push(a)})}),r}var L0u=class{input;context;constructor(t,r){this.input=t,this.context=r}errors(){return this.context.errors.errors}warnings(){return this.context.errors.warnings}};function d3h(e){return`#/${e.map(t=>t.replaceAll(/~/g,"~0").replaceAll(/\//g,"~1")).join("/")}`}var mo=class extends L0u{context;accessPath;pathId;constructor({input:t,context:r,accessPath:i,pathId:n}){if(super(t,r),this.context=r,this.accessPath=[...i],this.pathId=n,n!=null){let a=Array.isArray(this.pathId)?this.pathId:[this.pathId];a.every((o,c)=>o===this.accessPath[this.accessPath.length-a.length+c])||this.accessPath.push(...a)}r.logger.debug(`Processing ${d3h(this.accessPath)}`)}safeParse(...t){try{this.parse(...t)}catch{this.context.errors.error({message:"Error converting node. Please contact support if the error persists",path:this.accessPath})}}},qC=class extends mo{},zY=class extends qC{seenSchemas;constructor(t){super(t),this.seenSchemas=new Set(t.seenSchemas)}};var p3h="x-fern-base-path",_3h="x-fern-availability",V0u="x-fern-sdk-group-name",h3h="x-fern-global-headers",y3h="x-fern-sdk-method-name";var b3h="x-fern-webhook",v3h="x-fern-access-token-locator",g3h="x-fern-basic",O3h="x-fern-username-variable-name",m3h="x-fern-password-variable-name",A3h="x-fern-bearer",P3h="x-fern-token-variable-name",j3h="x-fern-header",w3h="x-fern-header-variable-name",E3h="x-fern-server-name",S3h="x-fern-examples";var W0u=class extends mo{serverName;constructor(t){super(t),this.safeParse()}parse(){this.serverName=this.input[E3h]}convert(){if(this.serverName!=null)return this.serverName}};var G0u=class extends mo{url;serverName;constructor(t){super(t),this.safeParse()}parse(){this.url=Object.entries(this.input.variables??{}).reduce((t,[r,i])=>t.replace(`{${r}}`,i.default),this.input.url)??this.input.url,this.serverName=new W0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})}convert(){let t=this.serverName?.convert()??this.url;if(!(this.url==null||t==null))return{id:uc.EnvironmentId(t),baseUrl:this.url}}};function CYi(e,t,r,i){let n=e??[],a=new Set(n.map(c=>c.url)),o=(t??[]).filter(c=>!a.has(c.url)).map((c,d)=>new G0u({input:c,context:r,accessPath:i,pathId:["servers",`${d}`]}));return[...n,...o]}function eg(e){return typeof e=="object"&&Ho(e)&&"$ref"in e&&typeof e.$ref=="string"}function zL(e,t,r){let i=e.$ref.substring(2).split("/").map(a=>a.replace(/~1/g,"/")),n=t;for(let a of i){if(typeof n!="object"||n==null)return r;n=n[a]}return n==null?r:(eg(n)&&(n=zL(n,t,r)),n)}function x0u(e,t){let r=t.components?.securitySchemes?.[e];if(r!=null)return eg(r)?zL(r,t,void 0):r}var v8h=ce(bM());var H0u=class extends mo{username;password;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[g3h];this.username=t?.username,this.password=t?.password}convert(){return{username:this.username,password:this.password}}};var K0u=class extends mo{passwordVariableName;constructor(t){super(t),this.safeParse()}parse(){this.passwordVariableName=this.input[m3h]}convert(){return this.passwordVariableName}};var J0u=class extends mo{usernameVariableName;constructor(t){super(t),this.safeParse()}parse(){this.usernameVariableName=this.input[O3h]}convert(){return this.usernameVariableName}};var $0u=class extends mo{bearerTokenVariableName;bearerTokenEnvVar;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[A3h];this.bearerTokenVariableName=t?.name,this.bearerTokenEnvVar=t?.env}convert(){return{tokenVariableName:this.bearerTokenVariableName,tokenEnvVar:this.bearerTokenEnvVar}}};var Y0u=class extends mo{tokenVariableName;constructor(t){super(t),this.safeParse()}parse(){this.tokenVariableName=this.input[P3h]}convert(){return this.tokenVariableName}};function M3h(e){return typeof e=="object"&&e!=null&&"in"in e&&e.in==="header"}var D3h="x-bearer-format",B3h="x-code-samples",I3h="x-codeSamples";var X0u=class extends mo{bearerFormat;constructor(t){super(t),this.safeParse()}parse(){this.bearerFormat=this.input[D3h]}convert(){return this.bearerFormat}};var Z0u=class extends mo{headerVariableName;headerEnvVar;headerPrefix;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[j3h];this.headerVariableName=t?.name,this.headerEnvVar=t?.env,this.headerPrefix=t?.prefix}convert(){return{name:this.headerVariableName,env:this.headerEnvVar,prefix:this.headerPrefix}}};var k0u=class extends mo{headerVariableName;constructor(t){super(t),this.safeParse()}parse(){this.headerVariableName=this.input[w3h]}convert(){return this.headerVariableName}};function C3h(e){return e.type==="apiKey"}var fla=class extends mo{headerName;headerBearerFormatNode;headerAuthNode;headerVariableNameNode;constructor(t){super(t),this.safeParse()}parse(){C3h(this.input)&&(this.headerName=this.input.name),this.headerAuthNode=new Z0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerVariableNameNode=new k0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerBearerFormatNode=new X0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})}convert(){let t=this.headerAuthNode?.convert();if(t!=null)return{type:"header",nameOverride:t?.name,headerWireValue:this.headerName??"Authorization",prefix:t?.prefix??this.headerBearerFormatNode?.convert()}}};function ewu(e){return e}function twu(e){return e==="__proto__"}function rwu(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function dla(e){return typeof e=="string"||typeof e=="symbol"?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function nXa(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(nXa).join(",");let t=String(e);return t==="0"&&Object.is(Number(e),-0)?"-0":t}function iwu(e){if(Array.isArray(e))return e.map(dla);if(typeof e=="symbol")return[e];e=nXa(e);let t=[],r=e.length;if(r===0)return t;let i=0,n="",a="",o=!1;for(e.charCodeAt(0)===46&&(t.push(""),i++);i<r;){let c=e[i];a?c==="\\"&&i+1<r?(i++,n+=e[i]):c===a?a="":n+=c:o?c==='"'||c==="'"?a=c:c==="]"?(o=!1,t.push(n),n=""):n+=c:c==="["?(o=!0,n&&(t.push(n),n="")):c==="."?n&&(t.push(n),n=""):n+=c,i++}return n&&t.push(n),t}function aXa(e,t,r){if(e==null)return r;switch(typeof t){case"string":{if(twu(t))return r;let i=e[t];return i===void 0?rwu(t)?aXa(e,iwu(t),r):r:i}case"number":case"symbol":{typeof t=="number"&&(t=dla(t));let i=e[t];return i===void 0?r:i}default:{if(Array.isArray(t))return WDB(e,t,r);if(Object.is(t?.valueOf(),-0)?t="-0":t=String(t),twu(t))return r;let i=e[t];return i===void 0?r:i}}}function WDB(e,t,r){if(t.length===0)return r;let i=e;for(let n=0;n<t.length;n++){if(i==null||twu(t[n]))return r;i=i[t[n]]}return i===void 0?r:i}function q3h(e){return function(t){return aXa(t,e)}}function T3h(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function nwu(e){return e==null||typeof e!="object"&&typeof e!="function"}function nil(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function oil(e,t,r){return typeof r!="function"?oil(e,t,()=>{}):ail(e,t,function i(n,a,o,c,d,s){let u=r(n,a,o,c,d,s);return u!==void 0?!!u:ail(n,a,i,s)},new Map)}function ail(e,t,r,i){if(t===e)return!0;switch(typeof t){case"object":return GDB(e,t,r,i);case"function":return Object.keys(t).length>0?ail(e,{...t},r,i):nil(e,t);default:return T3h(e)?typeof t=="string"?t==="":!0:nil(e,t)}}function GDB(e,t,r,i){if(t==null)return!0;if(Array.isArray(t))return R3h(e,t,r,i);if(t instanceof Map)return xDB(e,t,r,i);if(t instanceof Set)return HDB(e,t,r,i);let n=Object.keys(t);if(e==null)return n.length===0;if(n.length===0)return!0;if(i?.has(t))return i.get(t)===e;i?.set(t,e);try{for(let a=0;a<n.length;a++){let o=n[a];if(!nwu(e)&&!(o in e)||t[o]===void 0&&e[o]!==void 0||t[o]===null&&e[o]!==null||!r(e[o],t[o],o,e,t,i))return!1}return!0}finally{i?.delete(t)}}function xDB(e,t,r,i){if(t.size===0)return!0;if(!(e instanceof Map))return!1;for(let[n,a]of t.entries()){let o=e.get(n);if(r(o,a,n,e,t,i)===!1)return!1}return!0}function R3h(e,t,r,i){if(t.length===0)return!0;if(!Array.isArray(e))return!1;let n=new Set;for(let a=0;a<t.length;a++){let o=t[a],c=!1;for(let d=0;d<e.length;d++){if(n.has(d))continue;let s=e[d],u=!1;if(r(s,o,a,e,t,i)&&(u=!0),u){n.add(d),c=!0;break}}if(!c)return!1}return!0}function HDB(e,t,r,i){return t.size===0?!0:e instanceof Set?R3h([...e],[...t],r,i):!1}function awu(e,t){return oil(e,t,()=>{})}function z3h(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function owu(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var N3h="[object RegExp]",uwu="[object String]",swu="[object Number]",cwu="[object Boolean]",lwu="[object Arguments]",F3h="[object Symbol]",Q3h="[object Date]",U3h="[object Map]",L3h="[object Set]",V3h="[object Array]";var W3h="[object ArrayBuffer]",G3h="[object Object]";var x3h="[object DataView]",H3h="[object Uint8Array]",K3h="[object Uint8ClampedArray]",J3h="[object Uint16Array]",$3h="[object Uint32Array]";var Y3h="[object Int8Array]",X3h="[object Int16Array]",Z3h="[object Int32Array]";var k3h="[object Float32Array]",e8h="[object Float64Array]";function t8h(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function r8h(e,t){return qYi(e,void 0,e,new Map,t)}function qYi(e,t,r,i=new Map,n=void 0){let a=n?.(e,t,r,i);if(a!==void 0)return a;if(nwu(e))return e;if(i.has(e))return i.get(e);if(Array.isArray(e)){let o=new Array(e.length);i.set(e,o);for(let c=0;c<e.length;c++)o[c]=qYi(e[c],c,r,i,n);return Object.hasOwn(e,"index")&&(o.index=e.index),Object.hasOwn(e,"input")&&(o.input=e.input),o}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let o=new RegExp(e.source,e.flags);return o.lastIndex=e.lastIndex,o}if(e instanceof Map){let o=new Map;i.set(e,o);for(let[c,d]of e)o.set(c,qYi(d,c,r,i,n));return o}if(e instanceof Set){let o=new Set;i.set(e,o);for(let c of e)o.add(qYi(c,void 0,r,i,n));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(e))return e.subarray();if(t8h(e)){let o=new(Object.getPrototypeOf(e)).constructor(e.length);i.set(e,o);for(let c=0;c<e.length;c++)o[c]=qYi(e[c],c,r,i,n);return o}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){let o=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return i.set(e,o),uWt(o,e,r,i,n),o}if(typeof File<"u"&&e instanceof File){let o=new File([e],e.name,{type:e.type});return i.set(e,o),uWt(o,e,r,i,n),o}if(typeof Blob<"u"&&e instanceof Blob){let o=new Blob([e],{type:e.type});return i.set(e,o),uWt(o,e,r,i,n),o}if(e instanceof Error){let o=new e.constructor;return i.set(e,o),o.message=e.message,o.name=e.name,o.stack=e.stack,o.cause=e.cause,uWt(o,e,r,i,n),o}if(e instanceof Boolean){let o=new Boolean(e.valueOf());return i.set(e,o),uWt(o,e,r,i,n),o}if(e instanceof Number){let o=new Number(e.valueOf());return i.set(e,o),uWt(o,e,r,i,n),o}if(e instanceof String){let o=new String(e.valueOf());return i.set(e,o),uWt(o,e,r,i,n),o}if(typeof e=="object"&&KDB(e)){let o=Object.create(Object.getPrototypeOf(e));return i.set(e,o),uWt(o,e,r,i,n),o}return e}function uWt(e,t,r=e,i,n){let a=[...Object.keys(t),...z3h(t)];for(let o=0;o<a.length;o++){let c=a[o],d=Object.getOwnPropertyDescriptor(e,c);(d==null||d.writable)&&(e[c]=qYi(t[c],c,r,i,n))}}function KDB(e){switch(owu(e)){case lwu:case V3h:case W3h:case x3h:case cwu:case Q3h:case k3h:case e8h:case Y3h:case X3h:case Z3h:case U3h:case swu:case G3h:case N3h:case L3h:case uwu:case F3h:case H3h:case K3h:case J3h:case $3h:return!0;default:return!1}}function i8h(e){return qYi(e,void 0,e,new Map,void 0)}function n8h(e){return e=i8h(e),t=>awu(t,e)}function a8h(e,t){return r8h(e,(r,i,n,a)=>{let o=t?.(r,i,n,a);if(o!==void 0)return o;if(typeof e=="object")switch(Object.prototype.toString.call(e)){case swu:case uwu:case cwu:{let c=new e.constructor(e?.valueOf());return uWt(c,e),c}case lwu:{let c={};return uWt(c,e),c.length=e.length,c[Symbol.iterator]=e[Symbol.iterator],c}default:return}})}function o8h(e){return a8h(e)}var JDB=/^(?:0|[1-9]\d*)$/;function u8h(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e<t;case"symbol":return!1;case"string":return JDB.test(e)}}function s8h(e){return e!==null&&typeof e=="object"&&owu(e)==="[object Arguments]"}function c8h(e,t){let r;if(Array.isArray(t)?r=t:typeof t=="string"&&rwu(t)&&e?.[t]==null?r=iwu(t):r=[t],r.length===0)return!1;let i=e;for(let n=0;n<r.length;n++){let a=r[n];if((i==null||!Object.hasOwn(i,a))&&!((Array.isArray(i)||s8h(i))&&u8h(a)&&a<i.length))return!1;i=i[a]}return!0}function l8h(e,t){switch(typeof e){case"object":{Object.is(e?.valueOf(),-0)&&(e="-0");break}case"number":{e=dla(e);break}}return t=o8h(t),function(r){let i=aXa(r,e);return i===void 0?c8h(r,e):t===void 0?i===void 0:awu(i,t)}}function f8h(e){if(e==null)return ewu;switch(typeof e){case"function":return e;case"object":return Array.isArray(e)&&e.length===2?l8h(e[0],e[1]):n8h(e);case"string":case"symbol":case"number":return q3h(e)}}function d8h(e,t){let r={},i=Object.keys(e);for(let n=0;n<i.length;n++){let a=i[n],o=e[a];r[a]=t(o,a,e)}return r}function fwu(e,t=ewu){return e==null?{}:d8h(e,f8h(t))}function p8h(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}var $DB=new RegExp("\\p{Lu}?\\p{Ll}+|[0-9]+|\\p{Lu}+(?!\\p{Ll})|\\p{Emoji_Presentation}|\\p{Extended_Pictographic}|\\p{L}+","gu");function _8h(e){return Array.from(e.match($DB)??[])}function h8h(e){let t=_8h(e);if(t.length===0)return"";let[r,...i]=t;return`${r.toLowerCase()}${i.map(n=>p8h(n)).join("")}`}function y8h(e){return typeof e!="string"&&(e=nXa(e)),e.replace(/['\u2019]/g,"")}function sWt(e){return h8h(y8h(e))}function tj(e){if(e!=null)return Array.isArray(e)?e:[e]}function dwu({namespace:e,path:t,method:r,sdkMethodName:i,operationId:n,displayName:a,isWebhook:o}){if(t==null)return;let c=r!=null&&t!=null?`${r}_${t.split("/").join("_")}`:r??t.split("/").join("_");if(!(i==null&&n==null&&a==null&&c==null))return`${YDB(o)}${XDB(e)}.${ZDB(i,n,a,c)}`}function YDB(e){return e?"webhook_":"endpoint_"}function XDB(e){return e!=null?tj(e)?.map(t=>sWt(t)).join("/"):""}function ZDB(e,t,r,i){return e||t||sWt(r??"")||sWt(i??"")}function b8h(e){return e.length===0?!1:/^\$?(\.[\w*]+|\[['"][\w*]+['"]?\]|\[['"]?[\d*]+['"]?\]|\[[\d:]+\])*$/.test(e)}var pwu=class extends mo{accessTokenLocator;constructor(t){super(t),this.safeParse()}parse(){this.accessTokenLocator=this.input[v3h],this.accessTokenLocator!=null&&(b8h(this.accessTokenLocator)||(this.context.errors.error({message:"Invalid access token locator, must be a valid jq path",path:this.accessPath}),this.accessTokenLocator=void 0))}convert(){return this.accessTokenLocator}};var _wu=class extends mo{authorizationUrl;headerAuthNode;accessTokenLocatorNode;constructor(t){super(t),this.safeParse()}parse(){if(this.input.flows.clientCredentials!=null){let t=this.input.flows.clientCredentials;this.authorizationUrl=t.tokenUrl,this.authorizationUrl==null&&this.context.errors.error({message:"Expected 'tokenUrl' property to be specified",path:this.accessPath}),this.headerAuthNode=new fla({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.accessTokenLocatorNode=new pwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.authorizationUrl==null&&this.context.errors.error({message:"Expected 'tokenUrl' property to be specified",path:this.accessPath}),this.accessTokenLocatorNode?.accessTokenLocator==null&&this.context.errors.error({message:"Expected 'x-fern-access-token-locator' property to be specified",path:this.accessPath})}}convert(){let t=this.accessTokenLocatorNode?.convert();if(t==null||this.authorizationUrl==null)return{type:"bearerAuth",tokenName:void 0};let r=dwu({namespace:void 0,path:this.authorizationUrl,method:"POST",sdkMethodName:void 0,operationId:void 0,displayName:void 0,isWebhook:void 0});if(r!=null)return{type:"oAuth",value:{type:"clientCredentials",value:{type:"referencedEndpoint",endpointId:uc.EndpointId(r),accessTokenLocator:uc.JqString(t),headerName:this.headerAuthNode?.convert()?.headerWireValue,tokenPrefix:this.headerAuthNode?.convert()?.prefix}}}}};var pla=class extends mo{authScheme;headerAuthNode;bearerTokenNode;bearerTokenVariableNameNode;basicAuthNode;basicUsernameVariableNameNode;basicPasswordVariableNameNode;oauth2Node;constructor(t){super(t),this.safeParse()}parse(){switch(this.input.type){case"http":switch(this.input.scheme){case"basic":{this.authScheme="basic",this.basicAuthNode=new H0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicUsernameVariableNameNode=new J0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicPasswordVariableNameNode=new K0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),(this.basicAuthNode==null||this.basicAuthNode.username==null&&this.basicUsernameVariableNameNode?.usernameVariableName==null||this.basicAuthNode.password==null&&this.basicPasswordVariableNameNode?.passwordVariableName==null)&&this.context.errors.warning({message:"Basic auth should specify either a username or a username variable name",path:this.accessPath});break}case"bearer":{this.authScheme="bearer",this.bearerTokenNode=new $0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.bearerTokenVariableNameNode=new Y0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});break}default:{this.context.errors.warning({message:`Unsupported HTTP auth scheme: ${this.input.scheme}`,path:this.accessPath});break}}break;case"apiKey":{M3h(this.input)?(this.authScheme="header",this.headerAuthNode=new fla({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})):this.context.errors.error({message:`Unsupported API key location: ${this.input.in}`,path:this.accessPath});break}case"oauth2":{this.authScheme="oauth",this.oauth2Node=new _wu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});break}case"openIdConnect":{this.authScheme="bearer";break}}}convert(){switch(this.authScheme){case"basic":{let t=this.basicAuthNode?.convert();return{type:"basicAuth",usernameName:t?.username?.name??this.basicUsernameVariableNameNode?.convert(),passwordName:t?.password?.name??this.basicPasswordVariableNameNode?.convert()}}case"bearer":return{type:"bearerAuth",tokenName:this.bearerTokenNode?.convert()?.tokenVariableName??this.bearerTokenVariableNameNode?.convert()};case"header":return this.headerAuthNode?.convert();case"oauth":return this.oauth2Node?.convert();case void 0:return;default:new v8h.UnreachableCaseError(this.authScheme);return}}};var _la=class extends mo{authNodesMap;constructor(t){super(t),this.safeParse()}parse(){this.input.map((t,r)=>Object.keys(t).map(i=>{let n=x0u(i,this.context.document);if(n==null){this.context.errors.warning({message:`No auth scheme found for ${i}. Inline security schemes are not supported.`,path:this.accessPath});return}let a=new pla({input:n,context:this.context,accessPath:this.accessPath,pathId:["security",`${r}`]});a.convert()!=null?(this.authNodesMap??={},this.authNodesMap[i]=a):this.context.errors.warning({message:`No auth scheme found for ${i}`,path:this.accessPath})}))}convert(){return Object.fromEntries(Object.entries(this.authNodesMap??{}).map(([t,r])=>{let i=r.convert();if(i!=null)return[t,i]}).filter(Ho))}};var hwu=class extends mo{basePath;constructor(t){super(t),this.safeParse()}parse(){this.basePath=this.input[p3h],this.basePath!=null?(this.basePath.startsWith("/")&&(this.basePath=this.basePath.slice(1)),this.basePath.endsWith("/")&&(this.basePath=this.basePath.slice(0,-1))):this.basePath=void 0}convert(){return this.basePath}};function g8h(e){return"required"in e&&typeof e.required=="boolean"?e.required:!1}function O8h(e,t){return{type:"alias",value:{type:"optional",shape:e,default:t}}}function hla(e,t){return e==null?void 0:Object.entries(e).map(([i,n])=>tj(n.convert())?.map(o=>((t!=null&&!t.includes(i)||t==null&&!g8h(n))&&(o=O8h(o,o.type==="enum"?o.default:void 0)),{key:uc.PropertyKey(i),valueShape:o,description:n.description,availability:n.availability?.convert()})).filter(Ho)).filter(Ho).reduce((i,n)=>i.flatMap(a=>n.length>0?n.map(o=>[...a,o]):[[...a]]),[[]])}function ywu(e,t){return eg(e)?zL(e,t,void 0):e}function TYi(e,t){return e!=null&&e!==""?e:t!=null&&t!==""?t:void 0}function m8h(e,t){let r={...e};for(let[i,n]of Object.entries(t??{}))r[i]=[...r[i]??[],...n];return Object.keys(r).length>0?r:void 0}function A8h(e,t){if(e==null)return t;if(t==null)return e;let r=[];for(let i of e)for(let n of t)r.push({path:i.path??n.path,responseStatusCode:i.responseStatusCode??n.responseStatusCode,name:i.name??n.name,description:i.description??n.description,pathParameters:i.pathParameters??n.pathParameters,queryParameters:i.queryParameters??n.queryParameters,headers:i.headers??n.headers,requestBody:i.requestBody??n.requestBody,responseBody:i.responseBody??n.responseBody,snippets:{...n.snippets,...i.snippets}});return r}var P8h=ce(bM());var uil=["decimal","decimal128","double-int","double","float","sf-decimal"],sil=["int16","int32","int64","int8","sf-integer","uint8"],cil=["base64url","binary","byte","char","commonmark","date-time","date","decimal","decimal128","duration","email","hostname","html","http-date","idn-email","idn-hostname","int64","ipv4","ipv6","iri-reference","iri","json-pointer","media-range","password","regex","relative-json-pointer","sf-binary","sf-boolean","sf-string","sf-token","time","uri-reference","uri-template","uri","uuid"],lil=["beta","pre-release","in-development","generally-available","deprecated"];function TC(e,t){return eg(e)?zL(e,t,{type:"unknown","x-fern-type":"unknown",additionalProperties:!1}):e}var NSe=class extends mo{availability;constructor(t){super(t),this.safeParse()}parse(){if(TC(this.input,this.context.document)?.deprecated)this.availability="deprecated";else{let r=this.input[_3h];r!=null&&(lil.includes(r)?this.availability=r:(this.context.errors.warning({message:`Expected one of: ${lil.join(", ")}. Received: ${r}`,path:this.accessPath}),this.availability=void 0))}}convert(){switch(this.availability){case"beta":case"pre-release":return uc.Availability.Beta;case"in-development":return uc.Availability.InDevelopment;case"generally-available":return uc.Availability.GenerallyAvailable;case"deprecated":return uc.Availability.Deprecated;case void 0:return;default:new P8h.UnreachableCaseError(this.availability);return}}};var vwu=ce(bM());function j8h(e){return typeof e=="object"&&e!=null&&"language"in e}function w8h(e){return typeof e=="object"&&e!=null&&"sdk"in e}function E8h(e){return typeof e=="object"&&e!=null&&("error"in e||"body"in e)}function S8h(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)}function bwu(e){return typeof e=="object"&&e!=null&&"event"in e}function fil(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)&&e.stream.every(bwu)}function RYi(e){return typeof e=="object"&&e!=null&&"filename"in e&&"data"in e&&typeof e.filename=="string"&&typeof e.data=="string"}function M8h(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}var gwu=class extends mo{path;successResponseStatusCode;requestBodyByContentType;responseBodies;examples;constructor(t,r,i,n,a){super(t),this.path=r,this.successResponseStatusCode=i,this.requestBodyByContentType=n,this.responseBodies=a,this.safeParse()}parse(){this.examples=this.input[S3h]}convertFormDataExampleRequest(t,r){if(t.fields!=null)switch(t.contentType){case"form-data":return{type:"form",value:Object.fromEntries(Object.entries(t.fields).map(([n,a])=>{let o=typeof r=="object"?r[n]:void 0;switch(a.multipartType){case"file":return RYi(o)?[n,{type:"filenameWithData",filename:o.filename,data:uc.FileId(o.data)}]:o!=null?[n,{type:"filename",value:o}]:void 0;case"files":{if(Array.isArray(o)){if(o.every(c=>RYi(c)))return[n,{type:"filenamesWithData",value:o.map(c=>({filename:c.filename,data:uc.FileId(c.data)}))}];if(o.every(c=>typeof c=="string"))return[n,{type:"filenames",value:o}]}return}case"property":return[n,{type:"json",value:o}];case void 0:return;default:new vwu.UnreachableCaseError(a.multipartType);return}}).filter(Ho))};case"json":return{type:"json",value:r};case"bytes":return typeof r=="string"?{type:"bytes",value:{type:"base64",value:r}}:void 0;default:return}}convert(){if(this.examples==null)return;this.requestBodyByContentType!=null&&Object.keys(this.requestBodyByContentType).length>1&&this.context.logger.warn(`Multiple request bodies found for #/${[this.accessPath,this.pathId,"x-fern-examples"].join("/")}. Coercing to first request body until supported.`);let t=Object.keys(this.requestBodyByContentType??{})[0];return this.examples.flatMap(r=>(this.responseBodies??[]).map(i=>{let n=t!=null?this.requestBodyByContentType?.[t]:void 0,a;if(n!=null)switch(n.contentType){case"form-data":a=M8h(r.request)?this.convertFormDataExampleRequest(n,r.request):void 0;break;case"json":a=r.request!=null?{type:"json",value:r.request}:void 0;break;case"bytes":a=typeof r.request=="string"&&r.request!=null?{type:"bytes",value:{type:"base64",value:r.request}}:void 0;break;case void 0:break;default:new vwu.UnreachableCaseError(n.contentType);break}let o;switch(i.contentType){case"application/json":{E8h(r.response)&&(o={type:"json",value:r.response.body});break}case"text/event-stream":{fil(r.response)&&(o={type:"sse",value:r.response.stream.map(l=>({event:l.event,data:l.data}))});break}case"application/octet-stream":!fil(r.response)&&S8h(r.response)&&(o={type:"stream",value:r.response.stream});break;case void 0:break;default:new vwu.UnreachableCaseError(i.contentType);break}let c={};r["code-samples"]?.forEach(l=>{j8h(l)?l.language!=null&&(c[l.language]??=[],c[l.language]?.push({name:l.name,language:l.language,install:l.install,code:l.code,generated:!1,description:l.docs})):w8h(l)&&l.sdk!=null&&(c[l.sdk]??=[],c[l.sdk]?.push({name:l.name,language:l.sdk,install:void 0,code:l.code,generated:!1,description:l.docs}))});let d=Object.fromEntries(Object.entries(r["path-parameters"]??{}).map(([l,p])=>[uc.PropertyKey(l),p])),s=Object.fromEntries(Object.entries(r["query-parameters"]??{}).map(([l,p])=>[uc.PropertyKey(l),p])),u=Object.fromEntries(Object.entries(r.headers??{}).map(([l,p])=>[uc.PropertyKey(l),p]));return{path:this.path,responseStatusCode:this.successResponseStatusCode,name:r.name,description:r.docs,pathParameters:Object.keys(d).length>0?d:void 0,queryParameters:Object.keys(s).length>0?s:void 0,headers:Object.keys(u).length>0?u:void 0,requestBody:a,responseBody:o,snippets:c}}))}};var oXa=class extends mo{groupName;constructor(t){super(t),this.safeParse()}parse(){this.groupName=this.input[V0u]}convert(){if(this.groupName==null)return;let t;return Array.isArray(this.groupName)?t=this.groupName:t=[this.groupName],t.map(r=>uc.api.v1.SubpackageId(sWt(r)))}};var Owu=class extends mo{sdkMethodName;constructor(t){super(t),this.safeParse()}parse(){this.sdkMethodName=this.input[y3h]}convert(){return this.sdkMethodName}};var mwu=class extends mo{isWebhook;constructor(t){super(t),this.safeParse()}parse(){this.isWebhook=this.input[b3h]}convert(){return this.isWebhook}};var Awu=class extends mo{codeSamples;constructor(t){super(t),this.safeParse()}parse(){this.codeSamples=[...this.input[B3h]??[],...this.input[I3h]??[]],this.codeSamples.forEach(t=>{[...Object.values(uc.api.v1.read.SupportedLanguage),"Kotlin","Swift","PHP"].map(r=>r.toLowerCase()).includes(t.lang.toLowerCase())||this.context.errors.warning({message:`Unsupported language: ${t.lang}. This may not render correctly.`,path:this.accessPath})})}convert(){let t={};if(this.codeSamples?.forEach(r=>{t[r.lang.toLowerCase()]??=[],t[r.lang.toLowerCase()]?.push({name:r.label,language:r.lang,code:r.source,install:void 0,generated:!1,description:void 0})}),Object.keys(t).length!==0)return t}};var lOn=ce(bM());function dil(e,t){return eg(e)?zL(e,t,void 0):e}function D8h(e,t){return e.replace(/{(\w+)}/g,(r,i)=>t[i]!=null&&typeof t[i]=="string"||typeof t[i]=="number"||typeof t[i]=="boolean"?`${t[i]}`:r)}var FF="",RXt=class extends mo{path;responseStatusCode;name;shapes;resolvedRequestInput;resolvedResponseInput;summary;constructor(t,r,i,n,a){super(t),this.path=r,this.responseStatusCode=i,this.name=n,this.shapes=a,this.safeParse()}validateFormDataRequestExample(){return typeof this.resolvedRequestInput?.value!="object"?!1:Object.entries(this.shapes.requestBody?.fields??{}).reduce((t,[r,i])=>{let n=this.resolvedRequestInput?.value[r];switch(i.multipartType){case"file":return t&&(RYi(n)||typeof n=="string");case"files":return t&&Array.isArray(n)&&n.every(a=>RYi(a)||typeof a=="string");case"property":return t;case void 0:return t&&!1;default:return new lOn.UnreachableCaseError(i.multipartType),t}},!0)}parse(){let t=this.shapes.requestBody?.schema?.example({includeOptionals:!1,override:void 0});this.resolvedRequestInput=dil(this.input?.requestExample,this.context.document)??(t!=null?{value:t}:void 0);let r=this.shapes.responseBody?.schema?.example({includeOptionals:!1,override:void 0});if(this.resolvedResponseInput=dil(this.input?.responseExample,this.context.document)??(r!=null?{value:r}:void 0),this.summary=this.input?.requestExample?.summary??this.input?.responseExample?.summary,this.shapes.requestBody!=null&&this.resolvedRequestInput!=null)switch(this.shapes.requestBody?.contentType){case"json":{if(typeof this.resolvedRequestInput.value!="object"){this.context.errors.error({message:"Invalid example, expected object for json",path:this.accessPath});return}break}case"bytes":{if(typeof this.resolvedRequestInput.value!="string"){this.context.errors.error({message:"Invalid example, expected string for bytes",path:this.accessPath});return}break}case"form-data":{if(!this.validateFormDataRequestExample()){this.context.errors.error({message:"Invalid example, expected valid form-data",path:this.accessPath});return}break}case void 0:break;default:new lOn.UnreachableCaseError(this.shapes.requestBody?.contentType),this.context.errors.error({message:"Invalid example, unsupported content type",path:this.accessPath});return}if(this.shapes.responseBody!=null&&this.resolvedResponseInput!=null)switch(this.shapes.responseBody?.contentType){case"application/json":if(this.resolvedResponseInput!=null&&typeof this.resolvedResponseInput!="object"||this.resolvedResponseInput.value!=null&&typeof this.resolvedResponseInput.value!="object"){this.context.errors.error({message:"Invalid example, expected object for json",path:this.accessPath});return}break;case"text/event-stream":if(this.resolvedResponseInput.value!=null&&!Array.isArray(this.resolvedResponseInput.value)&&!this.resolvedResponseInput.value.every(bwu)){this.context.errors.error({message:"Invalid example, expected array of SSE events for event-stream",path:this.accessPath});return}break;case"application/octet-stream":if(this.resolvedResponseInput.value!=null&&typeof this.resolvedResponseInput.value!="string"&&!Array.isArray(this.resolvedResponseInput.value)){this.context.errors.error({message:"Invalid example, expected string or array for octet-stream",path:this.accessPath});return}break;case void 0:break;default:new lOn.UnreachableCaseError(this.shapes.responseBody?.contentType);return}}convertFormDataExampleRequest(){if(!(this.resolvedRequestInput==null||this.shapes.requestBody?.fields==null))switch(this.shapes.requestBody?.contentType){case"form-data":return{type:"form",value:Object.fromEntries(Object.entries(this.shapes.requestBody.fields).map(([r,i])=>{let n=this.resolvedRequestInput?.value?.[r];switch(i.multipartType){case"file":return RYi(n)?[r,{type:"filenameWithData",filename:n.filename,data:uc.FileId(n.data)}]:[r,{type:"filename",value:n}];case"files":{if(Array.isArray(n)){if(n.every(a=>RYi(a)))return[r,{type:"filenamesWithData",value:n.map(a=>({filename:a.filename,data:uc.FileId(a.data)}))}];if(n.every(a=>typeof a=="string"))return[r,{type:"filenames",value:n}]}return}case"property":return[r,{type:"json",value:n}];case void 0:return;default:new lOn.UnreachableCaseError(i.multipartType);return}}).filter(Ho))};case"json":return{type:"json",value:this.resolvedRequestInput.value};case"bytes":return typeof this.resolvedRequestInput.value=="string"?{type:"bytes",value:{type:"base64",value:this.resolvedRequestInput.value}}:void 0;default:return}}convertDescription(){if(this.resolvedRequestInput!=null&&this.resolvedResponseInput!=null)return this.resolvedResponseInput.description;if(this.resolvedRequestInput!=null)return this.resolvedRequestInput.description;if(this.resolvedResponseInput!=null)return this.resolvedResponseInput.description}convert(){let t;if(this.shapes.requestBody!=null&&this.resolvedRequestInput!=null)switch(this.shapes.requestBody.contentType){case"form-data":t=this.convertFormDataExampleRequest();break;case"json":t={type:"json",value:this.resolvedRequestInput.value};break;case"bytes":t={type:"bytes",value:{type:"base64",value:this.resolvedRequestInput.value}};break;case void 0:break;default:new lOn.UnreachableCaseError(this.shapes.requestBody?.contentType);break}let r;if(this.shapes.responseBody!=null&&this.resolvedResponseInput!=null)switch(this.shapes.responseBody.contentType){case"application/json":{r={type:"json",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break}case"text/event-stream":r={type:"sse",value:this.resolvedResponseInput?.value};break;case"application/octet-stream":r={type:typeof this.resolvedResponseInput?.value=="string"?"filename":"stream",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break;case void 0:r={type:"json",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break;default:new lOn.UnreachableCaseError(this.shapes.responseBody?.contentType);break}let i=Object.fromEntries(Object.entries(this.shapes.pathParameters??{}).map(([o,c])=>[o,c.example({includeOptionals:!1,override:o})]));i=Object.keys(i).length>0?i:void 0;let n=Object.fromEntries(Object.entries(this.shapes.queryParameters??{}).map(([o,c])=>c.required||c.inputExample!=null?[o,c.example({includeOptionals:!1,override:o})]:void 0).filter(Ho));n=Object.keys(n).length>0?n:void 0;let a=Object.fromEntries(Object.entries(this.shapes.requestHeaders??{}).map(([o,c])=>c.required||c.inputExample!=null?[o,c.example({includeOptionals:!1,override:o})]:void 0).filter(Ho));if(a=Object.keys(a).length>0?a:void 0,!(this.path==null&&t==null&&r==null&&a==null&&n==null&&i==null))return{path:D8h(this.path,i??{}),responseStatusCode:this.responseStatusCode,name:this.name!=null?TXt(this.name):this.summary!=null?TXt(this.summary):void 0,description:this.convertDescription(),pathParameters:i,queryParameters:n,headers:a,requestBody:t,responseBody:r,snippets:void 0}}};function B8h(e,t){return eg(e)?zL(e,t,void 0):e}var W8h=ce(bM());var I8h="#/components/schemas/";function yla(e){if(e.$ref.startsWith(I8h))return e.$ref.replace(I8h,"")}function D4i(e){if(e!=null)return{type:"alias",value:{type:"nullable",shape:e}}}function zYi(e){return typeof e.type=="string"&&e.type==="array"}function C8h(e){return e.type==="boolean"}function q8h(e){return e.type==="integer"}function NYi(e){return!Array.isArray(e.type)&&!zYi(e)}function T8h(e){return e!=null&&Array.isArray(e)&&e.every(t=>t.type==="null"||NYi(t)||zYi(t))}function R8h(e){return"nullable"in e&&typeof e.nullable=="boolean"}function z8h(e){return e.type==="null"}function N8h(e){return e.type==="number"}function pil(e){return e.type==null||typeof e.type=="string"&&e.type==="object"}function F8h(e){return e.type==="string"}var Pwu=class extends zY{item;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.item=new _w({input:this.input.items,context:this.context,accessPath:this.accessPath,pathId:"items",seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}),this.input.items==null&&this.context.errors.error({message:"Expected 'items' property to be specified",path:this.accessPath})}convert(){return tj(this.item?.convert())?.map(r=>({type:"alias",value:{type:"list",itemShape:r}}))}example(t){return this.input.example??this.input.examples?.[0]??[this.item?.example(t)]}};var jwu=class extends qC{constValue;description;availability;constructor(t){super(t),this.safeParse()}parse(){this.input.const!=null&&(typeof this.input.const=="string"||typeof this.input.const=="number"||typeof this.input.const=="boolean")?this.constValue=this.input.const.toString():this.context.errors.warning({message:`Unsupported const type: ${typeof this.input}`,path:this.accessPath}),this.description=this.input.description,this.availability=new NSe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"})}convert(){if(this.constValue!=null)return{type:"enum",default:this.constValue,values:[{value:this.constValue,description:this.description,availability:this.availability?.convert()}]}}example(){return this.input.example??this.input.examples?.[0]??this.constValue}};var wwu=class extends zY{typeNodes;nullable;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.parse()}parse(){this.typeNodes=this.input.map(t=>{if(t.type==="null")this.nullable=!0;else return new _w({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName})}).filter(Ho)}convert(){if(this.typeNodes==null)return;let i=this.typeNodes.map(n=>tj(n.convert())?.map(o=>({displayName:n.name,shape:o,description:n.description,availability:n.availability?.convert()}))).filter(Ho).reduce((n,a)=>n.flatMap(o=>a.length>0?a.map(c=>[...o,c]):[[...o]]),[[]]).map(n=>({type:"undiscriminatedUnion",variants:n}));return this.nullable?i.map(D4i).filter(Ho):i}example(t){return this.nullable?null:this.typeNodes?.[0]?.example(t)}};function Ewu(e){return e!=null&&e.length>0?e:[void 0]}var bla=class extends zY{description;extends=[];properties;extraProperties;requiredProperties;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.extends=[],this.requiredProperties=this.input.required,this.properties=Object.fromEntries(Object.entries(this.input.properties??{}).map(([t,r])=>[t,new _w({input:r,context:this.context,accessPath:this.accessPath,pathId:["properties",t],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})])),this.extraProperties=this.input.additionalProperties!=null?typeof this.input.additionalProperties=="boolean"?this.input.additionalProperties?this.input.title:void 0:new _w({input:this.input.additionalProperties,context:this.context,accessPath:this.accessPath,pathId:["additionalProperties"],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0,this.input.allOf!=null&&(this.extends=this.extends.concat(this.input.allOf.map((t,r)=>{if(eg(t))return yla(t);this.properties={...this.properties,...Object.fromEntries(Object.entries(t.properties??{}).map(([i,n])=>[i,new _w({input:n,context:this.context,accessPath:this.accessPath,pathId:["allOf",r.toString(),"properties",i],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))}}).filter(Ho))),this.description=this.input.description}convertProperties(){if(this.properties!=null)return hla(this.properties,this.requiredProperties)}convertExtraProperties(){return this.extraProperties==null?void 0:typeof this.extraProperties=="string"?[{type:"map",keyShape:{type:"alias",value:{type:"primitive",value:{type:"string",format:void 0,regex:void 0,minLength:void 0,maxLength:void 0,default:void 0}}},valueShape:{type:"alias",value:{type:"unknown",displayName:this.extraProperties}}}]:tj(this.extraProperties.convert())?.map(r=>({type:"map",keyShape:{type:"alias",value:{type:"primitive",value:{type:"string",format:void 0,regex:void 0,minLength:void 0,maxLength:void 0,default:void 0}}},valueShape:r})).filter(Ho)}convert(){let t=this.convertProperties();if(t==null)return;let r=this.convertExtraProperties();return t.flatMap(i=>Ewu(r).map(n=>(this.extends==null||this.extends.length===0)&&i.length===0&&n!=null?{type:"alias",value:n}:{type:"object",extends:this.extends.map(a=>uc.TypeId(a)),properties:i,extraProperties:n}))}example({includeOptionals:t}){let r={...this.properties};return this.input.allOf?.forEach(i=>{let n=TC(i,this.context.document);n!=null&&(r={...r,...Object.fromEntries(Object.entries(n.properties??{}).map(([a,o])=>[a,new _w({input:o,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))})}),this.input.example??this.input.examples?.[0]??(!t&&this.requiredProperties!=null&&this.requiredProperties.length>0?this.requiredProperties?.reduce((i,n)=>{let a=r?.[n];return i[n]=a?.example({includeOptionals:t,override:n}),i},{}):Object.entries(r).reduce((i,[n,a])=>(i[n]=a?.example({includeOptionals:t,override:n}),i),{}))}};var Swu=class extends zY{isNullable;discriminated;discriminant;discriminatedMapping;undiscriminatedMapping;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){if(this.input.oneOf!=null||this.input.anyOf!=null)if(this.isNullable=(this.input.oneOf??this.input.anyOf)?.some(t=>TC(t,this.context.document)?.type==="null"),this.input.discriminator==null)this.discriminated=!1,this.undiscriminatedMapping=(this.input.oneOf??this.input.anyOf)?.map(t=>TC(t,this.context.document)?.type!=="null"?new _w({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0).filter(Ho);else{let t=this.input.discriminator.mapping;if(t!=null){this.discriminated=!0,this.discriminant=this.input.discriminator.propertyName,this.discriminatedMapping={};let r=this.discriminatedMapping;Object.entries(t).map(([i,n])=>{let a=TC({$ref:n},this.context.document);if(a==null){this.context.errors.warning({message:`Expected schema reference. Received undefined reference: ${n}`,path:[...this.accessPath,"discriminator","mapping",i]});return}r[i]=new _w({input:a,context:this.context,accessPath:[...this.accessPath,"discriminator","mapping",i],pathId:i,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})})}}}convert(){if(!this.discriminated&&this.undiscriminatedMapping?.length===1){let n=this.undiscriminatedMapping?.flatMap(a=>a.convert()).filter(Ho);return this.isNullable&&n!=null?n.map(D4i).filter(Ho):n}let t=0,r=this.discriminated&&this.discriminant!=null&&this.discriminatedMapping!=null?{type:"discriminatedUnion",discriminant:uc.PropertyKey(this.discriminant),variants:Object.entries(this.discriminatedMapping).flatMap(([n,a])=>tj(a.convert())?.map(c=>{if(!(c==null||c.type!=="object"))return{discriminantValue:n,displayName:a.name??TXt(n),availability:a.availability?.convert(),description:a.description,...c}}).filter(Ho)).filter(Ho)}:this.undiscriminatedMapping!=null?{type:"undiscriminatedUnion",variants:this.undiscriminatedMapping.flatMap(n=>tj(n.convert())?.map(o=>{if(o==null)return;t+=1;let c=o.type==="object"?TXt(`${this.schemaName??"Variant"} ${t}`):void 0;return{displayName:n.name??(o.type==="alias"&&o.value.type==="id"?TXt(o.value.id):c),shape:o,description:n.description,availability:n.availability?.convert()}}).filter(Ho)).filter(Ho)}:void 0,i=this.isNullable?D4i(r):r;return i!=null?[i]:void 0}example(t){return this.input.example??this.input.examples?.[0]??this.undiscriminatedMapping?.[0]?.example(t)??Object.values(this.discriminatedMapping??{})[0]?.example(t)}};var Mwu=class extends qC{default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.input.default!=null&&typeof this.input.default!="boolean"&&this.context.errors.warning({message:`Expected default value to be a boolean. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default}convert(){return{type:"alias",value:{type:"primitive",value:{type:"boolean",default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:!1)}};var FYi=class extends qC{default;values=[];nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){if(this.input.enum!=null){let t=!0;this.values=this.input.enum.map((r,i)=>{if(t){if(eg(r)){let n=TC(r,this.context.document);r=typeof n=="string"?n:typeof n?.default=="string"?n?.default:typeof n?.example=="string"?n.example:void 0}if(typeof r!="string"){this.context.errors.error({message:`Expected enum values to be strings. Received ${r}`,path:[...this.accessPath,`enum[${i}]`]}),t=!1;return}return r}}).filter(Ho),this.values=Array.from(new Set(this.values))}this.default=this.input.default}convert(){return{type:"enum",values:this.values.map(t=>({value:t,description:void 0,availability:void 0})),default:this.default}}example(){return this.input.example??this.input.examples?.[0]??this.default??this.values[0]??(this.nullable?null:void 0)}};var Q8h=ce(bM());function kDB(e){return sil.includes(e)}var Dwu=class extends qC{format;minimum;maximum;default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.minimum=this.input.minimum,this.maximum=this.input.maximum,this.input.default!=null&&typeof this.input.default!="number"&&this.context.errors.warning({message:`Expected default value to be an integer. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(kDB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${sil.join(", ")}. Received ${this.input.format}`,path:this.accessPath}))}convert(){let t="integer";if(this.format!=null)switch(this.format){case"int64":t="long";break;case"int8":case"int16":case"int32":case"uint8":case"sf-integer":case void 0:t="integer";break;default:new Q8h.UnreachableCaseError(this.format);break}return{type:"alias",value:{type:"primitive",value:{type:t,minimum:this.minimum,maximum:this.maximum,default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:0)}};var Bwu=class extends qC{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){this.displayName=this.input.title}convert(){return D4i({type:"alias",value:{type:"unknown",displayName:this.displayName}})}example(){return null}};var U8h=ce(bM());function eBB(e){return uil.includes(e)}var Iwu=class extends qC{format;minimum;maximum;default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.minimum=this.input.minimum,this.maximum=this.input.maximum,this.input.default!=null&&typeof this.input.default!="number"&&this.context.errors.warning({message:`Expected default value to be a number. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(eBB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${uil.join(", ")}. Received ${this.input.format}`,path:this.accessPath}))}convert(){let t="double";if(this.format!=null)switch(this.format){case"decimal":case"decimal128":case"double-int":case"double":case"float":case"sf-decimal":case void 0:t="double";break;default:new U8h.UnreachableCaseError(this.format);break}return{type:"alias",value:{type:"primitive",value:{type:t,minimum:this.minimum,maximum:this.maximum,default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:0)}};var L8h=ce(bM());function tBB(e){return cil.includes(e)}var Cwu=class extends qC{format;regex;default;minLength;maxLength;enum;mimeType;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}mapToFdrType(t){switch(t){case"base64url":case"binary":case"byte":case"sf-binary":return"base64";case"date-time":return"datetime";case"int64":return"bigInteger";case"date":return"date";case"uuid":return"uuid";case"char":case"commonmark":case"decimal":case"decimal128":case"duration":case"email":case"hostname":case"html":case"http-date":case"idn-email":case"idn-hostname":case"ipv4":case"ipv6":case"iri-reference":case"iri":case"json-pointer":case"media-range":case"password":case"regex":case"relative-json-pointer":case"sf-boolean":case"sf-string":case"sf-token":case"time":case"uri-reference":case"uri-template":case"uri":case void 0:return"string";default:return new L8h.UnreachableCaseError(t),"string"}}parse(){this.regex=this.input.pattern,this.minLength=this.input.minLength,this.maxLength=this.input.maxLength,this.mimeType=this.input.contentMediaType,this.input.default!=null&&typeof this.input.default!="string"&&this.context.errors.warning({message:`Expected default value to be a string. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(tBB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${cil.join(", ")}. Received ${this.input.format}`,path:this.accessPath})),this.input.enum!=null&&(this.enum=new FYi({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"enum",nullable:this.nullable}))}convert(){if(this.enum!=null)return this.enum.convert();let t="string";return this.format!=null&&(t=this.mapToFdrType(this.format)),{type:"alias",value:{type:"primitive",value:t==="base64"?{type:t,mimeType:this.mimeType,default:this.default}:{type:t,format:t==="string"?this.format:void 0,regex:this.regex,minLength:this.minLength,maxLength:this.maxLength,default:this.default}}}}example({override:t}){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:t??"string")}};var V8h=ce(bM());var qwu=class extends qC{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){(0,V8h.noop)()}convert(){return{type:"alias",value:{type:"unknown",displayName:void 0}}}example(){}};var fOn=class extends zY{description;availability;schemaId;maybeEnumConverterNode;nullable;schemaName;constructor(t){super(t),this.nullable=t.nullable,this.schemaName=t.schemaName,this.description=t.description,this.availability=t.availability,this.safeParse()}parse(){this.schemaId=yla(this.input);let t=TC(this.input,this.context.document);t?.enum!=null&&NYi(t)&&(this.maybeEnumConverterNode=new FYi({input:t,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",nullable:this.nullable})),this.schemaId==null&&this.context.errors.error({message:`Unprocessable reference: ${this.input.$ref}`,path:this.accessPath})}convert(){if(this.schemaId!=null)return{type:"alias",value:{type:"id",id:uc.TypeId(this.schemaId),default:this.maybeEnumConverterNode?.default!=null?{type:"enum",value:this.maybeEnumConverterNode.default}:void 0}}}example(t){let r=TC(this.input,this.context.document);if(r!=null)return new _w({input:r,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName}).example(t)}};var _w=class e extends zY{typeShapeNode;description;name;examples;availability;nullable;schemaName;constructor(t){super(t),this.nullable=t.nullable,this.schemaName=t.schemaName,this.safeParse()}parse(){if(this.description=this.input.description,this.availability=new NSe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),NYi(this.input)&&R8h(this.input)&&(this.nullable=this.input.nullable!=null?this.input.nullable:this.nullable),eg(this.input)){let t=yla(this.input);if(t==null){this.context.errors.error({message:"Reference object does not have a valid schema ID",path:this.accessPath});return}if(this.seenSchemas.has(t)){this.context.errors.warning({message:"Circular or deeply nested schema found, terminating",path:this.accessPath});return}this.seenSchemas.add(t),this.typeShapeNode=new fOn({input:this.input,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName,description:this.description,availability:this.availability})}else if(this.name=this.input.title,this.examples=this.input.example,this.input.const!=null)this.typeShapeNode=new jwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});else if(T8h(this.input))this.typeShapeNode=new wwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(NYi(this.input)&&(this.input.oneOf!=null||this.input.anyOf!=null))this.typeShapeNode=new Swu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(pil(this.input)&&this.input.allOf!=null)this.typeShapeNode=new bla({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(NYi(this.input)&&this.input.enum!=null)this.typeShapeNode=new FYi({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable});else if(typeof this.input.type=="string"||Array.isArray(this.input.type)&&this.input.type.length===1){if(this.input.type=Array.isArray(this.input.type)?this.input.type[0]:this.input.type,!Array.isArray(this.input.type))switch(this.input.type){case"object":pil(this.input)&&(this.typeShapeNode=new bla({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"array":zYi(this.input)&&(this.typeShapeNode=new Pwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"boolean":C8h(this.input)&&(this.typeShapeNode=new Mwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"integer":q8h(this.input)&&(this.typeShapeNode=new Dwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"number":N8h(this.input)&&(this.typeShapeNode=new Iwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"string":F8h(this.input)&&(this.typeShapeNode=new Cwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"null":z8h(this.input)&&(this.typeShapeNode=new Bwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}));break;case void 0:break;default:new W8h.UnreachableCaseError(this.input.type);break}}else if(Array.isArray(this.input.type)&&this.input.type.includes("null")&&this.input.type.length===2){let t=this.input.type.filter(r=>r!=="null")[0];t!=="array"&&(this.typeShapeNode=new e({input:{...this.input,type:t},context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:!0,schemaName:this.schemaName}))}else this.input.properties!=null&&(this.typeShapeNode=new bla({input:{...this.input,type:"object"},context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));this.typeShapeNode==null&&(this.typeShapeNode=new qwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),!eg(this.input)&&(!zYi(this.input)&&this.input==null||zYi(this.input)&&this.input.items==null)&&this.context.errors.error({message:"Expected type declaration. Received: null",path:this.accessPath}))}convert(){let t=this.typeShapeNode?.convert();if(t==null)return;let r=tj(t)?.map(i=>this.nullable?D4i(i):i).filter(Ho);return Array.isArray(t)&&t.length>1?r:r?.[0]}example(t){return this.availability?.availability!=="deprecated"?this.typeShapeNode?.example(t):void 0}};function QYi(e){if(e!=null)return hla(e,Object.entries(e??{}).map(([t,r])=>r.required?t:void 0).filter(Ho))}var zXt=class extends qC{availability;required;schema;description;inputExample;constructor(t){super(t),this.safeParse(t.parameterName)}parse(t){this.description=this.input.description;let r;eg(this.input)?r=this.input:this.input.schema!=null?(r=this.input.schema,this.required=this.input.required):(r={type:"string"},this.required=!1),this.availability=new NSe({input:r,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=new _w({input:r,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:t});let i=B8h(this.input,this.context.document);this.inputExample=i?.example??Object.values(i?.examples??{})[0]}convert(){return this.schema?.convert()}example(t){return this.inputExample??this.schema?.example(t)}};function G8h(e,t){return eg(e)?zL(e,t,void 0):e}var _il=ce(bM());function Twu(e){let{uniqueId:t,type:r,contextTypes:i,description:n,availability:a}=e;i[uc.TypeId(t)]={name:t,shape:r,description:n,availability:a}}var x8h=ce(Hnc(),1),vla=class e{type;subtype;essence;parameters;mimeType;input;constructor(t,r,i,n,a,o){this.type=t,this.subtype=r,this.essence=i,this.parameters=n,this.mimeType=a,this.input=o}static APPLICATION_JSON="application/json";static APPLICATION_OCTET_STREAM="application/octet-stream";static MULTIPART_FORM_DATA="multipart/form-data";static parse(t){if(t==null)return null;let r=x8h.default.parse(t);return r==null?null:new e(r.type,r.subtype,r.essence,r.parameters,r,t)}toString(){return this.input}isText(){return this.type==="text"}isImage(){return this.type==="image"}isAudio(){return this.type==="audio"}isVideo(){return this.type==="video"}isFont(){return this.type==="font"}isMultipart(){return this.type==="multipart"}isApplication(){return this.type==="application"}isMessage(){return this.type==="message"}isModel(){return this.type==="model"}isCSS(){return this.isText()&&this.subtype==="css"}isCSV(){return this.isText()&&this.subtype==="csv"}isMarkdown(){return this.isText()&&this.subtype==="markdown"}isPlainText(){return this.isText()&&this.subtype==="plain"}isEventStream(){return this.isText()&&this.subtype==="event-stream"}isMultiPartFormData(){return this.isMultipart()&&this.subtype==="form-data"}isJSON(){return this.isApplication()&&this.subtype==="json"}containsJSON(){return this.isApplication()&&this.subtype.includes("json")}isURLEncoded(){return this.isApplication()&&this.subtype==="x-www-form-urlencoded"}isOctetStream(){return this.isApplication()&&this.subtype==="octet-stream"}isPDF(){return this.isApplication()&&this.subtype==="pdf"}isZip(){return this.isApplication()&&this.subtype==="zip"}isGzip(){return this.isApplication()&&this.subtype==="gzip"}isTar(){return this.isApplication()&&this.subtype==="tar"}isBrotli(){return this.isApplication()&&this.subtype==="br"}isDeflate(){return this.isApplication()&&this.subtype==="deflate"}isProtobuf(){return this.isApplication()&&this.subtype==="protobuf"}isAvif(){return this.isImage()&&this.subtype==="avif"}isWebP(){return this.isImage()&&this.subtype==="webp"}isSVG(){return this.isImage()&&this.subtype==="svg+xml"}isPNG(){return this.isImage()&&this.subtype==="png"}isJPEG(){return this.isImage()&&this.subtype==="jpeg"}isGIF(){return this.isImage()&&this.subtype==="gif"}isMPEG(){return this.isAudio()&&this.subtype==="mpeg"}isWAV(){return this.isAudio()&&this.subtype==="wav"}isHTML(){return this.mimeType.isHTML()}isXML(){return this.mimeType.isXML()}isJavaScript(){return this.mimeType.isJavaScript()}};function rBB(e){return typeof e.securitySchemes=="object"&&e.securitySchemes!=null}var Rwu=class extends mo{typeSchemas;securitySchemes;constructor(t){super(t),this.safeParse()}parse(){this.input.schemas!=null&&(this.typeSchemas=Object.fromEntries(Object.entries(this.input.schemas).map(([t,r])=>[t,new _w({input:r,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:new Set,nullable:void 0,schemaName:t})]))),rBB(this.input)&&this.input.securitySchemes!=null&&(this.securitySchemes=Object.fromEntries(Object.entries(this.input.securitySchemes??{}).map(([t,r],i)=>{let n;if(eg(r)?n=x0u(r.$ref,this.context.document):n=r,n!=null)return[t,new pla({input:n,context:this.context,accessPath:this.accessPath,pathId:["securitySchemes",`${i}`]})]}).filter(Ho)))}convert(){return{auths:this.securitySchemes!=null?Object.fromEntries(Object.entries(this.securitySchemes??{}).map(([t,r])=>{let i=r.convert();if(i!=null)return[uc.api.latest.AuthSchemeId(t),i]}).filter(Ho)):void 0,types:this.typeSchemas!=null?Object.fromEntries(Object.entries(this.typeSchemas).map(([t,r])=>{let i=r.name??t,n=tj(r.convert());return n==null?[t,void 0]:[uc.TypeId(t),{name:i,shape:n[0],description:r.description,availability:void 0}]}).filter(([t,r])=>Ho(r))):void 0}}};var zwu=class extends _w{multipartType;contentType;constructor(t){super(t),this.safeParse()}parse(){super.parse();let t=TC(this.input,this.context.document);if(t==null){this.context.errors.error({message:`Expected multipart form data property definition. ${eg(this.input)?`Received undefined reference: ${this.input.$ref}`:""}`,path:this.accessPath});return}if(t.type==="string"&&t.format==="binary")this.multipartType="file",this.contentType=t.contentMediaType;else if(t.type==="array"){let r=TC(t.items,this.context.document);r?.type==="string"&&r?.format==="binary"?(this.multipartType="files",this.contentType=r?.contentMediaType):(this.context.errors.warning({message:"Expected multipart form data files definition with array type with internal string type and binary format.",path:this.accessPath}),this.multipartType=void 0,this.contentType=void 0)}else this.multipartType="property",this.contentType=t.contentMediaType}};var Nwu=class extends mo{description;method;path;schema;isOptional;contentType;availability;requiredFields;fields;examples;constructor(t){super(t),this.method=t.method,this.path=t.path,this.safeParse(t)}parse({contentType:t}){if(this.input.schema!=null){let i=TC(this.input.schema,this.context.document);this.availability=new NSe({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=eg(this.input.schema)?new fOn({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:!1,schemaName:"Request Body",description:this.input.schema.description,availability:this.availability}):void 0;let n=vla.parse(t);n?.containsJSON()?(this.contentType="json",this.schema=this.schema??new _w({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:"Request Body"})):n?.isOctetStream()?(this.contentType="bytes",this.isOptional=i?.required==null):n?.isMultiPartFormData()?(this.contentType="form-data",this.requiredFields=i?.required,this.fields=Object.fromEntries(Object.entries(i?.properties??{}).map(([a,o])=>{if(o!=null)return[a,new zwu({input:o,context:this.context,accessPath:this.accessPath,pathId:`schema.${a}`,seenSchemas:new Set,nullable:void 0,schemaName:a})]}).filter(Ho))):this.context.errors.warning({message:`Expected request body of reference or object with json, streaming or form-data content types. Received: ${t}`,path:this.accessPath})}let r=this.schema?.example({includeOptionals:!0,override:void 0});this.examples={...this.input.example!=null?{[FF]:{value:this.input.example}}:{},...this.input.examples},r!=null&&Object.keys(this.examples).length===0&&(this.examples={[FF]:{value:r}})}convertJsonLike(){let t=this.schema?.convert();return t==null?void 0:tj(t)?.map(i=>{let n=i.type;switch(n){case"object":case"alias":return i;case"enum":case"undiscriminatedUnion":case"discriminatedUnion":{let a=sWt([this.method,this.path,this.contentType,"request"].join("_"));return Twu({uniqueId:a,type:i,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:uc.TypeId(a),default:i.type==="enum"&&i.default!=null?{type:"enum",value:i.default}:void 0}}}case void 0:return;default:new _il.UnreachableCaseError(n);return}}).filter(Ho)}convert(){if(this.schema instanceof fOn)return this.schema.convert();switch(this.contentType){case"json":return this.convertJsonLike();case"bytes":return{type:"bytes",isOptional:this.isOptional??!1,contentType:this.contentType};case"form-data":return Object.entries(this.fields??{}).map(([i,n])=>{switch(n.multipartType){case"file":return[{type:n.multipartType,key:uc.PropertyKey(i),isOptional:this.requiredFields?.includes(i)==null,contentType:n.contentType,description:n.description,availability:n.availability?.convert()}];case"files":return[{type:n.multipartType,key:uc.PropertyKey(i),isOptional:this.requiredFields?.includes(i)==null,contentType:n.contentType,description:n.description,availability:n.availability?.convert()}];case"property":{let a=tj(n.convert()),o=n.multipartType;return a?.map(c=>({type:o,key:uc.PropertyKey(i),contentType:n.contentType,exploded:void 0,valueShape:c,description:n.description,availability:n.availability?.convert()}))}case void 0:return[];default:return new _il.UnreachableCaseError(n.multipartType),[]}}).filter(Ho).reduce((i,n)=>i.flatMap(a=>n.length>0?n.map(o=>[...a,o]):[[...a]]),[[]]).map(i=>({type:"formData",fields:i,availability:this.availability?.convert(),description:this.description}));case void 0:return this.convertJsonLike();default:return}}};var Fwu=class extends mo{description;requestBodiesByContentType;constructor(t){super(t),this.safeParse(t)}parse({method:t,path:r}){let i=G8h(this.input,this.context.document);if(i==null){this.context.errors.error({message:"Expected request body. Received: null",path:this.accessPath});return}Object.entries(i.content).forEach(([n,a])=>{this.requestBodiesByContentType??={},this.requestBodiesByContentType[n]=new Nwu({input:a,context:this.context,accessPath:this.accessPath,pathId:"content",contentType:n,method:t,path:r})})}convert(){return Object.entries(this.requestBodiesByContentType??{}).flatMap(([t,r])=>tj(r.convert())?.map(n=>({description:this.description,contentType:t,body:n}))).filter(Ho)}convertToWebhookPayload(){return Object.values(this.requestBodiesByContentType??{}).flatMap(t=>tj(t.convert())?.map(i=>{if(!(i.type!=="alias"&&i.type!=="object"))return{description:this.description,shape:i}})).filter(Ho)}webhookExample(){return{payload:this.requestBodiesByContentType?.["application/json"]?.schema?.example({includeOptionals:!0,override:void 0})}}};var H8h={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Switch Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"};function K8h(e,t){if(eg(e)){let r=zL(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var Qwu=ce(bM());var J8h="application/json";var $8h="application/octet-stream";function Y8h(e,t){return e===t||t===FF||e===FF}var uXa=class extends mo{streamingFormat;path;method;statusCode;requests;shapes;schema;contentType;unsupportedContentType;contentSubtype;examples;empty;constructor(t,r,i,n,a,o,c,d){super(t),this.streamingFormat=i,this.path=n,this.method=a,this.statusCode=o,this.requests=c,this.shapes=d,this.safeParse(r)}matchRequestResponseExamplesByName(t,r,i){for(let n of t)for(let[a,o]of Object.entries(n?.examples??{}))for(let[c,d]of Object.entries(r))for(let s of d)Y8h(c,a)&&(i.add(c),this.examples?.push(new RXt({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,TYi(a,c),{requestBody:n,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}matchExamplesByIndex(t,r){let i=0;for(let n of t){let a=0;for(let[o,c]of r){if(a===i){let[d,s,u]=n??[void 0,void 0,void 0];this.examples?.push(...c.map(l=>new RXt({input:{requestExample:u,responseExample:l},context:this.context,accessPath:this.accessPath,pathId:s!=null&&s!==""?["examples",s]:"examples"},this.path,this.statusCode,TYi(s,o),{requestBody:d,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}a++}i++}if(t.length>r.length)for(let n of t.slice(r.length)){let[a,o]=r[r.length-1]??[void 0,void 0],[c,d,s]=n??[void 0,void 0,void 0];this.examples?.push(...(o??[void 0]).map(u=>new RXt({input:{requestExample:s,responseExample:u},context:this.context,accessPath:this.accessPath,pathId:d!=null&&d!==""?["examples",d]:"examples"},this.path,this.statusCode,TYi(d,a),{requestBody:c,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}if(r.length>t.length){let[n,a,o]=t[t.length-1]??[void 0,void 0,void 0];for(let[c,d]of r.slice(t.length))this.examples?.push(...d.map(s=>new RXt({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,TYi(a,c),{requestBody:n,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}}pushResponseExample(t,r,i,n){let a=t[FF];if(a!=null)for(let o of a)this.examples?.push(new RXt({input:{requestExample:n,responseExample:o},context:this.context,accessPath:this.accessPath,pathId:i!=null&&i!==""?["examples",i]:"examples"},this.path,this.statusCode,TYi(i,void 0),{requestBody:r,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders}))}addGlobalFallbackExample(t,r){if(t==null||t.length===0)this.pushResponseExample(r,void 0,void 0,void 0);else for(let i of t)if(Object.keys(i.examples??{}).length===0)this.pushResponseExample(r,i,void 0,void 0);else for(let[n,a]of Object.entries(i.examples??{}))this.pushResponseExample(r,i,n,a)}parse(t){if(t==="empty")this.empty=!0;else{let c=vla.parse(t);if(c?.isJSON()||c?.isEventStream())this.contentType=J8h,this.input.schema==null?(this.streamingFormat==null||this.streamingFormat==="json")&&this.context.errors.error({message:"Expected schema for JSON response body. Received null",path:this.accessPath}):this.schema=new _w({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"type",seenSchemas:new Set,nullable:void 0,schemaName:"Response Body"});else if(c?.isOctetStream())this.contentType=$8h,this.contentSubtype=TC(this.input.schema,this.context.document)?.contentMediaType;else if(this.unsupportedContentType=t,this.input.schema==null){this.context.errors.error({message:"Expected schema for plain text response body. Received null",path:this.accessPath});return}else this.schema=new _w({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:new Set,nullable:void 0,schemaName:"Response Body"})}let r={};this.input.examples!=null&&(r=fwu(this.input.examples,c=>[c])),this.input.example!=null&&Object.keys(r).length===0&&(r[FF]??=[],r[FF]=[{value:this.input.example}]);let i=TC(this.input.schema,this.context.document);if(i!=null&&(i.examples!=null&&Object.keys(r).length===0&&(r=fwu(i.examples,c=>[c])),i.example!=null&&Object.keys(r).length===0&&(r[FF]??=[],r[FF]?.push({value:i.example}))),Object.keys(r).length===0){let c=this.schema?.example({includeOptionals:!0,override:void 0});r[FF]??=[],r[FF]?.push(c!=null?{value:c}:void 0)}this.examples??=[];let n=new Set;this.matchRequestResponseExamplesByName(this.requests,r,n);let a=[];for(let c of this.requests)a.push(...Object.entries(c.examples??{}).filter(([d])=>!n.has(d)&&d!==FF).map(([d,s])=>[c,d,s]));let o=Object.entries(r).filter(([c,d])=>!n.has(c)&&Ho(d)&&c!==FF);Object.keys(r).every(c=>c===FF)||this.matchExamplesByIndex(a,o),!n.has(FF)&&this.examples.length===0&&this.addGlobalFallbackExample(this.requests,r),this.examples.length===0&&(this.examples=void 0)}convertStreamingFormat(){switch(this.streamingFormat){case"json":return tj(this.schema?.convert())?.map(r=>({type:"stream",terminator:"[DATA]",shape:r}));case"sse":return{type:"streamingText"};case void 0:return;default:new Qwu.UnreachableCaseError(this.streamingFormat);return}}convertJsonLike(){return tj(this.schema?.convert())?.map(r=>{let i=r.type;switch(i){case"alias":return r;case"discriminatedUnion":case"undiscriminatedUnion":case"enum":{let n=sWt([this.method,this.path,this.statusCode,"response"].join("_"));return Twu({uniqueId:n,type:r,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:uc.TypeId(n),default:r.type==="enum"&&r.default!=null?{type:"enum",value:r.default}:void 0}}}case"object":return r;default:new Qwu.UnreachableCaseError(i);return}}).filter(Ho)}convert(){if(this.empty)return{type:"empty"};if(this.contentType!=null)switch(this.contentType){case"application/json":return this.streamingFormat==null?this.convertJsonLike():this.convertStreamingFormat();case"application/octet-stream":return{type:"fileDownload",contentType:this.contentSubtype};case"text/event-stream":return this.convertStreamingFormat();case void 0:return;default:new Qwu.UnreachableCaseError(this.contentType);return}else return this.unsupportedContentType!=null?this.convertJsonLike():void 0}};var sXa=class extends mo{path;method;statusCode;requests;shapes;headers;responses;description;constructor(t,r,i,n,a,o){super(t),this.path=r,this.method=i,this.statusCode=n,this.requests=a,this.shapes=o,this.safeParse()}parse(t){this.description=this.input.description;let r=K8h(this.input,this.context.document);if(r==null){this.context.errors.error({message:eg(this.input)?`Undefined reference: ${this.input.$ref}`:"Expected response, received null",path:this.accessPath});return}Object.entries(r.headers??{}).forEach(([i,n])=>{this.headers??={},this.headers[i]=new zXt({input:n,context:this.context,accessPath:this.accessPath,pathId:"headers",parameterName:i})}),r.content==null?(this.responses??=[],this.responses.push(new uXa({input:{},context:this.context,accessPath:this.accessPath,pathId:["content"]},"empty",t,this.path,this.method,this.statusCode,this.requests,this.shapes))):Object.entries(r.content??{}).forEach(([i,n])=>{this.responses??=[],this.responses.push(new uXa({input:n,context:this.context,accessPath:this.accessPath,pathId:["content",i]},i,t,this.path,this.method,this.statusCode,this.requests,this.shapes))})}convert(){return this.responses?.flatMap(t=>t.convert()).filter(Ho)}};var Uwu=class extends mo{path;method;requests;shapes;responsesByStatusCode;errorsByStatusCode;constructor(t,r,i,n,a){super(t),this.path=r,this.method=i,this.requests=n,this.shapes=a,this.safeParse()}parse(){let t=this.input.default;Object.entries(this.input).forEach(([r,i])=>{r!=="default"&&(parseInt(r)>=400?(this.errorsByStatusCode??={},this.errorsByStatusCode[r]=new sXa({input:{...t,...i},context:this.context,accessPath:this.accessPath,pathId:"errors"},this.path,this.method,parseInt(r),[],this.shapes)):(this.responsesByStatusCode??={},this.responsesByStatusCode[r]=new sXa({input:i,context:this.context,accessPath:this.accessPath,pathId:"responses"},this.path,this.method,parseInt(r),this.requests,this.shapes)))})}convertResponseObjectToHttpResponses(){return Object.entries(this.responsesByStatusCode??{}).flatMap(([t,r])=>{let i=r.convert();if(i!=null)return Ewu(QYi(r.headers)).flatMap(n=>i?.map(a=>({headers:n,response:{statusCode:parseInt(t),body:a,description:r.description},examples:(r.responses??[]).flatMap(o=>(o.examples??[]).map(c=>c.convert()).filter(Ho))})))}).filter(Ho)}convertResponseObjectToErrors(){return Object.entries(this.errorsByStatusCode??{}).flatMap(([t,r])=>r.responses?.flatMap(i=>{let n=i.schema,a=tj(n?.convert());if(n!=null)return a?.map(o=>({statusCode:parseInt(t),shape:o,description:r.description??n.description,availability:n.availability?.convert(),name:n.name??H8h[parseInt(t)]??"UNKNOWN ERROR",examples:i.examples?.map(c=>{let d=c.convert();if(d!=null&&d.responseBody?.type==="json")return{name:d.name,description:d.description,responseBody:d.responseBody}}).filter(Ho)})).filter(Ho)})).filter(Ho)}convert(){return{responses:this.convertResponseObjectToHttpResponses(),errors:this.convertResponseObjectToErrors()}}};var UYi=class extends mo{servers;globalAuth;path;method;basePath;isWebhook;endpointIds;description;displayName;operationId;pathParameters;queryParameters;requestHeaders;requests;responses;availability;auth;namespaces;xFernExamplesNode;redocExamplesNode;emptyResponseExamples;constructor(t){super(t),this.servers=t.servers,this.globalAuth=t.globalAuth,this.path=t.path,this.method=t.method,this.basePath=t.basePath,this.isWebhook=t.isWebhook,this.safeParse()}pushEmptyResponseExample(t,r,i){this.emptyResponseExamples??=[],this.emptyResponseExamples.push(new RXt({input:{requestExample:t,responseExample:void 0},context:this.context,accessPath:this.accessPath,pathId:"examples"},this.path,200,TYi(i,void 0),{requestBody:r,pathParameters:this.pathParameters,queryParameters:this.queryParameters,requestHeaders:this.requestHeaders}))}parse(){if(this.isWebhook&&this.method!=="POST"&&this.method!=="GET"){this.context.errors.error({message:`Webhook method must be POST or GET. Received: ${this.method}`,path:this.accessPath});return}this.description=this.input.description,this.displayName=this.input.summary,this.operationId=this.input.operationId,this.availability=new NSe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),this.servers=CYi(this.servers,this.input.servers,this.context,this.accessPath),this.isWebhook=new mwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}).isWebhook||this.isWebhook,this.input.parameters?.map((i,n)=>{if(eg(i)){let a=ywu(i,this.context.document);if(a!=null)i=a;else{this.context.errors.warning({message:`Expected parameter reference to resolve to an object. Received undefined reference: ${i.$ref}`,path:[...this.accessPath,`parameters[${n}]`]});return}}i.in==="path"?i.schema!=null&&(this.pathParameters??={},this.pathParameters[i.name]=new zXt({input:i,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${n}`],parameterName:i.name})):i.in==="query"?i.schema!=null&&(this.queryParameters??={},this.queryParameters[i.name]=new zXt({input:i,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${n}`],parameterName:i.name})):i.in==="header"&&i.schema!=null&&(this.requestHeaders??={},this.requestHeaders[i.name]=new zXt({input:i,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${n}`],parameterName:i.name}))});for(let i of this.extractPathParameterIds()??[])this.pathParameters?.[i]==null&&this.context.errors.warning({message:`Path parameter not defined: ${i}`,path:[...this.accessPath,"parameters"]});if(this.redocExamplesNode=new Awu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-code-samples"}),this.requests=this.input.requestBody!=null?new Fwu({input:this.input.requestBody,context:this.context,accessPath:this.accessPath,pathId:"requestBody",method:this.method,path:this.path}):void 0,this.responses=this.input.responses!=null?new Uwu({input:this.input.responses,context:this.context,accessPath:this.accessPath,pathId:"responses"},this.path,this.method,Object.values(this.requests?.requestBodiesByContentType??{}),{pathParameters:this.pathParameters,queryParameters:this.queryParameters,requestHeaders:this.requestHeaders}):void 0,this.responses==null){let i=this.requests?.requestBodiesByContentType;i==null||Object.keys(i).length===0?this.pushEmptyResponseExample(void 0,void 0,void 0):Object.values(i).forEach(n=>{if(Object.keys(n.examples??{}).length===0){let a=n.schema?.example({includeOptionals:!1,override:void 0});a!=null&&this.pushEmptyResponseExample({value:a},n,void 0)}else Object.entries(n.examples??{}).forEach(([a,o])=>{this.pushEmptyResponseExample(o,n,a)})})}let t=200;this.responses?.responsesByStatusCode!=null&&(t=Number(Object.keys(this.responses.responsesByStatusCode)?.filter(i=>Number(i)>=200&&Number(i)<300)[0])),this.globalAuth!=null&&(this.auth=this.globalAuth),this.input.security!=null&&(this.auth=new _la({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"})),this.namespaces=[new oXa({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-group-name"})],this.namespaces?.every(i=>i.groupName==null)&&this.input.tags!=null&&(this.namespaces=this.input.tags.slice(0,1).map((i,n)=>new oXa({input:{[V0u]:i},context:this.context,accessPath:this.accessPath,pathId:["tags",`${n}`]})));let r=new Owu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-sdk-method-name"});this.endpointIds=this.namespaces.map(i=>dwu({namespace:tj(i?.groupName),path:this.path,method:this.method,sdkMethodName:r.sdkMethodName,operationId:this.input.operationId,displayName:this.displayName,isWebhook:this.isWebhook})).filter(Ho),this.xFernExamplesNode=new gwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-examples"},this.path,t,this.requests?.requestBodiesByContentType,this.responses?.responsesByStatusCode?.[t]?.responses)}extractPathParameterIds(){if(this.path!=null)return this.path.split("/").map(t=>{if(t.startsWith("{")&&t.endsWith("}"))return t.slice(1,-1).trim()}).filter(Ho)}convertPathToPathParts(){if(this.path===void 0)return;let t=this.path.startsWith("/")?this.path.slice(1):this.path,r=this.basePath?.convert();return(r?[r,...t.split("/")]:t.split("/")).reduce((n,a)=>(n.push({type:"literal",value:"/"}),a.startsWith("{")&&a.endsWith("}")?n.push({type:"pathParameter",value:uc.PropertyKey(a.slice(1,-1).trim())}):n.push({type:"literal",value:a}),n),[])}convert(){if(this.path==null||this.endpointIds==null)return;let{responses:t,errors:r}=this.responses?.convert()??{responses:void 0,errors:void 0},i=this.emptyResponseExamples?.map(u=>u.convert()).filter(Ho),n=A8h(this.xFernExamplesNode?.convert(),[...i??[],...t?.flatMap(u=>u.examples)??[]])?.map(u=>({...u,snippets:m8h(u.snippets,this.redocExamplesNode?.convert())}));if(this.isWebhook)return this.endpointIds.map((u,l)=>{if(!(this.method!=="POST"&&this.method!=="GET"))return{id:uc.WebhookId(u),description:this.description,availability:this.availability?.convert(),displayName:this.displayName,operationId:this.operationId,namespace:this.namespaces?.[l]?.convert(),method:this.method,path:this.convertPathToPathParts()?.map(p=>p.value.toString())??[],queryParameters:QYi(this.queryParameters)?.flat(),headers:QYi(this.requestHeaders)?.flat(),payloads:this.requests?.convertToWebhookPayload(),examples:[this.requests?.webhookExample()].filter(Ho)}}).filter(Ho);let a=this.servers?.map(u=>u.convert()).filter(Ho),o=this.convertPathToPathParts();if(o==null)return;let c,d=this.auth?.convert();d!=null&&(c=Object.keys(d));let s=t?.flatMap(u=>u.headers).filter(Ho);return this.endpointIds.map((u,l)=>({id:uc.EndpointId(u),description:this.description,availability:this.availability?.convert(),namespace:this.namespaces?.[l]?.convert()?.map(p=>uc.api.v1.SubpackageId(p)),displayName:this.displayName,operationId:this.operationId,method:this.method,path:o,auth:c?.map(p=>uc.api.latest.AuthSchemeId(p)),defaultEnvironment:a?.[0]?.id,environments:a,pathParameters:QYi(this.pathParameters)?.flat(),queryParameters:QYi(this.queryParameters)?.flat(),requestHeaders:QYi(this.requestHeaders)?.flat(),responseHeaders:s!=null&&s.length>0?s:void 0,requests:this.requests?.convert(),responses:t?.map(p=>p.response),errors:r,examples:n,snippetTemplates:void 0,protocol:{type:"rest"}}))}};var gla=class extends mo{description;get;post;put;patch;delete;path;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:i,isWebhook:n}){this.description=this.input.description;let a=CYi(t,this.input.servers,this.context,this.accessPath),o=Array.isArray(this.pathId)?this.pathId.join("/"):this.pathId;this.input.get!=null&&(this.get=new UYi({input:this.input.get,context:this.context,accessPath:this.accessPath,pathId:"get",servers:a,globalAuth:r,path:o,method:"GET",basePath:i,isWebhook:n})),this.input.post!=null&&(this.post=new UYi({input:this.input.post,context:this.context,accessPath:this.accessPath,pathId:"post",servers:a,globalAuth:r,path:o,method:"POST",basePath:i,isWebhook:n})),this.input.put!=null&&(this.put=new UYi({input:this.input.put,context:this.context,accessPath:this.accessPath,pathId:"put",servers:a,globalAuth:r,path:o,method:"PUT",basePath:i,isWebhook:!1})),this.input.patch!=null&&(this.patch=new UYi({input:this.input.patch,context:this.context,accessPath:this.accessPath,pathId:"patch",servers:a,globalAuth:r,path:o,method:"PATCH",basePath:i,isWebhook:!1})),this.input.delete!=null&&(this.delete=new UYi({input:this.input.delete,context:this.context,accessPath:this.accessPath,pathId:"delete",servers:a,globalAuth:r,path:o,method:"DELETE",basePath:i,isWebhook:!1}))}convert(){return[...this.get?.convert()??[],...this.post?.convert()??[],...this.put?.convert()??[],...this.patch?.convert()??[],...this.delete?.convert()??[]].filter(Ho)}};function Lwu(e){return"payloads"in e}var Vwu=class extends mo{paths;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:i}){this.paths=Object.entries(this.input).map(([n,a])=>{if(a!=null)return new gla({input:a,context:this.context,accessPath:this.accessPath,pathId:n,servers:CYi(t,a.servers,this.context,this.accessPath),globalAuth:r,basePath:i,isWebhook:void 0})}).filter(Ho)}convert(){if(this.paths==null)return;let t={},r={};return this.paths.forEach(i=>{let n=i.convert();n?.forEach(a=>{Lwu(a)?r[uc.WebhookId(a.id)]=a:t[uc.EndpointId(a.id)]=a})}),{endpoints:t,webhookEndpoints:r}}};var Wwu=class extends mo{globalHeaders;requiredProperties;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[h3h]?.map(r=>{let{header:i,...n}=r;return(n.optional!=null&&!n.optional||ywu(n,this.context.document)?.required)&&(this.requiredProperties??=[],this.requiredProperties?.push(i)),[i,new zXt({input:n,context:this.context,accessPath:this.accessPath,pathId:this.pathId,parameterName:i})]});t!=null&&(this.globalHeaders=Object.fromEntries(t))}convert(){return hla(this.globalHeaders,this.requiredProperties)?.flat()}};function X8h(e,t){if(eg(e)){let r=zL(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var Gwu=class extends mo{webhooks;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:i}){this.webhooks=Object.entries(this.input??{}).map(([n,a])=>{let o=X8h(a,this.context.document);if(o!=null)return new gla({input:o,context:this.context,accessPath:this.accessPath,pathId:n,servers:t,globalAuth:r,basePath:i,isWebhook:!0})}).filter(Ho)}convert(){return this.webhooks?.reduce((t,r)=>(r.convert()?.forEach(i=>{Lwu(i)&&(t[uc.WebhookId(i.id)]=i)}),t),{})}};var xwu=class extends mo{paths;webhooks;components;auth;globalHeaders;constructor(t){super(t),this.safeParse()}parse(){let t=CYi(void 0,this.input.servers,this.context,this.accessPath);this.input.security!=null&&(this.auth=new _la({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"}));let r=new hwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});this.input.paths==null&&this.input.webhooks==null&&this.context.errors.warning({message:"Expected 'paths' or 'webhooks' property to be specified",path:this.accessPath}),this.input.paths!=null&&(this.paths=new Vwu({input:this.input.paths,context:this.context,accessPath:this.accessPath,pathId:"paths",basePath:r,servers:t,globalAuth:this.auth})),this.input.webhooks!=null&&(this.webhooks=new Gwu({input:this.input.webhooks,context:this.context,accessPath:this.accessPath,pathId:"webhooks",basePath:r,servers:t,globalAuth:this.auth})),this.input.components!=null&&(this.components=new Rwu({input:this.input.components,context:this.context,accessPath:this.accessPath,pathId:"components"})),this.globalHeaders=new Wwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-global-headers"})}convert(){let t=Lve(),{webhookEndpoints:r,endpoints:i}=this.paths?.convert()??{},n={...this.webhooks?.convert()??{},...r??{}},a=f3h({endpoints:i,webhookEndpoints:n}),{types:o,auths:c}=this.components?.convert()??{};return{id:uc.ApiDefinitionId(t),endpoints:i??{},websockets:{},webhooks:n,types:{...o,...this.context.generatedTypes},subpackages:a,auths:{...c,...this.auth?.convert()??{}},globalHeaders:this.globalHeaders?.convert(),snippetsConfiguration:void 0}}};async function hil(e,t){if(e instanceof ESe){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof jS))return;let r=new Y8t(e.absoluteFilePath),i=await MSe({context:t,specs:e.specs}),n=await r.loadDocuments({context:t,specs:i,loadAiExamples:!0}),a;for(let o of n){if(o.type!=="openapi")continue;let c={document:o.value,logger:t.logger,errors:new U0u,generatedTypes:{}},d=new xwu({input:o.value,context:c,accessPath:[],pathId:e.workspaceName??"openapi parser"});a=j$n(a,d.convert())}return a}var hYh=ce(vil(),1),yYh=ce(qEu(),1),iMu=require("fs/promises"),bYh=ce(require("http"),1),vYh=ce(require("path"),1);var txh=require("events"),FEu=ce(require("fs"),1),mOn=ce(require("path"),1);var NGh=ce(require("os"),1),FGh=300,KYi=20,IXa=1e7,QGh=NGh.default.platform();var jzB=QGh==="darwin",Fnl=QGh==="win32",JYi=jzB||Fnl,UGh=3e3,LGh=2e4,Qnl=1250;var UXt;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(UXt||(UXt={}));var OOn;(function(e){e.CHANGE="change",e.RENAME="rename"})(OOn||(OOn={}));var CXa;(function(e){e.CHANGE="change",e.ERROR="error"})(CXa||(CXa={}));var rf;(function(e){e.ADD="add",e.ADD_DIR="addDir",e.CHANGE="change",e.RENAME="rename",e.RENAME_DIR="renameDir",e.UNLINK="unlink",e.UNLINK_DIR="unlinkDir"})(rf||(rf={}));var Vx;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(Vx||(Vx={}));var wzB=(e,t=1,r)=>{t=Math.max(1,t);let i=r?.leading??!1,n=r?.trailing??!0,a=Math.max(r?.maxWait??1/0,t),o,c,d=0,s=0,u=()=>{let g=Date.now(),A=g-d,j=g-s,M=A>=t||j>=a;return[g,M]},l=g=>{if(s=g,!o)return;let A=o;o=void 0,e.apply(void 0,A)},p=()=>{O(0)},_=()=>{c&&(p(),l(Date.now()))},h=g=>{if(s=g,i)return l(g)},y=g=>{if(n&&o)return l(g);o=void 0},b=()=>{c=void 0;let[g,A]=u();return A?y(g):v(g)},v=g=>{let A=g-d,j=g-s,M=t-A,w=a-j,D=Math.min(M,w);return O(D)},O=g=>{c&&clearTimeout(c),!(g<=0)&&(c=setTimeout(b,g))},m=(...g)=>{let[A,j]=u(),M=!!c;if(o=g,d=A,(j||!c)&&O(t),j)return M?l(A):h(A)};return m.cancel=p,m.flush=_,m},TEu=wzB;var Wnl=ce(require("fs"),1),zEu=ce(require("path"),1);var fm=ce(require("fs"),1),NL=require("util");var I4i=(e,t)=>function(...i){return e.apply(void 0,i).catch(t)},LXt=(e,t)=>function(...i){try{return e.apply(void 0,i)}catch(n){return t(n)}};var Unl=ce(require("process"),1),VGh=Unl.default.getuid?!Unl.default.getuid():!1,WGh=1e4,UY=()=>{};var qXa={isChangeErrorOk:e=>{if(!qXa.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!VGh&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!qXa.isNodeError(e))return!1;let{code:t}=e;return t==="EMFILE"||t==="ENFILE"||t==="EAGAIN"||t==="EBUSY"||t==="EACCESS"||t==="EACCES"||t==="EACCS"||t==="EPERM"},onChangeError:e=>{if(!qXa.isNodeError(e))throw e;if(!qXa.isChangeErrorOk(e))throw e}},RC=qXa;var Lnl=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=WGh,this.queueActive=new Set,this.queueWaiting=new Set,this.init=()=>{this.intervalId||(this.intervalId=setInterval(this.tick,this.interval))},this.reset=()=>{this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId)},this.add=t=>{this.queueWaiting.add(t),this.queueActive.size<this.limit/2?this.tick():this.init()},this.remove=t=>{this.queueWaiting.delete(t),this.queueActive.delete(t)},this.schedule=()=>new Promise(t=>{let r=()=>this.remove(i),i=()=>t(r);this.add(i)}),this.tick=()=>{if(!(this.queueActive.size>=this.limit)){if(!this.queueWaiting.size)return this.reset();for(let t of this.queueWaiting){if(this.queueActive.size>=this.limit)break;this.queueWaiting.delete(t),this.queueActive.add(t),t()}}}}},GGh=new Lnl;var C4i=(e,t)=>function(i){return function n(...a){return GGh.schedule().then(o=>{let c=s=>(o(),s),d=s=>{if(o(),Date.now()>=i)throw s;if(t(s)){let u=Math.round(100*Math.random());return new Promise(p=>setTimeout(p,u)).then(()=>n.apply(void 0,a))}throw s};return e.apply(void 0,a).then(c,d)})}},q4i=(e,t)=>function(i){return function n(...a){try{return e.apply(void 0,a)}catch(o){if(Date.now()>i)throw o;if(t(o))return n.apply(void 0,a);throw o}}};var EzB={attempt:{chmod:I4i((0,NL.promisify)(fm.default.chmod),RC.onChangeError),chown:I4i((0,NL.promisify)(fm.default.chown),RC.onChangeError),close:I4i((0,NL.promisify)(fm.default.close),UY),fsync:I4i((0,NL.promisify)(fm.default.fsync),UY),mkdir:I4i((0,NL.promisify)(fm.default.mkdir),UY),realpath:I4i((0,NL.promisify)(fm.default.realpath),UY),stat:I4i((0,NL.promisify)(fm.default.stat),UY),unlink:I4i((0,NL.promisify)(fm.default.unlink),UY),chmodSync:LXt(fm.default.chmodSync,RC.onChangeError),chownSync:LXt(fm.default.chownSync,RC.onChangeError),closeSync:LXt(fm.default.closeSync,UY),existsSync:LXt(fm.default.existsSync,UY),fsyncSync:LXt(fm.default.fsync,UY),mkdirSync:LXt(fm.default.mkdirSync,UY),realpathSync:LXt(fm.default.realpathSync,UY),statSync:LXt(fm.default.statSync,UY),unlinkSync:LXt(fm.default.unlinkSync,UY)},retry:{close:C4i((0,NL.promisify)(fm.default.close),RC.isRetriableError),fsync:C4i((0,NL.promisify)(fm.default.fsync),RC.isRetriableError),open:C4i((0,NL.promisify)(fm.default.open),RC.isRetriableError),readFile:C4i((0,NL.promisify)(fm.default.readFile),RC.isRetriableError),rename:C4i((0,NL.promisify)(fm.default.rename),RC.isRetriableError),stat:C4i((0,NL.promisify)(fm.default.stat),RC.isRetriableError),write:C4i((0,NL.promisify)(fm.default.write),RC.isRetriableError),writeFile:C4i((0,NL.promisify)(fm.default.writeFile),RC.isRetriableError),closeSync:q4i(fm.default.closeSync,RC.isRetriableError),fsyncSync:q4i(fm.default.fsyncSync,RC.isRetriableError),openSync:q4i(fm.default.openSync,RC.isRetriableError),readFileSync:q4i(fm.default.readFileSync,RC.isRetriableError),renameSync:q4i(fm.default.renameSync,RC.isRetriableError),statSync:q4i(fm.default.statSync,RC.isRetriableError),writeSync:q4i(fm.default.writeSync,RC.isRetriableError),writeFileSync:q4i(fm.default.writeFileSync,RC.isRetriableError)}},xGh=EzB;var REu=ce(require("fs"),1),TXa=ce(require("path"),1);var Vnl=()=>{};var SzB=()=>{let e=Vnl,t=Vnl,r=!1,i=!1;return{promise:new Promise((d,s)=>{e=u=>(r=!0,d(u)),t=u=>(i=!0,s(u))}),resolve:e,reject:t,isPending:()=>!r&&!i,isResolved:()=>r,isRejected:()=>i}},HGh=SzB;var MzB=()=>{let{promise:e,resolve:t,isPending:r}=HGh(),i=0,n=()=>{i+=1},a=()=>{i-=1,!i&&t()};return(()=>{n(),queueMicrotask(a)})(),{promise:e,isPending:r,increment:n,decrement:a}},KGh=MzB;var JGh={then:e=>{e()}};var $Gh=e=>Array.isArray(e)?e:[e],YGh=e=>typeof e=="function";var DzB=(e,t)=>{let r=t?.followSymlinks??!1,i=t?.depth??1/0,n=t?.limit??1/0,a=t?.ignore??[],o=$Gh(a).map(W=>YGh(W)?W:x=>W.test(x)),c=W=>o.some(x=>x(W)),d=t?.signal??{aborted:!1},s=t?.onDirents||(()=>{}),u=[],l=new Set,p={},_=[],h=new Set,y={},b=[],v=new Set,O={},m={},g=new Set,A={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{},map:{}},j={directories:u,directoriesNames:l,directoriesNamesToPaths:p,files:_,filesNames:h,filesNamesToPaths:y,symlinks:b,symlinksNames:v,symlinksNamesToPaths:O,map:m},{promise:M,increment:w,decrement:D}=KGh(),B=0,T=(W,x,Ee,ue)=>{g.has(x)||B>=n||(B+=1,W.directories.push(x),W.directoriesNames.add(Ee),u.push(x),l.add(Ee),p.propertyIsEnumerable(Ee)||(p[Ee]=[]),p[Ee].push(x),g.add(x),!(ue>=i)&&(B>=n||Y(x,ue+1)))},R=(W,x,Ee)=>{g.has(x)||B>=n||(B+=1,W.files.push(x),W.filesNames.add(Ee),_.push(x),h.add(Ee),y.propertyIsEnumerable(Ee)||(y[Ee]=[]),y[Ee].push(x),g.add(x))},q=(W,x,Ee,ue)=>{g.has(x)||B>=n||(B+=1,W.symlinks.push(x),W.symlinksNames.add(Ee),b.push(x),v.add(Ee),O.propertyIsEnumerable(Ee)||(O[Ee]=[]),O[Ee].push(x),g.add(x),r&&(ue>=i||B>=n||he(x,ue+1)))},z=(W,x,Ee,ue,Oe)=>{d.aborted||c(x)||(ue.isDirectory()?T(W,x,Ee,Oe):ue.isFile()?R(W,x,Ee):ue.isSymbolicLink()&&q(W,x,Ee,Oe))},Q=(W,x,Ee,ue)=>{if(d.aborted)return;let Oe=x===TXa.default.sep?"":TXa.default.sep,Fe=Ee.name,ae=`${x}${Oe}${Fe}`;c(ae)||(Ee.isDirectory()?T(W,ae,Fe,ue):Ee.isFile()?R(W,ae,Fe):Ee.isSymbolicLink()&&q(W,ae,Fe,ue))},H=(W,x,Ee,ue)=>{for(let Oe=0,Fe=Ee.length;Oe<Fe;Oe++)Q(W,x,Ee[Oe],ue)},Y=(W,x)=>{d.aborted||x>i||B>=n||(w(),REu.default.readdir(W,{withFileTypes:!0},(Ee,ue)=>{if(Ee||d.aborted||!ue.length)return D();(s(ue)||JGh).then(()=>{let Fe=m[W]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};H(Fe,W,ue,x),D()})}))},he=(W,x)=>{w(),REu.default.realpath(W,(Ee,ue)=>{if(Ee||d.aborted)return D();REu.default.stat(ue,(Oe,Fe)=>{if(Oe||d.aborted)return D();let ae=TXa.default.basename(ue),re=m[W]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};z(re,ue,ae,Fe,x),D()})})};return(async(W,x=1)=>(W=TXa.default.normalize(W),g.add(W),Y(W,x),await M,d.aborted?A:j))(e)},XGh=DzB;var VXt={lang:{debounce:TEu,attempt:e=>{try{return e()}catch(t){return VXt.lang.castError(t)}},castArray:e=>VXt.lang.isArray(e)?e:[e],castError:e=>VXt.lang.isError(e)?e:VXt.lang.isString(e)?new Error(e):new Error("Unknown error"),defer:e=>setTimeout(e,0),isArray:e=>Array.isArray(e),isError:e=>e instanceof Error,isFunction:e=>typeof e=="function",isNaN:e=>Number.isNaN(e),isNumber:e=>typeof e=="number",isPrimitive:e=>{if(e===null)return!0;let t=typeof e;return t!=="object"&&t!=="function"},isShallowEqual:(e,t)=>{if(e===t)return!0;if(VXt.lang.isNaN(e))return VXt.lang.isNaN(t);if(VXt.lang.isPrimitive(e)||VXt.lang.isPrimitive(t))return e===t;for(let r in e)if(!(r in t))return!1;for(let r in t)if(e[r]!==t[r])return!1;return!0},isSet:e=>e instanceof Set,isString:e=>typeof e=="string",isUndefined:e=>e===void 0,noop:()=>{},uniq:e=>e.length<2?e:Array.from(new Set(e))},fs:{getDepth:e=>Math.max(0,e.split(zEu.default.sep).length-1),getRealPath:(e,t)=>{try{return t?Wnl.default.realpathSync.native(e):Wnl.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===zEu.default.sep&&t.length-e.length>zEu.default.sep.length,poll:(e,t=LGh)=>xGh.retry.stat(t)(e,{bigint:!0}).catch(VXt.lang.noop),readdir:async(e,t,r=1/0,i=1/0,n,a)=>{if(a&&r===1&&e in a){let o=a[e];return[o.directories,o.files]}else{let o=await XGh(e,{depth:r,limit:i,ignore:t,signal:n});return[o.directories,o.files]}}}},Gp=VXt;var NEu=ce(require("path"),1);var Gnl=class{constructor(t,r,i){this.base=i,this.watcher=t,this.handler=r.handler,this.fswatcher=r.watcher,this.options=r.options,this.folderPath=r.folderPath,this.filePath=r.filePath,this.handlerBatched=this.base?this.base.onWatcherEvent.bind(this.base):this._makeHandlerBatched(this.options.debounce)}_isSubRoot(t){return this.filePath?t===this.filePath:t===this.folderPath||Gp.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=FGh){return(()=>{let r=this.watcher._readyWait,i=[],n=new Set,a=async(c,d)=>{let s=this.options.ignoreInitial?[]:c,u=await this.eventsPopulate([...d]),l=this.eventsDeduplicate([...s,...u]);this.onTargetEvents(l)},o=Gp.lang.debounce(()=>{this.watcher.isClosed()||(r=a(i,n),i=[],n=new Set)},t);return async(c,d="",s=!1)=>{s?await this.eventsPopulate([d],i,!0):n.add(d),r.then(o)}})()}eventsDeduplicate(t){if(t.length<2)return t;let r={};return t.reduce((i,n)=>{let[a,o]=n,c=r[o];return a===c||a===rf.CHANGE&&c===rf.ADD||(r[o]=a,i.push(n)),i},[])}async eventsPopulate(t,r=[],i=!1){return await Promise.all(t.map(async n=>{let a=await this.watcher._poller.update(n,this.options.pollingTimeout);await Promise.all(a.map(async o=>{r.push([o,n]),o===rf.ADD_DIR?await this.eventsPopulateAddDir(t,n,r,i):o===rf.UNLINK_DIR&&await this.eventsPopulateUnlinkDir(t,n,r,i)}))})),r}async eventsPopulateAddDir(t,r,i=[],n=!1){if(n)return i;let a=this.options.recursive?this.options.depth??KYi:Math.min(1,this.options.depth??KYi),o=this.options.limit??IXa,[c,d]=await Gp.fs.readdir(r,this.options.ignore,a,o,this.watcher._closeSignal),s=[...c,...d];return await Promise.all(s.map(u=>{if(!this.watcher.isIgnored(u,this.options.ignore)&&!t.includes(u))return this.eventsPopulate([u],i,!0)})),i}async eventsPopulateUnlinkDir(t,r,i=[],n=!1){if(n)return i;for(let a of this.watcher._poller.stats.keys())Gp.fs.isSubPath(r,a)&&(t.includes(a)||await this.eventsPopulate([a],i,!0));return i}onTargetAdd(t){this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAdd(t,this.options.renameTimeout):this.watcher.event(rf.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!JYi&&this.options.native!==!1&&this.watcher.watchDirectory(t,this.options,this.handler,void 0,this.base||this),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAddDir(t,this.options.renameTimeout):this.watcher.event(rf.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(rf.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(NEu.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(rf.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(NEu.default.dirname(t),t,!1),this.watcher.watchersClose(t),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlinkDir(t,this.options.renameTimeout):this.watcher.event(rf.UNLINK_DIR,t))}onTargetEvent(t){let[r,i]=t;r===rf.ADD?this.onTargetAdd(i):r===rf.ADD_DIR?this.onTargetAddDir(i):r===rf.CHANGE?this.onTargetChange(i):r===rf.UNLINK?this.onTargetUnlink(i):r===rf.UNLINK_DIR&&this.onTargetUnlinkDir(i)}onTargetEvents(t){for(let r of t)this.onTargetEvent(r)}onWatcherEvent(t,r,i=!1){return this.handlerBatched(t,r,i)}onWatcherChange(t=OOn.CHANGE,r){if(this.watcher.isClosed())return;let i=NEu.default.resolve(this.folderPath,r||"");this.filePath&&i!==this.folderPath&&i!==this.filePath||this.watcher.isIgnored(i,this.options.ignore)||this.onWatcherEvent(t,i)}onWatcherError(t){Fnl&&t.code==="EPERM"?this.onWatcherChange(OOn.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(CXa.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(CXa.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(OOn.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&JYi&&this.options.native!==!1?this.options.depth??KYi:Math.min(1,this.options.depth??KYi),i=this.options.limit??IXa,[n,a]=await Gp.fs.readdir(this.folderPath,this.options.ignore,r,i,this.watcher._closeSignal,this.options.readdirMap),o=[this.folderPath,...n,...a];await Promise.all(o.map(c=>{if(!this.watcher._poller.stats.has(c)&&!this.watcher.isIgnored(c,this.options.ignore))return this.onWatcherEvent(OOn.CHANGE,c,t)}))}}},ZGh=Gnl;var Wx={interval:100,intervalId:void 0,fns:new Map,init:()=>{Wx.intervalId||(Wx.intervalId=setInterval(Wx.resolve,Wx.interval))},reset:()=>{Wx.intervalId&&(clearInterval(Wx.intervalId),delete Wx.intervalId)},add:(e,t)=>{Wx.fns.set(e,Date.now()+t),Wx.init()},remove:e=>{Wx.fns.delete(e)},resolve:()=>{if(!Wx.fns.size)return Wx.reset();let e=Date.now();for(let[t,r]of Wx.fns)r>=e||(Wx.remove(t),t())}},RXa=Wx;var zXa=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=Qnl){let{ino:i,targetPath:n,events:a,locks:o}=t,c=()=>{let l=this._watcher._poller.paths.find(i||-1,p=>p!==n);if(l&&l!==n){if(Gp.fs.getRealPath(n,!0)===l)return;this._watcher.event(a.rename,l,n)}else this._watcher.event(a.add,n)};if(!i)return c();let d=()=>{o.add.delete(i),RXa.remove(s)},s=()=>{d(),c()};RXa.add(s,r);let u=()=>{let l=o.unlink.get(i);if(!l)return;d();let p=l();n===p?a.change&&this._watcher._poller.stats.has(n)&&this._watcher.event(a.change,n):this._watcher.event(a.rename,p,n)};o.add.set(i,u),u()}getLockUnlink(t,r=Qnl){let{ino:i,targetPath:n,events:a,locks:o}=t,c=()=>{this._watcher.event(a.unlink,n)};if(!i)return c();let d=()=>{o.unlink.delete(i),RXa.remove(s)},s=()=>{d(),c()};RXa.add(s,r);let u=()=>(d(),n);o.unlink.set(i,u),o.add.get(i)?.()}getLockTargetAdd(t,r){let i=this._watcher._poller.getIno(t,rf.ADD,UXt.FILE);return this.getLockAdd({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetAddDir(t,r){let i=this._watcher._poller.getIno(t,rf.ADD_DIR,UXt.DIR);return this.getLockAdd({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}getLockTargetUnlink(t,r){let i=this._watcher._poller.getIno(t,rf.UNLINK,UXt.FILE);return this.getLockUnlink({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetUnlinkDir(t,r){let i=this._watcher._poller.getIno(t,rf.UNLINK_DIR,UXt.DIR);return this.getLockUnlink({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}reset(){this._locksAdd=new Map,this._locksAddDir=new Map,this._locksUnlink=new Map,this._locksUnlinkDir=new Map,this._locksDir={add:this._locksAddDir,unlink:this._locksUnlinkDir},this._locksFile={add:this._locksAdd,unlink:this._locksUnlink}}};zXa.DIR_EVENTS={add:rf.ADD_DIR,rename:rf.RENAME_DIR,unlink:rf.UNLINK_DIR};zXa.FILE_EVENTS={add:rf.ADD,change:rf.CHANGE,rename:rf.RENAME,unlink:rf.UNLINK};var kGh=zXa;var xnl=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(Gp.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let i=this.map.get(t);if(Gp.lang.isSet(i)){let n=i.delete(r);return i.size||this.map.delete(t),n}else if(i===r)return this.map.delete(t),!0}return!1}find(t,r){if(this.map.has(t)){let i=this.map.get(t);if(Gp.lang.isSet(i))return Array.from(i).find(r);if(r(i))return i}}get(t){return this.map.get(t)}has(t,r){if(Gp.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let i=this.map.get(t);return Gp.lang.isSet(i)?i.has(r):i===r}return!1}set(t,r){if(this.map.has(t)){let i=this.map.get(t);Gp.lang.isSet(i)?i.add(r):i!==r&&this.map.set(t,new Set([i,r]))}else this.map.set(t,r);return this}},Hnl=xnl;var Knl=class{constructor(t){this.ino=t.ino<=Number.MAX_SAFE_INTEGER?Number(t.ino):t.ino,this.size=Number(t.size),this.atimeMs=Number(t.atimeMs),this.mtimeMs=Number(t.mtimeMs),this.ctimeMs=Number(t.ctimeMs),this.birthtimeMs=Number(t.birthtimeMs),this._isFile=t.isFile(),this._isDirectory=t.isDirectory(),this._isSymbolicLink=t.isSymbolicLink()}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isSymbolicLink(){return this._isSymbolicLink}},exh=Knl;var Jnl=class{constructor(){this.inos={},this.paths=new Hnl,this.stats=new Map}getIno(t,r,i){let n=this.inos[r];if(!n)return;let a=n[t];if(a&&!(i&&a[1]!==i))return a[0]}getStats(t){return this.stats.get(t)}async poll(t,r){let i=await Gp.fs.poll(t,r);if(!(!i||!(i.isFile()||i.isDirectory())))return new exh(i)}reset(){this.inos={},this.paths=new Hnl,this.stats=new Map}async update(t,r){let i=this.getStats(t),n=await this.poll(t,r);if(this.updateStats(t,n),!i&&n){if(n.isFile())return this.updateIno(t,rf.ADD,n),[rf.ADD];if(n.isDirectory())return this.updateIno(t,rf.ADD_DIR,n),[rf.ADD_DIR]}else if(i&&!n){if(i.isFile())return this.updateIno(t,rf.UNLINK,i),[rf.UNLINK];if(i.isDirectory())return this.updateIno(t,rf.UNLINK_DIR,i),[rf.UNLINK_DIR]}else if(i&&n){if(i.isFile()){if(n.isFile())return i.ino===n.ino&&!i.size&&!n.size?[]:(this.updateIno(t,rf.CHANGE,n),[rf.CHANGE]);if(n.isDirectory())return this.updateIno(t,rf.UNLINK,i),this.updateIno(t,rf.ADD_DIR,n),[rf.UNLINK,rf.ADD_DIR]}else if(i.isDirectory()){if(n.isFile())return this.updateIno(t,rf.UNLINK_DIR,i),this.updateIno(t,rf.ADD,n),[rf.UNLINK_DIR,rf.ADD];if(n.isDirectory())return i.ino===n.ino?[]:(this.updateIno(t,rf.UNLINK_DIR,i),this.updateIno(t,rf.ADD_DIR,n),[rf.UNLINK_DIR,rf.ADD_DIR])}}return[]}updateIno(t,r,i){let n=this.inos[r]=this.inos[r]||(this.inos[r]={}),a=i.isFile()?UXt.FILE:UXt.DIR;n[t]=[i.ino,a]}updateStats(t,r){if(r)this.paths.set(r.ino,t),this.stats.set(t,r);else{let i=this.stats.get(t)?.ino||-1;this.paths.delete(i,t),this.stats.delete(t)}}},$nl=Jnl;var Ynl=class e extends txh.EventEmitter{constructor(t,r,i){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(Vx.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(n=>this.on(Vx.CLOSE,n)),this._readyWait=new Promise(n=>this.on(Vx.READY,n)),this._locker=new kGh(this),this._roots=new Set,this._poller=new $nl,this._pollers=new Set,this._subwatchers=new Set,this._watchers={},this._watchersLock=Promise.resolve(),this._watchersRestorable={},this.watch(t,r,i)}isClosed(){return this._closed}isIgnored(t,r){return!!r&&(Gp.lang.isFunction(r)?!!r(t):r.test(t))}isReady(){return this._ready}close(){return this._locker.reset(),this._poller.reset(),this._roots.clear(),this.watchersClose(),this.isClosed()?!1:(this._closed=!0,this.emit(Vx.CLOSE))}error(t){if(this.isClosed())return!1;let r=Gp.lang.castError(t);return this.emit(Vx.ERROR,r)}event(t,r,i){return this.isClosed()?!1:(this.emit(Vx.ALL,t,r,i),this.emit(t,r,i))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(Vx.READY))}pollerExists(t,r){for(let i of this._pollers)if(i.targetPath===t&&Gp.lang.isShallowEqual(i.options,r))return!0;return!1}subwatcherExists(t,r){for(let i of this._subwatchers)if(i.targetPath===t&&Gp.lang.isShallowEqual(i.options,r))return!0;return!1}watchersClose(t,r,i=!0){if(t){let n=this._watchers[t];if(n)for(let a of[...n])r&&a.filePath!==r||this.watcherClose(a);if(i)for(let a in this._watchers)Gp.fs.isSubPath(t,a)&&this.watchersClose(a,r,!1)}else for(let n in this._watchers)this.watchersClose(n,r,!1)}watchersLock(t){return this._watchersLock.then(()=>this._watchersLock=new Promise(async r=>{await t(),r()}))}watchersRestore(){delete this._watchersRestoreTimeout;let t=Object.entries(this._watchersRestorable);this._watchersRestorable={};for(let[r,i]of t)this.watchPath(r,i.options,i.handler)}async watcherAdd(t,r){let{folderPath:i}=t;(this._watchers[i]=this._watchers[i]||[]).push(t);let a=new ZGh(this,t,r);return await a.init(),a}watcherClose(t){t.watcher.close();let r=this._watchers[t.folderPath];if(r){let a=r.indexOf(t);r.splice(a,1),r.length||delete this._watchers[t.folderPath]}let i=t.filePath||t.folderPath;this._roots.has(i)&&(this._watchersRestorable[i]=t,this._watchersRestoreTimeout||(this._watchersRestoreTimeout=Gp.lang.defer(()=>this.watchersRestore())))}watcherExists(t,r,i,n){if(this._watchers[t]?.find(c=>c.handler===i&&(!c.filePath||c.filePath===n)&&c.options.ignore===r.ignore&&!!c.options.native==!!r.native&&(!r.recursive||c.options.recursive)))return!0;let o=mOn.default.dirname(t);for(let c=1;c<1/0;c++){if(this._watchers[o]?.find(u=>(c===1||u.options.recursive&&c<=(u.options.depth??KYi))&&u.handler===i&&(!u.filePath||u.filePath===n)&&u.options.ignore===r.ignore&&!!u.options.native==!!r.native&&(!r.recursive||u.options.recursive&&JYi&&u.options.native!==!1)))return!0;if(!JYi)break;let s=mOn.default.dirname(t);if(o===s)break;o=s}return!1}async watchDirectories(t,r,i,n,a){if(this.isClosed())return;t=Gp.lang.uniq(t).sort();let o;for(let c of t)if(!this.isIgnored(c,r.ignore)&&!this.watcherExists(c,r,i,n))try{let d=!r.recursive||JYi&&r.native!==!1?r:{...r,recursive:!1},u={watcher:FEu.default.watch(c,d),handler:i,options:r,folderPath:c,filePath:n},l=o=await this.watcherAdd(u,a);if(this._roots.has(n||c)){let _={...r,ignoreInitial:!0,recursive:!1},h=mOn.default.dirname(c),y=c;await this.watchDirectories([h],_,i,y,l)}}catch(d){this.error(d)}return o}async watchDirectory(t,r,i,n,a){if(!this.isClosed()&&!this.isIgnored(t,r.ignore)){if(!r.recursive||JYi&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,i,n,a));{r={...r,recursive:!0};let o=r.depth??KYi,c=r.limit??IXa,[d]=await Gp.fs.readdir(t,r.ignore,o,c,this._closeSignal,r.readdirMap);return this.watchersLock(async()=>{let s=await this.watchDirectories([t],r,i,n,a);if(d.length){let u=Gp.fs.getDepth(t);for(let l of d){let p=Gp.fs.getDepth(l),_=Math.max(0,o-(p-u)),h={...r,depth:_};await this.watchDirectories([l],h,i,n,a||s)}}})}}}async watchFileOnce(t,r,i){if(this.isClosed()||(r={...r,ignoreInitial:!1},this.subwatcherExists(t,r)))return;let n={targetPath:t,options:r},a=(s,u)=>{u===t&&(d(),i())},o=new e(a),c=()=>{this._subwatchers.add(n),this.on(Vx.CLOSE,d),o.watchFile(t,r,a)},d=()=>{this._subwatchers.delete(n),this.removeListener(Vx.CLOSE,d),o.close()};return c()}async watchFile(t,r,i){if(this.isClosed()||this.isIgnored(t,r.ignore))return;r={...r,recursive:!1};let n=mOn.default.dirname(t);return this.watchDirectory(n,r,i,t)}async watchPollingOnce(t,r,i){if(this.isClosed())return;let n=!1,a=new $nl,o=await this.watchPolling(t,r,async()=>{n||!(await a.update(t,r.pollingTimeout)).length||n||(n=!0,o(),i())})}async watchPolling(t,r,i){if(this.isClosed())return Gp.lang.noop;if(this.pollerExists(t,r))return Gp.lang.noop;let n={...r,interval:r.pollingInterval??UGh},a={targetPath:t,options:r},o=()=>{this._pollers.add(a),this.on(Vx.CLOSE,c),FEu.default.watchFile(t,n,i)},c=()=>{this._pollers.delete(a),this.removeListener(Vx.CLOSE,c),FEu.default.unwatchFile(t,i)};return Gp.lang.attempt(o),()=>Gp.lang.attempt(c)}async watchUnknownChild(t,r,i){if(this.isClosed())return;let n=()=>this.watchPath(t,r,i);return this.watchFileOnce(t,r,n)}async watchUnknownTarget(t,r,i){if(this.isClosed())return;let n=()=>this.watchPath(t,r,i);return this.watchPollingOnce(t,r,n)}async watchPaths(t,r,i){if(this.isClosed())return;if(t=Gp.lang.uniq(t).sort(),t.every((a,o)=>t.every((c,d)=>d===o||!Gp.fs.isSubPath(a,c))))await Promise.all(t.map(a=>this.watchPath(a,r,i)));else for(let a of t)await this.watchPath(a,r,i)}async watchPath(t,r,i){if(this.isClosed()||(t=mOn.default.resolve(t),this.isIgnored(t,r.ignore)))return;let n=await Gp.fs.poll(t,r.pollingTimeout);if(n){if(n.isFile())return this.watchFile(t,r,i);if(n.isDirectory())return this.watchDirectory(t,r,i);this.error(`"${t}" is not supported`)}else{let a=mOn.default.dirname(t);return(await Gp.fs.poll(a,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,i):this.watchUnknownTarget(t,r,i)}}async watch(t,r,i=Gp.lang.noop){if(Gp.lang.isFunction(t))return this.watch([],{},t);if(Gp.lang.isUndefined(t))return this.watch([],r,i);if(Gp.lang.isFunction(r))return this.watch(t,{},r);if(Gp.lang.isUndefined(r))return this.watch(t,{},i);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let n=Gp.lang.castArray(t);n.forEach(a=>this._roots.add(a)),await this.watchPaths(n,r,i),!this.isClosed()&&(i!==Gp.lang.noop&&this.on(Vx.ALL,i),r.readdirMap=void 0,this.ready())}},QEu=Ynl;jru();var Rla=require("fs/promises"),rxh=require("os"),ixh=ce(require("path"),1),BzB=".fern",IzB="logs";function CzB(){return"cli@3.47.2"}var NXa=class{logFilePath=null;initialized=!1;sessionStartTime;constructor(){this.sessionStartTime=Date.now()}async initialize(){if(this.initialized)return;let t=Tt(Sr.of((0,rxh.homedir)()),Je.of(BzB)),r=Tt(t,Je.of(IzB));await Ai(r)||await(0,Rla.mkdir)(r,{recursive:!0});let n=`${new Date().toISOString().replace(/[:.]/g,"-")}.debug.log`;this.logFilePath=Tt(r,Je.of(n));let a=["================================================================================","Fern Docs Dev Debug Log",`Session started: ${new Date().toISOString()}`,`Log file: ${ixh.default.basename(this.logFilePath)}`,"================================================================================",""].join(`
|
|
1944
1944
|
`);await(0,Rla.writeFile)(this.logFilePath,a,"utf-8"),this.initialized=!0}getLogFilePath(){return this.logFilePath}async writeEntry(t){if(!this.initialized||!this.logFilePath)return;let r=JSON.stringify(t)+`
|
|
1945
1945
|
`;try{await(0,Rla.appendFile)(this.logFilePath,r,"utf-8")}catch{}}async logFrontendMetrics(t){let r={timestamp:t.timestamp,source:t.source,level:t.level,eventType:this.getEventType(t.payload,t.isAggregate),isAggregate:t.isAggregate,data:t.payload};await this.writeEntry(r)}async logCliMetric(t,r="info"){let i={timestamp:t.timestamp,source:CzB(),level:r,eventType:t.type,data:{durationMs:t.durationMs,metadata:t.metadata}};await this.writeEntry(i)}async logCliMemory(){let t=process.memoryUsage(),r={type:"cli_memory",timestamp:new Date().toISOString(),metadata:{heapUsed:t.heapUsed,heapTotal:t.heapTotal,external:t.external,rss:t.rss,heapUsedMB:Math.round(t.heapUsed/1024/1024*100)/100,heapTotalMB:Math.round(t.heapTotal/1024/1024*100)/100,rssMB:Math.round(t.rss/1024/1024*100)/100}};await this.logCliMetric(r)}async logCliReloadStart(){let t={type:"cli_reload_start",timestamp:new Date().toISOString()};await this.logCliMetric(t)}async logCliReloadFinish(t,r){let i={type:"cli_reload_finish",timestamp:new Date().toISOString(),durationMs:t,metadata:r};await this.logCliMetric(i)}async logCliDocsGeneration(t,r){let i={type:"cli_docs_generation",timestamp:new Date().toISOString(),durationMs:t,metadata:r};await this.logCliMetric(i)}async logCliValidation(t,r){let i={type:"cli_validation",timestamp:new Date().toISOString(),durationMs:t,metadata:{success:r}};await this.logCliMetric(i)}getEventType(t,r){return r?"aggregate_summary":"type"in t&&typeof t.type=="string"?t.type:"unknown"}static isMetricsMessage(t){if(typeof t!="object"||t===null)return!1;let r=t;return r.type==="metrics"&&typeof r.timestamp=="string"&&typeof r.source=="string"}};var Pol=ce(aal(),1),$$h=ce(BSu(),1),LY=require("fs/promises"),Y$h=require("os"),X$h=ce(M4(),1),Z$h=ce(K$h(),1),KSu=process.platform==="win32",Aol=Rt.cyan("[docs]:"),ZUB="etag",kUB=23,J$h=e=>e.padEnd(kUB," "),e4B="preview",t4B="app-preview",r4B="bundle",i4B=".next",n4B="standalone",a4B=".fern",o4B="packages/fern-docs/bundle/.next/server/instrumentation.js",u4B=".npmrc",s4B=".pnpmfile.cjs",c4B="pnpm-workspace.yaml",l4B='Cannot find matching keyid: {"signatures":';function f4B(){return Tt(Sr.of((0,Y$h.homedir)()),Je.of(a4B))}function Zla({app:e=!1}){return Tt(f4B(),Je.of(e?t4B:e4B))}function iXi({app:e=!1}){return Tt(Zla({app:e}),Je.of(e?i4B:r4B))}function uZa({app:e=!1}){return Tt(iXi({app:e}),Je.of(n4B))}function d4B({app:e=!1}){return Tt(uZa({app:e}),Je.of(o4B))}function p4B({app:e=!1}){return Tt(uZa({app:e}),Je.of(c4B))}function _4B({app:e=!1}){return Tt(uZa({app:e}),Je.of(s4B))}function h4B({app:e=!1}){return Tt(uZa({app:e}),Je.of(u4B))}function MOn(e){return new Error(`${e}. Please reach out to support@buildwithfern.com.`)}function y4B({app:e=!1}){return Tt(Zla({app:e}),Je.of(ZUB))}var b4B=`module.exports = {
|
|
1946
1946
|
hooks: {
|