fern-api 3.49.7 → 3.49.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +4 -4
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1266,7 +1266,7 @@ ${H9_.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&jRc(th
|
|
|
1266
1266
|
`+tyn.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?tyn.default.cyan(tG_(t,this.opt.mask)):tyn.default.italic(tyn.default.dim("[hidden]")):this.opt.mask?tG_(t,this.opt.mask):tyn.default.italic(tyn.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 KXo=ue(wR(),1);var tx_=ue(azc(),1),xXo=require("child_process"),Hta=require("fs"),GXo=ue(require("path"),1),rx_=ue(require("os"),1),ix_=require("crypto"),Wzc=ue(kG_(),1);var LXo=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var EGa=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var VXo=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var WXo=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function HXo(e="",t,r){let i=new Gzc(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 ex_(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function h_D(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 Gzc=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=h_D(t).map(n=>n.replace("\\ "," ")),i=r.shift();this.editor={args:r,bin:i}}createTemporaryFile(){try{let t=this.fileOptions.dir??rx_.default.tmpdir(),r=(0,ix_.randomUUID)(),i=ex_(this.fileOptions.prefix),n=ex_(this.fileOptions.postfix),a=`${i}${r}${n}`,o=GXo.default.resolve(t,a),c=GXo.default.resolve(t)+GXo.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,Hta.writeFileSync)(this.tempFile,this.text,d)}catch(t){throw new LXo(t)}}readTemporaryFile(){try{let t=(0,Hta.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,tx_.detect)(t)??"utf8";Wzc.default.encodingExists(r)||(r="utf8"),this.text=Wzc.default.decode(t,r)}}catch(t){throw new VXo(t)}}removeTemporaryFile(){try{(0,Hta.unlinkSync)(this.tempFile)}catch(t){throw new WXo(t)}}launchEditor(){try{let t=(0,xXo.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new EGa(t)}}launchEditorAsync(t){try{(0,xXo.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",i=>{this.lastExitStatus=i,setImmediate(t)})}catch(r){throw new EGa(r)}}};var nx_=ue(Rve(),1);var SGa=class extends ER{_run(t){this.done=t,this.editorResult=new nx_.Subject;let r=sL(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"?KXo.default.dim("Received"):KXo.default.dim("Press <enter> to launch your preferred editor."),t&&(r=KXo.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),HXo(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 cx_=require("stream");var ux_=ue(require("readline"),1),sx_=ue(ox_(),1),ayn=class{constructor(t){this.rl||=ux_.default.createInterface(b_D(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 b_D(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 sx_.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var MGa=class extends ayn{constructor(t={}){super(t),this.log=new cx_.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return fGa(this.rl,this.bottomBar.split(`
|
|
1267
1267
|
`).length),this}updateBottomBar(t){return fGa(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+`
|
|
1268
1268
|
`}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&&hXo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var sm=ue(Rve(),1),dx_=ue(V9a(),1);var JXo=ue(Rve(),1),lx_=ue(V9a(),1),$Xo=function(e,t,r){return typeof e[t]!="function"?(0,JXo.of)(e):(0,JXo.from)((0,lx_.default)(e[t])(r).then(i=>(e[t]=i,e)))};var fx_={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}},Kta=class extends ayn{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,sm.from)(t):(0,sm.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,sm.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,sm.from)([t]),this.process=i.pipe((0,sm.concatMap)(this.processQuestion.bind(this)),(0,sm.publish)()),this.process.connect(),this.process.pipe((0,sm.reduce)((n,a)=>(fx_.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,sm.defer)(()=>(0,sm.of)(t).pipe((0,sm.concatMap)(this.setDefaultType.bind(this)),(0,sm.concatMap)(this.filterIfRunnable.bind(this)),(0,sm.concatMap)(()=>$Xo(t,"message",this.answers)),(0,sm.concatMap)(()=>$Xo(t,"default",this.answers)),(0,sm.concatMap)(()=>$Xo(t,"choices",this.answers)),(0,sm.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,sm.defer)(()=>(0,sm.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,sm.defer)(()=>(0,sm.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&fx_.get(this.answers,t.name)!==void 0)return sm.EMPTY;if(t.when===!1)return sm.EMPTY;if(typeof t.when!="function")return(0,sm.of)(t);let{answers:r}=this;return(0,sm.defer)(()=>(0,sm.from)((0,dx_.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,sm.filter)(i=>i!=null)))}};function px_(e){let t=function(r,i){let n;try{n=new Kta(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",pGa),this.registerPrompt("input",eyn),this.registerPrompt("number",_Ga),this.registerPrompt("confirm",hGa),this.registerPrompt("rawlist",yGa),this.registerPrompt("expand",bGa),this.registerPrompt("checkbox",vGa),this.registerPrompt("password",gGa),this.registerPrompt("editor",SGa)},t.restoreDefaultPrompts(),t}var Hzc=px_();function g_D(e,t){Hzc.registerPrompt(e,t)}function O_D(){Hzc.restoreDefaultPrompts()}var m_D={prompt:Hzc,ui:{BottomBar:MGa,Prompt:Kta},createPromptModule:px_,registerPrompt:g_D,restoreDefaultPrompts:O_D,Separator:L$},YXo=m_D;var Jta=require("path");function hx_(){let e=A_D();return async t=>{for(let r of t)r.module=e(r.filename);return t}}function A_D(e=process.argv[1]?(0,Jta.dirname)(process.argv[1]):process.cwd(),t=Jta.sep==="\\"){let r=t?_x_(e):e;return i=>{if(!i)return;let n=t?_x_(i):i,{dir:a,base:o,ext:c}=Jta.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 _x_(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var Kzc=e=>{if("flags"in e){let t=yx_(e.flags),r=bx_(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,vx_(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,P_D(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function P_D(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 yx_=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,oyn(r)]).filter(([,t])=>t!==void 0)),bx_=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?vx_(i):void 0]}))};var oyn=e=>e===void 0?void 0:e.variant??e.enabled,vx_=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};var XXo="0123456789abcdef",ZXo=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+=XXo.charAt(this.bytes[r]>>>4),t+=XXo.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+=XXo.charAt(this.bytes[r]>>>4),t+=XXo.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}},Jzc=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??j_D()}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 ZXo.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,ZXo.ofInner(t)}},j_D=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())}),gx_,z$t=()=>w_D().toString(),w_D=()=>(gx_||(gx_=new Jzc)).generate();var E_D=["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"],Ox_=function(e,t=[]){if(!e)return!1;let r=e.toLowerCase();return E_D.concat(t).some(i=>{let n=i.toLowerCase();return r.indexOf(n)!==-1})};var W$=(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 M_D=Array.isArray,mx_=Object.prototype,V89=mx_.hasOwnProperty,$zc=mx_.toString,Ax_=M_D||function(e){return $zc.call(e)==="[object Array]"};var $ta=e=>e===void 0,DGa=e=>$zc.call(e)=="[object String]",Px_=e=>DGa(e)&&e.trim().length===0;var jx_=e=>$zc.call(e)=="[object Number]";var Yzc=e=>e instanceof Error;function D_D(e,t){try{return e instanceof t}catch{return!1}}function BGa(e){return e===null||typeof e!="object"}function uyn(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function wx_(e){return uyn(e,"ErrorEvent")}function kXo(e){return!$ta(Event)&&D_D(e,Event)}function Ex_(e){return uyn(e,"Object")}function IGa(e,t,r,i,n){return t>r&&(i.warn("min cannot be greater than max."),t=r),jx_(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),IGa(n||r,t,r,i))}var B_D=864e5,eZo=class{constructor(t){this._buckets={},this._onBucketRateLimited=t._onBucketRateLimited,this._bucketSize=IGa(t.bucketSize,0,100,t._logger),this._refillRate=IGa(t.refillRate,0,this._bucketSize,t._logger),this._refillInterval=IGa(t.refillInterval,0,B_D,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 tZo=class{add(t){let r=z$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 I_D(e=console){return{log:e.log.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),debug:e.debug.bind(e)}}var Sx_=(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=>Sx_(`${e} ${a}`,t,r)}},C_D=e=>e();function Mx_(e,t=C_D){return Sx_(e,t,I_D())}var Xta="Mobile",iZo="iOS",Yta="Android",Dx_="Tablet",eW9=Yta+" "+Dx_;var q_D="Apple",tW9=q_D+" Watch",Bx_="Safari",nZo="BlackBerry",Ix_="Samsung",T_D=Ix_+"Browser",R_D=Ix_+" Internet",aZo="Chrome",z_D=aZo+" OS",N_D=aZo+" "+iZo,Cx_="Internet Explorer",F_D=Cx_+" "+Xta,Zzc="Opera",rW9=Zzc+" Mini",qx_="Edge",Q_D="Microsoft "+qx_,kzc="Firefox",U_D=kzc+" "+iZo,eNc="Nintendo",tNc="PlayStation",rZo="Xbox",L_D=Yta+" "+Xta,V_D=Xta+" "+Bx_,CGa="Windows",W_D=CGa+" Phone";var Tx_="Generic",iW9=Tx_+" "+Xta.toLowerCase(),nW9=Tx_+" "+Dx_.toLowerCase(),G_D="Konqueror",YG="(\\d+(\\.\\d+)?)",Xzc=new RegExp("Version/"+YG),aW9=new RegExp(rZo,"i"),oW9=new RegExp(tNc+" \\w+","i"),uW9=new RegExp(eNc+" \\w+","i"),x_D=new RegExp(nZo+"|PlayBook|BB10","i"),H_D={"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 sW9={[F_D]:[new RegExp("rv:"+YG)],[Q_D]:[new RegExp(qx_+"?\\/"+YG)],[aZo]:[new RegExp("("+aZo+"|CrMo)\\/"+YG)],[N_D]:[new RegExp("CriOS\\/"+YG)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+YG)],[Bx_]:[Xzc],[V_D]:[Xzc],[Zzc]:[new RegExp("("+Zzc+"|OPR)\\/"+YG)],[kzc]:[new RegExp(kzc+"\\/"+YG)],[U_D]:[new RegExp("FxiOS\\/"+YG)],[G_D]:[new RegExp("Konqueror[:/]?"+YG,"i")],[nZo]:[new RegExp(nZo+" "+YG),Xzc],[L_D]:[new RegExp("android\\s"+YG,"i")],[R_D]:[new RegExp(T_D+"\\/"+YG)],[Cx_]:[new RegExp("(rv:|MSIE )"+YG)],Mozilla:[new RegExp("rv:"+YG)]};var cW9=[[new RegExp(rZo+"; "+rZo+" (.*?)[);]","i"),e=>[rZo,e&&e[1]||""]],[new RegExp(eNc,"i"),[eNc,""]],[new RegExp(tNc,"i"),[tNc,""]],[x_D,[nZo,""]],[new RegExp(CGa,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[W_D,""];if(new RegExp(Xta).test(t)&&!/IEMobile\b/.test(t))return[CGa+" "+Xta,""];let r=/Windows NT ([0-9.]+)/i.exec(t);if(r&&r[1]){let i=r[1],n=H_D[i]||"";return/arm/i.test(t)&&(n="RT"),[CGa,n]}return[CGa,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){let t=[e[3],e[4],e[5]||"0"];return[iZo,t.join(".")]}return[iZo,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=$ta(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Yta+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Yta+")","i"),e=>{if(e&&e[2]){let t=[e[2],e[3],e[4]||"0"];return[Yta,t.join(".")]}return[Yta,""]}],[/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/,[z_D,""]],[/Linux|debian/i,["Linux",""]]];var Rx_="utf8";function zx_(e,t){if(!e||typeof e!="string"||K_D(e))throw new Error(t)}function K_D(e){return e.trim().length===0}function Nx_(e){return e?.replace(/\/+$/,"")}async function Fx_(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 oZo(){return new Date().toISOString()}function syn(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var Qx_=e=>e instanceof Error;function rNc(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var uZo=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 Ux_(){return"CompressionStream"in globalThis}async function iNc(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 Zta=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()}},qGa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function Lx_(e){if(e instanceof Zta){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 nNc(e){return typeof e=="object"&&(e instanceof Zta||e instanceof qGa)}function Vx_(e){return typeof e=="object"&&e instanceof Zta&&e.status===413}var TGa=class{constructor(t,r={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new tZo,this._events=new uZo,this._isInitialized=!1,zx_(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=Nx_(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:nNc},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=Mx_("[PostHog]",this.logMsgIfDebug.bind(this)),this.disableCompression=!Ux_()||(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(W$.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(W$.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(W$.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=>Kzc(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=oyn(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(W$.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(W$.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(W$.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(W$.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this._logger.info("Queue is full, the oldest event is dropped.")),a.push({message:n}),this.setPersistedProperty(W$.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=syn(()=>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:oZo()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),o=`${this.host}/batch/`,c=this.disableCompression?null:await iNc(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:oZo(),uuid:i?.uuid?i.uuid:z$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 Lx_(t)})}async flush(){let t=rNc([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),rNc([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(W$.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(W$.Queue)||[]).slice(n.length);this.setPersistedProperty(W$.Queue,h),t=h},c={api_key:this.apiKey,batch:a,sent_at:oZo()};this.historicalMigration&&(c.historical_migration=!0);let d=JSON.stringify(c),s=`${this.host}/batch/`,u=this.disableCompression?null:await iNc(d,this.isDebug),l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",...u!==null&&{"Content-Encoding":"gzip"}},body:u||d},p={retryCheck:_=>Vx_(_)?!1:nNc(_)};try{await this.fetchWithRetry(s,l,p)}catch(_){if(Vx_(_)&&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 qGa||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,Rx_)}catch{a instanceof Blob?o=a.size:o=new TextEncoder().encode(a).length}return await Fx_(async()=>{let c=null;try{c=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(s){throw new qGa(s)}if(!(r.mode==="no-cors")&&(c.status<200||c.status>=400))throw new Zta(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(W$.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!nNc(n))throw n;await Lx_(n)}};return Promise.race([new Promise((n,a)=>{syn(()=>{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 G$={};Yt(G$,{DOMExceptionCoercer:()=>oNc,ErrorCoercer:()=>uNc,ErrorEventCoercer:()=>sNc,ErrorPropertiesBuilder:()=>aNc,EventCoercer:()=>fNc,ObjectCoercer:()=>lNc,PrimitiveCoercer:()=>dNc,PromiseRejectionEventCoercer:()=>pNc,ReduceableCache:()=>_Nc,StringCoercer:()=>cNc,chromeStackLineParser:()=>xx_,createStackParser:()=>uhD,geckoStackLineParser:()=>Kx_,nodeStackLineParser:()=>Xx_,opera10StackLineParser:()=>Jx_,opera11StackLineParser:()=>$x_,reverseAndStripFrames:()=>eH_,winjsStackLineParser:()=>Hx_});var sZo,Wx_,cZo;function Gx_(e){let t=globalThis._posthogChunkIds;if(!t)return;let r=Object.keys(t);return cZo&&r.length===Wx_||(Wx_=r.length,cZo=r.reduce((i,n)=>{sZo||(sZo={});let a=sZo[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,sZo[n]=[s,u];break}}}return i},{})),cZo}var J_D=4,aNc=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&&Ax_(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:Gx_(this.stackParser)}}buildCoercingContext(t,r,i=0){let n=(o,c)=>{if(c<=J_D){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 lL="?";function N$t(e,t,r,i,n){let a={platform:e,filename:t,function:r==="<anonymous>"?lL:r,in_app:!0};return $ta(i)||(a.lineno=i),$ta(n)||(a.colno=n),a}var lZo=(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]:lL,r?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]};var $_D=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Y_D=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,X_D=/\((\S*)(?::(\d+))(?::(\d+))\)/,xx_=(e,t)=>{let r=$_D.exec(e);if(r){let[,n,a,o]=r;return N$t(t,n,lL,+a,+o)}let i=Y_D.exec(e);if(i){if(i[2]&&i[2].indexOf("eval")===0){let c=X_D.exec(i[2]);c&&(i[2]=c[1],i[3]=c[2],i[4]=c[3])}let[a,o]=lZo(i[1]||lL,i[2]);return N$t(t,o,a,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}};var Z_D=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i,Hx_=(e,t)=>{let r=Z_D.exec(e);return r?N$t(t,r[2],r[1]||lL,+r[3],r[4]?+r[4]:void 0):void 0};var k_D=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ehD=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Kx_=(e,t)=>{let r=k_D.exec(e);if(r){if(r[3]&&r[3].indexOf(" > eval")>-1){let o=ehD.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]||lL;return[a,n]=lZo(a,n),N$t(t,n,a,r[4]?+r[4]:void 0,r[5]?+r[5]:void 0)}};var thD=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,Jx_=(e,t)=>{let r=thD.exec(e);return r?N$t(t,r[2],r[3]||lL,+r[1]):void 0},rhD=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i,$x_=(e,t)=>{let r=rhD.exec(e);return r?N$t(t,r[5],r[3]||r[4]||lL,+r[1],+r[2]):void 0};var ihD=/^\s*[-]{4,}$/,nhD=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,Xx_=(e,t)=>{let r=e.match(nhD);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||lL,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:Yx_(r[3]),colno:Yx_(r[4]),in_app:ahD(d||"",s),platform:t}}if(e.match(ihD))return{filename:e,platform:t}};function ahD(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 Yx_(e){return parseInt(e||"",10)||void 0}var Zx_=/\(error: (.*)\)/,kx_=50;function eH_(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,kx_).map(r=>({...r,filename:r.filename||ohD(t).filename,function:r.function||lL}))}function ohD(e){return e[e.length-1]||{}}function uhD(e,...t){return(r,i=0)=>{let n=[],a=r.split(`
|
|
1269
|
-
`);for(let o=i;o<a.length;o++){let c=a[o];if(c.length>1024)continue;let d=Zx_.test(c)?c.replace(Zx_,"$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>=kx_)break}}return eH_(n)}}var oNc=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,r){let i=DGa(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 uyn(t,"DOMException")}isDOMError(t){return uyn(t,"DOMError")}};var uNc=class{match(t){return Yzc(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 sNc=class{constructor(){}match(t){return wx_(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 shD=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,cNc=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(shD);return n&&(r=n[1],i=n[2]),[r,i]}};var tH_=["fatal","error","warning","log","info","debug"];function fZo(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 lNc=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 kXo(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=fZo(t);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${i}`}isSeverityLevel(t){return DGa(t)&&!Px_(t)&&tH_.indexOf(t)>=0}getErrorPropertyFromObject(t){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(Qx_(i))return i}}getObjectClassName(t){try{let r=Object.getPrototypeOf(t);return r?r.constructor.name:void 0}catch{return}}};var fNc=class{match(t){return kXo(t)}coerce(t,r){let i=t.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${fZo(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var dNc=class{match(t){return BGa(t)}coerce(t,r){return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var pNc=class{match(t){return uyn(t,"PromiseRejectionEvent")}coerce(t,r){let i=this.getUnhandledRejectionReason(t);return BGa(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(BGa(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 _Nc=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 nH_=require("fs"),aH_=require("readline"),dZo=new G$.ReduceableCache(25),oH_=new G$.ReduceableCache(20),hNc=7,chD=1e3,lhD=1e4;async function uH_(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"||_hD(o)||hhD(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(oH_.get(n))continue;let a=t[n];if(!a)continue;a.sort((d,s)=>d-s);let o=bhD(a);if(o.every(d=>yhD(n,d)))continue;let c=vhD(dZo,n,{});i.push(fhD(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&dhD(e,dZo),dZo.reduce(),e}function fhD(e,t,r){return new Promise(i=>{let n=(0,nH_.createReadStream)(e),a=(0,aH_.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(){oH_.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]=ghD(_,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 dhD(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;phD(r.lineno,r,i)}}function phD(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=sH_(e);n<e;n++){let a=r[n];if(a===void 0)return void rH_(t);t.pre_context.push(a)}if(r[e]===void 0)return void rH_(t);t.context_line=r[e];let i=cH_(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 rH_(e){delete e.pre_context,delete e.context_line,delete e.post_context}function _hD(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function hhD(e){return e.lineno!==void 0&&e.lineno>lhD||e.colno!==void 0&&e.colno>chD}function yhD(e,t){let r=dZo.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 bhD(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=iH_(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+hNc:(n.push(i),i=iH_(a)),t++}return n}function iH_(e){return[sH_(e),cH_(e)]}function sH_(e){return Math.max(1,e-hNc)}function cH_(e){return e+hNc}function vhD(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function ghD(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 OhD(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 lH_(e,t){globalThis.process?.on("uncaughtException",OhD(e,t))}function fH_(e){globalThis.process?.on("unhandledRejection",t=>e(t,{mechanism:{type:"onunhandledrejection",handled:!1}}))}var mhD=2e3,gQi=class e{constructor(t,r,i){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this._logger=i,this._rateLimiter=new eZo({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||z$t(),properties:{...o,...a}}}startAutocaptureIfEnabled(){this.isEnabled()&&(lH_(this.onException.bind(this),this.onFatalError.bind(this)),fH_(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(mhD),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};var dH_="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 AhD=6e4,PhD=1152921504606847e3,jhD=["is_not"],kta=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},q0=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},F$t=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},pZo=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 F$t||d instanceof q0?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 F$t||p instanceof q0?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 q0("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 q0("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 q0("Feature flags not available for dependency evaluation");if(!("dependency_chain"in t))throw new q0(`Flag dependency property for '${a}' is missing required 'dependency_chain' field`);let o=t.dependency_chain;if(!Array.isArray(o))throw new q0(`Flag dependency property for '${a}' has an invalid 'dependency_chain' (expected array, got ${typeof o})`);if(o.length===0)throw new q0(`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 q0(`Error evaluating flag dependency '${d}' for flag '${a}': ${l}`)}else n[d]=!1;else throw new q0(`Missing flag dependency '${d}' for flag '${a}'`)}if(n[d]==null)throw new q0(`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 F$t)throw u;if(u instanceof q0)c=!0;else throw u}if(d!==void 0)return d;if(c)throw new q0("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"?vH_(d,n,this.cohorts,this.debugMode):s==="flag"?await this.evaluateFlagDependency(d,r,n,a):bH_(d,n,c),!u)return!1}if(o==null)return!0}return!(o!=null&&await _H_(t.key,r)>o/100)}async getMatchingVariant(t,r){let i=await _H_(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(AhD,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 kta(`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 kta(`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 kta(`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 kta&&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=syn(()=>{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 _H_(e,t,r=""){let i=await pH_(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/PhD}function bH_(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 q0("Operator is_not_set is not supported")}else throw new q0(`Property ${i} not found in propertyValues`);let o=t[i];if(o==null&&!jhD.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 hH_(String(n))&&String(o).match(String(n))!==null;case"not_regex":return hH_(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 q0("Date operations cannot be performed on boolean values");let s=EhD(String(n));if(s==null&&(s=yH_(n)),s==null)throw new q0(`Invalid date: ${n}`);let u=yH_(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new q0(`Unknown operator: ${a}`)}}function whD(e,t){if(!(e in t))throw new F$t(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function vH_(e,t,r,i=!1){let n=String(e.value);whD(n,r);let a=r[n];return gH_(a,t,r,i)}function gH_(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=gH_(c,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof F$t)throw d;if(d instanceof q0)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new q0("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=vH_(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=bH_(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 F$t)throw d;if(d instanceof q0)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new q0("can't match cohort without a given cohort property value");return n==="AND"}function hH_(e){try{return new RegExp(e),!0}catch{return!1}}function yH_(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 q0(`${e} is in an invalid date format`)}throw new q0(`The date provided ${e} must be a string, number, or date object`)}function EhD(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 _Zo=class{getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}constructor(){this._memoryStorage={}}};var ShD=100,OH_=3e4,MhD=5e4,hZo=class extends TGa{constructor(t,r={}){if(super(t,r),this._memoryStorage=new _Zo,this.options=r,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,ShD):OH_,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 pZo({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 gQi(this,r,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||MhD}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 dH_}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=OH_){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=oyn(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 F$t||y instanceof q0)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=syn(()=>{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(Ex_(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(gQi.buildEventMessage(t,{syntheticException:n},r,i).then(a=>this.capture(a)))}async captureExceptionImmediate(t,r,i){let n=new Error("PostHog syntheticException");this.addPendingPromise(gQi.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=z$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"&&Ox_(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 mH_=require("async_hooks"),yZo=class{constructor(){this.storage=new mH_.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 AH_="posthog-node";function DhD(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[yNc.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 yNc=class{static#e=this.POSTHOG_ID_TAG="posthog_distinct_id";constructor(t,r,i,n,a){this.name=AH_,this.name=AH_,this.setupOnce=function(o,c){let d=c()?.getClient()?.getDsn()?.projectId;o(DhD(t,{organization:r,projectId:d,prefix:i,severityAllowList:n,sendExceptionsToPostHog:a??!0}))}}};gQi.errorPropertiesBuilder=new G$.ErrorPropertiesBuilder([new G$.EventCoercer,new G$.ErrorCoercer,new G$.ObjectCoercer,new G$.StringCoercer,new G$.PrimitiveCoercer],G$.createStackParser("node:javascript",G$.nodeStackLineParser),[hx_(),uH_]);var era=class extends hZo{getLibraryId(){return"posthog-node"}initializeContext(){return new yZo}};var bZo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new era(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.49.7",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var RGa=class{async sendEvent(){}async identify(){}async flush(){}};var tra=require("fs/promises"),EH_=require("os"),SH_=require("path");var PH_=ue(require("crypto")),gZo=new Uint8Array(256),vZo=gZo.length;function bNc(){return vZo>gZo.length-16&&(PH_.default.randomFillSync(gZo),vZo=0),gZo.slice(vZo,vZo+=16)}var fL=[];for(let e=0;e<256;++e)fL.push((e+256).toString(16).slice(1));function jH_(e,t=0){return fL[e[t+0]]+fL[e[t+1]]+fL[e[t+2]]+fL[e[t+3]]+"-"+fL[e[t+4]]+fL[e[t+5]]+"-"+fL[e[t+6]]+fL[e[t+7]]+"-"+fL[e[t+8]]+fL[e[t+9]]+"-"+fL[e[t+10]]+fL[e[t+11]]+fL[e[t+12]]+fL[e[t+13]]+fL[e[t+14]]+fL[e[t+15]]}var wH_=ue(require("crypto")),vNc={randomUUID:wH_.default.randomUUID};function BhD(e,t,r){if(vNc.randomUUID&&!t&&!e)return vNc.randomUUID();e=e||{};let i=e.random||(e.rng||bNc)();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 jH_(i)}var Nve=BhD;var IhD="id",ChD=".fern",zGa=class{posthog;userId;token;constructor({token:t,posthogApiKey:r}){this.posthog=new era(r),this.userId=t==null?void 0:GIc(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.49.7",...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 tL({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=qt(jr.of((0,EH_.homedir)()),xe.of(ChD),xe.of(IhD));await gi(t)||(await(0,tra.mkdir)((0,SH_.dirname)(t),{recursive:!0}),await(0,tra.writeFile)(t,Nve())),this.persistedDistinctId=(await(0,tra.readFile)(t)).toString()}return this.persistedDistinctId}};var gNc;async function rra(){return gNc==null&&(gNc=await qhD()),gNc}async function qhD(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new RGa;let r=await d7o();return r!=null?new zGa({token:r,posthogApiKey:e}):await vea()!=null?new bZo({posthogApiKey:e}):new zGa({token:void 0,posthogApiKey:e})}catch{return new RGa}}function NGa(e,t){return function(){return e.apply(t,arguments)}}var{toString:ThD}=Object.prototype,{getPrototypeOf:mNc}=Object,{iterator:mZo,toStringTag:DH_}=Symbol,AZo=(e=>t=>{let r=ThD.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),J3t=e=>(e=e.toLowerCase(),t=>AZo(t)===e),PZo=e=>t=>typeof t===e,{isArray:nra}=Array,ira=PZo("undefined");function FGa(e){return e!==null&&!ira(e)&&e.constructor!==null&&!ira(e.constructor)&&x$(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var BH_=J3t("ArrayBuffer");function RhD(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&BH_(e.buffer),t}var zhD=PZo("string"),x$=PZo("function"),IH_=PZo("number"),QGa=e=>e!==null&&typeof e=="object",NhD=e=>e===!0||e===!1,OZo=e=>{if(AZo(e)!=="object")return!1;let t=mNc(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(DH_ in e)&&!(mZo in e)},FhD=e=>{if(!QGa(e)||FGa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},QhD=J3t("Date"),UhD=J3t("File"),LhD=J3t("Blob"),VhD=J3t("FileList"),WhD=e=>QGa(e)&&x$(e.pipe),GhD=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||x$(e.append)&&((t=AZo(e))==="formdata"||t==="object"&&x$(e.toString)&&e.toString()==="[object FormData]"))},xhD=J3t("URLSearchParams"),[HhD,KhD,JhD,$hD]=["ReadableStream","Request","Response","Headers"].map(J3t),YhD=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function UGa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),nra(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(FGa(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 CH_(e,t){if(FGa(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 cyn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,qH_=e=>!ira(e)&&e!==cyn;function ONc(){let{caseless:e,skipUndefined:t}=qH_(this)&&this||{},r={},i=(n,a)=>{let o=e&&CH_(r,a)||a;OZo(r[o])&&OZo(n)?r[o]=ONc(r[o],n):OZo(n)?r[o]=ONc({},n):nra(n)?r[o]=n.slice():(!t||!ira(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&UGa(arguments[n],i);return r}var XhD=(e,t,r,{allOwnKeys:i}={})=>(UGa(t,(n,a)=>{r&&x$(n)?e[a]=NGa(n,r):e[a]=n},{allOwnKeys:i}),e),ZhD=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),khD=(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)},eyD=(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&&mNc(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},tyD=(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},ryD=e=>{if(!e)return null;if(nra(e))return e;let t=e.length;if(!IH_(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},iyD=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&mNc(Uint8Array)),nyD=(e,t)=>{let i=(e&&e[mZo]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},ayD=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},oyD=J3t("HTMLFormElement"),uyD=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),MH_=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),syD=J3t("RegExp"),TH_=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};UGa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},cyD=e=>{TH_(e,(t,r)=>{if(x$(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(x$(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+"'")})}})},lyD=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return nra(e)?i(e):i(String(e).split(t)),r},fyD=()=>{},dyD=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function pyD(e){return!!(e&&x$(e.append)&&e[DH_]==="FormData"&&e[mZo])}var _yD=e=>{let t=new Array(10),r=(i,n)=>{if(QGa(i)){if(t.indexOf(i)>=0)return;if(FGa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=nra(i)?[]:{};return UGa(i,(o,c)=>{let d=r(o,n+1);!ira(d)&&(a[c]=d)}),t[n]=void 0,a}}return i};return r(e,0)},hyD=J3t("AsyncFunction"),yyD=e=>e&&(QGa(e)||x$(e))&&x$(e.then)&&x$(e.catch),RH_=((e,t)=>e?setImmediate:t?((r,i)=>(cyn.addEventListener("message",({source:n,data:a})=>{n===cyn&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),cyn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",x$(cyn.postMessage)),byD=typeof queueMicrotask<"u"?queueMicrotask.bind(cyn):typeof process<"u"&&process.nextTick||RH_,vyD=e=>e!=null&&x$(e[mZo]),ir={isArray:nra,isArrayBuffer:BH_,isBuffer:FGa,isFormData:GhD,isArrayBufferView:RhD,isString:zhD,isNumber:IH_,isBoolean:NhD,isObject:QGa,isPlainObject:OZo,isEmptyObject:FhD,isReadableStream:HhD,isRequest:KhD,isResponse:JhD,isHeaders:$hD,isUndefined:ira,isDate:QhD,isFile:UhD,isBlob:LhD,isRegExp:syD,isFunction:x$,isStream:WhD,isURLSearchParams:xhD,isTypedArray:iyD,isFileList:VhD,forEach:UGa,merge:ONc,extend:XhD,trim:YhD,stripBOM:ZhD,inherits:khD,toFlatObject:eyD,kindOf:AZo,kindOfTest:J3t,endsWith:tyD,toArray:ryD,forEachEntry:nyD,matchAll:ayD,isHTMLForm:oyD,hasOwnProperty:MH_,hasOwnProp:MH_,reduceDescriptors:TH_,freezeMethods:cyD,toObjectSet:lyD,toCamelCase:uyD,noop:fyD,toFiniteNumber:dyD,findKey:CH_,global:cyn,isContextDefined:qH_,isSpecCompliantForm:pyD,toJSONObject:_yD,isAsyncFn:hyD,isThenable:yyD,setImmediate:RH_,asap:byD,isIterable:vyD};function ara(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(ara,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 zH_=ara.prototype,NH_={};["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=>{NH_[e]={value:e}});Object.defineProperties(ara,NH_);Object.defineProperty(zH_,"isAxiosError",{value:!0});ara.from=(e,t,r,i,n,a)=>{let o=Object.create(zH_);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 ara.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 Na=ara;var FH_=ue(zkn(),1),jZo=FH_.default;function ANc(e){return ir.isPlainObject(e)||ir.isArray(e)}function UH_(e){return ir.endsWith(e,"[]")?e.slice(0,-2):e}function QH_(e,t,r){return e?e.concat(t).map(function(n,a){return n=UH_(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function gyD(e){return ir.isArray(e)&&!e.some(ANc)}var OyD=ir.toFlatObject(ir,{},null,function(t){return/^is[A-Z]/.test(t)});function myD(e,t,r){if(!ir.isObject(e))throw new TypeError("target must be an object");t=t||new(jZo||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 Na("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)&&gyD(h)||(ir.isFileList(h)||ir.endsWith(y,"[]"))&&(v=ir.toArray(h)))return y=UH_(y),v.forEach(function(m,g){!(ir.isUndefined(m)||m===null)&&t.append(o===!0?QH_([y],g,a):o===null?y:y+"[]",s(m))}),!1}return ANc(h)?!0:(t.append(QH_(b,y,a),s(h)),!1)}let l=[],p=Object.assign(OyD,{defaultVisitor:u,convertValue:s,isVisitable:ANc});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 rKi=myD;function LH_(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function VH_(e,t){this._pairs=[],e&&rKi(e,this,t)}var WH_=VH_.prototype;WH_.append=function(t,r){this._pairs.push([t,r])};WH_.toString=function(t){let r=t?function(i){return t.call(this,i,LH_)}:LH_;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var GH_=VH_;function AyD(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function lyn(e,t,r){if(!t)return e;let i=r&&r.encode||AyD;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 GH_(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var PNc=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)})}},jNc=PNc;var ora={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var JH_=ue(require("crypto"),1);var xH_=ue(require("url"),1),HH_=xH_.default.URLSearchParams;var wNc="abcdefghijklmnopqrstuvwxyz",KH_="0123456789",$H_={DIGIT:KH_,ALPHA:wNc,ALPHA_DIGIT:wNc+wNc.toUpperCase()+KH_},PyD=(e=16,t=$H_.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);JH_.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},YH_={isNode:!0,classes:{URLSearchParams:HH_,FormData:jZo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:$H_,generateString:PyD,protocols:["http","https","file","data"]};var MNc={};Yt(MNc,{hasBrowserEnv:()=>SNc,hasStandardBrowserEnv:()=>jyD,hasStandardBrowserWebWorkerEnv:()=>wyD,navigator:()=>ENc,origin:()=>EyD});var SNc=typeof window<"u"&&typeof document<"u",ENc=typeof navigator=="object"&&navigator||void 0,jyD=SNc&&(!ENc||["ReactNative","NativeScript","NS"].indexOf(ENc.product)<0),wyD=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",EyD=SNc&&window.location.href||"http://localhost";var vA={...MNc,...YH_};function DNc(e,t){return rKi(e,new vA.classes.URLSearchParams,{visitor:function(r,i,n,a){return vA.isNode&&ir.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function SyD(e){return ir.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function MyD(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 DyD(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]=MyD(n[o])),!c)}if(ir.isFormData(e)&&ir.isFunction(e.entries)){let r={};return ir.forEachEntry(e,(i,n)=>{t(SyD(i),n,r,0)}),r}return null}var wZo=DyD;function ByD(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 BNc={transitional:ora,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(wZo(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 DNc(t,this.formSerializer).toString();if((c=ir.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return rKi(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),ByD(t)):t}],transformResponse:[function(t){let r=this.transitional||BNc.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"?Na.from(c,Na.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:vA.classes.FormData,Blob:vA.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=>{BNc.headers[e]={}});var ura=BNc;var IyD=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"]),XH_=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1269
|
+
`);for(let o=i;o<a.length;o++){let c=a[o];if(c.length>1024)continue;let d=Zx_.test(c)?c.replace(Zx_,"$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>=kx_)break}}return eH_(n)}}var oNc=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,r){let i=DGa(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 uyn(t,"DOMException")}isDOMError(t){return uyn(t,"DOMError")}};var uNc=class{match(t){return Yzc(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 sNc=class{constructor(){}match(t){return wx_(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 shD=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,cNc=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(shD);return n&&(r=n[1],i=n[2]),[r,i]}};var tH_=["fatal","error","warning","log","info","debug"];function fZo(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 lNc=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 kXo(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=fZo(t);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${i}`}isSeverityLevel(t){return DGa(t)&&!Px_(t)&&tH_.indexOf(t)>=0}getErrorPropertyFromObject(t){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(Qx_(i))return i}}getObjectClassName(t){try{let r=Object.getPrototypeOf(t);return r?r.constructor.name:void 0}catch{return}}};var fNc=class{match(t){return kXo(t)}coerce(t,r){let i=t.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${fZo(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var dNc=class{match(t){return BGa(t)}coerce(t,r){return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var pNc=class{match(t){return uyn(t,"PromiseRejectionEvent")}coerce(t,r){let i=this.getUnhandledRejectionReason(t);return BGa(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(BGa(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 _Nc=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 nH_=require("fs"),aH_=require("readline"),dZo=new G$.ReduceableCache(25),oH_=new G$.ReduceableCache(20),hNc=7,chD=1e3,lhD=1e4;async function uH_(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"||_hD(o)||hhD(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(oH_.get(n))continue;let a=t[n];if(!a)continue;a.sort((d,s)=>d-s);let o=bhD(a);if(o.every(d=>yhD(n,d)))continue;let c=vhD(dZo,n,{});i.push(fhD(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&dhD(e,dZo),dZo.reduce(),e}function fhD(e,t,r){return new Promise(i=>{let n=(0,nH_.createReadStream)(e),a=(0,aH_.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(){oH_.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]=ghD(_,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 dhD(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;phD(r.lineno,r,i)}}function phD(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=sH_(e);n<e;n++){let a=r[n];if(a===void 0)return void rH_(t);t.pre_context.push(a)}if(r[e]===void 0)return void rH_(t);t.context_line=r[e];let i=cH_(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 rH_(e){delete e.pre_context,delete e.context_line,delete e.post_context}function _hD(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function hhD(e){return e.lineno!==void 0&&e.lineno>lhD||e.colno!==void 0&&e.colno>chD}function yhD(e,t){let r=dZo.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 bhD(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=iH_(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+hNc:(n.push(i),i=iH_(a)),t++}return n}function iH_(e){return[sH_(e),cH_(e)]}function sH_(e){return Math.max(1,e-hNc)}function cH_(e){return e+hNc}function vhD(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function ghD(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 OhD(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 lH_(e,t){globalThis.process?.on("uncaughtException",OhD(e,t))}function fH_(e){globalThis.process?.on("unhandledRejection",t=>e(t,{mechanism:{type:"onunhandledrejection",handled:!1}}))}var mhD=2e3,gQi=class e{constructor(t,r,i){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this._logger=i,this._rateLimiter=new eZo({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||z$t(),properties:{...o,...a}}}startAutocaptureIfEnabled(){this.isEnabled()&&(lH_(this.onException.bind(this),this.onFatalError.bind(this)),fH_(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(mhD),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};var dH_="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 AhD=6e4,PhD=1152921504606847e3,jhD=["is_not"],kta=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},q0=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},F$t=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},pZo=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 F$t||d instanceof q0?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 F$t||p instanceof q0?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 q0("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 q0("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 q0("Feature flags not available for dependency evaluation");if(!("dependency_chain"in t))throw new q0(`Flag dependency property for '${a}' is missing required 'dependency_chain' field`);let o=t.dependency_chain;if(!Array.isArray(o))throw new q0(`Flag dependency property for '${a}' has an invalid 'dependency_chain' (expected array, got ${typeof o})`);if(o.length===0)throw new q0(`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 q0(`Error evaluating flag dependency '${d}' for flag '${a}': ${l}`)}else n[d]=!1;else throw new q0(`Missing flag dependency '${d}' for flag '${a}'`)}if(n[d]==null)throw new q0(`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 F$t)throw u;if(u instanceof q0)c=!0;else throw u}if(d!==void 0)return d;if(c)throw new q0("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"?vH_(d,n,this.cohorts,this.debugMode):s==="flag"?await this.evaluateFlagDependency(d,r,n,a):bH_(d,n,c),!u)return!1}if(o==null)return!0}return!(o!=null&&await _H_(t.key,r)>o/100)}async getMatchingVariant(t,r){let i=await _H_(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(AhD,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 kta(`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 kta(`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 kta(`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 kta&&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=syn(()=>{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 _H_(e,t,r=""){let i=await pH_(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/PhD}function bH_(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 q0("Operator is_not_set is not supported")}else throw new q0(`Property ${i} not found in propertyValues`);let o=t[i];if(o==null&&!jhD.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 hH_(String(n))&&String(o).match(String(n))!==null;case"not_regex":return hH_(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 q0("Date operations cannot be performed on boolean values");let s=EhD(String(n));if(s==null&&(s=yH_(n)),s==null)throw new q0(`Invalid date: ${n}`);let u=yH_(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new q0(`Unknown operator: ${a}`)}}function whD(e,t){if(!(e in t))throw new F$t(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function vH_(e,t,r,i=!1){let n=String(e.value);whD(n,r);let a=r[n];return gH_(a,t,r,i)}function gH_(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=gH_(c,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof F$t)throw d;if(d instanceof q0)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new q0("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=vH_(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=bH_(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 F$t)throw d;if(d instanceof q0)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new q0("can't match cohort without a given cohort property value");return n==="AND"}function hH_(e){try{return new RegExp(e),!0}catch{return!1}}function yH_(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 q0(`${e} is in an invalid date format`)}throw new q0(`The date provided ${e} must be a string, number, or date object`)}function EhD(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 _Zo=class{getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}constructor(){this._memoryStorage={}}};var ShD=100,OH_=3e4,MhD=5e4,hZo=class extends TGa{constructor(t,r={}){if(super(t,r),this._memoryStorage=new _Zo,this.options=r,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,ShD):OH_,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 pZo({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 gQi(this,r,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||MhD}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 dH_}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=OH_){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=oyn(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 F$t||y instanceof q0)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=syn(()=>{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(Ex_(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(gQi.buildEventMessage(t,{syntheticException:n},r,i).then(a=>this.capture(a)))}async captureExceptionImmediate(t,r,i){let n=new Error("PostHog syntheticException");this.addPendingPromise(gQi.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=z$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"&&Ox_(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 mH_=require("async_hooks"),yZo=class{constructor(){this.storage=new mH_.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 AH_="posthog-node";function DhD(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[yNc.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 yNc=class{static#e=this.POSTHOG_ID_TAG="posthog_distinct_id";constructor(t,r,i,n,a){this.name=AH_,this.name=AH_,this.setupOnce=function(o,c){let d=c()?.getClient()?.getDsn()?.projectId;o(DhD(t,{organization:r,projectId:d,prefix:i,severityAllowList:n,sendExceptionsToPostHog:a??!0}))}}};gQi.errorPropertiesBuilder=new G$.ErrorPropertiesBuilder([new G$.EventCoercer,new G$.ErrorCoercer,new G$.ObjectCoercer,new G$.StringCoercer,new G$.PrimitiveCoercer],G$.createStackParser("node:javascript",G$.nodeStackLineParser),[hx_(),uH_]);var era=class extends hZo{getLibraryId(){return"posthog-node"}initializeContext(){return new yZo}};var bZo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new era(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.49.8",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var RGa=class{async sendEvent(){}async identify(){}async flush(){}};var tra=require("fs/promises"),EH_=require("os"),SH_=require("path");var PH_=ue(require("crypto")),gZo=new Uint8Array(256),vZo=gZo.length;function bNc(){return vZo>gZo.length-16&&(PH_.default.randomFillSync(gZo),vZo=0),gZo.slice(vZo,vZo+=16)}var fL=[];for(let e=0;e<256;++e)fL.push((e+256).toString(16).slice(1));function jH_(e,t=0){return fL[e[t+0]]+fL[e[t+1]]+fL[e[t+2]]+fL[e[t+3]]+"-"+fL[e[t+4]]+fL[e[t+5]]+"-"+fL[e[t+6]]+fL[e[t+7]]+"-"+fL[e[t+8]]+fL[e[t+9]]+"-"+fL[e[t+10]]+fL[e[t+11]]+fL[e[t+12]]+fL[e[t+13]]+fL[e[t+14]]+fL[e[t+15]]}var wH_=ue(require("crypto")),vNc={randomUUID:wH_.default.randomUUID};function BhD(e,t,r){if(vNc.randomUUID&&!t&&!e)return vNc.randomUUID();e=e||{};let i=e.random||(e.rng||bNc)();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 jH_(i)}var Nve=BhD;var IhD="id",ChD=".fern",zGa=class{posthog;userId;token;constructor({token:t,posthogApiKey:r}){this.posthog=new era(r),this.userId=t==null?void 0:GIc(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.49.8",...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 tL({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=qt(jr.of((0,EH_.homedir)()),xe.of(ChD),xe.of(IhD));await gi(t)||(await(0,tra.mkdir)((0,SH_.dirname)(t),{recursive:!0}),await(0,tra.writeFile)(t,Nve())),this.persistedDistinctId=(await(0,tra.readFile)(t)).toString()}return this.persistedDistinctId}};var gNc;async function rra(){return gNc==null&&(gNc=await qhD()),gNc}async function qhD(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new RGa;let r=await d7o();return r!=null?new zGa({token:r,posthogApiKey:e}):await vea()!=null?new bZo({posthogApiKey:e}):new zGa({token:void 0,posthogApiKey:e})}catch{return new RGa}}function NGa(e,t){return function(){return e.apply(t,arguments)}}var{toString:ThD}=Object.prototype,{getPrototypeOf:mNc}=Object,{iterator:mZo,toStringTag:DH_}=Symbol,AZo=(e=>t=>{let r=ThD.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),J3t=e=>(e=e.toLowerCase(),t=>AZo(t)===e),PZo=e=>t=>typeof t===e,{isArray:nra}=Array,ira=PZo("undefined");function FGa(e){return e!==null&&!ira(e)&&e.constructor!==null&&!ira(e.constructor)&&x$(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var BH_=J3t("ArrayBuffer");function RhD(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&BH_(e.buffer),t}var zhD=PZo("string"),x$=PZo("function"),IH_=PZo("number"),QGa=e=>e!==null&&typeof e=="object",NhD=e=>e===!0||e===!1,OZo=e=>{if(AZo(e)!=="object")return!1;let t=mNc(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(DH_ in e)&&!(mZo in e)},FhD=e=>{if(!QGa(e)||FGa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},QhD=J3t("Date"),UhD=J3t("File"),LhD=J3t("Blob"),VhD=J3t("FileList"),WhD=e=>QGa(e)&&x$(e.pipe),GhD=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||x$(e.append)&&((t=AZo(e))==="formdata"||t==="object"&&x$(e.toString)&&e.toString()==="[object FormData]"))},xhD=J3t("URLSearchParams"),[HhD,KhD,JhD,$hD]=["ReadableStream","Request","Response","Headers"].map(J3t),YhD=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function UGa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),nra(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(FGa(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 CH_(e,t){if(FGa(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 cyn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,qH_=e=>!ira(e)&&e!==cyn;function ONc(){let{caseless:e,skipUndefined:t}=qH_(this)&&this||{},r={},i=(n,a)=>{let o=e&&CH_(r,a)||a;OZo(r[o])&&OZo(n)?r[o]=ONc(r[o],n):OZo(n)?r[o]=ONc({},n):nra(n)?r[o]=n.slice():(!t||!ira(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&UGa(arguments[n],i);return r}var XhD=(e,t,r,{allOwnKeys:i}={})=>(UGa(t,(n,a)=>{r&&x$(n)?e[a]=NGa(n,r):e[a]=n},{allOwnKeys:i}),e),ZhD=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),khD=(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)},eyD=(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&&mNc(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},tyD=(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},ryD=e=>{if(!e)return null;if(nra(e))return e;let t=e.length;if(!IH_(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},iyD=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&mNc(Uint8Array)),nyD=(e,t)=>{let i=(e&&e[mZo]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},ayD=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},oyD=J3t("HTMLFormElement"),uyD=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),MH_=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),syD=J3t("RegExp"),TH_=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};UGa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},cyD=e=>{TH_(e,(t,r)=>{if(x$(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(x$(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+"'")})}})},lyD=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return nra(e)?i(e):i(String(e).split(t)),r},fyD=()=>{},dyD=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function pyD(e){return!!(e&&x$(e.append)&&e[DH_]==="FormData"&&e[mZo])}var _yD=e=>{let t=new Array(10),r=(i,n)=>{if(QGa(i)){if(t.indexOf(i)>=0)return;if(FGa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=nra(i)?[]:{};return UGa(i,(o,c)=>{let d=r(o,n+1);!ira(d)&&(a[c]=d)}),t[n]=void 0,a}}return i};return r(e,0)},hyD=J3t("AsyncFunction"),yyD=e=>e&&(QGa(e)||x$(e))&&x$(e.then)&&x$(e.catch),RH_=((e,t)=>e?setImmediate:t?((r,i)=>(cyn.addEventListener("message",({source:n,data:a})=>{n===cyn&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),cyn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",x$(cyn.postMessage)),byD=typeof queueMicrotask<"u"?queueMicrotask.bind(cyn):typeof process<"u"&&process.nextTick||RH_,vyD=e=>e!=null&&x$(e[mZo]),ir={isArray:nra,isArrayBuffer:BH_,isBuffer:FGa,isFormData:GhD,isArrayBufferView:RhD,isString:zhD,isNumber:IH_,isBoolean:NhD,isObject:QGa,isPlainObject:OZo,isEmptyObject:FhD,isReadableStream:HhD,isRequest:KhD,isResponse:JhD,isHeaders:$hD,isUndefined:ira,isDate:QhD,isFile:UhD,isBlob:LhD,isRegExp:syD,isFunction:x$,isStream:WhD,isURLSearchParams:xhD,isTypedArray:iyD,isFileList:VhD,forEach:UGa,merge:ONc,extend:XhD,trim:YhD,stripBOM:ZhD,inherits:khD,toFlatObject:eyD,kindOf:AZo,kindOfTest:J3t,endsWith:tyD,toArray:ryD,forEachEntry:nyD,matchAll:ayD,isHTMLForm:oyD,hasOwnProperty:MH_,hasOwnProp:MH_,reduceDescriptors:TH_,freezeMethods:cyD,toObjectSet:lyD,toCamelCase:uyD,noop:fyD,toFiniteNumber:dyD,findKey:CH_,global:cyn,isContextDefined:qH_,isSpecCompliantForm:pyD,toJSONObject:_yD,isAsyncFn:hyD,isThenable:yyD,setImmediate:RH_,asap:byD,isIterable:vyD};function ara(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(ara,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 zH_=ara.prototype,NH_={};["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=>{NH_[e]={value:e}});Object.defineProperties(ara,NH_);Object.defineProperty(zH_,"isAxiosError",{value:!0});ara.from=(e,t,r,i,n,a)=>{let o=Object.create(zH_);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 ara.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 Na=ara;var FH_=ue(zkn(),1),jZo=FH_.default;function ANc(e){return ir.isPlainObject(e)||ir.isArray(e)}function UH_(e){return ir.endsWith(e,"[]")?e.slice(0,-2):e}function QH_(e,t,r){return e?e.concat(t).map(function(n,a){return n=UH_(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function gyD(e){return ir.isArray(e)&&!e.some(ANc)}var OyD=ir.toFlatObject(ir,{},null,function(t){return/^is[A-Z]/.test(t)});function myD(e,t,r){if(!ir.isObject(e))throw new TypeError("target must be an object");t=t||new(jZo||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 Na("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)&&gyD(h)||(ir.isFileList(h)||ir.endsWith(y,"[]"))&&(v=ir.toArray(h)))return y=UH_(y),v.forEach(function(m,g){!(ir.isUndefined(m)||m===null)&&t.append(o===!0?QH_([y],g,a):o===null?y:y+"[]",s(m))}),!1}return ANc(h)?!0:(t.append(QH_(b,y,a),s(h)),!1)}let l=[],p=Object.assign(OyD,{defaultVisitor:u,convertValue:s,isVisitable:ANc});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 rKi=myD;function LH_(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function VH_(e,t){this._pairs=[],e&&rKi(e,this,t)}var WH_=VH_.prototype;WH_.append=function(t,r){this._pairs.push([t,r])};WH_.toString=function(t){let r=t?function(i){return t.call(this,i,LH_)}:LH_;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var GH_=VH_;function AyD(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function lyn(e,t,r){if(!t)return e;let i=r&&r.encode||AyD;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 GH_(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var PNc=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)})}},jNc=PNc;var ora={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var JH_=ue(require("crypto"),1);var xH_=ue(require("url"),1),HH_=xH_.default.URLSearchParams;var wNc="abcdefghijklmnopqrstuvwxyz",KH_="0123456789",$H_={DIGIT:KH_,ALPHA:wNc,ALPHA_DIGIT:wNc+wNc.toUpperCase()+KH_},PyD=(e=16,t=$H_.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);JH_.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},YH_={isNode:!0,classes:{URLSearchParams:HH_,FormData:jZo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:$H_,generateString:PyD,protocols:["http","https","file","data"]};var MNc={};Yt(MNc,{hasBrowserEnv:()=>SNc,hasStandardBrowserEnv:()=>jyD,hasStandardBrowserWebWorkerEnv:()=>wyD,navigator:()=>ENc,origin:()=>EyD});var SNc=typeof window<"u"&&typeof document<"u",ENc=typeof navigator=="object"&&navigator||void 0,jyD=SNc&&(!ENc||["ReactNative","NativeScript","NS"].indexOf(ENc.product)<0),wyD=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",EyD=SNc&&window.location.href||"http://localhost";var vA={...MNc,...YH_};function DNc(e,t){return rKi(e,new vA.classes.URLSearchParams,{visitor:function(r,i,n,a){return vA.isNode&&ir.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function SyD(e){return ir.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function MyD(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 DyD(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]=MyD(n[o])),!c)}if(ir.isFormData(e)&&ir.isFunction(e.entries)){let r={};return ir.forEachEntry(e,(i,n)=>{t(SyD(i),n,r,0)}),r}return null}var wZo=DyD;function ByD(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 BNc={transitional:ora,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(wZo(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 DNc(t,this.formSerializer).toString();if((c=ir.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return rKi(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),ByD(t)):t}],transformResponse:[function(t){let r=this.transitional||BNc.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"?Na.from(c,Na.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:vA.classes.FormData,Blob:vA.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=>{BNc.headers[e]={}});var ura=BNc;var IyD=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"]),XH_=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1270
1270
|
`).forEach(function(o){n=o.indexOf(":"),r=o.substring(0,n).trim().toLowerCase(),i=o.substring(n+1).trim(),!(!r||t[r]&&IyD[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var ZH_=Symbol("internals");function LGa(e){return e&&String(e).trim().toLowerCase()}function EZo(e){return e===!1||e==null?e:ir.isArray(e)?e.map(EZo):String(e)}function CyD(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 qyD=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function INc(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 TyD(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function RyD(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 sra=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(c,d,s){let u=LGa(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]=EZo(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())&&!qyD(t))o(XH_(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=LGa(t),t){let i=ir.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return CyD(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=LGa(t),t){let i=ir.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||INc(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(o){if(o=LGa(o),o){let c=ir.findKey(i,o);c&&(!r||INc(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||INc(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]=EZo(n),delete r[a];return}let c=t?TyD(a):String(a).trim();c!==a&&delete r[a],r[c]=EZo(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(`
|
|
1271
1271
|
`)}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[ZH_]=this[ZH_]={accessors:{}}).accessors,n=this.prototype;function a(o){let c=LGa(o);i[c]||(RyD(n,o),i[c]=!0)}return ir.isArray(t)?t.forEach(a):a(t),this}};sra.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ir.reduceDescriptors(sra.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});ir.freezeMethods(sra);var PD=sra;function VGa(e,t){let r=this||ura,i=t||r,n=PD.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 WGa(e){return!!(e&&e.__CANCEL__)}function kH_(e,t,r){Na.call(this,e??"canceled",Na.ERR_CANCELED,t,r),this.name="CanceledError"}ir.inherits(kH_,Na,{__CANCEL__:!0});var Fve=kH_;function Q$t(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new Na("Request failed with status code "+r.status,[Na.ERR_BAD_REQUEST,Na.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function CNc(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function qNc(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function fyn(e,t,r){let i=!CNc(t);return e&&(i||r==!1)?qNc(e,t):t}var P7_=ue(TNc(),1),j7_=ue(require("http"),1),w7_=ue(require("https"),1),E7_=ue(require("util"),1),S7_=ue(u7_(),1),mQi=ue(require("zlib"),1);var _yn="1.12.2";function JGa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var ZyD=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function KNc(e,t,r){let i=r&&r.Blob||vA.classes.Blob,n=JGa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=ZyD.exec(e);if(!a)throw new Na("Invalid URL",Na.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 Na("Blob is not supported",Na.ERR_NOT_SUPPORT);return new i([s],{type:o})}return s}throw new Na("Unsupported protocol "+n,Na.ERR_NOT_SUPPORT)}var yyn=ue(require("stream"),1);var s7_=ue(require("stream"),1);var JNc=Symbol("internals"),$Nc=class extends s7_.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[JNc]={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[JNc];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[JNc],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)})}},YNc=$Nc;var M7_=require("events");var l7_=ue(require("util"),1),f7_=require("stream");var{asyncIterator:c7_}=Symbol,kyD=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[c7_]?yield*e[c7_]():yield e},SZo=kyD;var ebD=vA.ALPHABET.ALPHA_DIGIT+"-_",$Ga=typeof TextEncoder=="function"?new TextEncoder:new l7_.default.TextEncoder,hyn=`\r
|
|
1272
1272
|
`,tbD=$Ga.encode(hyn),rbD=2,XNc=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)}"`:""}${hyn}`;n?r=$Ga.encode(String(r).replace(/\r?\n|\r\n?/g,hyn)):a+=`Content-Type: ${r.type||"application/octet-stream"}${hyn}`,this.headers=$Ga.encode(a+hyn),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+rbD,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;ir.isTypedArray(t)?yield t:yield*SZo(t),yield tbD}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},ibD=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+vA.generateString(n,ebD)}=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=$Ga.encode("--"+a+hyn),c=$Ga.encode("--"+a+"--"+hyn),d=c.byteLength,s=Array.from(e.entries()).map(([l,p])=>{let _=new XNc(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),f7_.Readable.from((async function*(){for(let l of s)yield o,yield*l.encode();yield c})())},d7_=ibD;var p7_=ue(require("stream"),1),ZNc=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)}},_7_=ZNc;var nbD=(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,h7_=nbD;function abD(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 y7_=abD;function obD(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 b7_=obD;var OQi=(e,t,r=3)=>{let i=0,n=y7_(50,250);return b7_(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)},lra=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},fra=e=>(...t)=>ir.asap(()=>e(...t));function kNc(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 v7_={flush:mQi.default.constants.Z_SYNC_FLUSH,finishFlush:mQi.default.constants.Z_SYNC_FLUSH},ubD={flush:mQi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:mQi.default.constants.BROTLI_OPERATION_FLUSH},g7_=ir.isFunction(mQi.default.createBrotliDecompress),{http:sbD,https:cbD}=S7_.default,lbD=/https:?/,O7_=vA.protocols.map(e=>e+":"),m7_=(e,[t,r])=>(e.on("end",r).on("error",r),t);function fbD(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function D7_(e,t,r){let i=t;if(!i&&i!==!1){let n=P7_.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){D7_(a,t,a.href)}}var dbD=typeof process<"u"&&ir.kindOf(process)==="process",pbD=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)}),_bD=({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)}},A7_=(e,t)=>_bD(ir.isObject(e)?e:{address:e,family:t}),B7_=dbD&&function(t){return pbD(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 $=h7_(c,de=>ir.isArray(de)?de:[de]);c=(de,be,W)=>{$(de,be,(x,Ee,se)=>{if(x)return W(x);let Oe=ir.isArray(Ee)?Ee.map(Fe=>A7_(Fe)):[A7_(Ee,se)];be.all?W(x,Oe):W(x,Oe[0].address,Oe[0].family)})}}let y=new M7_.EventEmitter,b=()=>{t.cancelToken&&t.cancelToken.unsubscribe(v),t.signal&&t.signal.removeEventListener("abort",v),y.removeAllListeners()};a(($,de)=>{p=!0,de&&(_=!0,b())});function v($){y.emit("abort",!$||$.type?new Fve(null,t,h):$)}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=fyn(t.baseURL,t.url,t.allowAbsoluteUrls),m=new URL(O,vA.hasBrowserEnv?vA.origin:void 0),g=m.protocol||O7_[0];if(g==="data:"){if(t.maxContentLength>-1){let de=String(t.url||O||"");if(kNc(de)>t.maxContentLength)return n(new Na("maxContentLength size of "+t.maxContentLength+" exceeded",Na.ERR_BAD_RESPONSE,t))}let $;if(l!=="GET")return Q$t(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{$=KNc(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(de){throw Na.from(de,Na.ERR_BAD_REQUEST,t)}return s==="text"?($=$.toString(u),(!u||u==="utf8")&&($=ir.stripBOM($))):s==="stream"&&($=yyn.default.Readable.from($)),Q$t(i,n,{data:$,status:200,statusText:"OK",headers:new PD,config:t})}if(O7_.indexOf(g)===-1)return n(new Na("Unsupported protocol "+g,Na.ERR_BAD_REQUEST,t));let A=PD.from(t.headers).normalize();A.set("User-Agent","axios/"+_yn,!1);let{onUploadProgress:j,onDownloadProgress:M}=t,w=t.maxRate,D,B;if(ir.isSpecCompliantForm(o)){let $=A.getContentType(/boundary=([-_\w\d]{10,70})/i);o=d7_(o,de=>{A.set(de)},{tag:`axios-${_yn}-boundary`,boundary:$&&$[1]||void 0})}else if(ir.isFormData(o)&&ir.isFunction(o.getHeaders)){if(A.set(o.getHeaders()),!A.hasContentLength())try{let $=await E7_.default.promisify(o.getLength).call(o);Number.isFinite($)&&$>=0&&A.setContentLength($)}catch{}}else if(ir.isBlob(o)||ir.isFile(o))o.size&&A.setContentType(o.type||"application/octet-stream"),A.setContentLength(o.size||0),o=yyn.default.Readable.from(SZo(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 Na("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Na.ERR_BAD_REQUEST,t));if(A.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return n(new Na("Request body larger than maxBodyLength limit",Na.ERR_BAD_REQUEST,t))}let R=ir.toFiniteNumber(A.getContentLength());ir.isArray(w)?(D=w[0],B=w[1]):D=B=w,o&&(j||D)&&(ir.isStream(o)||(o=yyn.default.Readable.from(o,{objectMode:!1})),o=yyn.default.pipeline([o,new YNc({maxRate:ir.toFiniteNumber(D)})],ir.noop),j&&o.on("progress",m7_(o,lra(R,OQi(fra(j),!1,3)))));let T;if(t.auth){let $=t.auth.username||"",de=t.auth.password||"";T=$+":"+de}if(!T&&m.username){let $=m.username,de=m.password;T=$+":"+de}T&&A.delete("authorization");let q;try{q=lyn(m.pathname+m.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch($){let de=new Error($.message);return de.config=t,de.url=t.url,de.exists=!0,n(de)}A.set("Accept-Encoding","gzip, compress, deflate"+(g7_?", br":""),!1);let z={path:q,method:l,headers:A.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:T,protocol:g,family:d,beforeRedirect:fbD,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,D7_(z,t.proxy,g+"//"+m.hostname+(m.port?":"+m.port:"")+z.path));let N,H=lbD.test(z.protocol);if(z.agent=H?t.httpsAgent:t.httpAgent,t.transport?N=t.transport:t.maxRedirects===0?N=H?w7_.default:j7_.default:(t.maxRedirects&&(z.maxRedirects=t.maxRedirects),t.beforeRedirect&&(z.beforeRedirects.config=t.beforeRedirect),N=H?cbD:sbD),t.maxBodyLength>-1?z.maxBodyLength=t.maxBodyLength:z.maxBodyLength=1/0,t.insecureHTTPParser&&(z.insecureHTTPParser=t.insecureHTTPParser),h=N.request(z,function(de){if(h.destroyed)return;let be=[de],W=+de.headers["content-length"];if(M||B){let Fe=new YNc({maxRate:ir.toFiniteNumber(B)});M&&Fe.on("progress",m7_(Fe,lra(W,OQi(fra(M),!0,3)))),be.push(Fe)}let x=de,Ee=de.req||h;if(t.decompress!==!1&&de.headers["content-encoding"])switch((l==="HEAD"||de.statusCode===204)&&delete de.headers["content-encoding"],(de.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":be.push(mQi.default.createUnzip(v7_)),delete de.headers["content-encoding"];break;case"deflate":be.push(new _7_),be.push(mQi.default.createUnzip(v7_)),delete de.headers["content-encoding"];break;case"br":g7_&&(be.push(mQi.default.createBrotliDecompress(ubD)),delete de.headers["content-encoding"])}x=be.length>1?yyn.default.pipeline(be,ir.noop):be[0];let se=yyn.default.finished(x,()=>{se(),b()}),Oe={status:de.statusCode,statusText:de.statusMessage,headers:new PD(de.headers),config:t,request:Ee};if(s==="stream")Oe.data=x,Q$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 Na("maxContentLength size of "+t.maxContentLength+" exceeded",Na.ERR_BAD_RESPONSE,t,Ee)))}),x.on("aborted",function(){if(_)return;let Ge=new Na("stream has been aborted",Na.ERR_BAD_RESPONSE,t,Ee);x.destroy(Ge),n(Ge)}),x.on("error",function(Ge){h.destroyed||n(Na.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(Na.from(Ge,null,t,Oe.request,Oe))}Q$t(i,n,Oe)})}y.once("abort",Fe=>{x.destroyed||(x.emit("error",Fe),x.destroy())})}),y.once("abort",$=>{n($),h.destroy($)}),h.on("error",function(de){n(Na.from(de,null,t,h))}),h.on("socket",function(de){de.setKeepAlive(!0,1e3*60)}),t.timeout){let $=parseInt(t.timeout,10);if(Number.isNaN($)){n(new Na("error trying to parse `config.timeout` to int",Na.ERR_BAD_OPTION_VALUE,t,h));return}h.setTimeout($,function(){if(p)return;let be=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",W=t.transitional||ora;t.timeoutErrorMessage&&(be=t.timeoutErrorMessage),n(new Na(be,W.clarifyTimeoutError?Na.ETIMEDOUT:Na.ECONNABORTED,t,h)),v()})}if(ir.isStream(o)){let $=!1,de=!1;o.on("end",()=>{$=!0}),o.once("error",be=>{de=!0,h.destroy(be)}),o.on("close",()=>{!$&&!de&&v(new Fve("Request stream has been aborted",t,h))}),o.pipe(h)}else h.end(o)})};var I7_=vA.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,vA.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(vA.origin),vA.navigator&&/(msie|trident)/i.test(vA.navigator.userAgent)):()=>!0;var C7_=vA.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 q7_=e=>e instanceof PD?{...e}:e;function $3t(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(q7_(s),q7_(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 MZo=e=>{let t=$3t({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=PD.from(o),t.url=lyn(fyn(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(vA.hasStandardBrowserEnv||vA.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(vA.hasStandardBrowserEnv&&(i&&ir.isFunction(i)&&(i=i(t)),i||i!==!1&&I7_(t.url))){let d=n&&a&&C7_.read(a);d&&o.set(n,d)}return t};var hbD=typeof XMLHttpRequest<"u",T7_=hbD&&function(e){return new Promise(function(r,i){let n=MZo(e),a=n.data,o=PD.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=PD.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};Q$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 Na("Request aborted",Na.ECONNABORTED,e,b)),b=null)},b.onerror=function(g){let A=g&&g.message?g.message:"Network Error",j=new Na(A,Na.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||ora;n.timeoutErrorMessage&&(g=n.timeoutErrorMessage),i(new Na(g,A.clarifyTimeoutError?Na.ETIMEDOUT:Na.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]=OQi(s,!0),b.addEventListener("progress",p)),d&&b.upload&&([l,_]=OQi(d),b.upload.addEventListener("progress",l),b.upload.addEventListener("loadend",_)),(n.cancelToken||n.signal)&&(u=m=>{b&&(i(!m||m.type?new Fve(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=JGa(n.url);if(O&&vA.protocols.indexOf(O)===-1){i(new Na("Unsupported protocol "+O+":",Na.ERR_BAD_REQUEST,e));return}b.send(a||null)})};var ybD=(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 Na?u:new Fve(u instanceof Error?u.message:u))}},o=t&&setTimeout(()=>{o=null,a(new Na(`timeout ${t} of ms exceeded`,Na.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}},R7_=ybD;var bbD=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},vbD=async function*(e,t){for await(let r of gbD(e))yield*bbD(r,t)},gbD=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()}},eFc=(e,t,r,i)=>{let n=vbD(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 z7_=64*1024,{isFunction:DZo}=ir,ObD=(({Request:e,Response:t})=>({Request:e,Response:t}))(ir.global),{ReadableStream:N7_,TextEncoder:F7_}=ir.global,Q7_=(e,...t)=>{try{return!!e(...t)}catch{return!1}},mbD=e=>{e=ir.merge.call({skipUndefined:!0},ObD,e);let{fetch:t,Request:r,Response:i}=e,n=t?DZo(t):typeof fetch=="function",a=DZo(r),o=DZo(i);if(!n)return!1;let c=n&&DZo(N7_),d=n&&(typeof F7_=="function"?(h=>y=>h.encode(y))(new F7_):async h=>new Uint8Array(await new r(h).arrayBuffer())),s=a&&c&&Q7_(()=>{let h=!1,y=new r(vA.origin,{body:new N7_,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return h&&!y}),u=o&&c&&Q7_(()=>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 Na(`Response type '${h}' is not supported`,Na.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(vA.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}=MZo(h),R=t||fetch;M=M?(M+"").toLowerCase():"text";let T=R7_([O,m&&m.toAbortSignal()],g),q=null,z=T&&T.unsubscribe&&(()=>{T.unsubscribe()}),N;try{if(j&&s&&b!=="get"&&b!=="head"&&(N=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[se,Oe]=lra(N,OQi(fra(j)));v=eFc(x.body,z7_,se,Oe)}}ir.isString(D)||(D=D?"include":"omit");let H=a&&"credentials"in r.prototype,$={...B,signal:T,method:b.toUpperCase(),headers:w.normalize().toJSON(),body:v,duplex:"half",credentials:H?D:void 0};q=a&&new r(y,$);let de=await(a?R(q,B):R(y,$)),be=u&&(M==="stream"||M==="response");if(u&&(A||be&&z)){let x={};["status","statusText","headers"].forEach(Fe=>{x[Fe]=de[Fe]});let Ee=ir.toFiniteNumber(de.headers.get("content-length")),[se,Oe]=A&&lra(Ee,OQi(fra(A),!0))||[];de=new i(eFc(de.body,z7_,se,()=>{Oe&&Oe(),z&&z()}),x)}M=M||"text";let W=await l[ir.findKey(l,M)||"text"](de,h);return!be&&z&&z(),await new Promise((x,Ee)=>{Q$t(x,Ee,{data:W,headers:PD.from(de.headers),status:de.status,statusText:de.statusText,config:h,request:q})})}catch(H){throw z&&z(),H&&H.name==="TypeError"&&/Load failed|fetch/i.test(H.message)?Object.assign(new Na("Network Error",Na.ERR_NETWORK,h,q),{cause:H.cause||H}):Na.from(H,H&&H.code,h,q)}}},AbD=new Map,tFc=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=AbD;for(;c--;)d=a[c],s=u.get(d),s===void 0&&u.set(d,s=c?new Map:mbD(t)),u=s;return s},Vx9=tFc();var rFc={http:B7_,xhr:T7_,fetch:{get:tFc}};ir.forEach(rFc,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var U7_=e=>`- ${e}`,jbD=e=>ir.isFunction(e)||e===null||e===!1,BZo={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,!jbD(i)&&(n=rFc[(c=String(i)).toLowerCase()],n===void 0))throw new Na(`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 :
|
|
@@ -1505,7 +1505,7 @@ ${g}${O}${A}${Goa}`});var wKa=class{result=Qw.Success;logImmediately;logPrefix;s
|
|
|
1505
1505
|
Run ${Rt.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1506
1506
|
Run ${Rt.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),pra(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function IHc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!xyh(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+=`
|
|
1507
1507
|
${await p5D(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Rt.dim(c.currentVersion)+Rt.reset(" \u2192 ")+Rt.green(c.latestVersion);return n+=`
|
|
1508
|
-
`,i?pra(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function p5D(e){let r=await new Gyh.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 _5D({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await Kyh({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=fHi(u.name,l),_=await j3t({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 Kyh({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=fHi(s.name,u),p=await j3t({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 Kyh({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 Cve({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(c==null||c.groups==null)return;let d=i!=null?FN(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 Jyh(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=pY(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 j_u({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await _5D({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(...Jyh(s,d,t.logger));else o.push(...Jyh(c.versions,void 0,t.logger))}return o}var EKa=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 Hoa=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var CHc=(()=>{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})(),$yh=typeof globalThis.AbortController=="function",Yyh=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Xyh=typeof globalThis.ReadableStream=="function",Zyh=typeof globalThis.FormData=="function",w_u=["get","post","put","patch","head","delete"],h5D=()=>{};h5D();var kyh={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},E_u=2147483647,ebh=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,S_u=Symbol("stop"),tbh={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},rbh={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 y5D=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=ebh,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},ibh=(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))}}))},nbh=(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(ibh(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},abh=(e,t,r)=>{if(!e.body)return e;let i=y5D(r??e.body);return new Request(e,{duplex:"half",body:ibh(e.body,i,t)})};var Koa=e=>e!==null&&typeof e=="object";var SKa=(...e)=>{for(let t of e)if((!Koa(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return RHc({},...e)},qHc=(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 M_u(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:RHc(e[r]??[],t[r]??[])}var THc=(e={},t={})=>({beforeRequest:M_u(e,t,"beforeRequest"),beforeRetry:M_u(e,t,"beforeRetry"),afterResponse:M_u(e,t,"afterResponse"),beforeError:M_u(e,t,"beforeError")}),RHc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(Koa(n)){for(let[a,o]of Object.entries(n))Koa(o)&&a in t&&(o=RHc(t[a],o)),t={...t,[a]:o};Koa(n.hooks)&&(i=THc(i,n.hooks),t.hooks=i),Koa(n.headers)&&(r=qHc(r,n.headers),t.headers=r)}return t};var ubh=e=>w_u.includes(e)?e.toUpperCase():e,b5D=["get","put","head","delete","options","trace"],v5D=[408,413,429,500,502,503,504],g5D=[413,429,503],obh={limit:2,methods:b5D,statusCodes:v5D,afterStatusCodes:g5D,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},sbh=(e={})=>{if(typeof e=="number")return{...obh,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{...obh,...e}};async function zHc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new Hoa(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function NHc(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 cbh=(e,t)=>{let r={};for(let i in t)!(i in rbh)&&!(i in tbh)&&!(i in e)&&(r[i]=t[i]);return r},lbh=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 MKa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>E_u)throw new RangeError(`The \`timeout\` option cannot be greater than ${E_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 EKa(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(!Xyh)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return nbh(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(kyh))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:qHc(this._input.headers,r.headers),hooks:THc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:ubh(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:sbh(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($yh&&Yyh){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(CHc&&(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),lbh(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);(Zyh&&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(!CHc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=abh(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Hoa)throw t;if(t instanceof EKa){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),E_u);if(this._retryCount<1)throw r;await NHc(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})===S_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=cbh(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):zHc(this._originalRequest,t,this.abortController,this._options)}};var FHc=e=>{let t=(r,i)=>MKa.create(r,SKa(e,i));for(let r of w_u)t[r]=(i,n)=>MKa.create(i,SKa(e,n,{method:r}));return t.create=r=>FHc(SKa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),FHc(SKa(e,r))),t.stop=S_u,t},O5D=FHc(),fbh=O5D;var Tbh=ue(qbh(),1);function WHc(e){let t=(0,Tbh.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Mvh=ue(Svh(),1),Dvh=ue(SJ(),1),r7c=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},i7c=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function n7c(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??WHc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Mvh.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 fbh(o,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new r7c(e):l}if(t.allVersions)return s;let u=new i7c(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=Dvh.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 TKa(e,t){let{version:r}=await n7c(e.toLowerCase(),t);return r}async function UJi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:TKa(e.packageName,{version:t?"prerelease":"latest"})}var Bvh=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],U_u=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=mu.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new idn(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.49.7"}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,eLa({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await rra()).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 Hyh({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1508
|
+
`,i?pra(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function p5D(e){let r=await new Gyh.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 _5D({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await Kyh({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=fHi(u.name,l),_=await j3t({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 Kyh({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=fHi(s.name,u),p=await j3t({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 Kyh({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 Cve({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(c==null||c.groups==null)return;let d=i!=null?FN(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 Jyh(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=pY(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 j_u({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await _5D({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(...Jyh(s,d,t.logger));else o.push(...Jyh(c.versions,void 0,t.logger))}return o}var EKa=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 Hoa=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var CHc=(()=>{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})(),$yh=typeof globalThis.AbortController=="function",Yyh=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Xyh=typeof globalThis.ReadableStream=="function",Zyh=typeof globalThis.FormData=="function",w_u=["get","post","put","patch","head","delete"],h5D=()=>{};h5D();var kyh={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},E_u=2147483647,ebh=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,S_u=Symbol("stop"),tbh={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},rbh={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 y5D=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=ebh,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},ibh=(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))}}))},nbh=(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(ibh(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},abh=(e,t,r)=>{if(!e.body)return e;let i=y5D(r??e.body);return new Request(e,{duplex:"half",body:ibh(e.body,i,t)})};var Koa=e=>e!==null&&typeof e=="object";var SKa=(...e)=>{for(let t of e)if((!Koa(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return RHc({},...e)},qHc=(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 M_u(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:RHc(e[r]??[],t[r]??[])}var THc=(e={},t={})=>({beforeRequest:M_u(e,t,"beforeRequest"),beforeRetry:M_u(e,t,"beforeRetry"),afterResponse:M_u(e,t,"afterResponse"),beforeError:M_u(e,t,"beforeError")}),RHc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(Koa(n)){for(let[a,o]of Object.entries(n))Koa(o)&&a in t&&(o=RHc(t[a],o)),t={...t,[a]:o};Koa(n.hooks)&&(i=THc(i,n.hooks),t.hooks=i),Koa(n.headers)&&(r=qHc(r,n.headers),t.headers=r)}return t};var ubh=e=>w_u.includes(e)?e.toUpperCase():e,b5D=["get","put","head","delete","options","trace"],v5D=[408,413,429,500,502,503,504],g5D=[413,429,503],obh={limit:2,methods:b5D,statusCodes:v5D,afterStatusCodes:g5D,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},sbh=(e={})=>{if(typeof e=="number")return{...obh,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{...obh,...e}};async function zHc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new Hoa(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function NHc(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 cbh=(e,t)=>{let r={};for(let i in t)!(i in rbh)&&!(i in tbh)&&!(i in e)&&(r[i]=t[i]);return r},lbh=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 MKa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>E_u)throw new RangeError(`The \`timeout\` option cannot be greater than ${E_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 EKa(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(!Xyh)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return nbh(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(kyh))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:qHc(this._input.headers,r.headers),hooks:THc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:ubh(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:sbh(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($yh&&Yyh){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(CHc&&(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),lbh(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);(Zyh&&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(!CHc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=abh(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Hoa)throw t;if(t instanceof EKa){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),E_u);if(this._retryCount<1)throw r;await NHc(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})===S_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=cbh(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):zHc(this._originalRequest,t,this.abortController,this._options)}};var FHc=e=>{let t=(r,i)=>MKa.create(r,SKa(e,i));for(let r of w_u)t[r]=(i,n)=>MKa.create(i,SKa(e,n,{method:r}));return t.create=r=>FHc(SKa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),FHc(SKa(e,r))),t.stop=S_u,t},O5D=FHc(),fbh=O5D;var Tbh=ue(qbh(),1);function WHc(e){let t=(0,Tbh.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Mvh=ue(Svh(),1),Dvh=ue(SJ(),1),r7c=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},i7c=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function n7c(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??WHc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Mvh.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 fbh(o,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new r7c(e):l}if(t.allVersions)return s;let u=new i7c(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=Dvh.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 TKa(e,t){let{version:r}=await n7c(e.toLowerCase(),t);return r}async function UJi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:TKa(e.packageName,{version:t?"prerelease":"latest"})}var Bvh=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],U_u=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=mu.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new idn(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.49.8"}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,eLa({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await rra()).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 Hyh({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1509
1509
|
`)||(r+=`
|
|
1510
1510
|
`),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=dnc(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 wKa(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 rra()).sendEvent(t)}logger=rve((t,...r)=>this.log(t,...r));stderr=rve((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=Ivh(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?Ivh(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=Bvh[this.numTasks++%Bvh.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===Qw.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=>eVt.indexOf(n.level)>=eVt.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===mu.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 UJi({cliEnvironment:this.environment,includePreReleases:t}),i=pY(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await j_u({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await DHc({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(`
|
|
1511
1511
|
Cancelled by user.`),new pM):i}}async getInput(t){return await wHc({message:t.message,default:t.default})}};function Ivh(e){return`[${e}]:`}var A8t=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 L_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)=>L_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 Cvh(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 qvh(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 Tvh=Function.bind,Rvh=Tvh.bind(Tvh);function zvh(e,t,r){let i=Rvh(qvh,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]=Rvh(Cvh,null).apply(null,a)})}function E6D(){let e=Symbol("Singular"),t={registry:{}},r=L_u.bind(null,t,e);return zvh(r,t,e),r}function S6D(){let e={registry:{}},t=L_u.bind(null,e);return zvh(t,e),t}var Nvh={Singular:E6D,Collection:S6D};var M6D="0.0.0-development",D6D=`octokit-endpoint.js/${M6D} ${WN()}`,B6D={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":D6D},mediaType:{format:""}};function I6D(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function C6D(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 Uvh(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(i=>{C6D(t[i])?i in e?r[i]=Uvh(e[i],t[i]):Object.assign(r,{[i]:t[i]}):Object.assign(r,{[i]:t[i]})}),r}function Fvh(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function o7c(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=I6D(r.headers),Fvh(r),Fvh(r.headers);let i=Uvh(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 q6D(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 T6D=/\{[^{}}]+\}/g;function R6D(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function z6D(e){let t=e.match(T6D);return t?t.map(R6D).reduce((r,i)=>r.concat(i),[]):[]}function Qvh(e,t){let r={__proto__:null};for(let i of Object.keys(e))t.indexOf(i)===-1&&(r[i]=e[i]);return r}function Lvh(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 tua(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function RKa(e,t,r){return t=e==="+"||e==="#"?Lvh(t):tua(t),r?tua(r)+"="+t:t}function eua(e){return e!=null}function a7c(e){return e===";"||e==="&"||e==="?"}function N6D(e,t,r,i){var n=e[r],a=[];if(eua(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(RKa(t,n,a7c(t)?r:""));else if(i==="*")Array.isArray(n)?n.filter(eua).forEach(function(o){a.push(RKa(t,o,a7c(t)?r:""))}):Object.keys(n).forEach(function(o){eua(n[o])&&a.push(RKa(t,n[o],o))});else{let o=[];Array.isArray(n)?n.filter(eua).forEach(function(c){o.push(RKa(t,c))}):Object.keys(n).forEach(function(c){eua(n[c])&&(o.push(tua(c)),o.push(RKa(t,n[c].toString())))}),a7c(t)?a.push(tua(r)+"="+o.join(",")):o.length!==0&&a.push(o.join(","))}else t===";"?eua(n)&&a.push(tua(r)):n===""&&(t==="&"||t==="?")?a.push(tua(r)+"="):n===""&&a.push("");return a}function F6D(e){return{expand:Q6D.bind(null,e)}}function Q6D(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(N6D(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 Lvh(a)}),e==="/"?e:e.replace(/\/$/,"")}function Vvh(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),i=Object.assign({},e.headers),n,a=Qvh(e,["method","baseUrl","url","headers","request","mediaType"]),o=z6D(r);r=F6D(r).expand(a),/^http/.test(r)||(r=e.baseUrl+r);let c=Object.keys(e).filter(u=>o.includes(u)).concat("baseUrl"),d=Qvh(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=q6D(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 U6D(e,t,r){return Vvh(o7c(e,t,r))}function Wvh(e,t){let r=o7c(e,t),i=U6D.bind(null,r);return Object.assign(i,{DEFAULTS:r,defaults:Wvh.bind(null,r),merge:o7c.bind(null,r),parse:Vvh})}var Gvh=Wvh(null,B6D);var Yvh=ue(Jvh(),1);var P8t=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 L6D="10.0.6",V6D={headers:{"user-agent":`octokit-request.js/${L6D} ${WN()}`}};function W6D(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 $vh(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=W6D(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 P8t(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 P8t(o.statusText,c,{response:u,request:e})}if(c===304)throw u.data=await u7c(o),new P8t("Not modified",c,{response:u,request:e});if(c>=400)throw u.data=await u7c(o),new P8t(x6D(u.data),c,{response:u,request:e});return u.data=i?await u7c(o):o.body,u}async function u7c(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(()=>"");let r=(0,Yvh.safeParse)(t);if(G6D(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 G6D(e){return e.type==="application/json"||e.type==="application/scim+json"}function x6D(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 s7c(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 $vh(r.parse(o));let c=(d,s)=>$vh(r.parse(r.merge(d,s)));return Object.assign(c,{endpoint:r,defaults:s7c.bind(null,r)}),o.request.hook(c,o)},{endpoint:r,defaults:s7c.bind(null,r)})}var Qm=s7c(Gvh,V6D);var H6D="0.0.0-development";function K6D(e){return`Request failed due to following response errors:
|
|
@@ -1531,7 +1531,7 @@ Cancelled by user.`),new pM):i}}async getInput(t){return await wHc({message:t.me
|
|
|
1531
1531
|
`)),{ok:!0,value:t}):i}}function Lmu(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var xsa=class e extends Error{errors;constructor(t){super(t.map(Lmu).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var Hsa=class e extends Error{errors;constructor(t){super(t.map(Lmu).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function ej(e){return{optional:()=>IZc(e),transform:t=>CZc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new Hsa(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new xsa(i.errors)}}}function IZc(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:()=>xh.OPTIONAL};return{...t,...ej(t)}}function CZc(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,...ej(r)}}function hIh(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:MA(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:MA(t,"bigint")}]},getType:()=>xh.BIGINT};return{...IF(e),...ej(e)}}var ChB=/^([+-]?\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 yIh(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:MA(t,"string")}]}:ChB.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:MA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:MA(t,"Date object")}]},getType:()=>xh.DATE};return{...IF(e),...ej(e)}}function UW(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...IF(r),...ej(r)}}}function Vmu(e){let t=new Set(e);return UW(xh.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:MA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:MA(i,"enum")}]}:{ok:!0,value:i})()}function bIh(e){let t=qZc(e);return{...t,...ej(t)}}function qZc(e){return{parse:(t,r)=>Ksa(e).parse(t,r),json:(t,r)=>Ksa(e).json(t,r),getType:()=>Ksa(e).getType()}}function Ksa(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function h$a(e){return Object.entries(e)}function y$a(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function T$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 b$a(e){return Object.keys(e)}function vIh(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function F8t(e){return{withParsedProperties:t=>TZc(e,t)}}function TZc(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(!T$i(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:MA(i,"object")}]};let a=new Set(Object.keys(t)),o=y$a(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(o,n)},getType:()=>e.getType()};return{...r,...ej(r),...F8t(r)}}function gIh(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function R$i(e){return e.isProperty}function Wmu(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>R$i(i)?i.rawKey:r),_getParsedProperties:()=>b$a(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of h$a(e)){let d=R$i(c)?c.rawKey:o,s=R$i(c)?c.valueSchema:c,u={rawKey:d,parsedKey:o,valueSchema:s};n[d]=u,AIh(s)&&a.push(d)}return OIh({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 h$a(e)){let c=R$i(o)?o.valueSchema:o;AIh(c)&&n.push(a)}return OIh({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return R$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:()=>xh.OBJECT};return{...IF(t),...ej(t),...F8t(t),...ggn(t)}}function OIh({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!T$i(e))return{ok:!1,errors:[{path:a,message:MA(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 ggn(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>mIh({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>mIh({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>xh.OBJECT};return{...r,...ej(r),...F8t(r),...ggn(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:()=>xh.OBJECT};return{...t,...ej(t),...F8t(t),...ggn(t)}}}}function mIh({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,o]=vIh(b$a(t),s=>n.has(s)),c=r(y$a(t,o)),d=i(y$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 AIh(e){return!qhB(e)}function qhB(e){switch(e.getType()){case xh.ANY:case xh.UNKNOWN:case xh.OPTIONAL:return!0;default:return!1}}function PIh(e){return Wmu(e)}function jIh(e){let t={...qZc(e),_getRawProperties:()=>Ksa(e)._getRawProperties(),_getParsedProperties:()=>Ksa(e)._getParsedProperties()};return{...t,...ej(t),...F8t(t),...ggn(t)}}function Gmu(e){let t={parse:(r,i)=>wIh(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>wIh(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>xh.LIST};return{...IF(t),...ej(t)}}function wIh(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:MA(e,"list"),path:[]}]}}function EIh(e){return UW(xh.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:MA(r,`"${e}"`)}]})()}function SIh(e){return UW(xh.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:MA(r,`${e.toString()}`)}]})()}var MIh=UW(xh.ANY,e=>({ok:!0,value:e}));var DIh=UW(xh.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:MA(e,"boolean")}]});var BIh=UW(xh.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:MA(e,"number")}]});var IIh=UW(xh.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:MA(e,"string")}]});var CIh=UW(xh.UNKNOWN,e=>({ok:!0,value:e}));function TIh(e,t){let r={parse:(i,n)=>qIh({value:i,isKeyNumeric:e.getType()===xh.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)=>qIh({value:i,isKeyNumeric:e.getType()===xh.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:()=>xh.RECORD};return{...IF(r),...ej(r)}}function qIh({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return T$i(e)?h$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:MA(e,"object")}]}}function RIh(e){let t=Gmu(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:MA(i,"Set")}]},getType:()=>xh.SET};return{...IF(r),...ej(r)}}function NIh(e){let t={parse:(r,i)=>zIh((n,a)=>n.parse(r,a),e,i),json:(r,i)=>zIh((n,a)=>n.json(r,a),e,i),getType:()=>xh.UNDISCRIMINATED_UNION};return{...IF(t),...ej(t)}}function zIh(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 FIh(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function UIh(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=Vmu(b$a(t)),a={parse:(o,c)=>QIh({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)=>QIh({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:()=>xh.UNION};return{...IF(a),...ej(a),...F8t(a)}}function QIh({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!T$i(e))return{ok:!1,errors:[{path:c,message:MA(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 uXt=ta.objectWithoutOptionalProperties({docs:ta.string().optional()});var zZc={};Yt(zZc,{ConjureServiceName:()=>xmu,DefinitionFile:()=>LIh});var xmu=ta.string();var Hmu=ta.enum_(["rid","string","safelong","integer","double","boolean","binary"]);var z$i=ta.undiscriminatedUnion([Hmu,ta.string()]);var Kmu=ta.objectWithoutOptionalProperties({alias:z$i,docs:ta.string().optional()});var Jmu=ta.objectWithoutOptionalProperties({type:z$i,docs:ta.string().optional()});var N$i=ta.undiscriminatedUnion([z$i,Jmu]);var $mu=ta.objectWithoutOptionalProperties({union:ta.record(ta.string(),N$i)});var Ymu=ta.objectWithoutOptionalProperties({fields:ta.record(ta.string(),N$i)});var Xmu=ta.objectWithoutOptionalProperties({value:ta.string()}).extend(uXt);var Zmu=ta.undiscriminatedUnion([ta.string(),Xmu]);var kmu=ta.objectWithoutOptionalProperties({values:ta.list(Zmu)});var eAu=ta.undiscriminatedUnion([Kmu,$mu,Ymu,kmu]);var tAu=ta.objectWithoutOptionalProperties({objects:ta.record(ta.string(),eAu).optional()});var rAu=ta.objectWithoutOptionalProperties({conjureImports:ta.property("conjure-imports",ta.record(ta.string(),ta.string()).optional()),definitions:tAu.optional()});var iAu=ta.enum_(["none","header"]);var Jsa=ta.undiscriminatedUnion([iAu,ta.string()]);var nAu=ta.enum_(["path","query","body"]);var aAu=ta.objectWithoutOptionalProperties({paramType:ta.property("param-type",nAu),type:ta.string()}).extend(uXt);var oAu=ta.undiscriminatedUnion([ta.string(),aAu]);var uAu=ta.objectWithoutOptionalProperties({http:ta.string(),auth:Jsa.optional(),args:ta.record(ta.string(),oAu).optional(),returns:N$i.optional()}).extend(uXt);var sAu=ta.objectWithoutOptionalProperties({name:ta.string().optional(),package:ta.string().optional(),basePath:ta.property("base-path",ta.string().optional()),defaultAuth:ta.property("default-auth",Jsa.optional()),endpoints:ta.record(ta.string(),uAu).optional()}).extend(uXt);var LIh=ta.objectWithoutOptionalProperties({types:rAu.optional(),services:ta.record(xmu,sAu).optional()});var NZc={};Yt(NZc,{ConjureArgument:()=>oAu,ConjureArgumentWithParamType:()=>aAu,ConjureAuthDefinition:()=>Jsa,ConjureAuthDefinitionType:()=>iAu,ConjureEndpointDefinition:()=>uAu,ConjureParamType:()=>nAu,ConjureService:()=>sAu});var FZc={};Yt(FZc,{ConjureAliasDeclaration:()=>Kmu,ConjureDefinitions:()=>tAu,ConjureEnumDeclaration:()=>kmu,ConjureEnumVariant:()=>Zmu,ConjureEnumWithDocs:()=>Xmu,ConjureObjectDeclaration:()=>Ymu,ConjurePrimitive:()=>Hmu,ConjureType:()=>z$i,ConjureTypeDeclaration:()=>eAu,ConjureTypeReference:()=>N$i,ConjureTypeWithDocs:()=>Jmu,ConjureTypes:()=>rAu,ConjureUnionDeclaration:()=>$mu});var VIh=require("fs/promises");async function WIh(e,t){let r=[];for(let i of await A4(e,t))r.push(await ThB({relativeFilepath:Ef(e,i),absoluteFilepath:i}));return r}async function ThB({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,VIh.readFile)(t)).toString().replaceAll(/: rid(?:$|\s)/g,`: string
|
|
1532
1532
|
`).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:cAu.conjure.DefinitionFile.parseOrThrow(qi.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}function GIh(e,t){if(RhB(e))return t.alias(e);if(zhB(e))return t.enum(e);if(NhB(e))return t.object(e);if(FhB(e))return t.union(e);vt(e)}function RhB(e){return e?.alias!=null}function zhB(e){return e?.values!=null}function NhB(e){return e?.fields!=null}function FhB(e){return e?.union!=null}var v$a=class extends eJa{fernDefinitionBuilder=new Uvn(!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 xIh(t,(a,o,c)=>{for(let[u,l]of Object.entries(c.services??{})){let p=gRo({value:u,suffix:"Service"});this.conjureFilepathToFernFilepath[o]=xe.of(`${p}/__package__.yml`);return}let s=kzi(o)?.split(".")[0];s!=null&&(this.conjureFilepathToFernFilepath[o]=xe.of(`${s}/__package__.yml`))}),await xIh(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:xe.of(u)});this.fernDefinitionBuilder.addImport({file:d,fileToImport:xe.of(l),alias:s})}this.importAllTypes({conjureFile:c,fernFilePath:d});return}for(let[d,s]of Object.entries(c.services)){let u=gRo({value:d,suffix:"Service"}),l=xe.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:xe.of(h)});this.fernDefinitionBuilder.addImport({file:l,fileToImport:xe.of(y),alias:_})}for(let[_,h]of Object.entries(s.endpoints??{})){let y=Snc(h.http);if(y.type==="failure"){this.context?.logger.error(`Failed to parse ${h.http}. Skipping.`);continue}let v={auth:(h.auth??s.defaultAuth)!==pIh.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??{}))GIh(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=qt(Yi(t),xe.of(r)),a=CJ(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 xIh(e,t){for(let r of await WIh(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}function HIh(e,t){return nn(e,t)}var lAu=class extends A8t{type="conjure";absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=qt(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new yY({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 v$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:jr.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:n.rootApiFile["default-url"],contents:n.rootApiFile,rawContents:qi.dump(n.rootApiFile)},namedDefinitionFiles:{...HIh(n.definitionFiles,a=>({absoluteFilepath:jr.of("/DUMMY_PATH"),rawContents:qi.dump(a),contents:a})),[xe.of(Zb)]:{absoluteFilepath:jr.of("/DUMMY_PATH"),rawContents:qi.dump(n.packageMarkerFile),contents:n.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};var _qh=ue(ZIh(),1);var Gp;(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"})(Gp||(Gp={}));function kIh(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function fAu(e,t){for(let[r,i]of VI(e))UhB({relativeFilepath:r,failure:i,logger:t})}function UhB({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case Gp.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 Gp.FILE_READ:r.error("Failed to open file: "+e);break;case Gp.FILE_MISSING:r.error("Missing file: "+e);break;case Gp.FILE_PARSE:t.error instanceof I3a?r.error(f0e({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case Gp.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of LhB(i))r.error(f0e({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case Gp.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case Gp.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${pUo}: `+t.dependencyName);break;case Gp.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case Gp.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case Gp.JSONSCHEMA_VALIDATION:if(t.error.error!=null){let i=t.error.error.instancePath.split("/").filter(n=>n!=="").map(kIh);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(f0e({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(kIh);i.keyword==="required"&&i.params?.missingProperty?n.push(i.params.missingProperty):i.keyword==="additionalProperties"&&i.params?.additionalProperty&&n.push(i.params.additionalProperty),r.debug(f0e({title:i.message??"Unknown error",breadcrumbs:[e,...n]}))}break;default:vt(t)}}function LhB(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 eCh=require("fs/promises");async function tCh(e,t){let r=[];for(let i of await A4(e,t))r.push(await VhB({relativeFilepath:Ef(e,i),absoluteFilepath:i}));return r}async function VhB({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,eCh.readFile)(t)).toString()}}async function rCh(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:Gp.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 H2c=ue(s7i(),1);var nqh=require("fs"),cca=require("fs/promises");var aqh=require("os"),oqh=ue(require("path"),1),uqh=require("stream/promises");var iCh=ue(require("events"),1),Mx=ue(require("fs"),1);var WhB=Mx.default.writev,Q$i=Symbol("_autoClose"),U8t=Symbol("_close"),O$a=Symbol("_ended"),tj=Symbol("_fd"),LZc=Symbol("_finished"),xUi=Symbol("_flags"),VZc=Symbol("_flush"),HZc=Symbol("_handleChunk"),KZc=Symbol("_makeBuf"),A$a=Symbol("_mode"),dAu=Symbol("_needDrain"),Zsa=Symbol("_onerror"),ksa=Symbol("_onopen"),WZc=Symbol("_onread"),Ysa=Symbol("_onwrite"),U$i=Symbol("_open"),Q8t=Symbol("_path"),F$i=Symbol("_pos"),sXt=Symbol("_queue"),Xsa=Symbol("_read"),GZc=Symbol("_readSize"),GUi=Symbol("_reading"),m$a=Symbol("_remain"),xZc=Symbol("_size"),pAu=Symbol("_write"),mgn=Symbol("_writing"),_Au=Symbol("_defaultFlag"),Agn=Symbol("_errored"),Pgn=class extends uR{[Agn]=!1;[tj];[Q8t];[GZc];[GUi]=!1;[xZc];[m$a];[Q$i];constructor(t,r){if(r=r||{},super(r),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Agn]=!1,this[tj]=typeof r.fd=="number"?r.fd:void 0,this[Q8t]=t,this[GZc]=r.readSize||16*1024*1024,this[GUi]=!1,this[xZc]=typeof r.size=="number"?r.size:1/0,this[m$a]=this[xZc],this[Q$i]=typeof r.autoClose=="boolean"?r.autoClose:!0,typeof this[tj]=="number"?this[Xsa]():this[U$i]()}get fd(){return this[tj]}get path(){return this[Q8t]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[U$i](){Mx.default.open(this[Q8t],"r",(t,r)=>this[ksa](t,r))}[ksa](t,r){t?this[Zsa](t):(this[tj]=r,this.emit("open",r),this[Xsa]())}[KZc](){return Buffer.allocUnsafe(Math.min(this[GZc],this[m$a]))}[Xsa](){if(!this[GUi]){this[GUi]=!0;let t=this[KZc]();if(t.length===0)return process.nextTick(()=>this[WZc](null,0,t));Mx.default.read(this[tj],t,0,t.length,null,(r,i,n)=>this[WZc](r,i,n))}}[WZc](t,r,i){this[GUi]=!1,t?this[Zsa](t):this[HZc](r,i)&&this[Xsa]()}[U8t](){if(this[Q$i]&&typeof this[tj]=="number"){let t=this[tj];this[tj]=void 0,Mx.default.close(t,r=>r?this.emit("error",r):this.emit("close"))}}[Zsa](t){this[GUi]=!0,this[U8t](),this.emit("error",t)}[HZc](t,r){let i=!1;return this[m$a]-=t,t>0&&(i=super.write(t<r.length?r.subarray(0,t):r)),(t===0||this[m$a]<=0)&&(i=!1,this[U8t](),super.end()),i}emit(t,...r){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[tj]=="number"&&this[Xsa](),!1;case"error":return this[Agn]?!1:(this[Agn]=!0,super.emit(t,...r));default:return super.emit(t,...r)}}},hAu=class extends Pgn{[U$i](){let t=!0;try{this[ksa](null,Mx.default.openSync(this[Q8t],"r")),t=!1}finally{t&&this[U8t]()}}[Xsa](){let t=!0;try{if(!this[GUi]){this[GUi]=!0;do{let r=this[KZc](),i=r.length===0?0:Mx.default.readSync(this[tj],r,0,r.length,null);if(!this[HZc](i,r))break}while(!0);this[GUi]=!1}t=!1}finally{t&&this[U8t]()}}[U8t](){if(this[Q$i]&&typeof this[tj]=="number"){let t=this[tj];this[tj]=void 0,Mx.default.closeSync(t),this.emit("close")}}},HUi=class extends iCh.default{readable=!1;writable=!0;[Agn]=!1;[mgn]=!1;[O$a]=!1;[sXt]=[];[dAu]=!1;[Q8t];[A$a];[Q$i];[tj];[_Au];[xUi];[LZc]=!1;[F$i];constructor(t,r){r=r||{},super(r),this[Q8t]=t,this[tj]=typeof r.fd=="number"?r.fd:void 0,this[A$a]=r.mode===void 0?438:r.mode,this[F$i]=typeof r.start=="number"?r.start:void 0,this[Q$i]=typeof r.autoClose=="boolean"?r.autoClose:!0;let i=this[F$i]!==void 0?"r+":"w";this[_Au]=r.flags===void 0,this[xUi]=r.flags===void 0?i:r.flags,this[tj]===void 0&&this[U$i]()}emit(t,...r){if(t==="error"){if(this[Agn])return!1;this[Agn]=!0}return super.emit(t,...r)}get fd(){return this[tj]}get path(){return this[Q8t]}[Zsa](t){this[U8t](),this[mgn]=!0,this.emit("error",t)}[U$i](){Mx.default.open(this[Q8t],this[xUi],this[A$a],(t,r)=>this[ksa](t,r))}[ksa](t,r){this[_Au]&&this[xUi]==="r+"&&t&&t.code==="ENOENT"?(this[xUi]="w",this[U$i]()):t?this[Zsa](t):(this[tj]=r,this.emit("open",r),this[mgn]||this[VZc]())}end(t,r){return t&&this.write(t,r),this[O$a]=!0,!this[mgn]&&!this[sXt].length&&typeof this[tj]=="number"&&this[Ysa](null,0),this}write(t,r){return typeof t=="string"&&(t=Buffer.from(t,r)),this[O$a]?(this.emit("error",new Error("write() after end()")),!1):this[tj]===void 0||this[mgn]||this[sXt].length?(this[sXt].push(t),this[dAu]=!0,!1):(this[mgn]=!0,this[pAu](t),!0)}[pAu](t){Mx.default.write(this[tj],t,0,t.length,this[F$i],(r,i)=>this[Ysa](r,i))}[Ysa](t,r){t?this[Zsa](t):(this[F$i]!==void 0&&typeof r=="number"&&(this[F$i]+=r),this[sXt].length?this[VZc]():(this[mgn]=!1,this[O$a]&&!this[LZc]?(this[LZc]=!0,this[U8t](),this.emit("finish")):this[dAu]&&(this[dAu]=!1,this.emit("drain"))))}[VZc](){if(this[sXt].length===0)this[O$a]&&this[Ysa](null,0);else if(this[sXt].length===1)this[pAu](this[sXt].pop());else{let t=this[sXt];this[sXt]=[],WhB(this[tj],t,this[F$i],(r,i)=>this[Ysa](r,i))}}[U8t](){if(this[Q$i]&&typeof this[tj]=="number"){let t=this[tj];this[tj]=void 0,Mx.default.close(t,r=>r?this.emit("error",r):this.emit("close"))}}},eca=class extends HUi{[U$i](){let t;if(this[_Au]&&this[xUi]==="r+")try{t=Mx.default.openSync(this[Q8t],this[xUi],this[A$a])}catch(r){if(r?.code==="ENOENT")return this[xUi]="w",this[U$i]();throw r}else t=Mx.default.openSync(this[Q8t],this[xUi],this[A$a]);this[ksa](null,t)}[U8t](){if(this[Q$i]&&typeof this[tj]=="number"){let t=this[tj];this[tj]=void 0,Mx.default.closeSync(t),this.emit("close")}}[pAu](t){let r=!0;try{this[Ysa](null,Mx.default.writeSync(this[tj],t,0,t.length,this[F$i])),r=!1}finally{if(r)try{this[U8t]()}catch{}}}};var j2c=ue(require("path"),1);var Cgn=ue(require("fs"),1),TAu=require("path");var GhB=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),nCh=e=>!!e.sync&&!!e.file,aCh=e=>!e.sync&&!!e.file,oCh=e=>!!e.sync&&!e.file,uCh=e=>!e.sync&&!e.file;var sCh=e=>!!e.file;var xhB=e=>{let t=GhB.get(e);return t||e},P$a=(e={})=>{if(!e)return{};let t={};for(let[r,i]of Object.entries(e)){let n=xhB(r);t[n]=i}return t.chmod===void 0&&t.noChmod===!1&&(t.chmod=!0),delete t.noChmod,t};var cXt=(e,t,r,i,n)=>Object.assign((a=[],o,c)=>{Array.isArray(a)&&(o=a,a={}),typeof o=="function"&&(c=o,o=void 0),o?o=Array.from(o):o=[];let d=P$a(a);if(n?.(d,o),nCh(d)){if(typeof c=="function")throw new TypeError("callback not supported for sync tar functions");return e(d,o)}else if(aCh(d)){let s=t(d,o),u=c||void 0;return u?s.then(()=>u(),u):s}else if(oCh(d)){if(typeof c=="function")throw new TypeError("callback not supported for sync tar functions");return r(d,o)}else if(uCh(d)){if(typeof c=="function")throw new TypeError("callback only supported with file option");return i(d,o)}else throw new Error("impossible options??")},{syncFile:e,asyncFile:t,syncNoFile:r,asyncNoFile:i,validate:n});var jCh=require("events");var yAu=ue(require("assert"),1),L$i=require("buffer");var lCh=ue(require("zlib"),1);var cCh=ue(require("zlib"),1),HhB=cCh.default.constants||{ZLIB_VERNUM:4736},pSe=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},HhB));var KhB=L$i.Buffer.concat,fCh=Object.getOwnPropertyDescriptor(L$i.Buffer,"concat"),JhB=e=>e,$Zc=fCh?.writable===!0||fCh?.set!==void 0?e=>{L$i.Buffer.concat=e?JhB:KhB}:e=>{},jgn=Symbol("_superWrite"),tca=class extends Error{code;errno;constructor(t,r){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,r??this.constructor)}get name(){return"ZlibError"}},YZc=Symbol("flushFlag"),j$a=class extends uR{#e=!1;#t=!1;#r;#i;#n;#a;#o;get sawError(){return this.#e}get handle(){return this.#a}get flushFlag(){return this.#r}constructor(t,r){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#r=t.flush??0,this.#i=t.finishFlush??0,this.#n=t.fullFlushFlag??0,typeof lCh[r]!="function")throw new TypeError("Compression method not supported: "+r);try{this.#a=new lCh[r](t)}catch(i){throw new tca(i,this.constructor)}this.#o=i=>{this.#e||(this.#e=!0,this.close(),this.emit("error",i))},this.#a?.on("error",i=>this.#o(new tca(i))),this.once("end",()=>this.close)}close(){this.#a&&(this.#a.close(),this.#a=void 0,this.emit("close"))}reset(){if(!this.#e)return(0,yAu.default)(this.#a,"zlib binding closed"),this.#a.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#n),this.write(Object.assign(L$i.Buffer.alloc(0),{[YZc]:t})))}end(t,r,i){return typeof t=="function"&&(i=t,r=void 0,t=void 0),typeof r=="function"&&(i=r,r=void 0),t&&(r?this.write(t,r):this.write(t)),this.flush(this.#i),this.#t=!0,super.end(i)}get ended(){return this.#t}[jgn](t){return super.write(t)}write(t,r,i){if(typeof r=="function"&&(i=r,r="utf8"),typeof t=="string"&&(t=L$i.Buffer.from(t,r)),this.#e)return;(0,yAu.default)(this.#a,"zlib binding closed");let n=this.#a._handle,a=n.close;n.close=()=>{};let o=this.#a.close;this.#a.close=()=>{},$Zc(!0);let c;try{let s=typeof t[YZc]=="number"?t[YZc]:this.#r;c=this.#a._processChunk(t,s),$Zc(!1)}catch(s){$Zc(!1),this.#o(new tca(s,this.write))}finally{this.#a&&(this.#a._handle=n,n.close=a,this.#a.close=o,this.#a.removeAllListeners("error"))}this.#a&&this.#a.on("error",s=>this.#o(new tca(s,this.write)));let d;if(c)if(Array.isArray(c)&&c.length>0){let s=c[0];d=this[jgn](L$i.Buffer.from(s));for(let u=1;u<c.length;u++)d=this[jgn](c[u])}else d=this[jgn](L$i.Buffer.from(c));return i&&i(),d}},bAu=class extends j$a{#e;#t;constructor(t,r){t=t||{},t.flush=t.flush||pSe.Z_NO_FLUSH,t.finishFlush=t.finishFlush||pSe.Z_FINISH,t.fullFlushFlag=pSe.Z_FULL_FLUSH,super(t,r),this.#e=t.level,this.#t=t.strategy}params(t,r){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==t||this.#t!==r){this.flush(pSe.Z_SYNC_FLUSH),(0,yAu.default)(this.handle,"zlib binding closed");let i=this.handle.flush;this.handle.flush=(n,a)=>{typeof n=="function"&&(a=n,n=this.flushFlag),this.flush(n),a?.()};try{this.handle.params(t,r)}finally{this.handle.flush=i}this.handle&&(this.#e=t,this.#t=r)}}}};var vAu=class extends bAu{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[jgn](t){return this.#e?(this.#e=!1,t[9]=255,super[jgn](t)):super[jgn](t)}};var gAu=class extends bAu{constructor(t){super(t,"Unzip")}},OAu=class extends j$a{constructor(t,r){t=t||{},t.flush=t.flush||pSe.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||pSe.BROTLI_OPERATION_FINISH,t.fullFlushFlag=pSe.BROTLI_OPERATION_FLUSH,super(t,r)}},mAu=class extends OAu{constructor(t){super(t,"BrotliCompress")}},AAu=class extends OAu{constructor(t){super(t,"BrotliDecompress")}},PAu=class extends j$a{constructor(t,r){t=t||{},t.flush=t.flush||pSe.ZSTD_e_continue,t.finishFlush=t.finishFlush||pSe.ZSTD_e_end,t.fullFlushFlag=pSe.ZSTD_e_flush,super(t,r)}},jAu=class extends PAu{constructor(t){super(t,"ZstdCompress")}},wAu=class extends PAu{constructor(t){super(t,"ZstdDecompress")}};var Sgn=require("path");var dCh=(e,t)=>{if(Number.isSafeInteger(e))e<0?XhB(e,t):YhB(e,t);else throw Error("cannot encode number outside of javascript safe integer range");return t},YhB=(e,t)=>{t[0]=128;for(var r=t.length;r>1;r--)t[r-1]=e&255,e=Math.floor(e/256)},XhB=(e,t)=>{t[0]=255;var r=!1;e=e*-1;for(var i=t.length;i>1;i--){var n=e&255;e=Math.floor(e/256),r?t[i-1]=_Ch(n):n===0?t[i-1]=0:(r=!0,t[i-1]=hCh(n))}},pCh=e=>{let t=e[0],r=t===128?khB(e.subarray(1,e.length)):t===255?ZhB(e):null;if(r===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(r))throw Error("parsed number outside of javascript safe integer range");return r},ZhB=e=>{for(var t=e.length,r=0,i=!1,n=t-1;n>-1;n--){var a=Number(e[n]),o;i?o=_Ch(a):a===0?o=a:(i=!0,o=hCh(a)),o!==0&&(r-=o*Math.pow(256,t-n-1))}return r},khB=e=>{for(var t=e.length,r=0,i=t-1;i>-1;i--){var n=Number(e[i]);n!==0&&(r+=n*Math.pow(256,t-i-1))}return r},_Ch=e=>(255^e)&255,hCh=e=>(255^e)+1&255;var EAu=e=>SAu.has(e);var SAu=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),yCh=new Map(Array.from(SAu).map(e=>[e[1],e[0]]));var vge=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,r=0,i,n){Buffer.isBuffer(t)?this.decode(t,r||0,i,n):t&&this.#t(t)}decode(t,r,i,n){if(r||(r=0),!t||!(t.length>=r+512))throw new Error("need 512 bytes for header");this.path=i?.path??wgn(t,r,100),this.mode=i?.mode??n?.mode??V$i(t,r+100,8),this.uid=i?.uid??n?.uid??V$i(t,r+108,8),this.gid=i?.gid??n?.gid??V$i(t,r+116,8),this.size=i?.size??n?.size??V$i(t,r+124,12),this.mtime=i?.mtime??n?.mtime??XZc(t,r+136,12),this.cksum=V$i(t,r+148,12),n&&this.#t(n,!0),i&&this.#t(i);let a=wgn(t,r+156,1);if(EAu(a)&&(this.#e=a||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=wgn(t,r+157,100),t.subarray(r+257,r+265).toString()==="ustar\x0000")if(this.uname=i?.uname??n?.uname??wgn(t,r+265,32),this.gname=i?.gname??n?.gname??wgn(t,r+297,32),this.devmaj=i?.devmaj??n?.devmaj??V$i(t,r+329,8)??0,this.devmin=i?.devmin??n?.devmin??V$i(t,r+337,8)??0,t[r+475]!==0){let c=wgn(t,r+345,155);this.path=c+"/"+this.path}else{let c=wgn(t,r+345,130);c&&(this.path=c+"/"+this.path),this.atime=i?.atime??n?.atime??XZc(t,r+476,12),this.ctime=i?.ctime??n?.ctime??XZc(t,r+488,12)}let o=256;for(let c=r;c<r+148;c++)o+=t[c];for(let c=r+156;c<r+512;c++)o+=t[c];this.cksumValid=o===this.cksum,this.cksum===void 0&&o===256&&(this.nullBlock=!0)}#t(t,r=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([i,n])=>!(n==null||i==="path"&&r||i==="linkpath"&&r||i==="global"))))}encode(t,r=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=r+512))throw new Error("need 512 bytes for header");let i=this.ctime||this.atime?130:155,n=tyB(this.path||"",i),a=n[0],o=n[1];this.needPax=!!n[2],this.needPax=Egn(t,r,100,a)||this.needPax,this.needPax=W$i(t,r+100,8,this.mode)||this.needPax,this.needPax=W$i(t,r+108,8,this.uid)||this.needPax,this.needPax=W$i(t,r+116,8,this.gid)||this.needPax,this.needPax=W$i(t,r+124,12,this.size)||this.needPax,this.needPax=ZZc(t,r+136,12,this.mtime)||this.needPax,t[r+156]=this.#e.charCodeAt(0),this.needPax=Egn(t,r+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",r+257,8),this.needPax=Egn(t,r+265,32,this.uname)||this.needPax,this.needPax=Egn(t,r+297,32,this.gname)||this.needPax,this.needPax=W$i(t,r+329,8,this.devmaj)||this.needPax,this.needPax=W$i(t,r+337,8,this.devmin)||this.needPax,this.needPax=Egn(t,r+345,i,o)||this.needPax,t[r+475]!==0?this.needPax=Egn(t,r+345,155,o)||this.needPax:(this.needPax=Egn(t,r+345,130,o)||this.needPax,this.needPax=ZZc(t,r+476,12,this.atime)||this.needPax,this.needPax=ZZc(t,r+488,12,this.ctime)||this.needPax);let c=256;for(let d=r;d<r+148;d++)c+=t[d];for(let d=r+156;d<r+512;d++)c+=t[d];return this.cksum=c,W$i(t,r+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:SAu.get(this.#e)}get typeKey(){return this.#e}set type(t){let r=String(yCh.get(t));if(EAu(r)||r==="Unsupported")this.#e=r;else if(EAu(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},tyB=(e,t)=>{let i=e,n="",a,o=Sgn.posix.parse(e).root||".";if(Buffer.byteLength(i)<100)a=[i,n,!1];else{n=Sgn.posix.dirname(i),i=Sgn.posix.basename(i);do Buffer.byteLength(i)<=100&&Buffer.byteLength(n)<=t?a=[i,n,!1]:Buffer.byteLength(i)>100&&Buffer.byteLength(n)<=t?a=[i.slice(0,99),n,!0]:(i=Sgn.posix.join(Sgn.posix.basename(n),i),n=Sgn.posix.dirname(n));while(n!==o&&a===void 0);a||(a=[e.slice(0,99),"",!0])}return a},wgn=(e,t,r)=>e.subarray(t,t+r).toString("utf8").replace(/\0.*/,""),XZc=(e,t,r)=>ryB(V$i(e,t,r)),ryB=e=>e===void 0?void 0:new Date(e*1e3),V$i=(e,t,r)=>Number(e[t])&128?pCh(e.subarray(t,t+r)):nyB(e,t,r),iyB=e=>isNaN(e)?void 0:e,nyB=(e,t,r)=>iyB(parseInt(e.subarray(t,t+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),ayB={12:8589934591,8:2097151},W$i=(e,t,r,i)=>i===void 0?!1:i>ayB[r]||i<0?(dCh(i,e.subarray(t,t+r)),!0):(oyB(e,t,r,i),!1),oyB=(e,t,r,i)=>e.write(uyB(i,r),t,r,"ascii"),uyB=(e,t)=>syB(Math.floor(e).toString(8),t),syB=(e,t)=>(e.length===t-1?e:new Array(t-e.length-1).join("0")+e+" ")+"\0",ZZc=(e,t,r,i)=>i===void 0?!1:W$i(e,t,r,i.getTime()/1e3),cyB=new Array(156).join("\0"),Egn=(e,t,r,i)=>i===void 0?!1:(e.write(i+cyB,t,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r);var vCh=require("path");var G$i=class e{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(t,r=!1){this.atime=t.atime,this.charset=t.charset,this.comment=t.comment,this.ctime=t.ctime,this.dev=t.dev,this.gid=t.gid,this.global=r,this.gname=t.gname,this.ino=t.ino,this.linkpath=t.linkpath,this.mtime=t.mtime,this.nlink=t.nlink,this.path=t.path,this.size=t.size,this.uid=t.uid,this.uname=t.uname}encode(){let t=this.encodeBody();if(t==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(t),i=512*Math.ceil(1+r/512),n=Buffer.allocUnsafe(i);for(let a=0;a<512;a++)n[a]=0;new vge({path:("PaxHeader/"+(0,vCh.basename)(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(n),n.write(t,512,r,"utf8");for(let a=r+512;a<n.length;a++)n[a]=0;return n}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(t){if(this[t]===void 0)return"";let r=this[t],i=r instanceof Date?r.getTime()/1e3:r,n=" "+(t==="dev"||t==="ino"||t==="nlink"?"SCHILY.":"")+t+"="+i+`
|
|
1533
1533
|
`,a=Buffer.byteLength(n),o=Math.floor(Math.log(a)/Math.log(10))+1;return a+o>=Math.pow(10,o)&&(o+=1),o+a+n}static parse(t,r,i=!1){return new e(lyB(fyB(t),r),i)}},lyB=(e,t)=>t?Object.assign({},t,e):e,fyB=e=>e.replace(/\n$/,"").split(`
|
|
1534
|
-
`).reduce(dyB,Object.create(null)),dyB=(e,t)=>{let r=parseInt(t,10);if(r!==Buffer.byteLength(t)+1)return e;t=t.slice((r+" ").length);let i=t.split("="),n=i.shift();if(!n)return e;let a=n.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),o=i.join("=");return e[a]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(a)?new Date(Number(o)*1e3):/^[0-9]+$/.test(o)?+o:o,e};var pyB=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,k_=pyB!=="win32"?e=>e:e=>e&&e.replace(/\\/g,"/");var rca=class extends uR{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,r,i){switch(super({}),this.pause(),this.extended=r,this.globalExtended=i,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=k_(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?k_(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,r&&this.#e(r),i&&this.#e(i,!0)}write(t){let r=t.length;if(r>this.blockRemain)throw new Error("writing more to entry than is appropriate");let i=this.remain,n=this.blockRemain;return this.remain=Math.max(0,i-r),this.blockRemain=Math.max(0,n-r),this.ignore?!0:i>=r?super.write(t):super.write(t.subarray(0,i))}#e(t,r=!1){t.path&&(t.path=k_(t.path)),t.linkpath&&(t.linkpath=k_(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([i,n])=>!(n==null||i==="path"&&r))))}};var Mgn=(e,t,r,i={})=>{e.file&&(i.file=e.file),e.cwd&&(i.cwd=e.cwd),i.code=r instanceof Error&&r.code||t,i.tarCode=t,!e.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),e.emit("warn",t,r,i)):r instanceof Error?e.emit("error",Object.assign(r,i)):e.emit("error",Object.assign(new Error(`${t}: ${r}`),i))};var _yB=1024*1024,i2c=Buffer.from([31,139]),n2c=Buffer.from([40,181,47,253]),hyB=Math.max(i2c.length,n2c.length),_Se=Symbol("state"),Dgn=Symbol("writeEntry"),KUi=Symbol("readEntry"),kZc=Symbol("nextEntry"),gCh=Symbol("processEntry"),lXt=Symbol("extendedHeader"),w$a=Symbol("globalExtendedHeader"),x$i=Symbol("meta"),OCh=Symbol("emitMeta"),oE=Symbol("buffer"),JUi=Symbol("queue"),H$i=Symbol("ended"),e2c=Symbol("emittedEnd"),Bgn=Symbol("emit"),N1=Symbol("unzip"),MAu=Symbol("consumeChunk"),DAu=Symbol("consumeChunkSub"),t2c=Symbol("consumeBody"),mCh=Symbol("consumeMeta"),ACh=Symbol("consumeHeader"),E$a=Symbol("consuming"),r2c=Symbol("bufferConcat"),BAu=Symbol("maybeEnd"),ica=Symbol("writing"),K$i=Symbol("aborted"),IAu=Symbol("onDone"),Ign=Symbol("sawValidEntry"),CAu=Symbol("sawNullBlock"),qAu=Symbol("sawEOF"),PCh=Symbol("closeStream"),yyB=()=>!0,$Ui=class extends jCh.EventEmitter{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[JUi]=[];[oE];[KUi];[Dgn];[_Se]="begin";[x$i]="";[lXt];[w$a];[H$i]=!1;[N1];[K$i]=!1;[Ign];[CAu]=!1;[qAu]=!1;[ica]=!1;[E$a]=!1;[e2c]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(IAu,()=>{(this[_Se]==="begin"||this[Ign]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(IAu,t.ondone):this.on(IAu,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||_yB,this.filter=typeof t.filter=="function"?t.filter:yyB;let r=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:r?void 0:!1;let i=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:i?!0:void 0,this.on("end",()=>this[PCh]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,r,i={}){Mgn(this,t,r,i)}[ACh](t,r){this[Ign]===void 0&&(this[Ign]=!1);let i;try{i=new vge(t,r,this[lXt],this[w$a])}catch(n){return this.warn("TAR_ENTRY_INVALID",n)}if(i.nullBlock)this[CAu]?(this[qAu]=!0,this[_Se]==="begin"&&(this[_Se]="header"),this[Bgn]("eof")):(this[CAu]=!0,this[Bgn]("nullBlock"));else if(this[CAu]=!1,!i.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:i});else if(!i.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:i});else{let n=i.type;if(/^(Symbolic)?Link$/.test(n)&&!i.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:i});else if(!/^(Symbolic)?Link$/.test(n)&&!/^(Global)?ExtendedHeader$/.test(n)&&i.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:i});else{let a=this[Dgn]=new rca(i,this[lXt],this[w$a]);if(!this[Ign])if(a.remain){let o=()=>{a.invalid||(this[Ign]=!0)};a.on("end",o)}else this[Ign]=!0;a.meta?a.size>this.maxMetaEntrySize?(a.ignore=!0,this[Bgn]("ignoredEntry",a),this[_Se]="ignore",a.resume()):a.size>0&&(this[x$i]="",a.on("data",o=>this[x$i]+=o),this[_Se]="meta"):(this[lXt]=void 0,a.ignore=a.ignore||!this.filter(a.path,a),a.ignore?(this[Bgn]("ignoredEntry",a),this[_Se]=a.remain?"ignore":"header",a.resume()):(a.remain?this[_Se]="body":(this[_Se]="header",a.end()),this[KUi]?this[JUi].push(a):(this[JUi].push(a),this[kZc]())))}}}[PCh](){queueMicrotask(()=>this.emit("close"))}[gCh](t){let r=!0;if(!t)this[KUi]=void 0,r=!1;else if(Array.isArray(t)){let[i,...n]=t;this.emit(i,...n)}else this[KUi]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[kZc]()),r=!1);return r}[kZc](){do;while(this[gCh](this[JUi].shift()));if(!this[JUi].length){let t=this[KUi];!t||t.flowing||t.size===t.remain?this[ica]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[t2c](t,r){let i=this[Dgn];if(!i)throw new Error("attempt to consume body without entry??");let n=i.blockRemain??0,a=n>=t.length&&r===0?t:t.subarray(r,r+n);return i.write(a),i.blockRemain||(this[_Se]="header",this[Dgn]=void 0,i.end()),a.length}[mCh](t,r){let i=this[Dgn],n=this[t2c](t,r);return!this[Dgn]&&i&&this[OCh](i),n}[Bgn](t,r,i){!this[JUi].length&&!this[KUi]?this.emit(t,r,i):this[JUi].push([t,r,i])}[OCh](t){switch(this[Bgn]("meta",this[x$i]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[lXt]=G$i.parse(this[x$i],this[lXt],!1);break;case"GlobalExtendedHeader":this[w$a]=G$i.parse(this[x$i],this[w$a],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let r=this[lXt]??Object.create(null);this[lXt]=r,r.path=this[x$i].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let r=this[lXt]||Object.create(null);this[lXt]=r,r.linkpath=this[x$i].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[K$i]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,r,i){if(typeof r=="function"&&(i=r,r=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof r=="string"?r:"utf8")),this[K$i])return i?.(),!1;if((this[N1]===void 0||this.brotli===void 0&&this[N1]===!1)&&t){if(this[oE]&&(t=Buffer.concat([this[oE],t]),this[oE]=void 0),t.length<hyB)return this[oE]=t,i?.(),!0;for(let d=0;this[N1]===void 0&&d<i2c.length;d++)t[d]!==i2c[d]&&(this[N1]=!1);let o=!1;if(this[N1]===!1&&this.zstd!==!1){o=!0;for(let d=0;d<n2c.length;d++)if(t[d]!==n2c[d]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[N1]===!1&&c)if(t.length<512)if(this[H$i])this.brotli=!0;else return this[oE]=t,i?.(),!0;else try{new vge(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[N1]===void 0||this[N1]===!1&&(this.brotli||o)){let d=this[H$i];this[H$i]=!1,this[N1]=this[N1]===void 0?new gAu({}):o?new wAu({}):new AAu({}),this[N1].on("data",u=>this[MAu](u)),this[N1].on("error",u=>this.abort(u)),this[N1].on("end",()=>{this[H$i]=!0,this[MAu]()}),this[ica]=!0;let s=!!this[N1][d?"end":"write"](t);return this[ica]=!1,i?.(),s}}this[ica]=!0,this[N1]?this[N1].write(t):this[MAu](t),this[ica]=!1;let a=this[JUi].length?!1:this[KUi]?this[KUi].flowing:!0;return!a&&!this[JUi].length&&this[KUi]?.once("drain",()=>this.emit("drain")),i?.(),a}[r2c](t){t&&!this[K$i]&&(this[oE]=this[oE]?Buffer.concat([this[oE],t]):t)}[BAu](){if(this[H$i]&&!this[e2c]&&!this[K$i]&&!this[E$a]){this[e2c]=!0;let t=this[Dgn];if(t&&t.blockRemain){let r=this[oE]?this[oE].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${r} available)`,{entry:t}),this[oE]&&t.write(this[oE]),t.end()}this[Bgn](IAu)}}[MAu](t){if(this[E$a]&&t)this[r2c](t);else if(!t&&!this[oE])this[BAu]();else if(t){if(this[E$a]=!0,this[oE]){this[r2c](t);let r=this[oE];this[oE]=void 0,this[DAu](r)}else this[DAu](t);for(;this[oE]&&this[oE]?.length>=512&&!this[K$i]&&!this[qAu];){let r=this[oE];this[oE]=void 0,this[DAu](r)}this[E$a]=!1}(!this[oE]||this[H$i])&&this[BAu]()}[DAu](t){let r=0,i=t.length;for(;r+512<=i&&!this[K$i]&&!this[qAu];)switch(this[_Se]){case"begin":case"header":this[ACh](t,r),r+=512;break;case"ignore":case"body":r+=this[t2c](t,r);break;case"meta":r+=this[mCh](t,r);break;default:throw new Error("invalid state: "+this[_Se])}r<i&&(this[oE]?this[oE]=Buffer.concat([t.subarray(r),this[oE]]):this[oE]=t.subarray(r))}end(t,r,i){return typeof t=="function"&&(i=t,r=void 0,t=void 0),typeof r=="function"&&(i=r,r=void 0),typeof t=="string"&&(t=Buffer.from(t,r)),i&&this.once("finish",i),this[K$i]||(this[N1]?(t&&this[N1].write(t),this[N1].end()):(this[H$i]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[BAu]())),this}};var J$i=e=>{let t=e.length-1,r=-1;for(;t>-1&&e.charAt(t)==="/";)r=t,t--;return r===-1?e:e.slice(0,r)};var byB=e=>{let t=e.onReadEntry;e.onReadEntry=t?r=>{t(r),r.resume()}:r=>r.resume()},a2c=(e,t)=>{let r=new Map(t.map(a=>[J$i(a),!0])),i=e.filter,n=(a,o="")=>{let c=o||(0,TAu.parse)(a).root||".",d;if(a===c)d=!1;else{let s=r.get(a);s!==void 0?d=s:d=n((0,TAu.dirname)(a),c)}return r.set(a,d),d};e.filter=i?(a,o)=>i(a,o)&&n(J$i(a)):a=>n(J$i(a))},vyB=e=>{let t=new $Ui(e),r=e.file,i;try{i=Cgn.default.openSync(r,"r");let n=Cgn.default.fstatSync(i),a=e.maxReadSize||16*1024*1024;if(n.size<a){let o=Buffer.allocUnsafe(n.size),c=Cgn.default.readSync(i,o,0,n.size,0);t.end(c===o.byteLength?o:o.subarray(0,c))}else{let o=0,c=Buffer.allocUnsafe(a);for(;o<n.size;){let d=Cgn.default.readSync(i,c,0,a,o);if(d===0)break;o+=d,t.write(c.subarray(0,d))}t.end()}}finally{if(typeof i=="number")try{Cgn.default.closeSync(i)}catch{}}},gyB=(e,t)=>{let r=new $Ui(e),i=e.maxReadSize||16*1024*1024,n=e.file;return new Promise((o,c)=>{r.on("error",c),r.on("end",o),Cgn.default.stat(n,(d,s)=>{if(d)c(d);else{let u=new Pgn(n,{readSize:i,size:s.size});u.on("error",c),u.pipe(r)}})})},qgn=cXt(vyB,gyB,e=>new $Ui(e),e=>new $Ui(e),(e,t)=>{t?.length&&a2c(e,t),e.noResume||byB(e)});var q$a=ue(require("fs"),1);var L8t=ue(require("fs"),1);var l2c=ue(require("path"),1);var o2c=(e,t,r)=>(e&=4095,r&&(e=(e|384)&-19),t&&(e&256&&(e|=64),e&32&&(e|=8),e&4&&(e|=1)),e);var ECh=require("path"),{isAbsolute:OyB,parse:wCh}=ECh.win32,S$a=e=>{let t="",r=wCh(e);for(;OyB(e)||r.root;){let i=e.charAt(0)==="/"&&e.slice(0,4)!=="//?/"?"/":r.root;e=e.slice(i.length),t+=i,r=wCh(e)}return[t,e]};var RAu=["|","<",">","?",":"],u2c=RAu.map(e=>String.fromCharCode(61440+e.charCodeAt(0))),myB=new Map(RAu.map((e,t)=>[e,u2c[t]])),AyB=new Map(u2c.map((e,t)=>[e,RAu[t]])),s2c=e=>RAu.reduce((t,r)=>t.split(r).join(myB.get(r)),e),SCh=e=>u2c.reduce((t,r)=>t.split(r).join(AyB.get(r)),e);var qCh=(e,t)=>t?(e=k_(e).replace(/^\.(\/|$)/,""),J$i(t)+"/"+e):k_(e),PyB=16*1024*1024,DCh=Symbol("process"),BCh=Symbol("file"),ICh=Symbol("directory"),f2c=Symbol("symlink"),CCh=Symbol("hardlink"),M$a=Symbol("header"),zAu=Symbol("read"),d2c=Symbol("lstat"),NAu=Symbol("onlstat"),p2c=Symbol("onread"),_2c=Symbol("onreadlink"),h2c=Symbol("openfile"),y2c=Symbol("onopenfile"),$$i=Symbol("close"),FAu=Symbol("mode"),b2c=Symbol("awaitDrain"),c2c=Symbol("ondrain"),fXt=Symbol("prefix"),D$a=class extends uR{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(t,r={}){let i=P$a(r);super(),this.path=k_(t),this.portable=!!i.portable,this.maxReadSize=i.maxReadSize||PyB,this.linkCache=i.linkCache||new Map,this.statCache=i.statCache||new Map,this.preservePaths=!!i.preservePaths,this.cwd=k_(i.cwd||process.cwd()),this.strict=!!i.strict,this.noPax=!!i.noPax,this.noMtime=!!i.noMtime,this.mtime=i.mtime,this.prefix=i.prefix?k_(i.prefix):void 0,this.onWriteEntry=i.onWriteEntry,typeof i.onwarn=="function"&&this.on("warn",i.onwarn);let n=!1;if(!this.preservePaths){let[o,c]=S$a(this.path);o&&typeof c=="string"&&(this.path=c,n=o)}this.win32=!!i.win32||process.platform==="win32",this.win32&&(this.path=SCh(this.path.replace(/\\/g,"/")),t=t.replace(/\\/g,"/")),this.absolute=k_(i.absolute||l2c.default.resolve(this.cwd,t)),this.path===""&&(this.path="./"),n&&this.warn("TAR_ENTRY_INFO",`stripping ${n} from absolute path`,{entry:this,path:n+this.path});let a=this.statCache.get(this.absolute);a?this[NAu](a):this[d2c]()}warn(t,r,i={}){return Mgn(this,t,r,i)}emit(t,...r){return t==="error"&&(this.#e=!0),super.emit(t,...r)}[d2c](){L8t.default.lstat(this.absolute,(t,r)=>{if(t)return this.emit("error",t);this[NAu](r)})}[NAu](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=jyB(t),this.emit("stat",t),this[DCh]()}[DCh](){switch(this.type){case"File":return this[BCh]();case"Directory":return this[ICh]();case"SymbolicLink":return this[f2c]();default:return this.end()}}[FAu](t){return o2c(t,this.type==="Directory",this.portable)}[fXt](t){return qCh(t,this.prefix)}[M$a](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new vge({path:this[fXt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[fXt](this.linkpath):this.linkpath,mode:this[FAu](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new G$i({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[fXt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[fXt](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[ICh](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[M$a](),this.end()}[f2c](){L8t.default.readlink(this.absolute,(t,r)=>{if(t)return this.emit("error",t);this[_2c](r)})}[_2c](t){this.linkpath=k_(t),this[M$a](),this.end()}[CCh](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=k_(l2c.default.relative(this.cwd,t)),this.stat.size=0,this[M$a](),this.end()}[BCh](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,r=this.linkCache.get(t);if(r?.indexOf(this.cwd)===0)return this[CCh](r);this.linkCache.set(t,this.absolute)}if(this[M$a](),this.stat.size===0)return this.end();this[h2c]()}[h2c](){L8t.default.open(this.absolute,"r",(t,r)=>{if(t)return this.emit("error",t);this[y2c](r)})}[y2c](t){if(this.fd=t,this.#e)return this[$$i]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let r=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(r),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[zAu]()}[zAu](){let{fd:t,buf:r,offset:i,length:n,pos:a}=this;if(t===void 0||r===void 0)throw new Error("cannot read file without first opening");L8t.default.read(t,r,i,n,a,(o,c)=>{if(o)return this[$$i](()=>this.emit("error",o));this[p2c](c)})}[$$i](t=()=>{}){this.fd!==void 0&&L8t.default.close(this.fd,t)}[p2c](t){if(t<=0&&this.remain>0){let n=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[$$i](()=>this.emit("error",n))}if(t>this.remain){let n=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[$$i](()=>this.emit("error",n))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let n=t;n<this.length&&t<this.blockRemain;n++)this.buf[n+this.offset]=0,t++,this.remain++;let r=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(r)?this[c2c]():this[b2c](()=>this[c2c]())}[b2c](t){this.once("drain",t)}write(t,r,i){if(typeof r=="function"&&(i=r,r=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof r=="string"?r:"utf8")),this.blockRemain<t.length){let n=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",n)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,i)}[c2c](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[$$i](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[zAu]()}},QAu=class extends D$a{sync=!0;[d2c](){this[NAu](L8t.default.lstatSync(this.absolute))}[f2c](){this[_2c](L8t.default.readlinkSync(this.absolute))}[h2c](){this[y2c](L8t.default.openSync(this.absolute,"r"))}[zAu](){let t=!0;try{let{fd:r,buf:i,offset:n,length:a,pos:o}=this;if(r===void 0||i===void 0)throw new Error("fd and buf must be set in READ method");let c=L8t.default.readSync(r,i,n,a,o);this[p2c](c),t=!1}finally{if(t)try{this[$$i](()=>{})}catch{}}}[b2c](t){t()}[$$i](t=()=>{}){this.fd!==void 0&&L8t.default.closeSync(this.fd),t()}},UAu=class extends uR{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,r,i={}){return Mgn(this,t,r,i)}constructor(t,r={}){let i=P$a(r);super(),this.preservePaths=!!i.preservePaths,this.portable=!!i.portable,this.strict=!!i.strict,this.noPax=!!i.noPax,this.noMtime=!!i.noMtime,this.onWriteEntry=i.onWriteEntry,this.readEntry=t;let{type:n}=t;if(n==="Unsupported")throw new Error("writing entry that should be ignored");this.type=n,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=i.prefix,this.path=k_(t.path),this.mode=t.mode!==void 0?this[FAu](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:i.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?k_(t.linkpath):void 0,typeof i.onwarn=="function"&&this.on("warn",i.onwarn);let a=!1;if(!this.preservePaths){let[c,d]=S$a(this.path);c&&typeof d=="string"&&(this.path=d,a=c)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new vge({path:this[fXt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[fXt](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),a&&this.warn("TAR_ENTRY_INFO",`stripping ${a} from absolute path`,{entry:this,path:a+this.path}),this.header.encode()&&!this.noPax&&super.write(new G$i({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[fXt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[fXt](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let o=this.header?.block;if(!o)throw new Error("failed to encode header");super.write(o),t.pipe(this)}[fXt](t){return qCh(t,this.prefix)}[FAu](t){return o2c(t,this.type==="Directory",this.portable)}write(t,r,i){typeof r=="function"&&(i=r,r=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof r=="string"?r:"utf8"));let n=t.length;if(n>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=n,super.write(t,i)}end(t,r,i){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(i=t,r=void 0,t=void 0),typeof r=="function"&&(i=r,r=void 0),typeof t=="string"&&(t=Buffer.from(t,r??"utf8")),i&&this.once("finish",i),t?super.end(t,i):super.end(i),this}},jyB=e=>e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":"Unsupported";var LAu=class e{tail;head;length=0;static create(t=[]){return new e(t)}constructor(t=[]){for(let r of t)this.push(r)}*[Symbol.iterator](){for(let t=this.head;t;t=t.next)yield t.value}removeNode(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");let r=t.next,i=t.prev;return r&&(r.prev=i),i&&(i.next=r),t===this.head&&(this.head=r),t===this.tail&&(this.tail=i),this.length--,t.next=void 0,t.prev=void 0,t.list=void 0,r}unshiftNode(t){if(t===this.head)return;t.list&&t.list.removeNode(t);let r=this.head;t.list=this,t.next=r,r&&(r.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}pushNode(t){if(t===this.tail)return;t.list&&t.list.removeNode(t);let r=this.tail;t.list=this,t.prev=r,r&&(r.next=t),this.tail=t,this.head||(this.head=t),this.length++}push(...t){for(let r=0,i=t.length;r<i;r++)EyB(this,t[r]);return this.length}unshift(...t){for(var r=0,i=t.length;r<i;r++)SyB(this,t[r]);return this.length}pop(){if(!this.tail)return;let t=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,t}shift(){if(!this.head)return;let t=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,t}forEach(t,r){r=r||this;for(let i=this.head,n=0;i;n++)t.call(r,i.value,n,this),i=i.next}forEachReverse(t,r){r=r||this;for(let i=this.tail,n=this.length-1;i;n--)t.call(r,i.value,n,this),i=i.prev}get(t){let r=0,i=this.head;for(;i&&r<t;r++)i=i.next;if(r===t&&i)return i.value}getReverse(t){let r=0,i=this.tail;for(;i&&r<t;r++)i=i.prev;if(r===t&&i)return i.value}map(t,r){r=r||this;let i=new e;for(let n=this.head;n;)i.push(t.call(r,n.value,this)),n=n.next;return i}mapReverse(t,r){r=r||this;var i=new e;for(let n=this.tail;n;)i.push(t.call(r,n.value,this)),n=n.prev;return i}reduce(t,r){let i,n=this.head;if(arguments.length>1)i=r;else if(this.head)n=this.head.next,i=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var a=0;n;a++)i=t(i,n.value,a),n=n.next;return i}reduceReverse(t,r){let i,n=this.tail;if(arguments.length>1)i=r;else if(this.tail)n=this.tail.prev,i=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let a=this.length-1;n;a--)i=t(i,n.value,a),n=n.prev;return i}toArray(){let t=new Array(this.length);for(let r=0,i=this.head;i;r++)t[r]=i.value,i=i.next;return t}toArrayReverse(){let t=new Array(this.length);for(let r=0,i=this.tail;i;r++)t[r]=i.value,i=i.prev;return t}slice(t=0,r=this.length){r<0&&(r+=this.length),t<0&&(t+=this.length);let i=new e;if(r<t||r<0)return i;t<0&&(t=0),r>this.length&&(r=this.length);let n=this.head,a=0;for(a=0;n&&a<t;a++)n=n.next;for(;n&&a<r;a++,n=n.next)i.push(n.value);return i}sliceReverse(t=0,r=this.length){r<0&&(r+=this.length),t<0&&(t+=this.length);let i=new e;if(r<t||r<0)return i;t<0&&(t=0),r>this.length&&(r=this.length);let n=this.length,a=this.tail;for(;a&&n>r;n--)a=a.prev;for(;a&&n>t;n--,a=a.prev)i.push(a.value);return i}splice(t,r=0,...i){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);let n=this.head;for(let o=0;n&&o<t;o++)n=n.next;let a=[];for(let o=0;n&&o<r;o++)a.push(n.value),n=this.removeNode(n);n?n!==this.tail&&(n=n.prev):n=this.tail;for(let o of i)n=wyB(this,n,o);return a}reverse(){let t=this.head,r=this.tail;for(let i=t;i;i=i.prev){let n=i.prev;i.prev=i.next,i.next=n}return this.head=r,this.tail=t,this}};function wyB(e,t,r){let i=t,n=t?t.next:e.head,a=new B$a(r,i,n,e);return a.next===void 0&&(e.tail=a),a.prev===void 0&&(e.head=a),e.length++,a}function EyB(e,t){e.tail=new B$a(t,e.tail,void 0,e),e.head||(e.head=e.tail),e.length++}function SyB(e,t){e.head=new B$a(t,void 0,e.head,e),e.tail||(e.tail=e.head),e.length++}var B$a=class{list;next;prev;value;constructor(t,r,i,n){this.list=n,this.value=t,r?(r.next=this,this.prev=r):this.prev=void 0,i?(i.prev=this,this.next=i):this.next=void 0}};var P2c=ue(require("path"),1);var KAu=class{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(t,r){this.path=t||"./",this.absolute=r}},TCh=Buffer.alloc(1024),VAu=Symbol("onStat"),I$a=Symbol("ended"),V8t=Symbol("queue"),nca=Symbol("current"),Tgn=Symbol("process"),C$a=Symbol("processing"),RCh=Symbol("processJob"),W8t=Symbol("jobs"),v2c=Symbol("jobDone"),WAu=Symbol("addFSEntry"),zCh=Symbol("addTarEntry"),m2c=Symbol("stat"),A2c=Symbol("readdir"),GAu=Symbol("onreaddir"),xAu=Symbol("pipe"),NCh=Symbol("entry"),g2c=Symbol("entryOpt"),HAu=Symbol("writeEntryClass"),FCh=Symbol("write"),O2c=Symbol("ondrain"),Y$i=class extends uR{opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[HAu];onWriteEntry;[V8t];[W8t]=0;[C$a]=!1;[I$a]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=k_(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[HAu]=D$a,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new vAu(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new mAu(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new jAu(t.zstd)),!this.zip)throw new Error("impossible");let r=this.zip;r.on("data",i=>super.write(i)),r.on("end",()=>super.end()),r.on("drain",()=>this[O2c]()),this.on("resume",()=>r.resume())}else this.on("drain",this[O2c]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[V8t]=new LAu,this[W8t]=0,this.jobs=Number(t.jobs)||4,this[C$a]=!1,this[I$a]=!1}[FCh](t){return super.write(t)}add(t){return this.write(t),this}end(t,r,i){return typeof t=="function"&&(i=t,t=void 0),typeof r=="function"&&(i=r,r=void 0),t&&this.add(t),this[I$a]=!0,this[Tgn](),i&&i(),this}write(t){if(this[I$a])throw new Error("write after end");return t instanceof rca?this[zCh](t):this[WAu](t),this.flowing}[zCh](t){let r=k_(P2c.default.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let i=new KAu(t.path,r);i.entry=new UAu(t,this[g2c](i)),i.entry.on("end",()=>this[v2c](i)),this[W8t]+=1,this[V8t].push(i)}this[Tgn]()}[WAu](t){let r=k_(P2c.default.resolve(this.cwd,t));this[V8t].push(new KAu(t,r)),this[Tgn]()}[m2c](t){t.pending=!0,this[W8t]+=1;let r=this.follow?"stat":"lstat";q$a.default[r](t.absolute,(i,n)=>{t.pending=!1,this[W8t]-=1,i?this.emit("error",i):this[VAu](t,n)})}[VAu](t,r){this.statCache.set(t.absolute,r),t.stat=r,this.filter(t.path,r)||(t.ignore=!0),this[Tgn]()}[A2c](t){t.pending=!0,this[W8t]+=1,q$a.default.readdir(t.absolute,(r,i)=>{if(t.pending=!1,this[W8t]-=1,r)return this.emit("error",r);this[GAu](t,i)})}[GAu](t,r){this.readdirCache.set(t.absolute,r),t.readdir=r,this[Tgn]()}[Tgn](){if(!this[C$a]){this[C$a]=!0;for(let t=this[V8t].head;t&&this[W8t]<this.jobs;t=t.next)if(this[RCh](t.value),t.value.ignore){let r=t.next;this[V8t].removeNode(t),t.next=r}this[C$a]=!1,this[I$a]&&!this[V8t].length&&this[W8t]===0&&(this.zip?this.zip.end(TCh):(super.write(TCh),super.end()))}}get[nca](){return this[V8t]&&this[V8t].head&&this[V8t].head.value}[v2c](t){this[V8t].shift(),this[W8t]-=1,this[Tgn]()}[RCh](t){if(!t.pending){if(t.entry){t===this[nca]&&!t.piped&&this[xAu](t);return}if(!t.stat){let r=this.statCache.get(t.absolute);r?this[VAu](t,r):this[m2c](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let r=this.readdirCache.get(t.absolute);if(r?this[GAu](t,r):this[A2c](t),!t.readdir)return}if(t.entry=this[NCh](t),!t.entry){t.ignore=!0;return}t===this[nca]&&!t.piped&&this[xAu](t)}}}[g2c](t){return{onwarn:(r,i,n)=>this.warn(r,i,n),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[NCh](t){this[W8t]+=1;try{return new this[HAu](t.path,this[g2c](t)).on("end",()=>this[v2c](t)).on("error",i=>this.emit("error",i))}catch(r){this.emit("error",r)}}[O2c](){this[nca]&&this[nca].entry&&this[nca].entry.resume()}[xAu](t){t.piped=!0,t.readdir&&t.readdir.forEach(n=>{let a=t.path,o=a==="./"?"":a.replace(/\/*$/,"/");this[WAu](o+n)});let r=t.entry,i=this.zip;if(!r)throw new Error("cannot pipe without source");i?r.on("data",n=>{i.write(n)||r.pause()}):r.on("data",n=>{super.write(n)||r.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,r,i={}){Mgn(this,t,r,i)}},Rgn=class extends Y$i{sync=!0;constructor(t){super(t),this[HAu]=QAu}pause(){}resume(){}[m2c](t){let r=this.follow?"statSync":"lstatSync";this[VAu](t,q$a.default[r](t.absolute))}[A2c](t){this[GAu](t,q$a.default.readdirSync(t.absolute))}[xAu](t){let r=t.entry,i=this.zip;if(t.readdir&&t.readdir.forEach(n=>{let a=t.path,o=a==="./"?"":a.replace(/\/*$/,"/");this[WAu](o+n)}),!r)throw new Error("Cannot pipe without source");i?r.on("data",n=>{i.write(n)}):r.on("data",n=>{super[FCh](n)})}};var MyB=(e,t)=>{let r=new Rgn(e),i=new eca(e.file,{mode:e.mode||438});r.pipe(i),QCh(r,t)},DyB=(e,t)=>{let r=new Y$i(e),i=new HUi(e.file,{mode:e.mode||438});r.pipe(i);let n=new Promise((a,o)=>{i.on("error",o),i.on("close",a),r.on("error",o)});return UCh(r,t),n},QCh=(e,t)=>{t.forEach(r=>{r.charAt(0)==="@"?qgn({file:j2c.default.resolve(e.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>e.add(i)}):e.add(r)}),e.end()},UCh=async(e,t)=>{for(let r=0;r<t.length;r++){let i=String(t[r]);i.charAt(0)==="@"?await qgn({file:j2c.default.resolve(String(e.cwd),i.slice(1)),noResume:!0,onReadEntry:n=>{e.add(n)}}):e.add(i)}e.end()},ByB=(e,t)=>{let r=new Rgn(e);return QCh(r,t),r},IyB=(e,t)=>{let r=new Y$i(e);return UCh(r,t),r},w2c=cXt(MyB,DyB,ByB,IyB,(e,t)=>{if(!t?.length)throw new TypeError("no paths specified to add to archive")});var W2c=ue(require("fs"),1);var rqh=ue(require("assert"),1),V2c=require("crypto"),Lm=ue(require("fs"),1),dXt=ue(require("path"),1);var E2c=ue(require("fs"),1),CyB=process.env.__FAKE_PLATFORM__||process.platform,qyB=CyB==="win32",{O_CREAT:TyB,O_TRUNC:RyB,O_WRONLY:zyB}=E2c.default.constants,LCh=Number(process.env.__FAKE_FS_O_FILENAME__)||E2c.default.constants.UV_FS_O_FILEMAP||0,NyB=qyB&&!!LCh,FyB=512*1024,QyB=LCh|RyB|TyB|zyB,S2c=NyB?e=>e<FyB?QyB:"w":()=>"w";var T$a=ue(require("fs"),1),aca=ue(require("path"),1),M2c=(e,t,r)=>{try{return T$a.default.lchownSync(e,t,r)}catch(i){if(i?.code!=="ENOENT")throw i}},JAu=(e,t,r,i)=>{T$a.default.lchown(e,t,r,n=>{i(n&&n?.code!=="ENOENT"?n:null)})},UyB=(e,t,r,i,n)=>{if(t.isDirectory())D2c(aca.default.resolve(e,t.name),r,i,a=>{if(a)return n(a);let o=aca.default.resolve(e,t.name);JAu(o,r,i,n)});else{let a=aca.default.resolve(e,t.name);JAu(a,r,i,n)}},D2c=(e,t,r,i)=>{T$a.default.readdir(e,{withFileTypes:!0},(n,a)=>{if(n){if(n.code==="ENOENT")return i();if(n.code!=="ENOTDIR"&&n.code!=="ENOTSUP")return i(n)}if(n||!a.length)return JAu(e,t,r,i);let o=a.length,c=null,d=s=>{if(!c){if(s)return i(c=s);if(--o===0)return JAu(e,t,r,i)}};for(let s of a)UyB(e,s,t,r,d)})},LyB=(e,t,r,i)=>{t.isDirectory()&&B2c(aca.default.resolve(e,t.name),r,i),M2c(aca.default.resolve(e,t.name),r,i)},B2c=(e,t,r)=>{let i;try{i=T$a.default.readdirSync(e,{withFileTypes:!0})}catch(n){let a=n;if(a?.code==="ENOENT")return;if(a?.code==="ENOTDIR"||a?.code==="ENOTSUP")return M2c(e,t,r);throw a}for(let n of i)LyB(e,n,t,r);return M2c(e,t,r)};var EY=ue(require("fs"),1),VCh=ue(require("fs/promises"),1),N$a=ue(require("path"),1);var R$a=class extends Error{path;code;syscall="chdir";constructor(t,r){super(`${r}: Cannot cd into '${t}'`),this.path=t,this.code=r}get name(){return"CwdError"}};var z$a=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,r){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=r}get name(){return"SymlinkError"}};var VyB=(e,t)=>{EY.default.stat(e,(r,i)=>{(r||!i.isDirectory())&&(r=new R$a(e,r?.code||"ENOTDIR")),t(r)})},WCh=(e,t,r)=>{e=k_(e);let i=t.umask??18,n=t.mode|448,a=(n&i)!==0,o=t.uid,c=t.gid,d=typeof o=="number"&&typeof c=="number"&&(o!==t.processUid||c!==t.processGid),s=t.preserve,u=t.unlink,l=k_(t.cwd),p=(y,b)=>{y?r(y):b&&d?D2c(b,o,c,v=>p(v)):a?EY.default.chmod(e,n,r):r()};if(e===l)return VyB(e,p);if(s)return VCh.default.mkdir(e,{mode:n,recursive:!0}).then(y=>p(null,y??void 0),p);let h=k_(N$a.default.relative(l,e)).split("/");I2c(l,h,n,u,l,void 0,p)},I2c=(e,t,r,i,n,a,o)=>{if(!t.length)return o(null,a);let c=t.shift(),d=k_(N$a.default.resolve(e+"/"+c));EY.default.mkdir(d,r,GCh(d,t,r,i,n,a,o))},GCh=(e,t,r,i,n,a,o)=>c=>{c?EY.default.lstat(e,(d,s)=>{if(d)d.path=d.path&&k_(d.path),o(d);else if(s.isDirectory())I2c(e,t,r,i,n,a,o);else if(i)EY.default.unlink(e,u=>{if(u)return o(u);EY.default.mkdir(e,r,GCh(e,t,r,i,n,a,o))});else{if(s.isSymbolicLink())return o(new z$a(e,e+"/"+t.join("/")));o(c)}}):(a=a||e,I2c(e,t,r,i,n,a,o))},WyB=e=>{let t=!1,r;try{t=EY.default.statSync(e).isDirectory()}catch(i){r=i?.code}finally{if(!t)throw new R$a(e,r??"ENOTDIR")}},xCh=(e,t)=>{e=k_(e);let r=t.umask??18,i=t.mode|448,n=(i&r)!==0,a=t.uid,o=t.gid,c=typeof a=="number"&&typeof o=="number"&&(a!==t.processUid||o!==t.processGid),d=t.preserve,s=t.unlink,u=k_(t.cwd),l=y=>{y&&c&&B2c(y,a,o),n&&EY.default.chmodSync(e,i)};if(e===u)return WyB(u),l();if(d)return l(EY.default.mkdirSync(e,{mode:i,recursive:!0})??void 0);let _=k_(N$a.default.relative(u,e)).split("/"),h;for(let y=_.shift(),b=u;y&&(b+="/"+y);y=_.shift()){b=k_(N$a.default.resolve(b));try{EY.default.mkdirSync(b,i),h=h||b}catch{let O=EY.default.lstatSync(b);if(O.isDirectory())continue;if(s){EY.default.unlinkSync(b),EY.default.mkdirSync(b,i),h=h||b;continue}else if(O.isSymbolicLink())return new z$a(b,b+"/"+_.join("/"))}}return l(h)};var q2c=require("path");var C2c=Object.create(null),HCh=1e4,oca=new Set,KCh=e=>{oca.has(e)?oca.delete(e):C2c[e]=e.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),oca.add(e);let t=C2c[e],r=oca.size-HCh;if(r>HCh/10){for(let i of oca)if(oca.delete(i),delete C2c[i],--r<=0)break}return t};var GyB=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,xyB=GyB==="win32",HyB=e=>e.split("/").slice(0,-1).reduce((r,i)=>{let n=r[r.length-1];return n!==void 0&&(i=(0,q2c.join)(n,i)),r.push(i||"/"),r},[]),$Au=class{#e=new Map;#t=new Map;#r=new Set;reserve(t,r){t=xyB?["win32 parallelization disabled"]:t.map(n=>J$i((0,q2c.join)(KCh(n))));let i=new Set(t.map(n=>HyB(n)).reduce((n,a)=>n.concat(a)));this.#t.set(r,{dirs:i,paths:t});for(let n of t){let a=this.#e.get(n);a?a.push(r):this.#e.set(n,[r])}for(let n of i){let a=this.#e.get(n);if(!a)this.#e.set(n,[new Set([r])]);else{let o=a[a.length-1];o instanceof Set?o.add(r):a.push(new Set([r]))}}return this.#n(r)}#i(t){let r=this.#t.get(t);if(!r)throw new Error("function does not have any path reservations");return{paths:r.paths.map(i=>this.#e.get(i)),dirs:[...r.dirs].map(i=>this.#e.get(i))}}check(t){let{paths:r,dirs:i}=this.#i(t);return r.every(n=>n&&n[0]===t)&&i.every(n=>n&&n[0]instanceof Set&&n[0].has(t))}#n(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#a(t)),!0)}#a(t){if(!this.#r.has(t))return!1;let r=this.#t.get(t);if(!r)throw new Error("invalid reservation");let{paths:i,dirs:n}=r,a=new Set;for(let o of i){let c=this.#e.get(o);if(!c||c?.[0]!==t)continue;let d=c[1];if(!d){this.#e.delete(o);continue}if(c.shift(),typeof d=="function")a.add(d);else for(let s of d)a.add(s)}for(let o of n){let c=this.#e.get(o),d=c?.[0];if(!(!c||!(d instanceof Set)))if(d.size===1&&c.length===1){this.#e.delete(o);continue}else if(d.size===1){c.shift();let s=c[0];typeof s=="function"&&a.add(s)}else d.delete(t)}return this.#r.delete(t),a.forEach(o=>this.#n(o)),!0}};var JCh=Symbol("onEntry"),N2c=Symbol("checkFs"),$Ch=Symbol("checkFs2"),F2c=Symbol("isReusable"),hSe=Symbol("makeFs"),Q2c=Symbol("file"),U2c=Symbol("directory"),ZAu=Symbol("link"),YCh=Symbol("symlink"),XCh=Symbol("hardlink"),ZCh=Symbol("unsupported"),kCh=Symbol("checkPath"),T2c=Symbol("stripAbsolutePath"),X$i=Symbol("mkdir"),LW=Symbol("onError"),YAu=Symbol("pending"),eqh=Symbol("pend"),uca=Symbol("unpend"),R2c=Symbol("ended"),z2c=Symbol("maybeClose"),L2c=Symbol("skip"),F$a=Symbol("doChown"),Q$a=Symbol("uid"),U$a=Symbol("gid"),L$a=Symbol("checkedCwd"),KyB=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,V$a=KyB==="win32",JyB=1024,$yB=(e,t)=>{if(!V$a)return Lm.default.unlink(e,t);let r=e+".DELETE."+(0,V2c.randomBytes)(16).toString("hex");Lm.default.rename(e,r,i=>{if(i)return t(i);Lm.default.unlink(r,t)})},YyB=e=>{if(!V$a)return Lm.default.unlinkSync(e);let t=e+".DELETE."+(0,V2c.randomBytes)(16).toString("hex");Lm.default.renameSync(e,t),Lm.default.unlinkSync(t)},tqh=(e,t,r)=>e!==void 0&&e===e>>>0?e:t!==void 0&&t===t>>>0?t:r,sca=class extends $Ui{[R2c]=!1;[L$a]=!1;[YAu]=0;reservations=new $Au;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[R2c]=!0,this[z2c]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;t.preserveOwner===void 0&&typeof t.uid!="number"?this.preserveOwner=!!(process.getuid&&process.getuid()===0):this.preserveOwner=!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:JyB,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||V$a,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=k_(dXt.default.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:process.umask():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",r=>this[JCh](r))}warn(t,r,i={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(i.recoverable=!1),super.warn(t,r,i)}[z2c](){this[R2c]&&this[YAu]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[T2c](t,r){let i=t[r];if(!i||this.preservePaths)return!0;let n=i.split("/");if(n.includes("..")||V$a&&/^[a-z]:\.\.$/i.test(n[0]??""))return this.warn("TAR_ENTRY_ERROR",`${r} contains '..'`,{entry:t,[r]:i}),!1;let[a,o]=S$a(i);return a&&(t[r]=String(o),this.warn("TAR_ENTRY_INFO",`stripping ${a} from absolute ${r}`,{entry:t,[r]:i})),!0}[kCh](t){let r=k_(t.path),i=r.split("/");if(this.strip){if(i.length<this.strip)return!1;if(t.type==="Link"){let n=k_(String(t.linkpath)).split("/");if(n.length>=this.strip)t.linkpath=n.slice(this.strip).join("/");else return!1}i.splice(0,this.strip),t.path=i.join("/")}if(isFinite(this.maxDepth)&&i.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:r,depth:i.length,maxDepth:this.maxDepth}),!1;if(!this[T2c](t,"path")||!this[T2c](t,"linkpath"))return!1;if(dXt.default.isAbsolute(t.path)?t.absolute=k_(dXt.default.resolve(t.path)):t.absolute=k_(dXt.default.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:k_(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:n}=dXt.default.win32.parse(String(t.absolute));t.absolute=n+s2c(String(t.absolute).slice(n.length));let{root:a}=dXt.default.win32.parse(t.path);t.path=a+s2c(t.path.slice(a.length))}return!0}[JCh](t){if(!this[kCh](t))return t.resume();switch(rqh.default.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[N2c](t);case"CharacterDevice":case"BlockDevice":case"FIFO":default:return this[ZCh](t)}}[LW](t,r){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:r}),this[uca](),r.resume())}[X$i](t,r,i){WCh(k_(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:r},i)}[F$a](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[Q$a](t){return tqh(this.uid,t.uid,this.processUid)}[U$a](t){return tqh(this.gid,t.gid,this.processGid)}[Q2c](t,r){let i=typeof t.mode=="number"?t.mode&4095:this.fmode,n=new HUi(String(t.absolute),{flags:S2c(t.size),mode:i,autoClose:!1});n.on("error",d=>{n.fd&&Lm.default.close(n.fd,()=>{}),n.write=()=>!0,this[LW](d,t),r()});let a=1,o=d=>{if(d){n.fd&&Lm.default.close(n.fd,()=>{}),this[LW](d,t),r();return}--a===0&&n.fd!==void 0&&Lm.default.close(n.fd,s=>{s?this[LW](s,t):this[uca](),r()})};n.on("finish",()=>{let d=String(t.absolute),s=n.fd;if(typeof s=="number"&&t.mtime&&!this.noMtime){a++;let u=t.atime||new Date,l=t.mtime;Lm.default.futimes(s,u,l,p=>p?Lm.default.utimes(d,u,l,_=>o(_&&p)):o())}if(typeof s=="number"&&this[F$a](t)){a++;let u=this[Q$a](t),l=this[U$a](t);typeof u=="number"&&typeof l=="number"&&Lm.default.fchown(s,u,l,p=>p?Lm.default.chown(d,u,l,_=>o(_&&p)):o())}o()});let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",d=>{this[LW](d,t),r()}),t.pipe(c)),c.pipe(n)}[U2c](t,r){let i=typeof t.mode=="number"?t.mode&4095:this.dmode;this[X$i](String(t.absolute),i,n=>{if(n){this[LW](n,t),r();return}let a=1,o=()=>{--a===0&&(r(),this[uca](),t.resume())};t.mtime&&!this.noMtime&&(a++,Lm.default.utimes(String(t.absolute),t.atime||new Date,t.mtime,o)),this[F$a](t)&&(a++,Lm.default.chown(String(t.absolute),Number(this[Q$a](t)),Number(this[U$a](t)),o)),o()})}[ZCh](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[YCh](t,r){this[ZAu](t,String(t.linkpath),"symlink",r)}[XCh](t,r){let i=k_(dXt.default.resolve(this.cwd,String(t.linkpath)));this[ZAu](t,i,"link",r)}[eqh](){this[YAu]++}[uca](){this[YAu]--,this[z2c]()}[L2c](t){this[uca](),t.resume()}[F2c](t,r){return t.type==="File"&&!this.unlink&&r.isFile()&&r.nlink<=1&&!V$a}[N2c](t){this[eqh]();let r=[t.path];t.linkpath&&r.push(t.linkpath),this.reservations.reserve(r,i=>this[$Ch](t,i))}[$Ch](t,r){let i=c=>{r(c)},n=()=>{this[X$i](this.cwd,this.dmode,c=>{if(c){this[LW](c,t),i();return}this[L$a]=!0,a()})},a=()=>{if(t.absolute!==this.cwd){let c=k_(dXt.default.dirname(String(t.absolute)));if(c!==this.cwd)return this[X$i](c,this.dmode,d=>{if(d){this[LW](d,t),i();return}o()})}o()},o=()=>{Lm.default.lstat(String(t.absolute),(c,d)=>{if(d&&(this.keep||this.newer&&d.mtime>(t.mtime??d.mtime))){this[L2c](t),i();return}if(c||this[F2c](t,d))return this[hSe](null,t,i);if(d.isDirectory()){if(t.type==="Directory"){let s=this.chmod&&t.mode&&(d.mode&4095)!==t.mode,u=l=>this[hSe](l??null,t,i);return s?Lm.default.chmod(String(t.absolute),Number(t.mode),u):u()}if(t.absolute!==this.cwd)return Lm.default.rmdir(String(t.absolute),s=>this[hSe](s??null,t,i))}if(t.absolute===this.cwd)return this[hSe](null,t,i);$yB(String(t.absolute),s=>this[hSe](s??null,t,i))})};this[L$a]?a():n()}[hSe](t,r,i){if(t){this[LW](t,r),i();return}switch(r.type){case"File":case"OldFile":case"ContiguousFile":return this[Q2c](r,i);case"Link":return this[XCh](r,i);case"SymbolicLink":return this[YCh](r,i);case"Directory":case"GNUDumpDir":return this[U2c](r,i)}}[ZAu](t,r,i,n){Lm.default[i](r,String(t.absolute),a=>{a?this[LW](a,t):(this[uca](),t.resume()),n()})}},XAu=e=>{try{return[null,e()]}catch(t){return[t,null]}},W$a=class extends sca{sync=!0;[hSe](t,r){return super[hSe](t,r,()=>{})}[N2c](t){if(!this[L$a]){let a=this[X$i](this.cwd,this.dmode);if(a)return this[LW](a,t);this[L$a]=!0}if(t.absolute!==this.cwd){let a=k_(dXt.default.dirname(String(t.absolute)));if(a!==this.cwd){let o=this[X$i](a,this.dmode);if(o)return this[LW](o,t)}}let[r,i]=XAu(()=>Lm.default.lstatSync(String(t.absolute)));if(i&&(this.keep||this.newer&&i.mtime>(t.mtime??i.mtime)))return this[L2c](t);if(r||this[F2c](t,i))return this[hSe](null,t);if(i.isDirectory()){if(t.type==="Directory"){let o=this.chmod&&t.mode&&(i.mode&4095)!==t.mode,[c]=o?XAu(()=>{Lm.default.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[hSe](c,t)}let[a]=XAu(()=>Lm.default.rmdirSync(String(t.absolute)));this[hSe](a,t)}let[n]=t.absolute===this.cwd?[]:XAu(()=>YyB(String(t.absolute)));this[hSe](n,t)}[Q2c](t,r){let i=typeof t.mode=="number"?t.mode&4095:this.fmode,n=c=>{let d;try{Lm.default.closeSync(a)}catch(s){d=s}(c||d)&&this[LW](c||d,t),r()},a;try{a=Lm.default.openSync(String(t.absolute),S2c(t.size),i)}catch(c){return n(c)}let o=this.transform&&this.transform(t)||t;o!==t&&(o.on("error",c=>this[LW](c,t)),t.pipe(o)),o.on("data",c=>{try{Lm.default.writeSync(a,c,0,c.length)}catch(d){n(d)}}),o.on("end",()=>{let c=null;if(t.mtime&&!this.noMtime){let d=t.atime||new Date,s=t.mtime;try{Lm.default.futimesSync(a,d,s)}catch(u){try{Lm.default.utimesSync(String(t.absolute),d,s)}catch{c=u}}}if(this[F$a](t)){let d=this[Q$a](t),s=this[U$a](t);try{Lm.default.fchownSync(a,Number(d),Number(s))}catch(u){try{Lm.default.chownSync(String(t.absolute),Number(d),Number(s))}catch{c=c||u}}}n(c)})}[U2c](t,r){let i=typeof t.mode=="number"?t.mode&4095:this.dmode,n=this[X$i](String(t.absolute),i);if(n){this[LW](n,t),r();return}if(t.mtime&&!this.noMtime)try{Lm.default.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[F$a](t))try{Lm.default.chownSync(String(t.absolute),Number(this[Q$a](t)),Number(this[U$a](t)))}catch{}r(),t.resume()}[X$i](t,r){try{return xCh(k_(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:r})}catch(i){return i}}[ZAu](t,r,i,n){let a=`${i}Sync`;try{Lm.default[a](r,String(t.absolute)),n(),t.resume()}catch(o){return this[LW](o,t)}}};var XyB=e=>{let t=new W$a(e),r=e.file,i=W2c.default.statSync(r),n=e.maxReadSize||16*1024*1024;new hAu(r,{readSize:n,size:i.size}).pipe(t)},ZyB=(e,t)=>{let r=new sca(e),i=e.maxReadSize||16*1024*1024,n=e.file;return new Promise((o,c)=>{r.on("error",c),r.on("close",o),W2c.default.stat(n,(d,s)=>{if(d)c(d);else{let u=new Pgn(n,{readSize:i,size:s.size});u.on("error",c),u.pipe(r)}})})},G2c=cXt(XyB,ZyB,e=>new W$a(e),e=>new sca(e),(e,t)=>{t?.length&&a2c(e,t)});var SY=ue(require("fs"),1),x2c=ue(require("path"),1);var kyB=(e,t)=>{let r=new Rgn(e),i=!0,n,a;try{try{n=SY.default.openSync(e.file,"r+")}catch(d){if(d?.code==="ENOENT")n=SY.default.openSync(e.file,"w+");else throw d}let o=SY.default.fstatSync(n),c=Buffer.alloc(512);e:for(a=0;a<o.size;a+=512){for(let u=0,l=0;u<512;u+=l){if(l=SY.default.readSync(n,c,u,c.length-u,a+u),a===0&&c[0]===31&&c[1]===139)throw new Error("cannot append to compressed archives");if(!l)break e}let d=new vge(c);if(!d.cksumValid)break;let s=512*Math.ceil((d.size||0)/512);if(a+s+512>o.size)break;a+=s,e.mtimeCache&&d.mtime&&e.mtimeCache.set(String(d.path),d.mtime)}i=!1,ebB(e,r,a,n,t)}finally{if(i)try{SY.default.closeSync(n)}catch{}}},ebB=(e,t,r,i,n)=>{let a=new eca(e.file,{fd:i,start:r});t.pipe(a),rbB(t,n)},tbB=(e,t)=>{t=Array.from(t);let r=new Y$i(e),i=(a,o,c)=>{let d=(_,h)=>{_?SY.default.close(a,y=>c(_)):c(null,h)},s=0;if(o===0)return d(null,0);let u=0,l=Buffer.alloc(512),p=(_,h)=>{if(_||typeof h>"u")return d(_);if(u+=h,u<512&&h)return SY.default.read(a,l,u,l.length-u,s+u,p);if(s===0&&l[0]===31&&l[1]===139)return d(new Error("cannot append to compressed archives"));if(u<512)return d(null,s);let y=new vge(l);if(!y.cksumValid)return d(null,s);let b=512*Math.ceil((y.size??0)/512);if(s+b+512>o||(s+=b+512,s>=o))return d(null,s);e.mtimeCache&&y.mtime&&e.mtimeCache.set(String(y.path),y.mtime),u=0,SY.default.read(a,l,0,512,s,p)};SY.default.read(a,l,0,512,s,p)};return new Promise((a,o)=>{r.on("error",o);let c="r+",d=(s,u)=>{if(s&&s.code==="ENOENT"&&c==="r+")return c="w+",SY.default.open(e.file,c,d);if(s||!u)return o(s);SY.default.fstat(u,(l,p)=>{if(l)return SY.default.close(u,()=>o(l));i(u,p.size,(_,h)=>{if(_)return o(_);let y=new HUi(e.file,{fd:u,start:h});r.pipe(y),y.on("error",o),y.on("close",a),ibB(r,t)})})};SY.default.open(e.file,c,d)})},rbB=(e,t)=>{t.forEach(r=>{r.charAt(0)==="@"?qgn({file:x2c.default.resolve(e.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>e.add(i)}):e.add(r)}),e.end()},ibB=async(e,t)=>{for(let r=0;r<t.length;r++){let i=String(t[r]);i.charAt(0)==="@"?await qgn({file:x2c.default.resolve(String(e.cwd),i.slice(1)),noResume:!0,onReadEntry:n=>e.add(n)}):e.add(i)}e.end()},zgn=cXt(kyB,tbB,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(e,t)=>{if(!sCh(e))throw new TypeError("file is required");if(e.gzip||e.brotli||e.zstd||e.file.endsWith(".br")||e.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!t?.length)throw new TypeError("no paths specified to add/replace")});var nbB=cXt(zgn.syncFile,zgn.asyncFile,zgn.syncNoFile,zgn.asyncNoFile,(e,t=[])=>{zgn.validate?.(e,t),abB(e)}),abB=e=>{let t=e.filter;e.mtimeCache||(e.mtimeCache=new Map),e.filter=t?(r,i)=>t(r,i)&&!((e.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0)):(r,i)=>!((e.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0))};var sqh=ue(w4(),1);var obB=nQi();async function cqh({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:i,cliVersion:n,settings:a,loadAPIWorkspace:o}){let c,d={type:Gp.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},s=t.dependencies[e];return s==null?d={type:Gp.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${pbB(s)}`},async u=>{switch(s.type){case"version":c=await fbB({context:u,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:o});return;case"local":c=await lbB({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 lqh="dependencies";var ubB="metadata.json",sbB=".fern";function cbB(e){return qt(jr.of((0,aqh.homedir)()),xe.of(sbB),xe.of(lqh),xe.of(e.organization),xe.of(e.apiName),xe.of(e.version))}async function lbB({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:xe.of(e.path)},i);return t.logger.info("Loaded..."),o}async function fbB({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){let a=cbB(e),o=qt(a,xe.of(lqh)),c=qt(a,xe.of(ubB)),d;if(!await gi(o)||!await gi(c)){t.logger.info("Downloading manifest...");let l=await obB.definitionRegistry.get(H2c.FernFiddle.OrganizationId(e.organization),H2c.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,_=hvn(r),h=hvn(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,cca.mkdir)(o,{recursive:!0});try{await dbB({s3PreSignedReadUrl:l.body.definitionS3DownloadUrl,absolutePathToLocalOutput:o})}catch(y){t.failWithoutThrowing("Failed to download API",y);return}d=l.body,await(0,cca.writeFile)(c,JSON.stringify(d))}else d=JSON.parse((await(0,cca.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 dbB({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await iI.get(e,{responseType:"stream"}),i=await sqh.default.dir(),n=oqh.default.join(i.path,"api.tgz");await(0,uqh.pipeline)(r.data,(0,nqh.createWriteStream)(n)),await G2c({file:n,cwd:t})}function pbB(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:vt(e)}}async function fqh({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:i,settings:n,loadAPIWorkspace:a}){let o={},c={},d={};return await Promise.all(VI(t.packageMarkers).map(async([s,u])=>{if(u.contents.export==null)o[s]=u;else{let{export:l,...p}=u.contents;if(UA(p)>0)d[s]={type:Gp.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:s};else{let _=Yi(s);if(nVt(t.namedDefinitionFiles).some(y=>y!==s&&y.startsWith(_)))d[s]={type:Gp.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:_};else{let y=await cqh({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[Yi(s)]={definition:y.definition,url:typeof u.contents.export=="object"?u.contents.export.url:void 0}:d[s]=y.failure}}}})),UA(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:o,importedDefinitions:c}}var dqh=ue(require("path"),1);var K2c={};Yt(K2c,{additionalProperties:()=>bbB,default:()=>gbB,definitions:()=>vbB,properties:()=>hbB,required:()=>ybB,type:()=>_bB});var _bB="object",hbB={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"}]}},ybB=["name"],bbB=!1,vbB={"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"}]},omit:{oneOf:[{type:"boolean"},{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}},gbB={type:_bB,properties:hbB,required:ybB,additionalProperties:bbB,definitions:vbB};var J2c={};Yt(J2c,{additionalProperties:()=>AbB,default:()=>jbB,definitions:()=>PbB,properties:()=>mbB,type:()=>ObB});var ObB="object",mbB={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"}]}},AbB=!1,PbB={"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}},jbB={type:ObB,properties:mbB,additionalProperties:AbB,definitions:PbB};var $2c={};Yt($2c,{additionalProperties:()=>SbB,default:()=>DbB,definitions:()=>MbB,properties:()=>EbB,type:()=>wbB});var wbB="object",EbB={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"}]}},SbB=!1,MbB={"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"}]}},DbB={type:wbB,properties:EbB,additionalProperties:SbB,definitions:MbB};function pqh({files:e,absolutePathToDefinition:t}){let r,i={},n={},a={};for(let[o,c]of VI(e)){let d=c.contents,s=u=>{a[o]={type:Gp.JSONSCHEMA_VALIDATION,error:u}};if(o===KB){let u=lVt(d,K2c);if(u.success){let l=dI.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:l["default-url"],contents:l,rawContents:c.rawContents}}else s(u)}else if(dqh.default.basename(o)===Zb){let u=lVt(d,$2c);if(u.success){let l=dI.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=lVt(d,J2c);if(u.success){let l=dI.serialization.DefinitionFileSchema.parseOrThrow(d);i[o]={defaultUrl:void 0,contents:l,rawContents:c.rawContents,absoluteFilePath:qt(t,o)}}else s(u)}}return r==null?{didSucceed:!1,failures:{[xe.of(KB)]:{type:Gp.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:i,rootApiFile:r,packageMarkers:n}}var ySe=class extends A8t{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,_qh.default)(r??{}),n=this.fernWorkspaces[i];if(n==null){let a=t||this.context,o=qt(this.absoluteFilePath,xe.of(t1)),c=await tbc({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await tCh(o,"{yml,yaml}"),s=await rCh(d);if(!s.didSucceed)return fAu(s.failures,a.logger),a.failAndThrow();let u=pqh({files:s.files,absolutePathToDefinition:o});if(!u.didSucceed)return fAu(u.failures,a.logger),a.failAndThrow();let l=await fqh({dependenciesConfiguration:c,structuralValidationResult:u,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!l.didSucceed)return fAu(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 yY({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 H1h=require("fs/promises");var Q1h=ue(F1h(),1);async function uYa(e){return(await(0,Q1h.convertObj)(e,{})).openapi}var L1h=require("fs/promises");var U1h=require("fs/promises");async function bca({absoluteFilePathToOverrides:e,data:t,context:r,allowNullKeys:i}){let n=null;try{let a=(await(0,U1h.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 Pnc({data:t,overrides:n,allowNullKeys:i})}async function vkc({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,L1h.readFile)(t)).toString(),n=await qi.load(i);return r!=null?await bca({absoluteFilePathToOverrides:r,context:e,data:n}):n}var x1h=require("fs/promises");var yPu=require("fs/promises");var hPu=ue(require("path"),1),V1h=ue(w4(),1),gkc;async function vgB(){return gkc===void 0&&(gkc=(await V1h.default.dir({prefix:"fern-overlay-"})).path),gkc}async function W1h({absoluteFilePathToOverlay:e,absoluteFilePathToOpenAPI:t,data:r,context:i}){let n=await ggB(e,i);if(!OgB(n,i))return r;i.logger.debug(`Applying overlay "${n.info.title}" v${n.info.version}`);let a=ync({data:r,overlay:n}),o=await vgB(),c=hPu.default.basename(t),d=`${hPu.default.parse(c).name}.overlaid.json`,s=hPu.default.join(o,d);return await(0,yPu.writeFile)(s,JSON.stringify(a,null,2),"utf8"),i.logger.info(`Wrote overlaid OpenAPI spec to: ${s}`),a}async function ggB(e,t){let r;try{r=await(0,yPu.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 OgB(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 lYa=ue(Fmu(),1);var G1h=ue(Fmu(),1),sYa=ue(require("path"),1),cYa=class extends G1h.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://")||v0e(jr.of(i)))return i;if(this.absolutePathToOpenAPIOverlays!=null){let n=sYa.default.resolve(sYa.default.dirname(this.absolutePathToOpenAPIOverlays),r);if(v0e(jr.of(n)))return n}return this.absolutePathToOpenAPIOverrides!=null?sYa.default.resolve(sYa.default.dirname(this.absolutePathToOpenAPIOverrides),r):i}};async function Okc({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,absolutePathToOpenAPIOverlays:r,parsed:i}){return(i!=null?await(0,lYa.bundle)({...Qmu,doc:{source:new lYa.Source(e,"<openapi>"),parsed:i},externalRefResolver:new cYa({absolutePathToOpenAPIOverrides:t,absolutePathToOpenAPIOverlays:r})}):await(0,lYa.bundle)({...Qmu,ref:e,externalRefResolver:new cYa({absolutePathToOpenAPIOverrides:t,absolutePathToOpenAPIOverlays:r})})).bundle.parsed}function mgB(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 AgB=["examples","example",xi.EXAMPLES,AL.REDOCLY_CODE_SAMPLES_CAMEL,AL.REDOCLY_CODE_SAMPLES_KEBAB];async function fYa({context:e,absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r,absolutePathToOpenAPIOverlays:i,loadAiExamples:n=!1}){let a=await Okc({absolutePathToOpenAPI:t}),o;r!=null?o=r:typeof a=="object"&&a[xi.OPENAPI_OVERIDES_FILEPATH]!=null&&(o=qt(Yi(t),xe.of(a[xi.OPENAPI_OVERIDES_FILEPATH])));let c=a;if(o!=null&&(c=await bca({absoluteFilePathToOverrides:o,context:e,data:c,allowNullKeys:AgB})),i!=null&&(c=await W1h({absoluteFilePathToOverlay:i,absoluteFilePathToOpenAPI:t,context:e,data:c})),n){let d=qt(Yi(t),xe.of("ai_examples_override.yml"));try{let s=await(0,x1h.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=mgB(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 Okc({absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:o,absolutePathToOpenAPIOverlays:i,parsed:c}):c}var x8t=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,H1h.readFile)(a.absoluteFilepath)).toString(),c=Ef(this.absoluteFilePath,a.source.file);a.source.relativePathToDependency!=null&&(c=qt(a.source.relativePathToDependency,c));let d=a.source.type==="protobuf"?BW.protobuf({file:c}):BW.openapi({file:c});if(o.includes("openapi")||o.includes("swagger"))try{let s=await fYa({absolutePathToOpenAPI:a.absoluteFilepath,context:t,absolutePathToOpenAPIOverrides:a.absoluteFilepathToOverrides,absolutePathToOpenAPIOverlays:a.absoluteFilepathToOverlays,loadAiExamples:i});if(BZc(s)){n.push({type:"openapi",value:s,source:d,namespace:a.namespace,settings:iSe({options:a.settings})});continue}else if(p$a(s)){(!s.schemes||s.schemes.length===0)&&(s.schemes=["https"]);let u=await uYa(s);n.push({type:"openapi",value:u,source:d,namespace:a.namespace,settings:iSe({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 vkc({context:t,absoluteFilePath:a.absoluteFilepath,absoluteFilePathToOverrides:a.absoluteFilepathToOverrides});n.push({type:"asyncapi",value:s,source:d,namespace:a.namespace,settings:iSe({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 vkc({context:t,absoluteFilePath:a.absoluteFilepath,absoluteFilePathToOverrides:a.absoluteFilepathToOverrides});n.push({type:"asyncapi",value:s,source:d,namespace:a.namespace,settings:iSe({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 PgB=Qt.object({type:Qt.string(),channelId:Qt.string().optional(),messageId:Qt.string(),value:Qt.any()}),jgB=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(PgB)}),K1h=Qt.array(jgB);var bPu=class extends dl{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=K1h.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 vca=class extends ma{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 bPu({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 aYi=class extends Fm.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 QR.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 Fm.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 vPu=class extends dl{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 gca=class extends dl{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 gPu=class extends vca{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 gca({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 vPu({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],_=BM(l),h=uu(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=Nfn(uu(`${this.channelPath}_${a}`)).replace(/ /g,"");if("oneOf"in r.message){let u=new Fm.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 Fm.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=ni.named({fernFilepath:t.createFernFilepath(),name:s.typeDeclaration.name.name,typeId:s.typeDeclaration.name.typeId,displayName:void 0,default:void 0,inline:!1}),l=yL.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 aYi({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 aYi({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 aYi({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 Oca=class extends ma{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:MM.singleBaseUrl({environments:t})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var OPu=class extends Oca{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 mkc="$message.",J1h="#/channels/",$1h="#/servers/",mPu=class extends vca{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 gca({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=yL.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=BM(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 aYi({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(mkc)){this.context.errorCollector.collect({message:`Invalid location format: ${t}; expected ${mkc} prefix`,path:this.breadcrumbs});return}let n=r.substring(mkc.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($1h)){this.context.errorCollector.collect({message:`Failed to resolve server name from server ref ${r.$ref}`,path:this.breadcrumbs});return}let i=r.$ref.substring($1h.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(J1h))throw new Error(`Failed to resolve channel path from operation ${t.channel.$ref}`);return t.channel.$ref.substring(J1h.length)}};var APu=class extends Oca{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 dYa=class extends b8t{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 Fm.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 APu({context:this.context,breadcrumbs:["servers"],servers:r}).convert()}else{let r=this.context.spec.servers;t=new OPu({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 QR.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 mPu({context:this.context,breadcrumbs:["channels",t],websocketGroup:n,channel:r,channelPath:t,operations:c}).convert()}else a=new gPu({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 pYa=class extends gC{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:ni.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:ni.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:ni.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}};var rTh=ue(PPu(),1);var jPu=class extends dl{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 wPu=class extends dl{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 Y1h({globalHeaders:e,context:t}){return e.map(r=>({name:t.casingsGenerator.generateNameAndWireValue({name:r.name??"",wireValue:r.header}),valueType:r.optional?ma.OPTIONAL_STRING:ma.STRING,env:r.env,v2Examples:r.optional?void 0:SgB({header:r,context:t}),availability:void 0,docs:void 0}))}function SgB({header:e,context:t}){let r=new mF({breadcrumbs:[],context:t,schema:{type:"string"},example:e.header}),{validExample:i}=r.convert();return{userSpecifiedExamples:{},autogeneratedExamples:{globalHeaderExample:i}}}var EPu=class extends Fm.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 Fm.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 SPu=class extends Fm.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(tm.parse(this.contentType)?.isMultipart())return this.handleMultipartContent({contentType:this.contentType});if(this.isBinaryContentType())return this.handleBinaryContent({contentType:this.contentType})}isOrderedJsonOrFormContentType(){let t=tm.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=tm.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:Nm.reference({contentType:t,docs:this.description,requestBodyType:i.type,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:i.inlinedTypes??{}}:{requestBody:Nm.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:Nm.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:Nm.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:Nm.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?B1.file(sY.fileArray({key:t.name,isOptional:a,contentType:r,docs:t.docs})):B1.file(sY.file({key:t.name,isOptional:a,contentType:r,docs:t.docs})):B1.bodyProperty({...t,contentType:i?.contentType??r,style:DgB({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:Nm.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()))}},MgB={"application/json":"json"};function DgB({encoding:e}){if(e){if(e.explode)return"exploded";if(e.style==="form")return"form";if(e.contentType)return MgB[e.contentType]}}var BgB=/{([^}]+)}/g,IgB=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]),mca=class extends ma{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 sw.Get;case"post":return sw.Post;case"put":return sw.Put;case"delete":return sw.Delete;case"patch":return sw.Patch;case"head":return sw.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 EPu({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(RgB(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}}!IgB.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(BgB)].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:ma.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 SPu({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 QR.SdkMethodNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert()?.methodName,n=new QR.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?uu(this.operation.summary):uu(`${this.method}_${this.path.split("/").join("_")}`))}computeGroupNameFromTagAndOperationId(){let t=this.operation.tags?.[0],r=this.evaluateMethodNameFromOperation();if(t==null)return{method:r};let i=X1h(t),n=X1h(r);return nR(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:uu(o.join("_"))}}generateStringParameterExample({example:t}){let r=new Fm.ExampleConverter({breadcrumbs:this.breadcrumbs,context:this.context,schema:{type:"string"},example:t}),{validExample:i}=r.convert();return i}};function X1h(e){let t=CgB(e)?qgB(e):TgB(e);return t=t.map(r=>r.toLowerCase()),t=t0e(t),t}function CgB(e){return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)}function qgB(e){return e.split(/(?=[A-Z])/)}function TgB(e){return e.split(/[^a-zA-Z0-9]+/)}function RgB(e){return e?.header!=null}var Aca=class extends mca{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=pF.inlinedPayload({name:d.name,extends:d.extends,properties:d.properties});else if(d.type==="reference")s=pF.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=pF.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 jkc=ue(PPu(),1);var Z1h=["get","post","put","delete","patch","head"];var MPu=class extends dl{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 zgB=Qt.object({cursor:Qt.string(),next_cursor:Qt.string(),results:Qt.string()}),NgB=Qt.object({offset:Qt.string(),results:Qt.string(),step:Qt.string().optional(),"has-next-page":Qt.string().optional()}),Akc=Qt.union([Qt.boolean(),zgB,NgB]);var Pkc="$request.",DPu="$response.",BPu=class extends dl{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=Akc.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=Akc.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:gC.maybeTrimPrefix(r.cursor,Pkc),nextCursor:gC.maybeTrimPrefix(r.next_cursor,DPu),results:gC.maybeTrimPrefix(r.results,DPu)};let i=t;return{type:"offset",offset:gC.maybeTrimPrefix(i.offset,Pkc),results:gC.maybeTrimPrefix(i.results,DPu),step:i.step!=null?gC.maybeTrimPrefix(i.step,Pkc):void 0,hasNextPage:i["has-next-page"]!=null?gC.maybeTrimPrefix(i["has-next-page"],DPu):void 0}}};var FgB="$request.",QgB=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()}),UgB=Qt.union([Qt.boolean(),QgB]),IPu=class extends dl{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=UgB.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:gC.maybeTrimPrefix(r.data["stream-condition"],FgB),responseStream:r.data["response-stream"],response:r.data.response}}};var CPu=class extends dl{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 TPu=require("fs"),k1h=require("path");function LgB(e){return bl(e)&&typeof e.$ref=="string"}function VgB(e,t){if(e!=null){if(typeof e=="string")return e;if(LgB(e)){let r=(0,k1h.resolve)(t??process.cwd(),e.$ref);if((0,TPu.existsSync)(r))try{return(0,TPu.readFileSync)(r,"utf-8")}catch{return}}}}var qPu=class extends dl{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=bl(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(!bl(d))continue;let s=d,u=s.lang,l=s.label,p=s.source;if(typeof u!="string")continue;let _=VgB(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 zPu=require("fs"),eTh=require("path");function WgB(e){return bl(e)&&typeof e.$ref=="string"}function GgB(e,t){if(e!=null){if(typeof e=="string")return e;if(WgB(e)){let r=(0,eTh.resolve)(t??process.cwd(),e.$ref);if((0,zPu.existsSync)(r))try{return(0,zPu.readFileSync)(r,"utf-8")}catch{return}}}}function xgB(e,t){if(!Array.isArray(e))return[];let r=[];for(let i of e){if(!bl(i))continue;let a=GgB(i.code,t);a!=null&&r.push({...i,code:a})}return r}var RPu=class extends dl{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(!bl(a))return a;let c=a["code-samples"];if(c!=null){let d=xgB(c,this.baseDir);return{...a,"code-samples":d}}return a}).filter(a=>{let o=dI.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 _Ya=class extends dl{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 hYa=class extends Fm.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:Sd.json(_C.response({responseBodyType:r.type,docs:this.responseBody.description,v2Examples:r.schema?.typeDeclaration.v2Examples})),streamResponseBody:Sd.streaming(fI.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:Sd.streaming(fI.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:Sd.streaming(fI.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:Sd.json(_C.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:Sd.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:Sd.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:Sd.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 tm.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=ma.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=ni.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=ni.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 mF({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 NPu=class extends Fm.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:ni.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:tTh(`${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 Lpu[t]}getErrorIdFromErrorName(t){return this.context.enableUniqueErrorsPerEndpoint?tTh(`${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=ma.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=ni.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=ni.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 mF({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 tTh(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}var FPu=class e extends mca{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($=>$.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($=>$.error),O=BM(this.path),m=this.getEndpointBaseUrl(),g=this.getEndpointBaseUrls(),A=this.convertExamples({httpPath:O,httpMethod:t,baseUrl:m}),j=new Set(this.operation.security?.flatMap($=>Object.keys($))??[]),M=this.authSchemeToHeaders(Array.from(j));M.length>0&&a.push(...M);for(let $ of y){let de=$.error,be=$.errorType,W=de.error.errorId,x=$.examples;b[W]={name:de.error,displayName:$.displayName,discriminantValue:{name:de.error.name,wireValue:W},type:be,statusCode:$.statusCode,isWildcardStatusCode:$.isWildcardStatusCode,docs:de.docs,examples:[],v2Examples:{userSpecifiedExamples:x??{},autogeneratedExamples:{}},headers:$.headers}}let w=this.context.getAudiences({operation:this.operation,breadcrumbs:this.breadcrumbs})??[],B=new _Ya({context:this.context,breadcrumbs:this.breadcrumbs,document:this.context.spec}).convert(),q=new _Ya({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(($,de,be)=>de===be.findIndex(W=>W.name.wireValue===$.name.wireValue)),responseHeaders:p?.responseHeaders,sdkRequest:void 0,errors:v,auth:this.computeEndpointAuth(),security:this.computeEndpointSecurity(),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:gW.openapi(),audiences:w,retries:void 0,apiPlayground:q},N=this.context.namespace!=null?[this.context.namespace]:[],H=r?.map($=>uu($));return N.push(...H??[]),{audiences:w,group:r,groupDisplayName:n,errors:b,endpoint:{...z,id:`endpoint_${N.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_${N.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 hYa({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 NPu({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 hYa({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()}computeEndpointSecurity(){return this.operation.security!=null&&this.operation.security.length===0?[]:this.context.authOverrides?.auth!=null?this.getDefaultSecurityFromAuthOverrides():this.operation.security??this.context.spec.security}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"){let r={};return r[t]=[],[r]}if(typeof t=="object"&&"any"in t){let r=t.any;if(Array.isArray(r))return r.map(i=>{let n=typeof i=="string"?i:i.scheme,a={};return a[n]=[],a})}}authSchemeToHeaders(t){let r=[];for(let i of t){let n=this.idToAuthScheme?.[i];if(n==null)continue;let a={valueType:ma.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 RPu({context:this.context,breadcrumbs:this.breadcrumbs,operation:this.operation,baseDir:this.context.documentBaseDir}).convert()??[],c=new qPu({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 QR.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 nge.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 nge.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 QPu=class extends ma{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 Z1h){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 IPu({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 CPu({breadcrumbs:i,operation:t,context:n}).convert()?new Aca({context:this.context,breadcrumbs:i,operation:t,method:jkc.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path}).convert():void 0}tryParseAsHttpEndpoint({operation:t,method:r,operationBreadcrumbs:i,streamingExtension:n}){new BPu({breadcrumbs:i,operation:t,document:this.context.spec,context:this.context}).convert()!=null;let d=new MPu({breadcrumbs:i,operation:t,context:this.context}).convert();return new FPu({context:this.context,breadcrumbs:i,operation:t,method:jkc.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path,idempotent:d,idToAuthScheme:this.idToAuthScheme,topLevelServers:this.topLevelServers,streamingExtension:n}).convert()}};var UPu=class extends ma{securityScheme;schemeId;constructor({context:t,breadcrumbs:r,securityScheme:i,schemeId:n}){super({context:t,breadcrumbs:r}),this.securityScheme=i,this.schemeId=n}getExtension(t){return this.securityScheme[t]}convert(){switch(this.securityScheme.type){case"http":{if(this.securityScheme.scheme?.toLowerCase()==="bearer"){let t=this.getExtension("x-fern-bearer"),r=t?.name??"token",i=t?.env;return PA.bearer({key:this.schemeId,token:this.context.casingsGenerator.generateName(r),tokenEnvVar:i,docs:this.securityScheme.description})}if(this.securityScheme.scheme?.toLowerCase()==="basic"){let t=this.getExtension("x-fern-basic"),r=t?.username?.name??"username",i=t?.password?.name??"password",n=t?.username?.env,a=t?.password?.env;return PA.basic({key:this.schemeId,username:this.context.casingsGenerator.generateName(r),password:this.context.casingsGenerator.generateName(i),usernameEnvVar:n,passwordEnvVar:a,usernameOmit:!1,passwordOmit:!1,docs:this.securityScheme.description})}break}case"apiKey":{if(this.securityScheme.in==="header"){let t=this.getExtension("x-fern-header"),r=t?.name??"apiKey",i=t?.env,n=t?.prefix;return PA.header({key:this.schemeId,name:{name:this.context.casingsGenerator.generateName(r),wireValue:this.securityScheme.name},valueType:ma.OPTIONAL_STRING,prefix:n,headerEnvVar:i,docs:this.securityScheme.description})}break}case"oauth2":return PA.bearer({key:this.schemeId,token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description})}}};var yYa=class extends b8t{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 wPu({breadcrumbs:["x-fern-global-headers"],document:this.context.spec,context:this.context}).convert();if(r!=null){let i=Y1h({globalHeaders:r,context:this.context});this.addGlobalHeadersToIr(i),this.context.setGlobalHeaders(i)}}convertBasePath(){let r=new jPu({breadcrumbs:["x-fern-base-path"],document:this.context.spec,context:this.context}).convert();r!=null&&(this.ir.basePath=BM(r))}convertSecuritySchemes(){if(this.context.authOverrides){let r=fxc({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 UPu({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=nKa({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 nge({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 Fm.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 Aca({context:this.context,breadcrumbs:["webhooks",r],operation:t.post,method:rTh.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 QPu({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 LPu=class extends dl{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 e4i=class extends gC{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 Fm.SchemaConverters.SchemaConverter({context:this,breadcrumbs:r??[],schema:o.value,id:a}).convert();u!=null&&(d={[a]:u.convertedSchema})}return{ok:!0,reference:ni.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 LPu({breadcrumbs:["tags",r.name],tag:r,context:this}).convert()?.displayName??r.name;this.tagToDisplayName[r.name]=n}return this.tagToDisplayName[t]??t}};var HgB=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()}),KgB=HgB.extend({name:Qt.string(),in:Qt.string()}),JgB=Qt.array(KgB),VPu=class extends dl{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 JgB.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 WPu=class extends ma{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=BM(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 Fm.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 Fm.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?Nm.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:Sd.json(_C.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:gW.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 nge.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 GPu=class extends Fm.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 Fm.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 bYa=class extends b8t{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 nge({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 Fm.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 VPu({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 GPu({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 WPu({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 vYa=class extends gC{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:ni.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}};var HRh=require("fs/promises");var iTh={[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,Z0(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 $gB=["go","ruby"];function KPu({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let o=nOB(n),c=p=>({unsafeName:p,safeName:YgB({name:p,keywords:XgB({generationLanguage:e,keywords:t})})}),d=uu(o),s=Z0(d),u=zfn(o),l=Cfn(d);return r&&(!eOB(l)&&(e==null||$gB.includes(e))&&(d=l.map((p,_)=>{if(_>0){let h=xPu(p);if(h!=null)return h;if(HPu(p))return p.toUpperCase()}return p}).join(""),s=Z0(l.map((p,_)=>{let h=xPu(p);return h??(HPu(p)?p.toUpperCase():_===0?Z0(p):p)}).join(""))),u=o.split(" ").map(p=>p.split(/(\d+)/).map(zfn).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 YgB({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":kgB(e)?"_"+e:e}function XgB({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return iTh[e]}var ZgB=/^[0-9]/;function kgB(e){return ZgB.test(e)}function eOB(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=xPu(i)!=null||HPu(i),a=xPu(t)!=null||HPu(t);return n&&a})}function xPu(e){return rOB.get(e.toUpperCase())}function HPu(e){return tOB.has(e.toUpperCase())}var tOB=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"]),rOB=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]),iOB=[[/\[\]/g,"Array"]];function nOB(e){return iOB.reduce((t,[r,i])=>t.replace(r,i),e)}var nTh=require("fs/promises");async function wkc({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,nTh.readFile)(t)).toString(),n;try{n=JSON.parse(i)}catch{n=qi.load(i)}return r!=null?await bca({absoluteFilePathToOverrides:r,context:e,data:n}):n}var CRh=ue(IRh(),1);function uYi(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,CRh.default)(t,r,o)}async function vy(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...o}={}){let c=uYi(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 sYi(e,{logger:t,...r}={}){return(i,n)=>vy(t,e,i,{...r,...n})}var Dx=require("fs/promises"),VRh=ue(require("path"),1),Wkc=ue(w4(),1);var XmB=ue(w4(),1);function qRh(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 PYa,Vkc;async function Wgn(e,t,r=5e3){return PYa!==void 0?PYa:(Vkc==null&&(Vkc=ZmB(e,t,r)),Vkc)}async function ZmB(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)}),PYa=!1,t.debug("Network check succeeded - not in air-gapped mode"),!1}catch(i){let n=i instanceof Error?i.message:String(i);return qRh(n)?(PYa=!0,t.debug(`Network check failed - entering air-gapped mode: ${n}`),!0):(PYa=!1,!1)}}var TRh="buf.gen.yaml",kmB="output",RRh=`${kmB}/ir.json`,zRh="protoc-gen-fern",NRh=`version: v1
|
|
1534
|
+
`).reduce(dyB,Object.create(null)),dyB=(e,t)=>{let r=parseInt(t,10);if(r!==Buffer.byteLength(t)+1)return e;t=t.slice((r+" ").length);let i=t.split("="),n=i.shift();if(!n)return e;let a=n.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),o=i.join("=");return e[a]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(a)?new Date(Number(o)*1e3):/^[0-9]+$/.test(o)?+o:o,e};var pyB=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,k_=pyB!=="win32"?e=>e:e=>e&&e.replace(/\\/g,"/");var rca=class extends uR{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,r,i){switch(super({}),this.pause(),this.extended=r,this.globalExtended=i,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=k_(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?k_(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,r&&this.#e(r),i&&this.#e(i,!0)}write(t){let r=t.length;if(r>this.blockRemain)throw new Error("writing more to entry than is appropriate");let i=this.remain,n=this.blockRemain;return this.remain=Math.max(0,i-r),this.blockRemain=Math.max(0,n-r),this.ignore?!0:i>=r?super.write(t):super.write(t.subarray(0,i))}#e(t,r=!1){t.path&&(t.path=k_(t.path)),t.linkpath&&(t.linkpath=k_(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([i,n])=>!(n==null||i==="path"&&r))))}};var Mgn=(e,t,r,i={})=>{e.file&&(i.file=e.file),e.cwd&&(i.cwd=e.cwd),i.code=r instanceof Error&&r.code||t,i.tarCode=t,!e.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),e.emit("warn",t,r,i)):r instanceof Error?e.emit("error",Object.assign(r,i)):e.emit("error",Object.assign(new Error(`${t}: ${r}`),i))};var _yB=1024*1024,i2c=Buffer.from([31,139]),n2c=Buffer.from([40,181,47,253]),hyB=Math.max(i2c.length,n2c.length),_Se=Symbol("state"),Dgn=Symbol("writeEntry"),KUi=Symbol("readEntry"),kZc=Symbol("nextEntry"),gCh=Symbol("processEntry"),lXt=Symbol("extendedHeader"),w$a=Symbol("globalExtendedHeader"),x$i=Symbol("meta"),OCh=Symbol("emitMeta"),oE=Symbol("buffer"),JUi=Symbol("queue"),H$i=Symbol("ended"),e2c=Symbol("emittedEnd"),Bgn=Symbol("emit"),N1=Symbol("unzip"),MAu=Symbol("consumeChunk"),DAu=Symbol("consumeChunkSub"),t2c=Symbol("consumeBody"),mCh=Symbol("consumeMeta"),ACh=Symbol("consumeHeader"),E$a=Symbol("consuming"),r2c=Symbol("bufferConcat"),BAu=Symbol("maybeEnd"),ica=Symbol("writing"),K$i=Symbol("aborted"),IAu=Symbol("onDone"),Ign=Symbol("sawValidEntry"),CAu=Symbol("sawNullBlock"),qAu=Symbol("sawEOF"),PCh=Symbol("closeStream"),yyB=()=>!0,$Ui=class extends jCh.EventEmitter{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[JUi]=[];[oE];[KUi];[Dgn];[_Se]="begin";[x$i]="";[lXt];[w$a];[H$i]=!1;[N1];[K$i]=!1;[Ign];[CAu]=!1;[qAu]=!1;[ica]=!1;[E$a]=!1;[e2c]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(IAu,()=>{(this[_Se]==="begin"||this[Ign]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(IAu,t.ondone):this.on(IAu,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||_yB,this.filter=typeof t.filter=="function"?t.filter:yyB;let r=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:r?void 0:!1;let i=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:i?!0:void 0,this.on("end",()=>this[PCh]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,r,i={}){Mgn(this,t,r,i)}[ACh](t,r){this[Ign]===void 0&&(this[Ign]=!1);let i;try{i=new vge(t,r,this[lXt],this[w$a])}catch(n){return this.warn("TAR_ENTRY_INVALID",n)}if(i.nullBlock)this[CAu]?(this[qAu]=!0,this[_Se]==="begin"&&(this[_Se]="header"),this[Bgn]("eof")):(this[CAu]=!0,this[Bgn]("nullBlock"));else if(this[CAu]=!1,!i.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:i});else if(!i.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:i});else{let n=i.type;if(/^(Symbolic)?Link$/.test(n)&&!i.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:i});else if(!/^(Symbolic)?Link$/.test(n)&&!/^(Global)?ExtendedHeader$/.test(n)&&i.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:i});else{let a=this[Dgn]=new rca(i,this[lXt],this[w$a]);if(!this[Ign])if(a.remain){let o=()=>{a.invalid||(this[Ign]=!0)};a.on("end",o)}else this[Ign]=!0;a.meta?a.size>this.maxMetaEntrySize?(a.ignore=!0,this[Bgn]("ignoredEntry",a),this[_Se]="ignore",a.resume()):a.size>0&&(this[x$i]="",a.on("data",o=>this[x$i]+=o),this[_Se]="meta"):(this[lXt]=void 0,a.ignore=a.ignore||!this.filter(a.path,a),a.ignore?(this[Bgn]("ignoredEntry",a),this[_Se]=a.remain?"ignore":"header",a.resume()):(a.remain?this[_Se]="body":(this[_Se]="header",a.end()),this[KUi]?this[JUi].push(a):(this[JUi].push(a),this[kZc]())))}}}[PCh](){queueMicrotask(()=>this.emit("close"))}[gCh](t){let r=!0;if(!t)this[KUi]=void 0,r=!1;else if(Array.isArray(t)){let[i,...n]=t;this.emit(i,...n)}else this[KUi]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[kZc]()),r=!1);return r}[kZc](){do;while(this[gCh](this[JUi].shift()));if(!this[JUi].length){let t=this[KUi];!t||t.flowing||t.size===t.remain?this[ica]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[t2c](t,r){let i=this[Dgn];if(!i)throw new Error("attempt to consume body without entry??");let n=i.blockRemain??0,a=n>=t.length&&r===0?t:t.subarray(r,r+n);return i.write(a),i.blockRemain||(this[_Se]="header",this[Dgn]=void 0,i.end()),a.length}[mCh](t,r){let i=this[Dgn],n=this[t2c](t,r);return!this[Dgn]&&i&&this[OCh](i),n}[Bgn](t,r,i){!this[JUi].length&&!this[KUi]?this.emit(t,r,i):this[JUi].push([t,r,i])}[OCh](t){switch(this[Bgn]("meta",this[x$i]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[lXt]=G$i.parse(this[x$i],this[lXt],!1);break;case"GlobalExtendedHeader":this[w$a]=G$i.parse(this[x$i],this[w$a],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let r=this[lXt]??Object.create(null);this[lXt]=r,r.path=this[x$i].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let r=this[lXt]||Object.create(null);this[lXt]=r,r.linkpath=this[x$i].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[K$i]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,r,i){if(typeof r=="function"&&(i=r,r=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof r=="string"?r:"utf8")),this[K$i])return i?.(),!1;if((this[N1]===void 0||this.brotli===void 0&&this[N1]===!1)&&t){if(this[oE]&&(t=Buffer.concat([this[oE],t]),this[oE]=void 0),t.length<hyB)return this[oE]=t,i?.(),!0;for(let d=0;this[N1]===void 0&&d<i2c.length;d++)t[d]!==i2c[d]&&(this[N1]=!1);let o=!1;if(this[N1]===!1&&this.zstd!==!1){o=!0;for(let d=0;d<n2c.length;d++)if(t[d]!==n2c[d]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[N1]===!1&&c)if(t.length<512)if(this[H$i])this.brotli=!0;else return this[oE]=t,i?.(),!0;else try{new vge(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[N1]===void 0||this[N1]===!1&&(this.brotli||o)){let d=this[H$i];this[H$i]=!1,this[N1]=this[N1]===void 0?new gAu({}):o?new wAu({}):new AAu({}),this[N1].on("data",u=>this[MAu](u)),this[N1].on("error",u=>this.abort(u)),this[N1].on("end",()=>{this[H$i]=!0,this[MAu]()}),this[ica]=!0;let s=!!this[N1][d?"end":"write"](t);return this[ica]=!1,i?.(),s}}this[ica]=!0,this[N1]?this[N1].write(t):this[MAu](t),this[ica]=!1;let a=this[JUi].length?!1:this[KUi]?this[KUi].flowing:!0;return!a&&!this[JUi].length&&this[KUi]?.once("drain",()=>this.emit("drain")),i?.(),a}[r2c](t){t&&!this[K$i]&&(this[oE]=this[oE]?Buffer.concat([this[oE],t]):t)}[BAu](){if(this[H$i]&&!this[e2c]&&!this[K$i]&&!this[E$a]){this[e2c]=!0;let t=this[Dgn];if(t&&t.blockRemain){let r=this[oE]?this[oE].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${r} available)`,{entry:t}),this[oE]&&t.write(this[oE]),t.end()}this[Bgn](IAu)}}[MAu](t){if(this[E$a]&&t)this[r2c](t);else if(!t&&!this[oE])this[BAu]();else if(t){if(this[E$a]=!0,this[oE]){this[r2c](t);let r=this[oE];this[oE]=void 0,this[DAu](r)}else this[DAu](t);for(;this[oE]&&this[oE]?.length>=512&&!this[K$i]&&!this[qAu];){let r=this[oE];this[oE]=void 0,this[DAu](r)}this[E$a]=!1}(!this[oE]||this[H$i])&&this[BAu]()}[DAu](t){let r=0,i=t.length;for(;r+512<=i&&!this[K$i]&&!this[qAu];)switch(this[_Se]){case"begin":case"header":this[ACh](t,r),r+=512;break;case"ignore":case"body":r+=this[t2c](t,r);break;case"meta":r+=this[mCh](t,r);break;default:throw new Error("invalid state: "+this[_Se])}r<i&&(this[oE]?this[oE]=Buffer.concat([t.subarray(r),this[oE]]):this[oE]=t.subarray(r))}end(t,r,i){return typeof t=="function"&&(i=t,r=void 0,t=void 0),typeof r=="function"&&(i=r,r=void 0),typeof t=="string"&&(t=Buffer.from(t,r)),i&&this.once("finish",i),this[K$i]||(this[N1]?(t&&this[N1].write(t),this[N1].end()):(this[H$i]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[BAu]())),this}};var J$i=e=>{let t=e.length-1,r=-1;for(;t>-1&&e.charAt(t)==="/";)r=t,t--;return r===-1?e:e.slice(0,r)};var byB=e=>{let t=e.onReadEntry;e.onReadEntry=t?r=>{t(r),r.resume()}:r=>r.resume()},a2c=(e,t)=>{let r=new Map(t.map(a=>[J$i(a),!0])),i=e.filter,n=(a,o="")=>{let c=o||(0,TAu.parse)(a).root||".",d;if(a===c)d=!1;else{let s=r.get(a);s!==void 0?d=s:d=n((0,TAu.dirname)(a),c)}return r.set(a,d),d};e.filter=i?(a,o)=>i(a,o)&&n(J$i(a)):a=>n(J$i(a))},vyB=e=>{let t=new $Ui(e),r=e.file,i;try{i=Cgn.default.openSync(r,"r");let n=Cgn.default.fstatSync(i),a=e.maxReadSize||16*1024*1024;if(n.size<a){let o=Buffer.allocUnsafe(n.size),c=Cgn.default.readSync(i,o,0,n.size,0);t.end(c===o.byteLength?o:o.subarray(0,c))}else{let o=0,c=Buffer.allocUnsafe(a);for(;o<n.size;){let d=Cgn.default.readSync(i,c,0,a,o);if(d===0)break;o+=d,t.write(c.subarray(0,d))}t.end()}}finally{if(typeof i=="number")try{Cgn.default.closeSync(i)}catch{}}},gyB=(e,t)=>{let r=new $Ui(e),i=e.maxReadSize||16*1024*1024,n=e.file;return new Promise((o,c)=>{r.on("error",c),r.on("end",o),Cgn.default.stat(n,(d,s)=>{if(d)c(d);else{let u=new Pgn(n,{readSize:i,size:s.size});u.on("error",c),u.pipe(r)}})})},qgn=cXt(vyB,gyB,e=>new $Ui(e),e=>new $Ui(e),(e,t)=>{t?.length&&a2c(e,t),e.noResume||byB(e)});var q$a=ue(require("fs"),1);var L8t=ue(require("fs"),1);var l2c=ue(require("path"),1);var o2c=(e,t,r)=>(e&=4095,r&&(e=(e|384)&-19),t&&(e&256&&(e|=64),e&32&&(e|=8),e&4&&(e|=1)),e);var ECh=require("path"),{isAbsolute:OyB,parse:wCh}=ECh.win32,S$a=e=>{let t="",r=wCh(e);for(;OyB(e)||r.root;){let i=e.charAt(0)==="/"&&e.slice(0,4)!=="//?/"?"/":r.root;e=e.slice(i.length),t+=i,r=wCh(e)}return[t,e]};var RAu=["|","<",">","?",":"],u2c=RAu.map(e=>String.fromCharCode(61440+e.charCodeAt(0))),myB=new Map(RAu.map((e,t)=>[e,u2c[t]])),AyB=new Map(u2c.map((e,t)=>[e,RAu[t]])),s2c=e=>RAu.reduce((t,r)=>t.split(r).join(myB.get(r)),e),SCh=e=>u2c.reduce((t,r)=>t.split(r).join(AyB.get(r)),e);var qCh=(e,t)=>t?(e=k_(e).replace(/^\.(\/|$)/,""),J$i(t)+"/"+e):k_(e),PyB=16*1024*1024,DCh=Symbol("process"),BCh=Symbol("file"),ICh=Symbol("directory"),f2c=Symbol("symlink"),CCh=Symbol("hardlink"),M$a=Symbol("header"),zAu=Symbol("read"),d2c=Symbol("lstat"),NAu=Symbol("onlstat"),p2c=Symbol("onread"),_2c=Symbol("onreadlink"),h2c=Symbol("openfile"),y2c=Symbol("onopenfile"),$$i=Symbol("close"),FAu=Symbol("mode"),b2c=Symbol("awaitDrain"),c2c=Symbol("ondrain"),fXt=Symbol("prefix"),D$a=class extends uR{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(t,r={}){let i=P$a(r);super(),this.path=k_(t),this.portable=!!i.portable,this.maxReadSize=i.maxReadSize||PyB,this.linkCache=i.linkCache||new Map,this.statCache=i.statCache||new Map,this.preservePaths=!!i.preservePaths,this.cwd=k_(i.cwd||process.cwd()),this.strict=!!i.strict,this.noPax=!!i.noPax,this.noMtime=!!i.noMtime,this.mtime=i.mtime,this.prefix=i.prefix?k_(i.prefix):void 0,this.onWriteEntry=i.onWriteEntry,typeof i.onwarn=="function"&&this.on("warn",i.onwarn);let n=!1;if(!this.preservePaths){let[o,c]=S$a(this.path);o&&typeof c=="string"&&(this.path=c,n=o)}this.win32=!!i.win32||process.platform==="win32",this.win32&&(this.path=SCh(this.path.replace(/\\/g,"/")),t=t.replace(/\\/g,"/")),this.absolute=k_(i.absolute||l2c.default.resolve(this.cwd,t)),this.path===""&&(this.path="./"),n&&this.warn("TAR_ENTRY_INFO",`stripping ${n} from absolute path`,{entry:this,path:n+this.path});let a=this.statCache.get(this.absolute);a?this[NAu](a):this[d2c]()}warn(t,r,i={}){return Mgn(this,t,r,i)}emit(t,...r){return t==="error"&&(this.#e=!0),super.emit(t,...r)}[d2c](){L8t.default.lstat(this.absolute,(t,r)=>{if(t)return this.emit("error",t);this[NAu](r)})}[NAu](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=jyB(t),this.emit("stat",t),this[DCh]()}[DCh](){switch(this.type){case"File":return this[BCh]();case"Directory":return this[ICh]();case"SymbolicLink":return this[f2c]();default:return this.end()}}[FAu](t){return o2c(t,this.type==="Directory",this.portable)}[fXt](t){return qCh(t,this.prefix)}[M$a](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new vge({path:this[fXt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[fXt](this.linkpath):this.linkpath,mode:this[FAu](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new G$i({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[fXt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[fXt](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[ICh](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[M$a](),this.end()}[f2c](){L8t.default.readlink(this.absolute,(t,r)=>{if(t)return this.emit("error",t);this[_2c](r)})}[_2c](t){this.linkpath=k_(t),this[M$a](),this.end()}[CCh](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=k_(l2c.default.relative(this.cwd,t)),this.stat.size=0,this[M$a](),this.end()}[BCh](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,r=this.linkCache.get(t);if(r?.indexOf(this.cwd)===0)return this[CCh](r);this.linkCache.set(t,this.absolute)}if(this[M$a](),this.stat.size===0)return this.end();this[h2c]()}[h2c](){L8t.default.open(this.absolute,"r",(t,r)=>{if(t)return this.emit("error",t);this[y2c](r)})}[y2c](t){if(this.fd=t,this.#e)return this[$$i]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let r=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(r),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[zAu]()}[zAu](){let{fd:t,buf:r,offset:i,length:n,pos:a}=this;if(t===void 0||r===void 0)throw new Error("cannot read file without first opening");L8t.default.read(t,r,i,n,a,(o,c)=>{if(o)return this[$$i](()=>this.emit("error",o));this[p2c](c)})}[$$i](t=()=>{}){this.fd!==void 0&&L8t.default.close(this.fd,t)}[p2c](t){if(t<=0&&this.remain>0){let n=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[$$i](()=>this.emit("error",n))}if(t>this.remain){let n=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[$$i](()=>this.emit("error",n))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let n=t;n<this.length&&t<this.blockRemain;n++)this.buf[n+this.offset]=0,t++,this.remain++;let r=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(r)?this[c2c]():this[b2c](()=>this[c2c]())}[b2c](t){this.once("drain",t)}write(t,r,i){if(typeof r=="function"&&(i=r,r=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof r=="string"?r:"utf8")),this.blockRemain<t.length){let n=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",n)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,i)}[c2c](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[$$i](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[zAu]()}},QAu=class extends D$a{sync=!0;[d2c](){this[NAu](L8t.default.lstatSync(this.absolute))}[f2c](){this[_2c](L8t.default.readlinkSync(this.absolute))}[h2c](){this[y2c](L8t.default.openSync(this.absolute,"r"))}[zAu](){let t=!0;try{let{fd:r,buf:i,offset:n,length:a,pos:o}=this;if(r===void 0||i===void 0)throw new Error("fd and buf must be set in READ method");let c=L8t.default.readSync(r,i,n,a,o);this[p2c](c),t=!1}finally{if(t)try{this[$$i](()=>{})}catch{}}}[b2c](t){t()}[$$i](t=()=>{}){this.fd!==void 0&&L8t.default.closeSync(this.fd),t()}},UAu=class extends uR{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,r,i={}){return Mgn(this,t,r,i)}constructor(t,r={}){let i=P$a(r);super(),this.preservePaths=!!i.preservePaths,this.portable=!!i.portable,this.strict=!!i.strict,this.noPax=!!i.noPax,this.noMtime=!!i.noMtime,this.onWriteEntry=i.onWriteEntry,this.readEntry=t;let{type:n}=t;if(n==="Unsupported")throw new Error("writing entry that should be ignored");this.type=n,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=i.prefix,this.path=k_(t.path),this.mode=t.mode!==void 0?this[FAu](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:i.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?k_(t.linkpath):void 0,typeof i.onwarn=="function"&&this.on("warn",i.onwarn);let a=!1;if(!this.preservePaths){let[c,d]=S$a(this.path);c&&typeof d=="string"&&(this.path=d,a=c)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new vge({path:this[fXt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[fXt](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),a&&this.warn("TAR_ENTRY_INFO",`stripping ${a} from absolute path`,{entry:this,path:a+this.path}),this.header.encode()&&!this.noPax&&super.write(new G$i({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[fXt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[fXt](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let o=this.header?.block;if(!o)throw new Error("failed to encode header");super.write(o),t.pipe(this)}[fXt](t){return qCh(t,this.prefix)}[FAu](t){return o2c(t,this.type==="Directory",this.portable)}write(t,r,i){typeof r=="function"&&(i=r,r=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof r=="string"?r:"utf8"));let n=t.length;if(n>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=n,super.write(t,i)}end(t,r,i){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(i=t,r=void 0,t=void 0),typeof r=="function"&&(i=r,r=void 0),typeof t=="string"&&(t=Buffer.from(t,r??"utf8")),i&&this.once("finish",i),t?super.end(t,i):super.end(i),this}},jyB=e=>e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":"Unsupported";var LAu=class e{tail;head;length=0;static create(t=[]){return new e(t)}constructor(t=[]){for(let r of t)this.push(r)}*[Symbol.iterator](){for(let t=this.head;t;t=t.next)yield t.value}removeNode(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");let r=t.next,i=t.prev;return r&&(r.prev=i),i&&(i.next=r),t===this.head&&(this.head=r),t===this.tail&&(this.tail=i),this.length--,t.next=void 0,t.prev=void 0,t.list=void 0,r}unshiftNode(t){if(t===this.head)return;t.list&&t.list.removeNode(t);let r=this.head;t.list=this,t.next=r,r&&(r.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}pushNode(t){if(t===this.tail)return;t.list&&t.list.removeNode(t);let r=this.tail;t.list=this,t.prev=r,r&&(r.next=t),this.tail=t,this.head||(this.head=t),this.length++}push(...t){for(let r=0,i=t.length;r<i;r++)EyB(this,t[r]);return this.length}unshift(...t){for(var r=0,i=t.length;r<i;r++)SyB(this,t[r]);return this.length}pop(){if(!this.tail)return;let t=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,t}shift(){if(!this.head)return;let t=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,t}forEach(t,r){r=r||this;for(let i=this.head,n=0;i;n++)t.call(r,i.value,n,this),i=i.next}forEachReverse(t,r){r=r||this;for(let i=this.tail,n=this.length-1;i;n--)t.call(r,i.value,n,this),i=i.prev}get(t){let r=0,i=this.head;for(;i&&r<t;r++)i=i.next;if(r===t&&i)return i.value}getReverse(t){let r=0,i=this.tail;for(;i&&r<t;r++)i=i.prev;if(r===t&&i)return i.value}map(t,r){r=r||this;let i=new e;for(let n=this.head;n;)i.push(t.call(r,n.value,this)),n=n.next;return i}mapReverse(t,r){r=r||this;var i=new e;for(let n=this.tail;n;)i.push(t.call(r,n.value,this)),n=n.prev;return i}reduce(t,r){let i,n=this.head;if(arguments.length>1)i=r;else if(this.head)n=this.head.next,i=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var a=0;n;a++)i=t(i,n.value,a),n=n.next;return i}reduceReverse(t,r){let i,n=this.tail;if(arguments.length>1)i=r;else if(this.tail)n=this.tail.prev,i=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let a=this.length-1;n;a--)i=t(i,n.value,a),n=n.prev;return i}toArray(){let t=new Array(this.length);for(let r=0,i=this.head;i;r++)t[r]=i.value,i=i.next;return t}toArrayReverse(){let t=new Array(this.length);for(let r=0,i=this.tail;i;r++)t[r]=i.value,i=i.prev;return t}slice(t=0,r=this.length){r<0&&(r+=this.length),t<0&&(t+=this.length);let i=new e;if(r<t||r<0)return i;t<0&&(t=0),r>this.length&&(r=this.length);let n=this.head,a=0;for(a=0;n&&a<t;a++)n=n.next;for(;n&&a<r;a++,n=n.next)i.push(n.value);return i}sliceReverse(t=0,r=this.length){r<0&&(r+=this.length),t<0&&(t+=this.length);let i=new e;if(r<t||r<0)return i;t<0&&(t=0),r>this.length&&(r=this.length);let n=this.length,a=this.tail;for(;a&&n>r;n--)a=a.prev;for(;a&&n>t;n--,a=a.prev)i.push(a.value);return i}splice(t,r=0,...i){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);let n=this.head;for(let o=0;n&&o<t;o++)n=n.next;let a=[];for(let o=0;n&&o<r;o++)a.push(n.value),n=this.removeNode(n);n?n!==this.tail&&(n=n.prev):n=this.tail;for(let o of i)n=wyB(this,n,o);return a}reverse(){let t=this.head,r=this.tail;for(let i=t;i;i=i.prev){let n=i.prev;i.prev=i.next,i.next=n}return this.head=r,this.tail=t,this}};function wyB(e,t,r){let i=t,n=t?t.next:e.head,a=new B$a(r,i,n,e);return a.next===void 0&&(e.tail=a),a.prev===void 0&&(e.head=a),e.length++,a}function EyB(e,t){e.tail=new B$a(t,e.tail,void 0,e),e.head||(e.head=e.tail),e.length++}function SyB(e,t){e.head=new B$a(t,void 0,e.head,e),e.tail||(e.tail=e.head),e.length++}var B$a=class{list;next;prev;value;constructor(t,r,i,n){this.list=n,this.value=t,r?(r.next=this,this.prev=r):this.prev=void 0,i?(i.prev=this,this.next=i):this.next=void 0}};var P2c=ue(require("path"),1);var KAu=class{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(t,r){this.path=t||"./",this.absolute=r}},TCh=Buffer.alloc(1024),VAu=Symbol("onStat"),I$a=Symbol("ended"),V8t=Symbol("queue"),nca=Symbol("current"),Tgn=Symbol("process"),C$a=Symbol("processing"),RCh=Symbol("processJob"),W8t=Symbol("jobs"),v2c=Symbol("jobDone"),WAu=Symbol("addFSEntry"),zCh=Symbol("addTarEntry"),m2c=Symbol("stat"),A2c=Symbol("readdir"),GAu=Symbol("onreaddir"),xAu=Symbol("pipe"),NCh=Symbol("entry"),g2c=Symbol("entryOpt"),HAu=Symbol("writeEntryClass"),FCh=Symbol("write"),O2c=Symbol("ondrain"),Y$i=class extends uR{opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[HAu];onWriteEntry;[V8t];[W8t]=0;[C$a]=!1;[I$a]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=k_(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[HAu]=D$a,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new vAu(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new mAu(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new jAu(t.zstd)),!this.zip)throw new Error("impossible");let r=this.zip;r.on("data",i=>super.write(i)),r.on("end",()=>super.end()),r.on("drain",()=>this[O2c]()),this.on("resume",()=>r.resume())}else this.on("drain",this[O2c]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[V8t]=new LAu,this[W8t]=0,this.jobs=Number(t.jobs)||4,this[C$a]=!1,this[I$a]=!1}[FCh](t){return super.write(t)}add(t){return this.write(t),this}end(t,r,i){return typeof t=="function"&&(i=t,t=void 0),typeof r=="function"&&(i=r,r=void 0),t&&this.add(t),this[I$a]=!0,this[Tgn](),i&&i(),this}write(t){if(this[I$a])throw new Error("write after end");return t instanceof rca?this[zCh](t):this[WAu](t),this.flowing}[zCh](t){let r=k_(P2c.default.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let i=new KAu(t.path,r);i.entry=new UAu(t,this[g2c](i)),i.entry.on("end",()=>this[v2c](i)),this[W8t]+=1,this[V8t].push(i)}this[Tgn]()}[WAu](t){let r=k_(P2c.default.resolve(this.cwd,t));this[V8t].push(new KAu(t,r)),this[Tgn]()}[m2c](t){t.pending=!0,this[W8t]+=1;let r=this.follow?"stat":"lstat";q$a.default[r](t.absolute,(i,n)=>{t.pending=!1,this[W8t]-=1,i?this.emit("error",i):this[VAu](t,n)})}[VAu](t,r){this.statCache.set(t.absolute,r),t.stat=r,this.filter(t.path,r)||(t.ignore=!0),this[Tgn]()}[A2c](t){t.pending=!0,this[W8t]+=1,q$a.default.readdir(t.absolute,(r,i)=>{if(t.pending=!1,this[W8t]-=1,r)return this.emit("error",r);this[GAu](t,i)})}[GAu](t,r){this.readdirCache.set(t.absolute,r),t.readdir=r,this[Tgn]()}[Tgn](){if(!this[C$a]){this[C$a]=!0;for(let t=this[V8t].head;t&&this[W8t]<this.jobs;t=t.next)if(this[RCh](t.value),t.value.ignore){let r=t.next;this[V8t].removeNode(t),t.next=r}this[C$a]=!1,this[I$a]&&!this[V8t].length&&this[W8t]===0&&(this.zip?this.zip.end(TCh):(super.write(TCh),super.end()))}}get[nca](){return this[V8t]&&this[V8t].head&&this[V8t].head.value}[v2c](t){this[V8t].shift(),this[W8t]-=1,this[Tgn]()}[RCh](t){if(!t.pending){if(t.entry){t===this[nca]&&!t.piped&&this[xAu](t);return}if(!t.stat){let r=this.statCache.get(t.absolute);r?this[VAu](t,r):this[m2c](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let r=this.readdirCache.get(t.absolute);if(r?this[GAu](t,r):this[A2c](t),!t.readdir)return}if(t.entry=this[NCh](t),!t.entry){t.ignore=!0;return}t===this[nca]&&!t.piped&&this[xAu](t)}}}[g2c](t){return{onwarn:(r,i,n)=>this.warn(r,i,n),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[NCh](t){this[W8t]+=1;try{return new this[HAu](t.path,this[g2c](t)).on("end",()=>this[v2c](t)).on("error",i=>this.emit("error",i))}catch(r){this.emit("error",r)}}[O2c](){this[nca]&&this[nca].entry&&this[nca].entry.resume()}[xAu](t){t.piped=!0,t.readdir&&t.readdir.forEach(n=>{let a=t.path,o=a==="./"?"":a.replace(/\/*$/,"/");this[WAu](o+n)});let r=t.entry,i=this.zip;if(!r)throw new Error("cannot pipe without source");i?r.on("data",n=>{i.write(n)||r.pause()}):r.on("data",n=>{super.write(n)||r.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,r,i={}){Mgn(this,t,r,i)}},Rgn=class extends Y$i{sync=!0;constructor(t){super(t),this[HAu]=QAu}pause(){}resume(){}[m2c](t){let r=this.follow?"statSync":"lstatSync";this[VAu](t,q$a.default[r](t.absolute))}[A2c](t){this[GAu](t,q$a.default.readdirSync(t.absolute))}[xAu](t){let r=t.entry,i=this.zip;if(t.readdir&&t.readdir.forEach(n=>{let a=t.path,o=a==="./"?"":a.replace(/\/*$/,"/");this[WAu](o+n)}),!r)throw new Error("Cannot pipe without source");i?r.on("data",n=>{i.write(n)}):r.on("data",n=>{super[FCh](n)})}};var MyB=(e,t)=>{let r=new Rgn(e),i=new eca(e.file,{mode:e.mode||438});r.pipe(i),QCh(r,t)},DyB=(e,t)=>{let r=new Y$i(e),i=new HUi(e.file,{mode:e.mode||438});r.pipe(i);let n=new Promise((a,o)=>{i.on("error",o),i.on("close",a),r.on("error",o)});return UCh(r,t),n},QCh=(e,t)=>{t.forEach(r=>{r.charAt(0)==="@"?qgn({file:j2c.default.resolve(e.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>e.add(i)}):e.add(r)}),e.end()},UCh=async(e,t)=>{for(let r=0;r<t.length;r++){let i=String(t[r]);i.charAt(0)==="@"?await qgn({file:j2c.default.resolve(String(e.cwd),i.slice(1)),noResume:!0,onReadEntry:n=>{e.add(n)}}):e.add(i)}e.end()},ByB=(e,t)=>{let r=new Rgn(e);return QCh(r,t),r},IyB=(e,t)=>{let r=new Y$i(e);return UCh(r,t),r},w2c=cXt(MyB,DyB,ByB,IyB,(e,t)=>{if(!t?.length)throw new TypeError("no paths specified to add to archive")});var W2c=ue(require("fs"),1);var rqh=ue(require("assert"),1),V2c=require("crypto"),Lm=ue(require("fs"),1),dXt=ue(require("path"),1);var E2c=ue(require("fs"),1),CyB=process.env.__FAKE_PLATFORM__||process.platform,qyB=CyB==="win32",{O_CREAT:TyB,O_TRUNC:RyB,O_WRONLY:zyB}=E2c.default.constants,LCh=Number(process.env.__FAKE_FS_O_FILENAME__)||E2c.default.constants.UV_FS_O_FILEMAP||0,NyB=qyB&&!!LCh,FyB=512*1024,QyB=LCh|RyB|TyB|zyB,S2c=NyB?e=>e<FyB?QyB:"w":()=>"w";var T$a=ue(require("fs"),1),aca=ue(require("path"),1),M2c=(e,t,r)=>{try{return T$a.default.lchownSync(e,t,r)}catch(i){if(i?.code!=="ENOENT")throw i}},JAu=(e,t,r,i)=>{T$a.default.lchown(e,t,r,n=>{i(n&&n?.code!=="ENOENT"?n:null)})},UyB=(e,t,r,i,n)=>{if(t.isDirectory())D2c(aca.default.resolve(e,t.name),r,i,a=>{if(a)return n(a);let o=aca.default.resolve(e,t.name);JAu(o,r,i,n)});else{let a=aca.default.resolve(e,t.name);JAu(a,r,i,n)}},D2c=(e,t,r,i)=>{T$a.default.readdir(e,{withFileTypes:!0},(n,a)=>{if(n){if(n.code==="ENOENT")return i();if(n.code!=="ENOTDIR"&&n.code!=="ENOTSUP")return i(n)}if(n||!a.length)return JAu(e,t,r,i);let o=a.length,c=null,d=s=>{if(!c){if(s)return i(c=s);if(--o===0)return JAu(e,t,r,i)}};for(let s of a)UyB(e,s,t,r,d)})},LyB=(e,t,r,i)=>{t.isDirectory()&&B2c(aca.default.resolve(e,t.name),r,i),M2c(aca.default.resolve(e,t.name),r,i)},B2c=(e,t,r)=>{let i;try{i=T$a.default.readdirSync(e,{withFileTypes:!0})}catch(n){let a=n;if(a?.code==="ENOENT")return;if(a?.code==="ENOTDIR"||a?.code==="ENOTSUP")return M2c(e,t,r);throw a}for(let n of i)LyB(e,n,t,r);return M2c(e,t,r)};var EY=ue(require("fs"),1),VCh=ue(require("fs/promises"),1),N$a=ue(require("path"),1);var R$a=class extends Error{path;code;syscall="chdir";constructor(t,r){super(`${r}: Cannot cd into '${t}'`),this.path=t,this.code=r}get name(){return"CwdError"}};var z$a=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,r){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=r}get name(){return"SymlinkError"}};var VyB=(e,t)=>{EY.default.stat(e,(r,i)=>{(r||!i.isDirectory())&&(r=new R$a(e,r?.code||"ENOTDIR")),t(r)})},WCh=(e,t,r)=>{e=k_(e);let i=t.umask??18,n=t.mode|448,a=(n&i)!==0,o=t.uid,c=t.gid,d=typeof o=="number"&&typeof c=="number"&&(o!==t.processUid||c!==t.processGid),s=t.preserve,u=t.unlink,l=k_(t.cwd),p=(y,b)=>{y?r(y):b&&d?D2c(b,o,c,v=>p(v)):a?EY.default.chmod(e,n,r):r()};if(e===l)return VyB(e,p);if(s)return VCh.default.mkdir(e,{mode:n,recursive:!0}).then(y=>p(null,y??void 0),p);let h=k_(N$a.default.relative(l,e)).split("/");I2c(l,h,n,u,l,void 0,p)},I2c=(e,t,r,i,n,a,o)=>{if(!t.length)return o(null,a);let c=t.shift(),d=k_(N$a.default.resolve(e+"/"+c));EY.default.mkdir(d,r,GCh(d,t,r,i,n,a,o))},GCh=(e,t,r,i,n,a,o)=>c=>{c?EY.default.lstat(e,(d,s)=>{if(d)d.path=d.path&&k_(d.path),o(d);else if(s.isDirectory())I2c(e,t,r,i,n,a,o);else if(i)EY.default.unlink(e,u=>{if(u)return o(u);EY.default.mkdir(e,r,GCh(e,t,r,i,n,a,o))});else{if(s.isSymbolicLink())return o(new z$a(e,e+"/"+t.join("/")));o(c)}}):(a=a||e,I2c(e,t,r,i,n,a,o))},WyB=e=>{let t=!1,r;try{t=EY.default.statSync(e).isDirectory()}catch(i){r=i?.code}finally{if(!t)throw new R$a(e,r??"ENOTDIR")}},xCh=(e,t)=>{e=k_(e);let r=t.umask??18,i=t.mode|448,n=(i&r)!==0,a=t.uid,o=t.gid,c=typeof a=="number"&&typeof o=="number"&&(a!==t.processUid||o!==t.processGid),d=t.preserve,s=t.unlink,u=k_(t.cwd),l=y=>{y&&c&&B2c(y,a,o),n&&EY.default.chmodSync(e,i)};if(e===u)return WyB(u),l();if(d)return l(EY.default.mkdirSync(e,{mode:i,recursive:!0})??void 0);let _=k_(N$a.default.relative(u,e)).split("/"),h;for(let y=_.shift(),b=u;y&&(b+="/"+y);y=_.shift()){b=k_(N$a.default.resolve(b));try{EY.default.mkdirSync(b,i),h=h||b}catch{let O=EY.default.lstatSync(b);if(O.isDirectory())continue;if(s){EY.default.unlinkSync(b),EY.default.mkdirSync(b,i),h=h||b;continue}else if(O.isSymbolicLink())return new z$a(b,b+"/"+_.join("/"))}}return l(h)};var q2c=require("path");var C2c=Object.create(null),HCh=1e4,oca=new Set,KCh=e=>{oca.has(e)?oca.delete(e):C2c[e]=e.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),oca.add(e);let t=C2c[e],r=oca.size-HCh;if(r>HCh/10){for(let i of oca)if(oca.delete(i),delete C2c[i],--r<=0)break}return t};var GyB=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,xyB=GyB==="win32",HyB=e=>e.split("/").slice(0,-1).reduce((r,i)=>{let n=r[r.length-1];return n!==void 0&&(i=(0,q2c.join)(n,i)),r.push(i||"/"),r},[]),$Au=class{#e=new Map;#t=new Map;#r=new Set;reserve(t,r){t=xyB?["win32 parallelization disabled"]:t.map(n=>J$i((0,q2c.join)(KCh(n))));let i=new Set(t.map(n=>HyB(n)).reduce((n,a)=>n.concat(a)));this.#t.set(r,{dirs:i,paths:t});for(let n of t){let a=this.#e.get(n);a?a.push(r):this.#e.set(n,[r])}for(let n of i){let a=this.#e.get(n);if(!a)this.#e.set(n,[new Set([r])]);else{let o=a[a.length-1];o instanceof Set?o.add(r):a.push(new Set([r]))}}return this.#n(r)}#i(t){let r=this.#t.get(t);if(!r)throw new Error("function does not have any path reservations");return{paths:r.paths.map(i=>this.#e.get(i)),dirs:[...r.dirs].map(i=>this.#e.get(i))}}check(t){let{paths:r,dirs:i}=this.#i(t);return r.every(n=>n&&n[0]===t)&&i.every(n=>n&&n[0]instanceof Set&&n[0].has(t))}#n(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#a(t)),!0)}#a(t){if(!this.#r.has(t))return!1;let r=this.#t.get(t);if(!r)throw new Error("invalid reservation");let{paths:i,dirs:n}=r,a=new Set;for(let o of i){let c=this.#e.get(o);if(!c||c?.[0]!==t)continue;let d=c[1];if(!d){this.#e.delete(o);continue}if(c.shift(),typeof d=="function")a.add(d);else for(let s of d)a.add(s)}for(let o of n){let c=this.#e.get(o),d=c?.[0];if(!(!c||!(d instanceof Set)))if(d.size===1&&c.length===1){this.#e.delete(o);continue}else if(d.size===1){c.shift();let s=c[0];typeof s=="function"&&a.add(s)}else d.delete(t)}return this.#r.delete(t),a.forEach(o=>this.#n(o)),!0}};var JCh=Symbol("onEntry"),N2c=Symbol("checkFs"),$Ch=Symbol("checkFs2"),F2c=Symbol("isReusable"),hSe=Symbol("makeFs"),Q2c=Symbol("file"),U2c=Symbol("directory"),ZAu=Symbol("link"),YCh=Symbol("symlink"),XCh=Symbol("hardlink"),ZCh=Symbol("unsupported"),kCh=Symbol("checkPath"),T2c=Symbol("stripAbsolutePath"),X$i=Symbol("mkdir"),LW=Symbol("onError"),YAu=Symbol("pending"),eqh=Symbol("pend"),uca=Symbol("unpend"),R2c=Symbol("ended"),z2c=Symbol("maybeClose"),L2c=Symbol("skip"),F$a=Symbol("doChown"),Q$a=Symbol("uid"),U$a=Symbol("gid"),L$a=Symbol("checkedCwd"),KyB=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,V$a=KyB==="win32",JyB=1024,$yB=(e,t)=>{if(!V$a)return Lm.default.unlink(e,t);let r=e+".DELETE."+(0,V2c.randomBytes)(16).toString("hex");Lm.default.rename(e,r,i=>{if(i)return t(i);Lm.default.unlink(r,t)})},YyB=e=>{if(!V$a)return Lm.default.unlinkSync(e);let t=e+".DELETE."+(0,V2c.randomBytes)(16).toString("hex");Lm.default.renameSync(e,t),Lm.default.unlinkSync(t)},tqh=(e,t,r)=>e!==void 0&&e===e>>>0?e:t!==void 0&&t===t>>>0?t:r,sca=class extends $Ui{[R2c]=!1;[L$a]=!1;[YAu]=0;reservations=new $Au;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[R2c]=!0,this[z2c]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;t.preserveOwner===void 0&&typeof t.uid!="number"?this.preserveOwner=!!(process.getuid&&process.getuid()===0):this.preserveOwner=!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:JyB,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||V$a,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=k_(dXt.default.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:process.umask():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",r=>this[JCh](r))}warn(t,r,i={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(i.recoverable=!1),super.warn(t,r,i)}[z2c](){this[R2c]&&this[YAu]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[T2c](t,r){let i=t[r];if(!i||this.preservePaths)return!0;let n=i.split("/");if(n.includes("..")||V$a&&/^[a-z]:\.\.$/i.test(n[0]??""))return this.warn("TAR_ENTRY_ERROR",`${r} contains '..'`,{entry:t,[r]:i}),!1;let[a,o]=S$a(i);return a&&(t[r]=String(o),this.warn("TAR_ENTRY_INFO",`stripping ${a} from absolute ${r}`,{entry:t,[r]:i})),!0}[kCh](t){let r=k_(t.path),i=r.split("/");if(this.strip){if(i.length<this.strip)return!1;if(t.type==="Link"){let n=k_(String(t.linkpath)).split("/");if(n.length>=this.strip)t.linkpath=n.slice(this.strip).join("/");else return!1}i.splice(0,this.strip),t.path=i.join("/")}if(isFinite(this.maxDepth)&&i.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:r,depth:i.length,maxDepth:this.maxDepth}),!1;if(!this[T2c](t,"path")||!this[T2c](t,"linkpath"))return!1;if(dXt.default.isAbsolute(t.path)?t.absolute=k_(dXt.default.resolve(t.path)):t.absolute=k_(dXt.default.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:k_(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:n}=dXt.default.win32.parse(String(t.absolute));t.absolute=n+s2c(String(t.absolute).slice(n.length));let{root:a}=dXt.default.win32.parse(t.path);t.path=a+s2c(t.path.slice(a.length))}return!0}[JCh](t){if(!this[kCh](t))return t.resume();switch(rqh.default.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[N2c](t);case"CharacterDevice":case"BlockDevice":case"FIFO":default:return this[ZCh](t)}}[LW](t,r){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:r}),this[uca](),r.resume())}[X$i](t,r,i){WCh(k_(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:r},i)}[F$a](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[Q$a](t){return tqh(this.uid,t.uid,this.processUid)}[U$a](t){return tqh(this.gid,t.gid,this.processGid)}[Q2c](t,r){let i=typeof t.mode=="number"?t.mode&4095:this.fmode,n=new HUi(String(t.absolute),{flags:S2c(t.size),mode:i,autoClose:!1});n.on("error",d=>{n.fd&&Lm.default.close(n.fd,()=>{}),n.write=()=>!0,this[LW](d,t),r()});let a=1,o=d=>{if(d){n.fd&&Lm.default.close(n.fd,()=>{}),this[LW](d,t),r();return}--a===0&&n.fd!==void 0&&Lm.default.close(n.fd,s=>{s?this[LW](s,t):this[uca](),r()})};n.on("finish",()=>{let d=String(t.absolute),s=n.fd;if(typeof s=="number"&&t.mtime&&!this.noMtime){a++;let u=t.atime||new Date,l=t.mtime;Lm.default.futimes(s,u,l,p=>p?Lm.default.utimes(d,u,l,_=>o(_&&p)):o())}if(typeof s=="number"&&this[F$a](t)){a++;let u=this[Q$a](t),l=this[U$a](t);typeof u=="number"&&typeof l=="number"&&Lm.default.fchown(s,u,l,p=>p?Lm.default.chown(d,u,l,_=>o(_&&p)):o())}o()});let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",d=>{this[LW](d,t),r()}),t.pipe(c)),c.pipe(n)}[U2c](t,r){let i=typeof t.mode=="number"?t.mode&4095:this.dmode;this[X$i](String(t.absolute),i,n=>{if(n){this[LW](n,t),r();return}let a=1,o=()=>{--a===0&&(r(),this[uca](),t.resume())};t.mtime&&!this.noMtime&&(a++,Lm.default.utimes(String(t.absolute),t.atime||new Date,t.mtime,o)),this[F$a](t)&&(a++,Lm.default.chown(String(t.absolute),Number(this[Q$a](t)),Number(this[U$a](t)),o)),o()})}[ZCh](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[YCh](t,r){this[ZAu](t,String(t.linkpath),"symlink",r)}[XCh](t,r){let i=k_(dXt.default.resolve(this.cwd,String(t.linkpath)));this[ZAu](t,i,"link",r)}[eqh](){this[YAu]++}[uca](){this[YAu]--,this[z2c]()}[L2c](t){this[uca](),t.resume()}[F2c](t,r){return t.type==="File"&&!this.unlink&&r.isFile()&&r.nlink<=1&&!V$a}[N2c](t){this[eqh]();let r=[t.path];t.linkpath&&r.push(t.linkpath),this.reservations.reserve(r,i=>this[$Ch](t,i))}[$Ch](t,r){let i=c=>{r(c)},n=()=>{this[X$i](this.cwd,this.dmode,c=>{if(c){this[LW](c,t),i();return}this[L$a]=!0,a()})},a=()=>{if(t.absolute!==this.cwd){let c=k_(dXt.default.dirname(String(t.absolute)));if(c!==this.cwd)return this[X$i](c,this.dmode,d=>{if(d){this[LW](d,t),i();return}o()})}o()},o=()=>{Lm.default.lstat(String(t.absolute),(c,d)=>{if(d&&(this.keep||this.newer&&d.mtime>(t.mtime??d.mtime))){this[L2c](t),i();return}if(c||this[F2c](t,d))return this[hSe](null,t,i);if(d.isDirectory()){if(t.type==="Directory"){let s=this.chmod&&t.mode&&(d.mode&4095)!==t.mode,u=l=>this[hSe](l??null,t,i);return s?Lm.default.chmod(String(t.absolute),Number(t.mode),u):u()}if(t.absolute!==this.cwd)return Lm.default.rmdir(String(t.absolute),s=>this[hSe](s??null,t,i))}if(t.absolute===this.cwd)return this[hSe](null,t,i);$yB(String(t.absolute),s=>this[hSe](s??null,t,i))})};this[L$a]?a():n()}[hSe](t,r,i){if(t){this[LW](t,r),i();return}switch(r.type){case"File":case"OldFile":case"ContiguousFile":return this[Q2c](r,i);case"Link":return this[XCh](r,i);case"SymbolicLink":return this[YCh](r,i);case"Directory":case"GNUDumpDir":return this[U2c](r,i)}}[ZAu](t,r,i,n){Lm.default[i](r,String(t.absolute),a=>{a?this[LW](a,t):(this[uca](),t.resume()),n()})}},XAu=e=>{try{return[null,e()]}catch(t){return[t,null]}},W$a=class extends sca{sync=!0;[hSe](t,r){return super[hSe](t,r,()=>{})}[N2c](t){if(!this[L$a]){let a=this[X$i](this.cwd,this.dmode);if(a)return this[LW](a,t);this[L$a]=!0}if(t.absolute!==this.cwd){let a=k_(dXt.default.dirname(String(t.absolute)));if(a!==this.cwd){let o=this[X$i](a,this.dmode);if(o)return this[LW](o,t)}}let[r,i]=XAu(()=>Lm.default.lstatSync(String(t.absolute)));if(i&&(this.keep||this.newer&&i.mtime>(t.mtime??i.mtime)))return this[L2c](t);if(r||this[F2c](t,i))return this[hSe](null,t);if(i.isDirectory()){if(t.type==="Directory"){let o=this.chmod&&t.mode&&(i.mode&4095)!==t.mode,[c]=o?XAu(()=>{Lm.default.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[hSe](c,t)}let[a]=XAu(()=>Lm.default.rmdirSync(String(t.absolute)));this[hSe](a,t)}let[n]=t.absolute===this.cwd?[]:XAu(()=>YyB(String(t.absolute)));this[hSe](n,t)}[Q2c](t,r){let i=typeof t.mode=="number"?t.mode&4095:this.fmode,n=c=>{let d;try{Lm.default.closeSync(a)}catch(s){d=s}(c||d)&&this[LW](c||d,t),r()},a;try{a=Lm.default.openSync(String(t.absolute),S2c(t.size),i)}catch(c){return n(c)}let o=this.transform&&this.transform(t)||t;o!==t&&(o.on("error",c=>this[LW](c,t)),t.pipe(o)),o.on("data",c=>{try{Lm.default.writeSync(a,c,0,c.length)}catch(d){n(d)}}),o.on("end",()=>{let c=null;if(t.mtime&&!this.noMtime){let d=t.atime||new Date,s=t.mtime;try{Lm.default.futimesSync(a,d,s)}catch(u){try{Lm.default.utimesSync(String(t.absolute),d,s)}catch{c=u}}}if(this[F$a](t)){let d=this[Q$a](t),s=this[U$a](t);try{Lm.default.fchownSync(a,Number(d),Number(s))}catch(u){try{Lm.default.chownSync(String(t.absolute),Number(d),Number(s))}catch{c=c||u}}}n(c)})}[U2c](t,r){let i=typeof t.mode=="number"?t.mode&4095:this.dmode,n=this[X$i](String(t.absolute),i);if(n){this[LW](n,t),r();return}if(t.mtime&&!this.noMtime)try{Lm.default.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[F$a](t))try{Lm.default.chownSync(String(t.absolute),Number(this[Q$a](t)),Number(this[U$a](t)))}catch{}r(),t.resume()}[X$i](t,r){try{return xCh(k_(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:r})}catch(i){return i}}[ZAu](t,r,i,n){let a=`${i}Sync`;try{Lm.default[a](r,String(t.absolute)),n(),t.resume()}catch(o){return this[LW](o,t)}}};var XyB=e=>{let t=new W$a(e),r=e.file,i=W2c.default.statSync(r),n=e.maxReadSize||16*1024*1024;new hAu(r,{readSize:n,size:i.size}).pipe(t)},ZyB=(e,t)=>{let r=new sca(e),i=e.maxReadSize||16*1024*1024,n=e.file;return new Promise((o,c)=>{r.on("error",c),r.on("close",o),W2c.default.stat(n,(d,s)=>{if(d)c(d);else{let u=new Pgn(n,{readSize:i,size:s.size});u.on("error",c),u.pipe(r)}})})},G2c=cXt(XyB,ZyB,e=>new W$a(e),e=>new sca(e),(e,t)=>{t?.length&&a2c(e,t)});var SY=ue(require("fs"),1),x2c=ue(require("path"),1);var kyB=(e,t)=>{let r=new Rgn(e),i=!0,n,a;try{try{n=SY.default.openSync(e.file,"r+")}catch(d){if(d?.code==="ENOENT")n=SY.default.openSync(e.file,"w+");else throw d}let o=SY.default.fstatSync(n),c=Buffer.alloc(512);e:for(a=0;a<o.size;a+=512){for(let u=0,l=0;u<512;u+=l){if(l=SY.default.readSync(n,c,u,c.length-u,a+u),a===0&&c[0]===31&&c[1]===139)throw new Error("cannot append to compressed archives");if(!l)break e}let d=new vge(c);if(!d.cksumValid)break;let s=512*Math.ceil((d.size||0)/512);if(a+s+512>o.size)break;a+=s,e.mtimeCache&&d.mtime&&e.mtimeCache.set(String(d.path),d.mtime)}i=!1,ebB(e,r,a,n,t)}finally{if(i)try{SY.default.closeSync(n)}catch{}}},ebB=(e,t,r,i,n)=>{let a=new eca(e.file,{fd:i,start:r});t.pipe(a),rbB(t,n)},tbB=(e,t)=>{t=Array.from(t);let r=new Y$i(e),i=(a,o,c)=>{let d=(_,h)=>{_?SY.default.close(a,y=>c(_)):c(null,h)},s=0;if(o===0)return d(null,0);let u=0,l=Buffer.alloc(512),p=(_,h)=>{if(_||typeof h>"u")return d(_);if(u+=h,u<512&&h)return SY.default.read(a,l,u,l.length-u,s+u,p);if(s===0&&l[0]===31&&l[1]===139)return d(new Error("cannot append to compressed archives"));if(u<512)return d(null,s);let y=new vge(l);if(!y.cksumValid)return d(null,s);let b=512*Math.ceil((y.size??0)/512);if(s+b+512>o||(s+=b+512,s>=o))return d(null,s);e.mtimeCache&&y.mtime&&e.mtimeCache.set(String(y.path),y.mtime),u=0,SY.default.read(a,l,0,512,s,p)};SY.default.read(a,l,0,512,s,p)};return new Promise((a,o)=>{r.on("error",o);let c="r+",d=(s,u)=>{if(s&&s.code==="ENOENT"&&c==="r+")return c="w+",SY.default.open(e.file,c,d);if(s||!u)return o(s);SY.default.fstat(u,(l,p)=>{if(l)return SY.default.close(u,()=>o(l));i(u,p.size,(_,h)=>{if(_)return o(_);let y=new HUi(e.file,{fd:u,start:h});r.pipe(y),y.on("error",o),y.on("close",a),ibB(r,t)})})};SY.default.open(e.file,c,d)})},rbB=(e,t)=>{t.forEach(r=>{r.charAt(0)==="@"?qgn({file:x2c.default.resolve(e.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>e.add(i)}):e.add(r)}),e.end()},ibB=async(e,t)=>{for(let r=0;r<t.length;r++){let i=String(t[r]);i.charAt(0)==="@"?await qgn({file:x2c.default.resolve(String(e.cwd),i.slice(1)),noResume:!0,onReadEntry:n=>e.add(n)}):e.add(i)}e.end()},zgn=cXt(kyB,tbB,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(e,t)=>{if(!sCh(e))throw new TypeError("file is required");if(e.gzip||e.brotli||e.zstd||e.file.endsWith(".br")||e.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!t?.length)throw new TypeError("no paths specified to add/replace")});var nbB=cXt(zgn.syncFile,zgn.asyncFile,zgn.syncNoFile,zgn.asyncNoFile,(e,t=[])=>{zgn.validate?.(e,t),abB(e)}),abB=e=>{let t=e.filter;e.mtimeCache||(e.mtimeCache=new Map),e.filter=t?(r,i)=>t(r,i)&&!((e.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0)):(r,i)=>!((e.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0))};var sqh=ue(w4(),1);var obB=nQi();async function cqh({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:i,cliVersion:n,settings:a,loadAPIWorkspace:o}){let c,d={type:Gp.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},s=t.dependencies[e];return s==null?d={type:Gp.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${pbB(s)}`},async u=>{switch(s.type){case"version":c=await fbB({context:u,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:o});return;case"local":c=await lbB({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 lqh="dependencies";var ubB="metadata.json",sbB=".fern";function cbB(e){return qt(jr.of((0,aqh.homedir)()),xe.of(sbB),xe.of(lqh),xe.of(e.organization),xe.of(e.apiName),xe.of(e.version))}async function lbB({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:xe.of(e.path)},i);return t.logger.info("Loaded..."),o}async function fbB({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){let a=cbB(e),o=qt(a,xe.of(lqh)),c=qt(a,xe.of(ubB)),d;if(!await gi(o)||!await gi(c)){t.logger.info("Downloading manifest...");let l=await obB.definitionRegistry.get(H2c.FernFiddle.OrganizationId(e.organization),H2c.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,_=hvn(r),h=hvn(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,cca.mkdir)(o,{recursive:!0});try{await dbB({s3PreSignedReadUrl:l.body.definitionS3DownloadUrl,absolutePathToLocalOutput:o})}catch(y){t.failWithoutThrowing("Failed to download API",y);return}d=l.body,await(0,cca.writeFile)(c,JSON.stringify(d))}else d=JSON.parse((await(0,cca.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 dbB({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await iI.get(e,{responseType:"stream"}),i=await sqh.default.dir(),n=oqh.default.join(i.path,"api.tgz");await(0,uqh.pipeline)(r.data,(0,nqh.createWriteStream)(n)),await G2c({file:n,cwd:t})}function pbB(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:vt(e)}}async function fqh({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:i,settings:n,loadAPIWorkspace:a}){let o={},c={},d={};return await Promise.all(VI(t.packageMarkers).map(async([s,u])=>{if(u.contents.export==null)o[s]=u;else{let{export:l,...p}=u.contents;if(UA(p)>0)d[s]={type:Gp.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:s};else{let _=Yi(s);if(nVt(t.namedDefinitionFiles).some(y=>y!==s&&y.startsWith(_)))d[s]={type:Gp.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:_};else{let y=await cqh({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[Yi(s)]={definition:y.definition,url:typeof u.contents.export=="object"?u.contents.export.url:void 0}:d[s]=y.failure}}}})),UA(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:o,importedDefinitions:c}}var dqh=ue(require("path"),1);var K2c={};Yt(K2c,{additionalProperties:()=>bbB,default:()=>gbB,definitions:()=>vbB,properties:()=>hbB,required:()=>ybB,type:()=>_bB});var _bB="object",hbB={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"}]}},ybB=["name"],bbB=!1,vbB={"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"}]},omit:{oneOf:[{type:"boolean"},{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}},gbB={type:_bB,properties:hbB,required:ybB,additionalProperties:bbB,definitions:vbB};var J2c={};Yt(J2c,{additionalProperties:()=>AbB,default:()=>jbB,definitions:()=>PbB,properties:()=>mbB,type:()=>ObB});var ObB="object",mbB={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"}]}},AbB=!1,PbB={"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}},jbB={type:ObB,properties:mbB,additionalProperties:AbB,definitions:PbB};var $2c={};Yt($2c,{additionalProperties:()=>SbB,default:()=>DbB,definitions:()=>MbB,properties:()=>EbB,type:()=>wbB});var wbB="object",EbB={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"}]}},SbB=!1,MbB={"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"}]}},DbB={type:wbB,properties:EbB,additionalProperties:SbB,definitions:MbB};function pqh({files:e,absolutePathToDefinition:t}){let r,i={},n={},a={};for(let[o,c]of VI(e)){let d=c.contents,s=u=>{a[o]={type:Gp.JSONSCHEMA_VALIDATION,error:u}};if(o===KB){let u=lVt(d,K2c);if(u.success){let l=dI.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:l["default-url"],contents:l,rawContents:c.rawContents}}else s(u)}else if(dqh.default.basename(o)===Zb){let u=lVt(d,$2c);if(u.success){let l=dI.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=lVt(d,J2c);if(u.success){let l=dI.serialization.DefinitionFileSchema.parseOrThrow(d);i[o]={defaultUrl:void 0,contents:l,rawContents:c.rawContents,absoluteFilePath:qt(t,o)}}else s(u)}}return r==null?{didSucceed:!1,failures:{[xe.of(KB)]:{type:Gp.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:i,rootApiFile:r,packageMarkers:n}}var ySe=class extends A8t{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,_qh.default)(r??{}),n=this.fernWorkspaces[i];if(n==null){let a=t||this.context,o=qt(this.absoluteFilePath,xe.of(t1)),c=await tbc({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await tCh(o,"{yml,yaml}"),s=await rCh(d);if(!s.didSucceed)return fAu(s.failures,a.logger),a.failAndThrow();let u=pqh({files:s.files,absolutePathToDefinition:o});if(!u.didSucceed)return fAu(u.failures,a.logger),a.failAndThrow();let l=await fqh({dependenciesConfiguration:c,structuralValidationResult:u,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!l.didSucceed)return fAu(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 yY({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 H1h=require("fs/promises");var Q1h=ue(F1h(),1);async function uYa(e){return(await(0,Q1h.convertObj)(e,{})).openapi}var L1h=require("fs/promises");var U1h=require("fs/promises");async function bca({absoluteFilePathToOverrides:e,data:t,context:r,allowNullKeys:i}){let n=null;try{let a=(await(0,U1h.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 Pnc({data:t,overrides:n,allowNullKeys:i})}async function vkc({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,L1h.readFile)(t)).toString(),n=await qi.load(i);return r!=null?await bca({absoluteFilePathToOverrides:r,context:e,data:n}):n}var x1h=require("fs/promises");var yPu=require("fs/promises");var hPu=ue(require("path"),1),V1h=ue(w4(),1),gkc;async function vgB(){return gkc===void 0&&(gkc=(await V1h.default.dir({prefix:"fern-overlay-"})).path),gkc}async function W1h({absoluteFilePathToOverlay:e,absoluteFilePathToOpenAPI:t,data:r,context:i}){let n=await ggB(e,i);if(!OgB(n,i))return r;i.logger.debug(`Applying overlay "${n.info.title}" v${n.info.version}`);let a=ync({data:r,overlay:n}),o=await vgB(),c=hPu.default.basename(t),d=`${hPu.default.parse(c).name}.overlaid.json`,s=hPu.default.join(o,d);return await(0,yPu.writeFile)(s,JSON.stringify(a,null,2),"utf8"),i.logger.info(`Wrote overlaid OpenAPI spec to: ${s}`),a}async function ggB(e,t){let r;try{r=await(0,yPu.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 OgB(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 lYa=ue(Fmu(),1);var G1h=ue(Fmu(),1),sYa=ue(require("path"),1),cYa=class extends G1h.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://")||v0e(jr.of(i)))return i;if(this.absolutePathToOpenAPIOverlays!=null){let n=sYa.default.resolve(sYa.default.dirname(this.absolutePathToOpenAPIOverlays),r);if(v0e(jr.of(n)))return n}return this.absolutePathToOpenAPIOverrides!=null?sYa.default.resolve(sYa.default.dirname(this.absolutePathToOpenAPIOverrides),r):i}};async function Okc({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,absolutePathToOpenAPIOverlays:r,parsed:i}){return(i!=null?await(0,lYa.bundle)({...Qmu,doc:{source:new lYa.Source(e,"<openapi>"),parsed:i},externalRefResolver:new cYa({absolutePathToOpenAPIOverrides:t,absolutePathToOpenAPIOverlays:r})}):await(0,lYa.bundle)({...Qmu,ref:e,externalRefResolver:new cYa({absolutePathToOpenAPIOverrides:t,absolutePathToOpenAPIOverlays:r})})).bundle.parsed}function mgB(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 AgB=["examples","example",xi.EXAMPLES,AL.REDOCLY_CODE_SAMPLES_CAMEL,AL.REDOCLY_CODE_SAMPLES_KEBAB];async function fYa({context:e,absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r,absolutePathToOpenAPIOverlays:i,loadAiExamples:n=!1}){let a=await Okc({absolutePathToOpenAPI:t}),o;r!=null?o=r:typeof a=="object"&&a[xi.OPENAPI_OVERIDES_FILEPATH]!=null&&(o=qt(Yi(t),xe.of(a[xi.OPENAPI_OVERIDES_FILEPATH])));let c=a;if(o!=null&&(c=await bca({absoluteFilePathToOverrides:o,context:e,data:c,allowNullKeys:AgB})),i!=null&&(c=await W1h({absoluteFilePathToOverlay:i,absoluteFilePathToOpenAPI:t,context:e,data:c})),n){let d=qt(Yi(t),xe.of("ai_examples_override.yml"));try{let s=await(0,x1h.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=mgB(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 Okc({absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:o,absolutePathToOpenAPIOverlays:i,parsed:c}):c}var x8t=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,H1h.readFile)(a.absoluteFilepath)).toString(),c=Ef(this.absoluteFilePath,a.source.file);a.source.relativePathToDependency!=null&&(c=qt(a.source.relativePathToDependency,c));let d=a.source.type==="protobuf"?BW.protobuf({file:c}):BW.openapi({file:c});if(o.includes("openapi")||o.includes("swagger"))try{let s=await fYa({absolutePathToOpenAPI:a.absoluteFilepath,context:t,absolutePathToOpenAPIOverrides:a.absoluteFilepathToOverrides,absolutePathToOpenAPIOverlays:a.absoluteFilepathToOverlays,loadAiExamples:i});if(BZc(s)){n.push({type:"openapi",value:s,source:d,namespace:a.namespace,settings:iSe({options:a.settings})});continue}else if(p$a(s)){(!s.schemes||s.schemes.length===0)&&(s.schemes=["https"]);let u=await uYa(s);n.push({type:"openapi",value:u,source:d,namespace:a.namespace,settings:iSe({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 vkc({context:t,absoluteFilePath:a.absoluteFilepath,absoluteFilePathToOverrides:a.absoluteFilepathToOverrides});n.push({type:"asyncapi",value:s,source:d,namespace:a.namespace,settings:iSe({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 vkc({context:t,absoluteFilePath:a.absoluteFilepath,absoluteFilePathToOverrides:a.absoluteFilepathToOverrides});n.push({type:"asyncapi",value:s,source:d,namespace:a.namespace,settings:iSe({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 PgB=Qt.object({type:Qt.string(),channelId:Qt.string().optional(),messageId:Qt.string(),value:Qt.any()}),jgB=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(PgB)}),K1h=Qt.array(jgB);var bPu=class extends dl{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=K1h.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 vca=class extends ma{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 bPu({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 aYi=class extends Fm.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 QR.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 Fm.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 vPu=class extends dl{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 gca=class extends dl{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 gPu=class extends vca{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 gca({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 vPu({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],_=BM(l),h=uu(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=Nfn(uu(`${this.channelPath}_${a}`)).replace(/ /g,"");if("oneOf"in r.message){let u=new Fm.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 Fm.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=ni.named({fernFilepath:t.createFernFilepath(),name:s.typeDeclaration.name.name,typeId:s.typeDeclaration.name.typeId,displayName:void 0,default:void 0,inline:!1}),l=yL.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 aYi({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 aYi({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 aYi({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 Oca=class extends ma{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:MM.singleBaseUrl({environments:t})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var OPu=class extends Oca{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 mkc="$message.",J1h="#/channels/",$1h="#/servers/",mPu=class extends vca{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 gca({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=yL.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=BM(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 aYi({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(mkc)){this.context.errorCollector.collect({message:`Invalid location format: ${t}; expected ${mkc} prefix`,path:this.breadcrumbs});return}let n=r.substring(mkc.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($1h)){this.context.errorCollector.collect({message:`Failed to resolve server name from server ref ${r.$ref}`,path:this.breadcrumbs});return}let i=r.$ref.substring($1h.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(J1h))throw new Error(`Failed to resolve channel path from operation ${t.channel.$ref}`);return t.channel.$ref.substring(J1h.length)}};var APu=class extends Oca{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 dYa=class extends b8t{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 Fm.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 APu({context:this.context,breadcrumbs:["servers"],servers:r}).convert()}else{let r=this.context.spec.servers;t=new OPu({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 QR.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 mPu({context:this.context,breadcrumbs:["channels",t],websocketGroup:n,channel:r,channelPath:t,operations:c}).convert()}else a=new gPu({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 pYa=class extends gC{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:ni.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:ni.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:ni.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}};var rTh=ue(PPu(),1);var jPu=class extends dl{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 wPu=class extends dl{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 Y1h({globalHeaders:e,context:t}){return e.map(r=>({name:t.casingsGenerator.generateNameAndWireValue({name:r.name??"",wireValue:r.header}),valueType:r.optional?ma.OPTIONAL_STRING:ma.STRING,env:r.env,v2Examples:r.optional?void 0:SgB({header:r,context:t}),availability:void 0,docs:void 0}))}function SgB({header:e,context:t}){let r=new mF({breadcrumbs:[],context:t,schema:{type:"string"},example:e.header}),{validExample:i}=r.convert();return{userSpecifiedExamples:{},autogeneratedExamples:{globalHeaderExample:i}}}var EPu=class extends Fm.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 Fm.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 SPu=class extends Fm.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(tm.parse(this.contentType)?.isMultipart())return this.handleMultipartContent({contentType:this.contentType});if(this.isBinaryContentType())return this.handleBinaryContent({contentType:this.contentType})}isOrderedJsonOrFormContentType(){let t=tm.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=tm.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:Nm.reference({contentType:t,docs:this.description,requestBodyType:i.type,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:i.inlinedTypes??{}}:{requestBody:Nm.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:Nm.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:Nm.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:Nm.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?B1.file(sY.fileArray({key:t.name,isOptional:a,contentType:r,docs:t.docs})):B1.file(sY.file({key:t.name,isOptional:a,contentType:r,docs:t.docs})):B1.bodyProperty({...t,contentType:i?.contentType??r,style:DgB({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:Nm.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()))}},MgB={"application/json":"json"};function DgB({encoding:e}){if(e){if(e.explode)return"exploded";if(e.style==="form")return"form";if(e.contentType)return MgB[e.contentType]}}var BgB=/{([^}]+)}/g,IgB=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]),mca=class extends ma{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 sw.Get;case"post":return sw.Post;case"put":return sw.Put;case"delete":return sw.Delete;case"patch":return sw.Patch;case"head":return sw.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 EPu({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(RgB(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}}!IgB.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(BgB)].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:ma.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 SPu({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 QR.SdkMethodNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert()?.methodName,n=new QR.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?uu(this.operation.summary):uu(`${this.method}_${this.path.split("/").join("_")}`))}computeGroupNameFromTagAndOperationId(){let t=this.operation.tags?.[0],r=this.evaluateMethodNameFromOperation();if(t==null)return{method:r};let i=X1h(t),n=X1h(r);return nR(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:uu(o.join("_"))}}generateStringParameterExample({example:t}){let r=new Fm.ExampleConverter({breadcrumbs:this.breadcrumbs,context:this.context,schema:{type:"string"},example:t}),{validExample:i}=r.convert();return i}};function X1h(e){let t=CgB(e)?qgB(e):TgB(e);return t=t.map(r=>r.toLowerCase()),t=t0e(t),t}function CgB(e){return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)}function qgB(e){return e.split(/(?=[A-Z])/)}function TgB(e){return e.split(/[^a-zA-Z0-9]+/)}function RgB(e){return e?.header!=null}var Aca=class extends mca{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=pF.inlinedPayload({name:d.name,extends:d.extends,properties:d.properties});else if(d.type==="reference")s=pF.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=pF.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 jkc=ue(PPu(),1);var Z1h=["get","post","put","delete","patch","head"];var MPu=class extends dl{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 zgB=Qt.object({cursor:Qt.string(),next_cursor:Qt.string(),results:Qt.string()}),NgB=Qt.object({offset:Qt.string(),results:Qt.string(),step:Qt.string().optional(),"has-next-page":Qt.string().optional()}),Akc=Qt.union([Qt.boolean(),zgB,NgB]);var Pkc="$request.",DPu="$response.",BPu=class extends dl{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=Akc.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=Akc.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:gC.maybeTrimPrefix(r.cursor,Pkc),nextCursor:gC.maybeTrimPrefix(r.next_cursor,DPu),results:gC.maybeTrimPrefix(r.results,DPu)};let i=t;return{type:"offset",offset:gC.maybeTrimPrefix(i.offset,Pkc),results:gC.maybeTrimPrefix(i.results,DPu),step:i.step!=null?gC.maybeTrimPrefix(i.step,Pkc):void 0,hasNextPage:i["has-next-page"]!=null?gC.maybeTrimPrefix(i["has-next-page"],DPu):void 0}}};var FgB="$request.",QgB=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()}),UgB=Qt.union([Qt.boolean(),QgB]),IPu=class extends dl{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=UgB.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:gC.maybeTrimPrefix(r.data["stream-condition"],FgB),responseStream:r.data["response-stream"],response:r.data.response}}};var CPu=class extends dl{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 TPu=require("fs"),k1h=require("path");function LgB(e){return bl(e)&&typeof e.$ref=="string"}function VgB(e,t){if(e!=null){if(typeof e=="string")return e;if(LgB(e)){let r=(0,k1h.resolve)(t??process.cwd(),e.$ref);if((0,TPu.existsSync)(r))try{return(0,TPu.readFileSync)(r,"utf-8")}catch{return}}}}var qPu=class extends dl{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=bl(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(!bl(d))continue;let s=d,u=s.lang,l=s.label,p=s.source;if(typeof u!="string")continue;let _=VgB(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 zPu=require("fs"),eTh=require("path");function WgB(e){return bl(e)&&typeof e.$ref=="string"}function GgB(e,t){if(e!=null){if(typeof e=="string")return e;if(WgB(e)){let r=(0,eTh.resolve)(t??process.cwd(),e.$ref);if((0,zPu.existsSync)(r))try{return(0,zPu.readFileSync)(r,"utf-8")}catch{return}}}}function xgB(e,t){if(!Array.isArray(e))return[];let r=[];for(let i of e){if(!bl(i))continue;let a=GgB(i.code,t);a!=null&&r.push({...i,code:a})}return r}var RPu=class extends dl{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(!bl(a))return a;let c=a["code-samples"];if(c!=null){let d=xgB(c,this.baseDir);return{...a,"code-samples":d}}return a}).filter(a=>{let o=dI.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 _Ya=class extends dl{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 hYa=class extends Fm.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:Sd.json(_C.response({responseBodyType:r.type,docs:this.responseBody.description,v2Examples:r.schema?.typeDeclaration.v2Examples})),streamResponseBody:Sd.streaming(fI.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:Sd.streaming(fI.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:Sd.streaming(fI.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:Sd.json(_C.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:Sd.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:Sd.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:Sd.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 tm.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=ma.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=ni.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=ni.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 mF({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 NPu=class extends Fm.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:ni.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:tTh(`${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,mediaTypeObject:n});if(a.type.type==="named")return this.constructErrorConverterOutput({errorName:r,errorId:o,fernFilepath:a.type.fernFilepath,convertedSchema:a,mediaTypeObject:n})}}constructErrorConverterOutput({errorName:t,errorId:r,fernFilepath:i,convertedSchema:n,mediaTypeObject:a}){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:this.convertErrorExamples({mediaTypeObject:a}),headers:this.convertResponseHeaders()}}convertErrorExamples({mediaTypeObject:t}){let r=this.context.getNamedExamplesFromMediaTypeObject({mediaTypeObject:t,breadcrumbs:this.breadcrumbs,defaultExampleName:`${[...this.group,this.method].join("_")}_error_example`});if(r.length===0)return;let i=new Set,n={};for(let[a,o]of r){let c=this.context.resolveExampleWithValue(o),d=this.context.resolveExampleRecursively({example:o,breadcrumbs:this.breadcrumbs}),s=this.getIdForErrorExample({key:a,example:d,usedExampleNames:i});i.add(s),c!=null&&(n[s]=c)}return Object.keys(n).length>0?n:void 0}getIdForErrorExample({key:t,example:r,usedExampleNames:i}){if(this.context.isExampleWithSummary(r)){let n=r.summary;if(!i.has(n))return n;let a=`${n} (${t})`;return i.has(a)?t:a}return t}getErrorNameForStatusCode(t,r){if(r){if(t===400)return"ClientRequestError";if(t===500)return"ServerError"}return Lpu[t]}getErrorIdFromErrorName(t){return this.context.enableUniqueErrorsPerEndpoint?tTh(`${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=ma.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=ni.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=ni.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 mF({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 tTh(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}var FPu=class e extends mca{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($=>$.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($=>$.error),O=BM(this.path),m=this.getEndpointBaseUrl(),g=this.getEndpointBaseUrls(),A=this.convertExamples({httpPath:O,httpMethod:t,baseUrl:m}),j=new Set(this.operation.security?.flatMap($=>Object.keys($))??[]),M=this.authSchemeToHeaders(Array.from(j));M.length>0&&a.push(...M);for(let $ of y){let de=$.error,be=$.errorType,W=de.error.errorId,x=$.examples;b[W]={name:de.error,displayName:$.displayName,discriminantValue:{name:de.error.name,wireValue:W},type:be,statusCode:$.statusCode,isWildcardStatusCode:$.isWildcardStatusCode,docs:de.docs,examples:[],v2Examples:{userSpecifiedExamples:x??{},autogeneratedExamples:{}},headers:$.headers}}let w=this.context.getAudiences({operation:this.operation,breadcrumbs:this.breadcrumbs})??[],B=new _Ya({context:this.context,breadcrumbs:this.breadcrumbs,document:this.context.spec}).convert(),q=new _Ya({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(($,de,be)=>de===be.findIndex(W=>W.name.wireValue===$.name.wireValue)),responseHeaders:p?.responseHeaders,sdkRequest:void 0,errors:v,auth:this.computeEndpointAuth(),security:this.computeEndpointSecurity(),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:gW.openapi(),audiences:w,retries:void 0,apiPlayground:q},N=this.context.namespace!=null?[this.context.namespace]:[],H=r?.map($=>uu($));return N.push(...H??[]),{audiences:w,group:r,groupDisplayName:n,errors:b,endpoint:{...z,id:`endpoint_${N.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_${N.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 hYa({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 NPu({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 hYa({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()}computeEndpointSecurity(){return this.operation.security!=null&&this.operation.security.length===0?[]:this.context.authOverrides?.auth!=null?this.getDefaultSecurityFromAuthOverrides():this.operation.security??this.context.spec.security}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"){let r={};return r[t]=[],[r]}if(typeof t=="object"&&"any"in t){let r=t.any;if(Array.isArray(r))return r.map(i=>{let n=typeof i=="string"?i:i.scheme,a={};return a[n]=[],a})}}authSchemeToHeaders(t){let r=[];for(let i of t){let n=this.idToAuthScheme?.[i];if(n==null)continue;let a={valueType:ma.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 RPu({context:this.context,breadcrumbs:this.breadcrumbs,operation:this.operation,baseDir:this.context.documentBaseDir}).convert()??[],c=new qPu({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 QR.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 nge.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 nge.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 QPu=class extends ma{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 Z1h){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 IPu({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 CPu({breadcrumbs:i,operation:t,context:n}).convert()?new Aca({context:this.context,breadcrumbs:i,operation:t,method:jkc.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path}).convert():void 0}tryParseAsHttpEndpoint({operation:t,method:r,operationBreadcrumbs:i,streamingExtension:n}){new BPu({breadcrumbs:i,operation:t,document:this.context.spec,context:this.context}).convert()!=null;let d=new MPu({breadcrumbs:i,operation:t,context:this.context}).convert();return new FPu({context:this.context,breadcrumbs:i,operation:t,method:jkc.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path,idempotent:d,idToAuthScheme:this.idToAuthScheme,topLevelServers:this.topLevelServers,streamingExtension:n}).convert()}};var UPu=class extends ma{securityScheme;schemeId;constructor({context:t,breadcrumbs:r,securityScheme:i,schemeId:n}){super({context:t,breadcrumbs:r}),this.securityScheme=i,this.schemeId=n}getExtension(t){return this.securityScheme[t]}convert(){switch(this.securityScheme.type){case"http":{if(this.securityScheme.scheme?.toLowerCase()==="bearer"){let t=this.getExtension("x-fern-bearer"),r=t?.name??"token",i=t?.env;return PA.bearer({key:this.schemeId,token:this.context.casingsGenerator.generateName(r),tokenEnvVar:i,docs:this.securityScheme.description})}if(this.securityScheme.scheme?.toLowerCase()==="basic"){let t=this.getExtension("x-fern-basic"),r=t?.username?.name??"username",i=t?.password?.name??"password",n=t?.username?.env,a=t?.password?.env;return PA.basic({key:this.schemeId,username:this.context.casingsGenerator.generateName(r),password:this.context.casingsGenerator.generateName(i),usernameEnvVar:n,passwordEnvVar:a,usernameOmit:!1,passwordOmit:!1,docs:this.securityScheme.description})}break}case"apiKey":{if(this.securityScheme.in==="header"){let t=this.getExtension("x-fern-header"),r=t?.name??"apiKey",i=t?.env,n=t?.prefix;return PA.header({key:this.schemeId,name:{name:this.context.casingsGenerator.generateName(r),wireValue:this.securityScheme.name},valueType:ma.OPTIONAL_STRING,prefix:n,headerEnvVar:i,docs:this.securityScheme.description})}break}case"oauth2":return PA.bearer({key:this.schemeId,token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description})}}};var yYa=class extends b8t{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 wPu({breadcrumbs:["x-fern-global-headers"],document:this.context.spec,context:this.context}).convert();if(r!=null){let i=Y1h({globalHeaders:r,context:this.context});this.addGlobalHeadersToIr(i),this.context.setGlobalHeaders(i)}}convertBasePath(){let r=new jPu({breadcrumbs:["x-fern-base-path"],document:this.context.spec,context:this.context}).convert();r!=null&&(this.ir.basePath=BM(r))}convertSecuritySchemes(){if(this.context.authOverrides){let r=fxc({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 UPu({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=nKa({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 nge({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 Fm.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 Aca({context:this.context,breadcrumbs:["webhooks",r],operation:t.post,method:rTh.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 QPu({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 LPu=class extends dl{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 e4i=class extends gC{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 Fm.SchemaConverters.SchemaConverter({context:this,breadcrumbs:r??[],schema:o.value,id:a}).convert();u!=null&&(d={[a]:u.convertedSchema})}return{ok:!0,reference:ni.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 LPu({breadcrumbs:["tags",r.name],tag:r,context:this}).convert()?.displayName??r.name;this.tagToDisplayName[r.name]=n}return this.tagToDisplayName[t]??t}};var HgB=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()}),KgB=HgB.extend({name:Qt.string(),in:Qt.string()}),JgB=Qt.array(KgB),VPu=class extends dl{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 JgB.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 WPu=class extends ma{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=BM(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 Fm.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 Fm.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?Nm.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:Sd.json(_C.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:gW.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 nge.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 GPu=class extends Fm.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 Fm.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 bYa=class extends b8t{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 nge({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 Fm.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 VPu({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 GPu({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 WPu({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 vYa=class extends gC{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:ni.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}};var HRh=require("fs/promises");var iTh={[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,Z0(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 $gB=["go","ruby"];function KPu({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let o=nOB(n),c=p=>({unsafeName:p,safeName:YgB({name:p,keywords:XgB({generationLanguage:e,keywords:t})})}),d=uu(o),s=Z0(d),u=zfn(o),l=Cfn(d);return r&&(!eOB(l)&&(e==null||$gB.includes(e))&&(d=l.map((p,_)=>{if(_>0){let h=xPu(p);if(h!=null)return h;if(HPu(p))return p.toUpperCase()}return p}).join(""),s=Z0(l.map((p,_)=>{let h=xPu(p);return h??(HPu(p)?p.toUpperCase():_===0?Z0(p):p)}).join(""))),u=o.split(" ").map(p=>p.split(/(\d+)/).map(zfn).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 YgB({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":kgB(e)?"_"+e:e}function XgB({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return iTh[e]}var ZgB=/^[0-9]/;function kgB(e){return ZgB.test(e)}function eOB(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=xPu(i)!=null||HPu(i),a=xPu(t)!=null||HPu(t);return n&&a})}function xPu(e){return rOB.get(e.toUpperCase())}function HPu(e){return tOB.has(e.toUpperCase())}var tOB=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"]),rOB=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]),iOB=[[/\[\]/g,"Array"]];function nOB(e){return iOB.reduce((t,[r,i])=>t.replace(r,i),e)}var nTh=require("fs/promises");async function wkc({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let i=(await(0,nTh.readFile)(t)).toString(),n;try{n=JSON.parse(i)}catch{n=qi.load(i)}return r!=null?await bca({absoluteFilePathToOverrides:r,context:e,data:n}):n}var CRh=ue(IRh(),1);function uYi(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,CRh.default)(t,r,o)}async function vy(e,t,r=[],{doNotPipeOutput:i=!1,secrets:n=[],substitutions:a={},...o}={}){let c=uYi(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 sYi(e,{logger:t,...r}={}){return(i,n)=>vy(t,e,i,{...r,...n})}var Dx=require("fs/promises"),VRh=ue(require("path"),1),Wkc=ue(w4(),1);var XmB=ue(w4(),1);function qRh(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 PYa,Vkc;async function Wgn(e,t,r=5e3){return PYa!==void 0?PYa:(Vkc==null&&(Vkc=ZmB(e,t,r)),Vkc)}async function ZmB(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)}),PYa=!1,t.debug("Network check succeeded - not in air-gapped mode"),!1}catch(i){let n=i instanceof Error?i.message:String(i);return qRh(n)?(PYa=!0,t.debug(`Network check failed - entering air-gapped mode: ${n}`),!0):(PYa=!1,!1)}}var TRh="buf.gen.yaml",kmB="output",RRh=`${kmB}/ir.json`,zRh="protoc-gen-fern",NRh=`version: v1
|
|
1535
1535
|
`,FRh=`version: v2
|
|
1536
1536
|
`,tju=e=>{let t=`version: v1
|
|
1537
1537
|
`;if(e.length>0){t+=`deps:
|
|
@@ -1946,7 +1946,7 @@ The generated documentation will replace this placeholder page with complete API
|
|
|
1946
1946
|
- Class and function references
|
|
1947
1947
|
- Type annotations and signatures
|
|
1948
1948
|
- Docstring content
|
|
1949
|
-
`;return this.parsedDocsConfig.pages[xe.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=Nt.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?Nt.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 $fn(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 uOn(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:Nt.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):zG.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(ss),remote:this.parsedDocsConfig.js.remote?.map(t=>({...t,url:zG.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 $fn(t,"type")._visit({filepath:({value:r})=>({type:"fileId",value:this.getFileId(r)}),url:({value:r})=>({type:"url",value:zG.Url(r)}),_other:()=>this.taskContext.failAndThrow("Invalid metadata configuration")})}};function UEB(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:`${zx(o)}/${i}/${n}/blob/${a}/fern/${t}?plain=1`,launch:r}}function LEB(e){switch(e){case"beta":return Nt.V1.NavigationV1Availability.Beta;case"deprecated":return Nt.V1.NavigationV1Availability.Deprecated;case"ga":return Nt.V1.NavigationV1Availability.GenerallyAvailable;case"stable":return Nt.V1.NavigationV1Availability.Stable;default:vt(e)}}async function qL(e){return(await Promise.all(e.apiWorkspaces.map(async t=>t instanceof jS?t:null))).filter(ss)}async function Dtl(e,t,r){if(e instanceof ySe){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 Rx({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 sc={};Yt(sc,{AlgoliaSearchIndex:()=>FUh,ApiDefinitionId:()=>a4h,ApiId:()=>c4h,Availability:()=>j4h,DocsConfigId:()=>l4h,EndpointId:()=>d4h,EndpointPathLiteral:()=>A4h,EnvironmentId:()=>f4h,FileId:()=>b4h,HttpMethod:()=>P4h,IndexSegmentId:()=>QUh,JqString:()=>g4h,OrgId:()=>u4h,PageId:()=>y4h,PayloadLocation:()=>X4h,PropertyKey:()=>O4h,PullRequestState:()=>H4h,RoleId:()=>m4h,TokenId:()=>s4h,TypeId:()=>h4h,Url:()=>v4h,VersionId:()=>o4h,WebSocketId:()=>p4h,WebhookId:()=>_4h,algolia:()=>Btl,api:()=>Utl,commons:()=>Ltl,diff:()=>w4h,docs:()=>Ytl,generators:()=>Ztl,git:()=>ktl,navigation:()=>rrl,sdks:()=>nrl,snippets:()=>$4h,snippetsFactory:()=>Y4h,templates:()=>arl,tokens:()=>Z4h});var Btl={};Yt(Btl,{AlgoliaSearchIndex:()=>FUh,IndexSegmentId:()=>QUh});function FUh(e){return e}function QUh(e){return e}var Utl={};Yt(Utl,{latest:()=>qtl,v1:()=>Qtl});var qtl={};Yt(qtl,{AuthSchemeId:()=>UUh,WebhookHttpMethod:()=>GUh,auth:()=>Itl,commons:()=>LUh,endpoint:()=>VUh,type_:()=>WUh,webhook:()=>Ctl,websocket:()=>xUh});var Itl={};Yt(Itl,{AuthSchemeId:()=>UUh});function UUh(e){return e}var LUh={};var VUh={};var WUh={};var Ctl={};Yt(Ctl,{WebhookHttpMethod:()=>GUh});var GUh={Get:"GET",Post:"POST"};var xUh={};var Qtl={};Yt(Qtl,{SubpackageId:()=>t4h,WebSocketMessageId:()=>r4h,WebSocketMessageOrigin:()=>i4h,WebhookHttpMethod:()=>n4h,commons:()=>Ftl,db:()=>Ttl,read:()=>ztl,register:()=>Ntl});var Ttl={};Yt(Ttl,{endpoint:()=>HUh});var HUh={};var ztl={};Yt(ztl,{SupportedLanguage:()=>KUh,endpoint:()=>Rtl,type_:()=>JUh,webhook:()=>$Uh,websocket:()=>YUh});var Rtl={};Yt(Rtl,{SupportedLanguage:()=>KUh});var KUh={Curl:"curl",Python:"python",Javascript:"javascript",Js:"js",Node:"node",Typescript:"typescript",Ts:"ts",Go:"go",Ruby:"ruby",Csharp:"csharp"};var JUh={};var $Uh={};var YUh={};var Ntl={};Yt(Ntl,{SourceId:()=>VEB,endpoint:()=>XUh,type_:()=>ZUh,webhook:()=>kUh,websocket:()=>e4h});var XUh={};var ZUh={};var kUh={};var e4h={};function VEB(e){return e}var Ftl={};Yt(Ftl,{SubpackageId:()=>t4h,WebSocketMessageId:()=>r4h,WebSocketMessageOrigin:()=>i4h,WebhookHttpMethod:()=>n4h});function t4h(e){return e}function r4h(e){return e}var i4h={Client:"client",Server:"server"};var n4h={Get:"GET",Post:"POST"};var Ltl={};Yt(Ltl,{ApiDefinitionId:()=>a4h,ApiId:()=>c4h,Availability:()=>j4h,DocsConfigId:()=>l4h,EndpointId:()=>d4h,EndpointPathLiteral:()=>A4h,EnvironmentId:()=>f4h,FileId:()=>b4h,HttpMethod:()=>P4h,JqString:()=>g4h,OrgId:()=>u4h,PageId:()=>y4h,PropertyKey:()=>O4h,RoleId:()=>m4h,TokenId:()=>s4h,TypeId:()=>h4h,Url:()=>v4h,VersionId:()=>o4h,WebSocketId:()=>p4h,WebhookId:()=>_4h});function a4h(e){return e}function o4h(e){return e}function u4h(e){return e}function s4h(e){return e}function c4h(e){return e}function l4h(e){return e}function f4h(e){return e}function d4h(e){return e}function p4h(e){return e}function _4h(e){return e}function h4h(e){return e}function y4h(e){return e}function b4h(e){return e}function v4h(e){return e}function g4h(e){return e}function O4h(e){return e}function m4h(e){return e}function A4h(e){return e}var P4h={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE"};var j4h={Stable:"Stable",GenerallyAvailable:"GenerallyAvailable",InDevelopment:"InDevelopment",PreRelease:"PreRelease",Deprecated:"Deprecated",Beta:"Beta"};var w4h={};var Ytl={};Yt(Ytl,{latest:()=>Gtl,v1:()=>Jtl,v2:()=>$tl});var Gtl={};Yt(Gtl,{Layout:()=>S4h,MdxEngine:()=>WEB,TwitterCardSetting:()=>M4h,commons:()=>E4h,frontmatter:()=>Vtl,seo:()=>Wtl});var WEB={NextMdxRemote:"next-mdx-remote",MdxBundler:"mdx-bundler"};var E4h={};var Vtl={};Yt(Vtl,{Layout:()=>S4h});var S4h={Guide:"guide",Overview:"overview",Reference:"reference",Page:"page",Custom:"custom"};var Wtl={};Yt(Wtl,{TwitterCardSetting:()=>M4h});var M4h={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var Jtl={};Yt(Jtl,{commons:()=>Ktl,db:()=>D4h,read:()=>B4h,write:()=>xtl});var D4h={};var B4h={};var xtl={};Yt(xtl,{DocsRegistrationId:()=>xEB,FilePath:()=>GEB});function GEB(e){return e}function xEB(e){return e}var Ktl={};Yt(Ktl,{ContentAlignment:()=>T4h,FontDisplay:()=>Q4h,FontStyle:()=>F4h,HeaderPosition:()=>R4h,JsScriptStrategy:()=>N4h,ProgrammingLanguage:()=>I4h,SearchbarPlacement:()=>C4h,TabsPlacement:()=>q4h,TwitterCardSetting:()=>z4h,commons:()=>Htl});var Htl={};Yt(Htl,{ContentAlignment:()=>T4h,FontDisplay:()=>Q4h,FontStyle:()=>F4h,HeaderPosition:()=>R4h,JsScriptStrategy:()=>N4h,ProgrammingLanguage:()=>I4h,SearchbarPlacement:()=>C4h,TabsPlacement:()=>q4h,TwitterCardSetting:()=>z4h});var I4h={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 C4h={Header:"HEADER",HeaderTabs:"HEADER_TABS",Sidebar:"SIDEBAR"};var q4h={Header:"HEADER",Sidebar:"SIDEBAR"};var T4h={Center:"CENTER",Left:"LEFT"};var R4h={Fixed:"FIXED",Absolute:"ABSOLUTE"};var z4h={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var N4h={BeforeInteractive:"beforeInteractive",AfterInteractive:"afterInteractive",LazyOnload:"lazyOnload"};var F4h={Normal:"normal",Italic:"italic"};var Q4h={Auto:"auto",Block:"block",Swap:"swap",Fallback:"fallback",Optional:"optional"};var $tl={};Yt($tl,{read:()=>U4h,write:()=>L4h});var U4h={};var L4h={};var Ztl={};Yt(Ztl,{ChangelogEntryType:()=>W4h,GeneratorId:()=>HEB,GeneratorLanguage:()=>KEB,ReleaseType:()=>G4h,cli:()=>V4h,commons:()=>Xtl,versions:()=>x4h});var V4h={};var Xtl={};Yt(Xtl,{ChangelogEntryType:()=>W4h,ReleaseType:()=>G4h});var W4h={Fix:"fix",Feat:"feat",Chore:"chore",Break:"break",Internal:"internal"};var G4h={Ga:"GA",Rc:"RC"};var x4h={};function HEB(e){return e}var KEB={Python:"python",Go:"go",Java:"java",Typescript:"typescript",Ruby:"ruby",Csharp:"csharp",Php:"php",Swift:"swift",Rust:"rust"};var ktl={};Yt(ktl,{PullRequestState:()=>H4h});var H4h={Open:"open",Closed:"closed",Merged:"merged"};var rrl={};Yt(rrl,{latest:()=>erl,v1:()=>trl});var erl={};Yt(erl,{NodeId:()=>YEB,ProductId:()=>XEB,Slug:()=>JEB,TabId:()=>$EB});function JEB(e){return e}function $EB(e){return e}function YEB(e){return e}function XEB(e){return e}var trl={};Yt(trl,{NavigationV1Availability:()=>rSB,NodeId:()=>eSB,ProductId:()=>tSB,Slug:()=>ZEB,TabId:()=>kEB});function ZEB(e){return e}function kEB(e){return e}function eSB(e){return e}function tSB(e){return e}var rSB={Stable:"stable",GenerallyAvailable:"generally-available",InDevelopment:"in-development",PreRelease:"pre-release",Beta:"beta",Deprecated:"deprecated"};var nrl={};Yt(nrl,{Language:()=>K4h,VersionBump:()=>J4h,versions:()=>irl});var irl={};Yt(irl,{Language:()=>K4h,VersionBump:()=>J4h});var K4h={Go:"Go",TypeScript:"TypeScript",Java:"Java",Python:"Python",Csharp:"Csharp",Ruby:"Ruby"};var J4h={Major:"MAJOR",Minor:"MINOR",Patch:"PATCH"};var $4h={};var Y4h={};var arl={};Yt(arl,{PayloadLocation:()=>X4h});var X4h={Body:"BODY",Query:"QUERY",Path:"PATH",Headers:"HEADERS",Relative:"RELATIVE",Auth:"AUTH"};var Z4h={};var j0u=class{warnings=[];errors=[];error(t){this.errors.push(t)}warning(t){this.warnings.push(t)}};function Ko(e){return e!=null}var eLh=ue(A4a(),1);var k4h=["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 EXt(e){return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e=e.replace(/_/g," "),e=e.replace(/-/g," "),(0,eLh.default)(e,{special:k4h}).replace(/V\s(\d)/g,"V$1")}function tLh({endpoints:e,webhookEndpoints:t}){let r={};return Object.values({...e,...t}).forEach(i=>{let n=[];i.namespace?.forEach(a=>{let o=[...n,a],c=sc.api.v1.SubpackageId(o.join("."));r[c]={id:c,name:a,displayName:EXt(a)},n.push(a)})}),r}var w0u=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 rLh(e){return`#/${e.map(t=>t.replaceAll(/~/g,"~0").replaceAll(/\//g,"~1")).join("/")}`}var Ao=class extends w0u{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 ${rLh(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 Ao{},qY=class extends qC{seenSchemas;constructor(t){super(t),this.seenSchemas=new Set(t.seenSchemas)}};var iLh="x-fern-base-path",nLh="x-fern-availability",E0u="x-fern-sdk-group-name",aLh="x-fern-global-headers",oLh="x-fern-sdk-method-name";var uLh="x-fern-webhook",sLh="x-fern-access-token-locator",cLh="x-fern-basic",lLh="x-fern-username-variable-name",fLh="x-fern-password-variable-name",dLh="x-fern-bearer",pLh="x-fern-token-variable-name",_Lh="x-fern-header",hLh="x-fern-header-variable-name",yLh="x-fern-server-name",bLh="x-fern-examples";var S0u=class extends Ao{serverName;constructor(t){super(t),this.safeParse()}parse(){this.serverName=this.input[yLh]}convert(){if(this.serverName!=null)return this.serverName}};var M0u=class extends Ao{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 S0u({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:sc.EnvironmentId(t),baseUrl:this.url}}};function mYi(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 M0u({input:c,context:r,accessPath:i,pathId:["servers",`${d}`]}));return[...n,...o]}function tg(e){return typeof e=="object"&&Ko(e)&&"$ref"in e&&typeof e.$ref=="string"}function TL(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:(tg(n)&&(n=TL(n,t,r)),n)}function D0u(e,t){let r=t.components?.securitySchemes?.[e];if(r!=null)return tg(r)?TL(r,t,void 0):r}var NLh=ue(vM());var B0u=class extends Ao{username;password;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[cLh];this.username=t?.username,this.password=t?.password}convert(){return{username:this.username,password:this.password}}};var I0u=class extends Ao{passwordVariableName;constructor(t){super(t),this.safeParse()}parse(){this.passwordVariableName=this.input[fLh]}convert(){return this.passwordVariableName}};var C0u=class extends Ao{usernameVariableName;constructor(t){super(t),this.safeParse()}parse(){this.usernameVariableName=this.input[lLh]}convert(){return this.usernameVariableName}};var q0u=class extends Ao{bearerTokenVariableName;bearerTokenEnvVar;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[dLh];this.bearerTokenVariableName=t?.name,this.bearerTokenEnvVar=t?.env}convert(){return{tokenVariableName:this.bearerTokenVariableName,tokenEnvVar:this.bearerTokenEnvVar}}};var T0u=class extends Ao{tokenVariableName;constructor(t){super(t),this.safeParse()}parse(){this.tokenVariableName=this.input[pLh]}convert(){return this.tokenVariableName}};function vLh(e){return typeof e=="object"&&e!=null&&"in"in e&&e.in==="header"}var gLh="x-bearer-format",OLh="x-code-samples",mLh="x-codeSamples";var R0u=class extends Ao{bearerFormat;constructor(t){super(t),this.safeParse()}parse(){this.bearerFormat=this.input[gLh]}convert(){return this.bearerFormat}};var z0u=class extends Ao{headerVariableName;headerEnvVar;headerPrefix;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[_Lh];this.headerVariableName=t?.name,this.headerEnvVar=t?.env,this.headerPrefix=t?.prefix}convert(){return{name:this.headerVariableName,env:this.headerEnvVar,prefix:this.headerPrefix}}};var N0u=class extends Ao{headerVariableName;constructor(t){super(t),this.safeParse()}parse(){this.headerVariableName=this.input[hLh]}convert(){return this.headerVariableName}};function ALh(e){return e.type==="apiKey"}var ela=class extends Ao{headerName;headerBearerFormatNode;headerAuthNode;headerVariableNameNode;constructor(t){super(t),this.safeParse()}parse(){ALh(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 N0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerBearerFormatNode=new R0u({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 F0u(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function tla(e){return typeof e=="string"||typeof e=="symbol"?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function sOn(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(sOn).join(",");let t=String(e);return t==="0"&&Object.is(Number(e),-0)?"-0":t}function Q0u(e){if(Array.isArray(e))return e.map(tla);if(typeof e=="symbol")return[e];e=sOn(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 ZYa(e,t,r){if(e==null)return r;switch(typeof t){case"string":{if(T3o(t))return r;let i=e[t];return i===void 0?F0u(t)?ZYa(e,Q0u(t),r):r:i}case"number":case"symbol":{typeof t=="number"&&(t=tla(t));let i=e[t];return i===void 0?r:i}default:{if(Array.isArray(t))return iSB(e,t,r);if(Object.is(t?.valueOf(),-0)?t="-0":t=String(t),T3o(t))return r;let i=e[t];return i===void 0?r:i}}}function iSB(e,t,r){if(t.length===0)return r;let i=e;for(let n=0;n<t.length;n++){if(i==null||T3o(t[n]))return r;i=i[t[n]]}return i===void 0?r:i}function PLh(e){return function(t){return ZYa(t,e)}}function jLh(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function orl(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function srl(e,t,r){return typeof r!="function"?srl(e,t,()=>{}):url(e,t,function i(n,a,o,c,d,s){let u=r(n,a,o,c,d,s);return u!==void 0?!!u:url(n,a,i,s)},new Map)}function url(e,t,r,i){if(t===e)return!0;switch(typeof t){case"object":return nSB(e,t,r,i);case"function":return Object.keys(t).length>0?url(e,{...t},r,i):orl(e,t);default:return jLh(e)?typeof t=="string"?t==="":!0:orl(e,t)}}function nSB(e,t,r,i){if(t==null)return!0;if(Array.isArray(t))return wLh(e,t,r,i);if(t instanceof Map)return aSB(e,t,r,i);if(t instanceof Set)return oSB(e,t,r,i);let n=Object.keys(t);if(e==null||T3a(e))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(!T3a(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 aSB(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 wLh(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 oSB(e,t,r,i){return t.size===0?!0:e instanceof Set?wLh([...e],[...t],r,i):!1}function U0u(e,t){return srl(e,t,()=>{})}function ELh(e){return e=_xp(e),t=>U0u(t,e)}function SLh(e,t){return pxp(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 I3o:case B3o:case C3o:{let c=new e.constructor(e?.valueOf());return SVt(c,e),c}case q3o:{let c={};return SVt(c,e),c.length=e.length,c[Symbol.iterator]=e[Symbol.iterator],c}default:return}})}function MLh(e){return SLh(e)}var uSB=/^(?:0|[1-9]\d*)$/;function DLh(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 uSB.test(e)}}function BLh(e){return e!==null&&typeof e=="object"&&D3o(e)==="[object Arguments]"}function ILh(e,t){let r;if(Array.isArray(t)?r=t:typeof t=="string"&&F0u(t)&&e?.[t]==null?r=Q0u(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)||BLh(i))&&DLh(a)&&a<i.length))return!1;i=i[a]}return!0}function CLh(e,t){switch(typeof e){case"object":{Object.is(e?.valueOf(),-0)&&(e="-0");break}case"number":{e=tla(e);break}}return t=MLh(t),function(r){let i=ZYa(r,e);return i===void 0?ILh(r,e):t===void 0?i===void 0:U0u(i,t)}}function qLh(e){if(e==null)return P8o;switch(typeof e){case"function":return e;case"object":return Array.isArray(e)&&e.length===2?CLh(e[0],e[1]):ELh(e);case"string":case"symbol":case"number":return PLh(e)}}function L0u(e,t=P8o){return e==null?{}:I4(e,qLh(t))}function TLh(e){return bKp(sOn(e))}function RLh(e){return typeof e!="string"&&(e=sOn(e)),e.replace(/['\u2019]/g,"")}function rWt(e){return yxp(RLh(TLh(e)))}function ij(e){if(e!=null)return Array.isArray(e)?e:[e]}function V0u({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`${sSB(o)}${cSB(e)}.${lSB(i,n,a,c)}`}function sSB(e){return e?"webhook_":"endpoint_"}function cSB(e){return e!=null?ij(e)?.map(t=>rWt(t)).join("/"):""}function lSB(e,t,r,i){return e||t||rWt(r??"")||rWt(i??"")}function zLh(e){return e.length===0?!1:/^\$?(\.[\w*]+|\[['"][\w*]+['"]?\]|\[['"]?[\d*]+['"]?\]|\[[\d:]+\])*$/.test(e)}var W0u=class extends Ao{accessTokenLocator;constructor(t){super(t),this.safeParse()}parse(){this.accessTokenLocator=this.input[sLh],this.accessTokenLocator!=null&&(zLh(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 G0u=class extends Ao{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 ela({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.accessTokenLocatorNode=new W0u({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=V0u({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:sc.EndpointId(r),accessTokenLocator:sc.JqString(t),headerName:this.headerAuthNode?.convert()?.headerWireValue,tokenPrefix:this.headerAuthNode?.convert()?.prefix}}}}};var rla=class extends Ao{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 B0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicUsernameVariableNameNode=new C0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicPasswordVariableNameNode=new I0u({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 q0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.bearerTokenVariableNameNode=new T0u({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":{vLh(this.input)?(this.authScheme="header",this.headerAuthNode=new ela({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 G0u({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 NLh.UnreachableCaseError(this.authScheme);return}}};var ila=class extends Ao{authNodesMap;constructor(t){super(t),this.safeParse()}parse(){this.input.map((t,r)=>Object.keys(t).map(i=>{let n=D0u(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 rla({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(Ko))}};var x0u=class extends Ao{basePath;constructor(t){super(t),this.safeParse()}parse(){this.basePath=this.input[iLh],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 FLh(e){return"required"in e&&typeof e.required=="boolean"?e.required:!1}function QLh(e,t){return{type:"alias",value:{type:"optional",shape:e,default:t}}}function nla(e,t){return e==null?void 0:Object.entries(e).map(([i,n])=>ij(n.convert())?.map(o=>((t!=null&&!t.includes(i)||t==null&&!FLh(n))&&(o=QLh(o,o.type==="enum"?o.default:void 0)),{key:sc.PropertyKey(i),valueShape:o,description:n.description,availability:n.availability?.convert()})).filter(Ko)).filter(Ko).reduce((i,n)=>i.flatMap(a=>n.length>0?n.map(o=>[...a,o]):[[...a]]),[[]])}function H0u(e,t){return tg(e)?TL(e,t,void 0):e}function AYi(e,t){return e!=null&&e!==""?e:t!=null&&t!==""?t:void 0}function ULh(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 LLh(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 VLh=ue(vM());var crl=["decimal","decimal128","double-int","double","float","sf-decimal"],lrl=["int16","int32","int64","int8","sf-integer","uint8"],frl=["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"],drl=["beta","pre-release","in-development","generally-available","deprecated"];function TC(e,t){return tg(e)?TL(e,t,{type:"unknown","x-fern-type":"unknown",additionalProperties:!1}):e}var SSe=class extends Ao{availability;constructor(t){super(t),this.safeParse()}parse(){if(TC(this.input,this.context.document)?.deprecated)this.availability="deprecated";else{let r=this.input[nLh];r!=null&&(drl.includes(r)?this.availability=r:(this.context.errors.warning({message:`Expected one of: ${drl.join(", ")}. Received: ${r}`,path:this.accessPath}),this.availability=void 0))}}convert(){switch(this.availability){case"beta":case"pre-release":return sc.Availability.Beta;case"in-development":return sc.Availability.InDevelopment;case"generally-available":return sc.Availability.GenerallyAvailable;case"deprecated":return sc.Availability.Deprecated;case void 0:return;default:new VLh.UnreachableCaseError(this.availability);return}}};var J0u=ue(vM());function WLh(e){return typeof e=="object"&&e!=null&&"language"in e}function GLh(e){return typeof e=="object"&&e!=null&&"sdk"in e}function xLh(e){return typeof e=="object"&&e!=null&&("error"in e||"body"in e)}function HLh(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)}function K0u(e){return typeof e=="object"&&e!=null&&"event"in e}function prl(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)&&e.stream.every(K0u)}function PYi(e){return typeof e=="object"&&e!=null&&"filename"in e&&"data"in e&&typeof e.filename=="string"&&typeof e.data=="string"}function KLh(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}var $0u=class extends Ao{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[bLh]}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 PYi(o)?[n,{type:"filenameWithData",filename:o.filename,data:sc.FileId(o.data)}]:o!=null?[n,{type:"filename",value:o}]:void 0;case"files":{if(Array.isArray(o)){if(o.every(c=>PYi(c)))return[n,{type:"filenamesWithData",value:o.map(c=>({filename:c.filename,data:sc.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 J0u.UnreachableCaseError(a.multipartType);return}}).filter(Ko))};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=KLh(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 J0u.UnreachableCaseError(n.contentType);break}let o;switch(i.contentType){case"application/json":{xLh(r.response)&&(o={type:"json",value:r.response.body});break}case"text/event-stream":{prl(r.response)&&(o={type:"sse",value:r.response.stream.map(l=>({event:l.event,data:l.data}))});break}case"application/octet-stream":!prl(r.response)&&HLh(r.response)&&(o={type:"stream",value:r.response.stream});break;case void 0:break;default:new J0u.UnreachableCaseError(i.contentType);break}let c={};r["code-samples"]?.forEach(l=>{WLh(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})):GLh(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])=>[sc.PropertyKey(l),p])),s=Object.fromEntries(Object.entries(r["query-parameters"]??{}).map(([l,p])=>[sc.PropertyKey(l),p])),u=Object.fromEntries(Object.entries(r.headers??{}).map(([l,p])=>[sc.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 kYa=class extends Ao{groupName;constructor(t){super(t),this.safeParse()}parse(){this.groupName=this.input[E0u]}convert(){if(this.groupName==null)return;let t;return Array.isArray(this.groupName)?t=this.groupName:t=[this.groupName],t.map(r=>sc.api.v1.SubpackageId(rWt(r)))}};var Y0u=class extends Ao{sdkMethodName;constructor(t){super(t),this.safeParse()}parse(){this.sdkMethodName=this.input[oLh]}convert(){return this.sdkMethodName}};var X0u=class extends Ao{isWebhook;constructor(t){super(t),this.safeParse()}parse(){this.isWebhook=this.input[uLh]}convert(){return this.isWebhook}};var Z0u=class extends Ao{codeSamples;constructor(t){super(t),this.safeParse()}parse(){this.codeSamples=[...this.input[OLh]??[],...this.input[mLh]??[]],this.codeSamples.forEach(t=>{[...Object.values(sc.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 cOn=ue(vM());function _rl(e,t){return tg(e)?TL(e,t,void 0):e}function JLh(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 zF="",SXt=class extends Ao{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&&(PYi(n)||typeof n=="string");case"files":return t&&Array.isArray(n)&&n.every(a=>PYi(a)||typeof a=="string");case"property":return t;case void 0:return t&&!1;default:return new cOn.UnreachableCaseError(i.multipartType),t}},!0)}parse(){let t=this.shapes.requestBody?.schema?.example({includeOptionals:!1,override:void 0});this.resolvedRequestInput=_rl(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=_rl(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 cOn.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(K0u)){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 cOn.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 PYi(n)?[r,{type:"filenameWithData",filename:n.filename,data:sc.FileId(n.data)}]:[r,{type:"filename",value:n}];case"files":{if(Array.isArray(n)){if(n.every(a=>PYi(a)))return[r,{type:"filenamesWithData",value:n.map(a=>({filename:a.filename,data:sc.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 cOn.UnreachableCaseError(i.multipartType);return}}).filter(Ko))};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 cOn.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 cOn.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(Ko));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(Ko));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:JLh(this.path,i??{}),responseStatusCode:this.responseStatusCode,name:this.name!=null?EXt(this.name):this.summary!=null?EXt(this.summary):void 0,description:this.convertDescription(),pathParameters:i,queryParameters:n,headers:a,requestBody:t,responseBody:r,snippets:void 0}}};function $Lh(e,t){return tg(e)?TL(e,t,void 0):e}var sVh=ue(vM());var YLh="#/components/schemas/";function ala(e){if(e.$ref.startsWith(YLh))return e.$ref.replace(YLh,"")}function _4i(e){if(e!=null)return{type:"alias",value:{type:"nullable",shape:e}}}function jYi(e){return typeof e.type=="string"&&e.type==="array"}function XLh(e){return e.type==="boolean"}function ZLh(e){return e.type==="integer"}function wYi(e){return!Array.isArray(e.type)&&!jYi(e)}function kLh(e){return e!=null&&Array.isArray(e)&&e.every(t=>t.type==="null"||wYi(t)||jYi(t))}function eVh(e){return"nullable"in e&&typeof e.nullable=="boolean"}function tVh(e){return e.type==="null"}function rVh(e){return e.type==="number"}function hrl(e){return e.type==null||typeof e.type=="string"&&e.type==="object"}function iVh(e){return e.type==="string"}var k0u=class extends qY{item;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.item=new hw({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 ij(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 ewu=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 SSe({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 twu=class extends qY{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 hw({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName})}).filter(Ko)}convert(){if(this.typeNodes==null)return;let i=this.typeNodes.map(n=>ij(n.convert())?.map(o=>({displayName:n.name,shape:o,description:n.description,availability:n.availability?.convert()}))).filter(Ko).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(_4i).filter(Ko):i}example(t){return this.nullable?null:this.typeNodes?.[0]?.example(t)}};function rwu(e){return e!=null&&e.length>0?e:[void 0]}var ola=class extends qY{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 hw({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 hw({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(tg(t))return ala(t);this.properties={...this.properties,...Object.fromEntries(Object.entries(t.properties??{}).map(([i,n])=>[i,new hw({input:n,context:this.context,accessPath:this.accessPath,pathId:["allOf",r.toString(),"properties",i],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))}}).filter(Ko))),this.description=this.input.description}convertProperties(){if(this.properties!=null)return nla(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}}}]:ij(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(Ko)}convert(){let t=this.convertProperties();if(t==null)return;let r=this.convertExtraProperties();return t.flatMap(i=>rwu(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=>sc.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 hw({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 iwu=class extends qY{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 hw({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0).filter(Ko);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 hw({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(Ko);return this.isNullable&&n!=null?n.map(_4i).filter(Ko):n}let t=0,r=this.discriminated&&this.discriminant!=null&&this.discriminatedMapping!=null?{type:"discriminatedUnion",discriminant:sc.PropertyKey(this.discriminant),variants:Object.entries(this.discriminatedMapping).flatMap(([n,a])=>ij(a.convert())?.map(c=>{if(!(c==null||c.type!=="object"))return{discriminantValue:n,displayName:a.name??EXt(n),availability:a.availability?.convert(),description:a.description,...c}}).filter(Ko)).filter(Ko)}:this.undiscriminatedMapping!=null?{type:"undiscriminatedUnion",variants:this.undiscriminatedMapping.flatMap(n=>ij(n.convert())?.map(o=>{if(o==null)return;t+=1;let c=o.type==="object"?EXt(`${this.schemaName??"Variant"} ${t}`):void 0;return{displayName:n.name??(o.type==="alias"&&o.value.type==="id"?EXt(o.value.id):c),shape:o,description:n.description,availability:n.availability?.convert()}}).filter(Ko)).filter(Ko)}:void 0,i=this.isNullable?_4i(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 nwu=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 EYi=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(tg(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(Ko),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 nVh=ue(vM());function fSB(e){return lrl.includes(e)}var awu=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&&(fSB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${lrl.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 nVh.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 owu=class extends qC{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){this.displayName=this.input.title}convert(){return _4i({type:"alias",value:{type:"unknown",displayName:this.displayName}})}example(){return null}};var aVh=ue(vM());function dSB(e){return crl.includes(e)}var uwu=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&&(dSB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${crl.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 aVh.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 oVh=ue(vM());function pSB(e){return frl.includes(e)}var swu=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 oVh.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&&(pSB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${frl.join(", ")}. Received ${this.input.format}`,path:this.accessPath})),this.input.enum!=null&&(this.enum=new EYi({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 uVh=ue(vM());var cwu=class extends qC{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){(0,uVh.noop)()}convert(){return{type:"alias",value:{type:"unknown",displayName:void 0}}}example(){}};var lOn=class extends qY{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=ala(this.input);let t=TC(this.input,this.context.document);t?.enum!=null&&wYi(t)&&(this.maybeEnumConverterNode=new EYi({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:sc.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 hw({input:r,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName}).example(t)}};var hw=class e extends qY{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 SSe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),wYi(this.input)&&eVh(this.input)&&(this.nullable=this.input.nullable!=null?this.input.nullable:this.nullable),tg(this.input)){let t=ala(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 lOn({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 ewu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});else if(kLh(this.input))this.typeShapeNode=new twu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(wYi(this.input)&&(this.input.oneOf!=null||this.input.anyOf!=null))this.typeShapeNode=new iwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(hrl(this.input)&&this.input.allOf!=null)this.typeShapeNode=new ola({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(wYi(this.input)&&this.input.enum!=null)this.typeShapeNode=new EYi({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":hrl(this.input)&&(this.typeShapeNode=new ola({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"array":jYi(this.input)&&(this.typeShapeNode=new k0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"boolean":XLh(this.input)&&(this.typeShapeNode=new nwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"integer":ZLh(this.input)&&(this.typeShapeNode=new awu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"number":rVh(this.input)&&(this.typeShapeNode=new uwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"string":iVh(this.input)&&(this.typeShapeNode=new swu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"null":tVh(this.input)&&(this.typeShapeNode=new owu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}));break;case void 0:break;default:new sVh.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 ola({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 cwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),!tg(this.input)&&(!jYi(this.input)&&this.input==null||jYi(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=ij(t)?.map(i=>this.nullable?_4i(i):i).filter(Ko);return Array.isArray(t)&&t.length>1?r:r?.[0]}example(t){return this.availability?.availability!=="deprecated"?this.typeShapeNode?.example(t):void 0}};function SYi(e){if(e!=null)return nla(e,Object.entries(e??{}).map(([t,r])=>r.required?t:void 0).filter(Ko))}var MXt=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;tg(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 SSe({input:r,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=new hw({input:r,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:t});let i=$Lh(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 cVh(e,t){return tg(e)?TL(e,t,void 0):e}var yrl=ue(vM());function lwu(e){let{uniqueId:t,type:r,contextTypes:i,description:n,availability:a}=e;i[sc.TypeId(t)]={name:t,shape:r,description:n,availability:a}}var lVh=ue(mnc(),1),ula=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=lVh.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 _SB(e){return typeof e.securitySchemes=="object"&&e.securitySchemes!=null}var fwu=class extends Ao{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 hw({input:r,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:new Set,nullable:void 0,schemaName:t})]))),_SB(this.input)&&this.input.securitySchemes!=null&&(this.securitySchemes=Object.fromEntries(Object.entries(this.input.securitySchemes??{}).map(([t,r],i)=>{let n;if(tg(r)?n=D0u(r.$ref,this.context.document):n=r,n!=null)return[t,new rla({input:n,context:this.context,accessPath:this.accessPath,pathId:["securitySchemes",`${i}`]})]}).filter(Ko)))}convert(){return{auths:this.securitySchemes!=null?Object.fromEntries(Object.entries(this.securitySchemes??{}).map(([t,r])=>{let i=r.convert();if(i!=null)return[sc.api.latest.AuthSchemeId(t),i]}).filter(Ko)):void 0,types:this.typeSchemas!=null?Object.fromEntries(Object.entries(this.typeSchemas).map(([t,r])=>{let i=r.name??t,n=ij(r.convert());return n==null?[t,void 0]:[sc.TypeId(t),{name:i,shape:n[0],description:r.description,availability:void 0}]}).filter(([t,r])=>Ko(r))):void 0}}};var dwu=class extends hw{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. ${tg(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 pwu=class extends Ao{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 SSe({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=tg(this.input.schema)?new lOn({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=ula.parse(t);n?.containsJSON()?(this.contentType="json",this.schema=this.schema??new hw({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 dwu({input:o,context:this.context,accessPath:this.accessPath,pathId:`schema.${a}`,seenSchemas:new Set,nullable:void 0,schemaName:a})]}).filter(Ko))):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?{[zF]:{value:this.input.example}}:{},...this.input.examples},r!=null&&Object.keys(this.examples).length===0&&(this.examples={[zF]:{value:r}})}convertJsonLike(){let t=this.schema?.convert();return t==null?void 0:ij(t)?.map(i=>{let n=i.type;switch(n){case"object":case"alias":return i;case"enum":case"undiscriminatedUnion":case"discriminatedUnion":{let a=rWt([this.method,this.path,this.contentType,"request"].join("_"));return lwu({uniqueId:a,type:i,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:sc.TypeId(a),default:i.type==="enum"&&i.default!=null?{type:"enum",value:i.default}:void 0}}}case void 0:return;default:new yrl.UnreachableCaseError(n);return}}).filter(Ko)}convert(){if(this.schema instanceof lOn)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:sc.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:sc.PropertyKey(i),isOptional:this.requiredFields?.includes(i)==null,contentType:n.contentType,description:n.description,availability:n.availability?.convert()}];case"property":{let a=ij(n.convert()),o=n.multipartType;return a?.map(c=>({type:o,key:sc.PropertyKey(i),contentType:n.contentType,exploded:void 0,valueShape:c,description:n.description,availability:n.availability?.convert()}))}case void 0:return[];default:return new yrl.UnreachableCaseError(n.multipartType),[]}}).filter(Ko).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 _wu=class extends Ao{description;requestBodiesByContentType;constructor(t){super(t),this.safeParse(t)}parse({method:t,path:r}){let i=cVh(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 pwu({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])=>ij(r.convert())?.map(n=>({description:this.description,contentType:t,body:n}))).filter(Ko)}convertToWebhookPayload(){return Object.values(this.requestBodiesByContentType??{}).flatMap(t=>ij(t.convert())?.map(i=>{if(!(i.type!=="alias"&&i.type!=="object"))return{description:this.description,shape:i}})).filter(Ko)}webhookExample(){return{payload:this.requestBodiesByContentType?.["application/json"]?.schema?.example({includeOptionals:!0,override:void 0})}}};var fVh={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 dVh(e,t){if(tg(e)){let r=TL(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var hwu=ue(vM());var pVh="application/json";var _Vh="application/octet-stream";function hVh(e,t){return e===t||t===zF||e===zF}var eXa=class extends Ao{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)hVh(c,a)&&(i.add(c),this.examples?.push(new SXt({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,AYi(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 SXt({input:{requestExample:u,responseExample:l},context:this.context,accessPath:this.accessPath,pathId:s!=null&&s!==""?["examples",s]:"examples"},this.path,this.statusCode,AYi(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 SXt({input:{requestExample:s,responseExample:u},context:this.context,accessPath:this.accessPath,pathId:d!=null&&d!==""?["examples",d]:"examples"},this.path,this.statusCode,AYi(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 SXt({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,AYi(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[zF];if(a!=null)for(let o of a)this.examples?.push(new SXt({input:{requestExample:n,responseExample:o},context:this.context,accessPath:this.accessPath,pathId:i!=null&&i!==""?["examples",i]:"examples"},this.path,this.statusCode,AYi(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=ula.parse(t);if(c?.isJSON()||c?.isEventStream())this.contentType=pVh,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 hw({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=_Vh,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 hw({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=L0u(this.input.examples,c=>[c])),this.input.example!=null&&Object.keys(r).length===0&&(r[zF]??=[],r[zF]=[{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=L0u(i.examples,c=>[c])),i.example!=null&&Object.keys(r).length===0&&(r[zF]??=[],r[zF]?.push({value:i.example}))),Object.keys(r).length===0){let c=this.schema?.example({includeOptionals:!0,override:void 0});r[zF]??=[],r[zF]?.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!==zF).map(([d,s])=>[c,d,s]));let o=Object.entries(r).filter(([c,d])=>!n.has(c)&&Ko(d)&&c!==zF);Object.keys(r).every(c=>c===zF)||this.matchExamplesByIndex(a,o),!n.has(zF)&&this.examples.length===0&&this.addGlobalFallbackExample(this.requests,r),this.examples.length===0&&(this.examples=void 0)}convertStreamingFormat(){switch(this.streamingFormat){case"json":return ij(this.schema?.convert())?.map(r=>({type:"stream",terminator:"[DATA]",shape:r}));case"sse":return{type:"streamingText"};case void 0:return;default:new hwu.UnreachableCaseError(this.streamingFormat);return}}convertJsonLike(){return ij(this.schema?.convert())?.map(r=>{let i=r.type;switch(i){case"alias":return r;case"discriminatedUnion":case"undiscriminatedUnion":case"enum":{let n=rWt([this.method,this.path,this.statusCode,"response"].join("_"));return lwu({uniqueId:n,type:r,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:sc.TypeId(n),default:r.type==="enum"&&r.default!=null?{type:"enum",value:r.default}:void 0}}}case"object":return r;default:new hwu.UnreachableCaseError(i);return}}).filter(Ko)}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 hwu.UnreachableCaseError(this.contentType);return}else return this.unsupportedContentType!=null?this.convertJsonLike():void 0}};var tXa=class extends Ao{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=dVh(this.input,this.context.document);if(r==null){this.context.errors.error({message:tg(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 MXt({input:n,context:this.context,accessPath:this.accessPath,pathId:"headers",parameterName:i})}),r.content==null?(this.responses??=[],this.responses.push(new eXa({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 eXa({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(Ko)}};var ywu=class extends Ao{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 tXa({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 tXa({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 rwu(SYi(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(Ko))})))}).filter(Ko)}convertResponseObjectToErrors(){return Object.entries(this.errorsByStatusCode??{}).flatMap(([t,r])=>r.responses?.flatMap(i=>{let n=i.schema,a=ij(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??fVh[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(Ko)})).filter(Ko)})).filter(Ko)}convert(){return{responses:this.convertResponseObjectToHttpResponses(),errors:this.convertResponseObjectToErrors()}}};var MYi=class extends Ao{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 SXt({input:{requestExample:t,responseExample:void 0},context:this.context,accessPath:this.accessPath,pathId:"examples"},this.path,200,AYi(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 SSe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),this.servers=mYi(this.servers,this.input.servers,this.context,this.accessPath),this.isWebhook=new X0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}).isWebhook||this.isWebhook,this.input.parameters?.map((i,n)=>{if(tg(i)){let a=H0u(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 MXt({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 MXt({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 MXt({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 Z0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-code-samples"}),this.requests=this.input.requestBody!=null?new _wu({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 ywu({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 ila({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"})),this.namespaces=[new kYa({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 kYa({input:{[E0u]:i},context:this.context,accessPath:this.accessPath,pathId:["tags",`${n}`]})));let r=new Y0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-sdk-method-name"});this.endpointIds=this.namespaces.map(i=>V0u({namespace:ij(i?.groupName),path:this.path,method:this.method,sdkMethodName:r.sdkMethodName,operationId:this.input.operationId,displayName:this.displayName,isWebhook:this.isWebhook})).filter(Ko),this.xFernExamplesNode=new $0u({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(Ko)}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:sc.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(Ko),n=LLh(this.xFernExamplesNode?.convert(),[...i??[],...t?.flatMap(u=>u.examples)??[]])?.map(u=>({...u,snippets:ULh(u.snippets,this.redocExamplesNode?.convert())}));if(this.isWebhook)return this.endpointIds.map((u,l)=>{if(!(this.method!=="POST"&&this.method!=="GET"))return{id:sc.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:SYi(this.queryParameters)?.flat(),headers:SYi(this.requestHeaders)?.flat(),payloads:this.requests?.convertToWebhookPayload(),examples:[this.requests?.webhookExample()].filter(Ko)}}).filter(Ko);let a=this.servers?.map(u=>u.convert()).filter(Ko),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(Ko);return this.endpointIds.map((u,l)=>({id:sc.EndpointId(u),description:this.description,availability:this.availability?.convert(),namespace:this.namespaces?.[l]?.convert()?.map(p=>sc.api.v1.SubpackageId(p)),displayName:this.displayName,operationId:this.operationId,method:this.method,path:o,auth:c?.map(p=>sc.api.latest.AuthSchemeId(p)),defaultEnvironment:a?.[0]?.id,environments:a,pathParameters:SYi(this.pathParameters)?.flat(),queryParameters:SYi(this.queryParameters)?.flat(),requestHeaders:SYi(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 sla=class extends Ao{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=mYi(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 MYi({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 MYi({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 MYi({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 MYi({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 MYi({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(Ko)}};function bwu(e){return"payloads"in e}var vwu=class extends Ao{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 sla({input:a,context:this.context,accessPath:this.accessPath,pathId:n,servers:mYi(t,a.servers,this.context,this.accessPath),globalAuth:r,basePath:i,isWebhook:void 0})}).filter(Ko)}convert(){if(this.paths==null)return;let t={},r={};return this.paths.forEach(i=>{let n=i.convert();n?.forEach(a=>{bwu(a)?r[sc.WebhookId(a.id)]=a:t[sc.EndpointId(a.id)]=a})}),{endpoints:t,webhookEndpoints:r}}};var gwu=class extends Ao{globalHeaders;requiredProperties;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[aLh]?.map(r=>{let{header:i,...n}=r;return(n.optional!=null&&!n.optional||H0u(n,this.context.document)?.required)&&(this.requiredProperties??=[],this.requiredProperties?.push(i)),[i,new MXt({input:n,context:this.context,accessPath:this.accessPath,pathId:this.pathId,parameterName:i})]});t!=null&&(this.globalHeaders=Object.fromEntries(t))}convert(){return nla(this.globalHeaders,this.requiredProperties)?.flat()}};function yVh(e,t){if(tg(e)){let r=TL(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var Owu=class extends Ao{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=yVh(a,this.context.document);if(o!=null)return new sla({input:o,context:this.context,accessPath:this.accessPath,pathId:n,servers:t,globalAuth:r,basePath:i,isWebhook:!0})}).filter(Ko)}convert(){return this.webhooks?.reduce((t,r)=>(r.convert()?.forEach(i=>{bwu(i)&&(t[sc.WebhookId(i.id)]=i)}),t),{})}};var mwu=class extends Ao{paths;webhooks;components;auth;globalHeaders;constructor(t){super(t),this.safeParse()}parse(){let t=mYi(void 0,this.input.servers,this.context,this.accessPath);this.input.security!=null&&(this.auth=new ila({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"}));let r=new x0u({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 Owu({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 fwu({input:this.input.components,context:this.context,accessPath:this.accessPath,pathId:"components"})),this.globalHeaders=new gwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-global-headers"})}convert(){let t=Nve(),{webhookEndpoints:r,endpoints:i}=this.paths?.convert()??{},n={...this.webhooks?.convert()??{},...r??{}},a=tLh({endpoints:i,webhookEndpoints:n}),{types:o,auths:c}=this.components?.convert()??{};return{id:sc.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 brl(e,t){if(e instanceof ySe){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof jS))return;let r=new x8t(e.absoluteFilePath),i=await vSe({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 j0u,generatedTypes:{}},d=new mwu({input:o.value,context:c,accessPath:[],pathId:e.workspaceName??"openapi parser"});a=j$n(a,d.convert())}return a}var TKh=ue(Orl(),1),RKh=ue(cEu(),1),qSu=require("fs/promises"),zKh=ue(require("http"),1),NKh=ue(require("path"),1);var O6h=require("events"),_Eu=ue(require("fs"),1),OOn=ue(require("path"),1);var r6h=ue(require("os"),1),i6h=300,RYi=20,jXa=1e7,n6h=r6h.default.platform();var z1B=n6h==="darwin",Uil=n6h==="win32",zYi=z1B||Uil,a6h=3e3,o6h=2e4,Lil=1250;var CXt;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(CXt||(CXt={}));var gOn;(function(e){e.CHANGE="change",e.RENAME="rename"})(gOn||(gOn={}));var wXa;(function(e){e.CHANGE="change",e.ERROR="error"})(wXa||(wXa={}));var nf;(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"})(nf||(nf={}));var Qx;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(Qx||(Qx={}));var N1B=(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},lEu=N1B;var xil=ue(require("fs"),1),dEu=ue(require("path"),1);var dm=ue(require("fs"),1),RL=require("util");var y4i=(e,t)=>function(...i){return e.apply(void 0,i).catch(t)},qXt=(e,t)=>function(...i){try{return e.apply(void 0,i)}catch(n){return t(n)}};var Vil=ue(require("process"),1),u6h=Vil.default.getuid?!Vil.default.getuid():!1,s6h=1e4,NY=()=>{};var EXa={isChangeErrorOk:e=>{if(!EXa.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!u6h&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!EXa.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(!EXa.isNodeError(e))throw e;if(!EXa.isChangeErrorOk(e))throw e}},RC=EXa;var Wil=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=s6h,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()}}}}},c6h=new Wil;var b4i=(e,t)=>function(i){return function n(...a){return c6h.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)})}},v4i=(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 F1B={attempt:{chmod:y4i((0,RL.promisify)(dm.default.chmod),RC.onChangeError),chown:y4i((0,RL.promisify)(dm.default.chown),RC.onChangeError),close:y4i((0,RL.promisify)(dm.default.close),NY),fsync:y4i((0,RL.promisify)(dm.default.fsync),NY),mkdir:y4i((0,RL.promisify)(dm.default.mkdir),NY),realpath:y4i((0,RL.promisify)(dm.default.realpath),NY),stat:y4i((0,RL.promisify)(dm.default.stat),NY),unlink:y4i((0,RL.promisify)(dm.default.unlink),NY),chmodSync:qXt(dm.default.chmodSync,RC.onChangeError),chownSync:qXt(dm.default.chownSync,RC.onChangeError),closeSync:qXt(dm.default.closeSync,NY),existsSync:qXt(dm.default.existsSync,NY),fsyncSync:qXt(dm.default.fsync,NY),mkdirSync:qXt(dm.default.mkdirSync,NY),realpathSync:qXt(dm.default.realpathSync,NY),statSync:qXt(dm.default.statSync,NY),unlinkSync:qXt(dm.default.unlinkSync,NY)},retry:{close:b4i((0,RL.promisify)(dm.default.close),RC.isRetriableError),fsync:b4i((0,RL.promisify)(dm.default.fsync),RC.isRetriableError),open:b4i((0,RL.promisify)(dm.default.open),RC.isRetriableError),readFile:b4i((0,RL.promisify)(dm.default.readFile),RC.isRetriableError),rename:b4i((0,RL.promisify)(dm.default.rename),RC.isRetriableError),stat:b4i((0,RL.promisify)(dm.default.stat),RC.isRetriableError),write:b4i((0,RL.promisify)(dm.default.write),RC.isRetriableError),writeFile:b4i((0,RL.promisify)(dm.default.writeFile),RC.isRetriableError),closeSync:v4i(dm.default.closeSync,RC.isRetriableError),fsyncSync:v4i(dm.default.fsyncSync,RC.isRetriableError),openSync:v4i(dm.default.openSync,RC.isRetriableError),readFileSync:v4i(dm.default.readFileSync,RC.isRetriableError),renameSync:v4i(dm.default.renameSync,RC.isRetriableError),statSync:v4i(dm.default.statSync,RC.isRetriableError),writeSync:v4i(dm.default.writeSync,RC.isRetriableError),writeFileSync:v4i(dm.default.writeFileSync,RC.isRetriableError)}},l6h=F1B;var fEu=ue(require("fs"),1),SXa=ue(require("path"),1);var Gil=()=>{};var Q1B=()=>{let e=Gil,t=Gil,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}},f6h=Q1B;var U1B=()=>{let{promise:e,resolve:t,isPending:r}=f6h(),i=0,n=()=>{i+=1},a=()=>{i-=1,!i&&t()};return(()=>{n(),queueMicrotask(a)})(),{promise:e,isPending:r,increment:n,decrement:a}},d6h=U1B;var p6h={then:e=>{e()}};var _6h=e=>Array.isArray(e)?e:[e],h6h=e=>typeof e=="function";var L1B=(e,t)=>{let r=t?.followSymlinks??!1,i=t?.depth??1/0,n=t?.limit??1/0,a=t?.ignore??[],o=_6h(a).map(W=>h6h(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}=d6h(),B=0,R=(W,x,Ee,se)=>{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),!(se>=i)&&(B>=n||$(x,se+1)))},T=(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,se)=>{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&&(se>=i||B>=n||de(x,se+1)))},z=(W,x,Ee,se,Oe)=>{d.aborted||c(x)||(se.isDirectory()?R(W,x,Ee,Oe):se.isFile()?T(W,x,Ee):se.isSymbolicLink()&&q(W,x,Ee,Oe))},N=(W,x,Ee,se)=>{if(d.aborted)return;let Oe=x===SXa.default.sep?"":SXa.default.sep,Fe=Ee.name,ae=`${x}${Oe}${Fe}`;c(ae)||(Ee.isDirectory()?R(W,ae,Fe,se):Ee.isFile()?T(W,ae,Fe):Ee.isSymbolicLink()&&q(W,ae,Fe,se))},H=(W,x,Ee,se)=>{for(let Oe=0,Fe=Ee.length;Oe<Fe;Oe++)N(W,x,Ee[Oe],se)},$=(W,x)=>{d.aborted||x>i||B>=n||(w(),fEu.default.readdir(W,{withFileTypes:!0},(Ee,se)=>{if(Ee||d.aborted||!se.length)return D();(s(se)||p6h).then(()=>{let Fe=m[W]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};H(Fe,W,se,x),D()})}))},de=(W,x)=>{w(),fEu.default.realpath(W,(Ee,se)=>{if(Ee||d.aborted)return D();fEu.default.stat(se,(Oe,Fe)=>{if(Oe||d.aborted)return D();let ae=SXa.default.basename(se),re=m[W]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};z(re,se,ae,Fe,x),D()})})};return(async(W,x=1)=>(W=SXa.default.normalize(W),g.add(W),$(W,x),await M,d.aborted?A:j))(e)},y6h=L1B;var TXt={lang:{debounce:lEu,attempt:e=>{try{return e()}catch(t){return TXt.lang.castError(t)}},castArray:e=>TXt.lang.isArray(e)?e:[e],castError:e=>TXt.lang.isError(e)?e:TXt.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(TXt.lang.isNaN(e))return TXt.lang.isNaN(t);if(TXt.lang.isPrimitive(e)||TXt.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(dEu.default.sep).length-1),getRealPath:(e,t)=>{try{return t?xil.default.realpathSync.native(e):xil.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===dEu.default.sep&&t.length-e.length>dEu.default.sep.length,poll:(e,t=o6h)=>l6h.retry.stat(t)(e,{bigint:!0}).catch(TXt.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 y6h(e,{depth:r,limit:i,ignore:t,signal:n});return[o.directories,o.files]}}}},xp=TXt;var pEu=ue(require("path"),1);var Hil=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||xp.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=i6h){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=xp.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===nf.CHANGE&&c===nf.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===nf.ADD_DIR?await this.eventsPopulateAddDir(t,n,r,i):o===nf.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??RYi:Math.min(1,this.options.depth??RYi),o=this.options.limit??jXa,[c,d]=await xp.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())xp.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(nf.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!zYi&&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(nf.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(nf.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(pEu.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(nf.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(pEu.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(nf.UNLINK_DIR,t))}onTargetEvent(t){let[r,i]=t;r===nf.ADD?this.onTargetAdd(i):r===nf.ADD_DIR?this.onTargetAddDir(i):r===nf.CHANGE?this.onTargetChange(i):r===nf.UNLINK?this.onTargetUnlink(i):r===nf.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=gOn.CHANGE,r){if(this.watcher.isClosed())return;let i=pEu.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){Uil&&t.code==="EPERM"?this.onWatcherChange(gOn.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(wXa.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(wXa.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(gOn.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&zYi&&this.options.native!==!1?this.options.depth??RYi:Math.min(1,this.options.depth??RYi),i=this.options.limit??jXa,[n,a]=await xp.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(gOn.CHANGE,c,t)}))}}},b6h=Hil;var Ux={interval:100,intervalId:void 0,fns:new Map,init:()=>{Ux.intervalId||(Ux.intervalId=setInterval(Ux.resolve,Ux.interval))},reset:()=>{Ux.intervalId&&(clearInterval(Ux.intervalId),delete Ux.intervalId)},add:(e,t)=>{Ux.fns.set(e,Date.now()+t),Ux.init()},remove:e=>{Ux.fns.delete(e)},resolve:()=>{if(!Ux.fns.size)return Ux.reset();let e=Date.now();for(let[t,r]of Ux.fns)r>=e||(Ux.remove(t),t())}},MXa=Ux;var DXa=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=Lil){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(xp.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),MXa.remove(s)},s=()=>{d(),c()};MXa.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=Lil){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),MXa.remove(s)},s=()=>{d(),c()};MXa.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,nf.ADD,CXt.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,nf.ADD_DIR,CXt.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,nf.UNLINK,CXt.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,nf.UNLINK_DIR,CXt.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}}};DXa.DIR_EVENTS={add:nf.ADD_DIR,rename:nf.RENAME_DIR,unlink:nf.UNLINK_DIR};DXa.FILE_EVENTS={add:nf.ADD,change:nf.CHANGE,rename:nf.RENAME,unlink:nf.UNLINK};var v6h=DXa;var Kil=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(xp.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let i=this.map.get(t);if(xp.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(xp.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(xp.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let i=this.map.get(t);return xp.lang.isSet(i)?i.has(r):i===r}return!1}set(t,r){if(this.map.has(t)){let i=this.map.get(t);xp.lang.isSet(i)?i.add(r):i!==r&&this.map.set(t,new Set([i,r]))}else this.map.set(t,r);return this}},Jil=Kil;var $il=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}},g6h=$il;var Yil=class{constructor(){this.inos={},this.paths=new Jil,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 xp.fs.poll(t,r);if(!(!i||!(i.isFile()||i.isDirectory())))return new g6h(i)}reset(){this.inos={},this.paths=new Jil,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,nf.ADD,n),[nf.ADD];if(n.isDirectory())return this.updateIno(t,nf.ADD_DIR,n),[nf.ADD_DIR]}else if(i&&!n){if(i.isFile())return this.updateIno(t,nf.UNLINK,i),[nf.UNLINK];if(i.isDirectory())return this.updateIno(t,nf.UNLINK_DIR,i),[nf.UNLINK_DIR]}else if(i&&n){if(i.isFile()){if(n.isFile())return i.ino===n.ino&&!i.size&&!n.size?[]:(this.updateIno(t,nf.CHANGE,n),[nf.CHANGE]);if(n.isDirectory())return this.updateIno(t,nf.UNLINK,i),this.updateIno(t,nf.ADD_DIR,n),[nf.UNLINK,nf.ADD_DIR]}else if(i.isDirectory()){if(n.isFile())return this.updateIno(t,nf.UNLINK_DIR,i),this.updateIno(t,nf.ADD,n),[nf.UNLINK_DIR,nf.ADD];if(n.isDirectory())return i.ino===n.ino?[]:(this.updateIno(t,nf.UNLINK_DIR,i),this.updateIno(t,nf.ADD_DIR,n),[nf.UNLINK_DIR,nf.ADD_DIR])}}return[]}updateIno(t,r,i){let n=this.inos[r]=this.inos[r]||(this.inos[r]={}),a=i.isFile()?CXt.FILE:CXt.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)}}},Xil=Yil;var Zil=class e extends O6h.EventEmitter{constructor(t,r,i){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(Qx.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(n=>this.on(Qx.CLOSE,n)),this._readyWait=new Promise(n=>this.on(Qx.READY,n)),this._locker=new v6h(this),this._roots=new Set,this._poller=new Xil,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&&(xp.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(Qx.CLOSE))}error(t){if(this.isClosed())return!1;let r=xp.lang.castError(t);return this.emit(Qx.ERROR,r)}event(t,r,i){return this.isClosed()?!1:(this.emit(Qx.ALL,t,r,i),this.emit(t,r,i))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(Qx.READY))}pollerExists(t,r){for(let i of this._pollers)if(i.targetPath===t&&xp.lang.isShallowEqual(i.options,r))return!0;return!1}subwatcherExists(t,r){for(let i of this._subwatchers)if(i.targetPath===t&&xp.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)xp.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 b6h(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=xp.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=OOn.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??RYi))&&u.handler===i&&(!u.filePath||u.filePath===n)&&u.options.ignore===r.ignore&&!!u.options.native==!!r.native&&(!r.recursive||u.options.recursive&&zYi&&u.options.native!==!1)))return!0;if(!zYi)break;let s=OOn.default.dirname(t);if(o===s)break;o=s}return!1}async watchDirectories(t,r,i,n,a){if(this.isClosed())return;t=xp.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||zYi&&r.native!==!1?r:{...r,recursive:!1},u={watcher:_Eu.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=OOn.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||zYi&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,i,n,a));{r={...r,recursive:!0};let o=r.depth??RYi,c=r.limit??jXa,[d]=await xp.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=xp.fs.getDepth(t);for(let l of d){let p=xp.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(Qx.CLOSE,d),o.watchFile(t,r,a)},d=()=>{this._subwatchers.delete(n),this.removeListener(Qx.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=OOn.default.dirname(t);return this.watchDirectory(n,r,i,t)}async watchPollingOnce(t,r,i){if(this.isClosed())return;let n=!1,a=new Xil,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 xp.lang.noop;if(this.pollerExists(t,r))return xp.lang.noop;let n={...r,interval:r.pollingInterval??a6h},a={targetPath:t,options:r},o=()=>{this._pollers.add(a),this.on(Qx.CLOSE,c),_Eu.default.watchFile(t,n,i)},c=()=>{this._pollers.delete(a),this.removeListener(Qx.CLOSE,c),_Eu.default.unwatchFile(t,i)};return xp.lang.attempt(o),()=>xp.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=xp.lang.uniq(t).sort(),t.every((a,o)=>t.every((c,d)=>d===o||!xp.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=OOn.default.resolve(t),this.isIgnored(t,r.ignore)))return;let n=await xp.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=OOn.default.dirname(t);return(await xp.fs.poll(a,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,i):this.watchUnknownTarget(t,r,i)}}async watch(t,r,i=xp.lang.noop){if(xp.lang.isFunction(t))return this.watch([],{},t);if(xp.lang.isUndefined(t))return this.watch([],r,i);if(xp.lang.isFunction(r))return this.watch(t,{},r);if(xp.lang.isUndefined(r))return this.watch(t,{},i);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let n=xp.lang.castArray(t);n.forEach(a=>this._roots.add(a)),await this.watchPaths(n,r,i),!this.isClosed()&&(i!==xp.lang.noop&&this.on(Qx.ALL,i),r.readdirMap=void 0,this.ready())}},hEu=Zil;Eru();var jla=require("fs/promises"),m6h=require("os"),A6h=ue(require("path"),1),V1B=".fern",W1B="logs";function G1B(){return"cli@3.49.7"}var BXa=class{logFilePath=null;initialized=!1;sessionStartTime;constructor(){this.sessionStartTime=Date.now()}async initialize(){if(this.initialized)return;let t=qt(jr.of((0,m6h.homedir)()),xe.of(V1B)),r=qt(t,xe.of(W1B));await gi(r)||await(0,jla.mkdir)(r,{recursive:!0});let n=`${new Date().toISOString().replace(/[:.]/g,"-")}.debug.log`;this.logFilePath=qt(r,xe.of(n));let a=["================================================================================","Fern Docs Dev Debug Log",`Session started: ${new Date().toISOString()}`,`Log file: ${A6h.default.basename(this.logFilePath)}`,"================================================================================",""].join(`
|
|
1949
|
+
`;return this.parsedDocsConfig.pages[xe.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=Nt.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?Nt.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 $fn(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 uOn(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:Nt.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):zG.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(ss),remote:this.parsedDocsConfig.js.remote?.map(t=>({...t,url:zG.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 $fn(t,"type")._visit({filepath:({value:r})=>({type:"fileId",value:this.getFileId(r)}),url:({value:r})=>({type:"url",value:zG.Url(r)}),_other:()=>this.taskContext.failAndThrow("Invalid metadata configuration")})}};function UEB(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:`${zx(o)}/${i}/${n}/blob/${a}/fern/${t}?plain=1`,launch:r}}function LEB(e){switch(e){case"beta":return Nt.V1.NavigationV1Availability.Beta;case"deprecated":return Nt.V1.NavigationV1Availability.Deprecated;case"ga":return Nt.V1.NavigationV1Availability.GenerallyAvailable;case"stable":return Nt.V1.NavigationV1Availability.Stable;default:vt(e)}}async function qL(e){return(await Promise.all(e.apiWorkspaces.map(async t=>t instanceof jS?t:null))).filter(ss)}async function Dtl(e,t,r){if(e instanceof ySe){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 Rx({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 sc={};Yt(sc,{AlgoliaSearchIndex:()=>FUh,ApiDefinitionId:()=>a4h,ApiId:()=>c4h,Availability:()=>j4h,DocsConfigId:()=>l4h,EndpointId:()=>d4h,EndpointPathLiteral:()=>A4h,EnvironmentId:()=>f4h,FileId:()=>b4h,HttpMethod:()=>P4h,IndexSegmentId:()=>QUh,JqString:()=>g4h,OrgId:()=>u4h,PageId:()=>y4h,PayloadLocation:()=>X4h,PropertyKey:()=>O4h,PullRequestState:()=>H4h,RoleId:()=>m4h,TokenId:()=>s4h,TypeId:()=>h4h,Url:()=>v4h,VersionId:()=>o4h,WebSocketId:()=>p4h,WebhookId:()=>_4h,algolia:()=>Btl,api:()=>Utl,commons:()=>Ltl,diff:()=>w4h,docs:()=>Ytl,generators:()=>Ztl,git:()=>ktl,navigation:()=>rrl,sdks:()=>nrl,snippets:()=>$4h,snippetsFactory:()=>Y4h,templates:()=>arl,tokens:()=>Z4h});var Btl={};Yt(Btl,{AlgoliaSearchIndex:()=>FUh,IndexSegmentId:()=>QUh});function FUh(e){return e}function QUh(e){return e}var Utl={};Yt(Utl,{latest:()=>qtl,v1:()=>Qtl});var qtl={};Yt(qtl,{AuthSchemeId:()=>UUh,WebhookHttpMethod:()=>GUh,auth:()=>Itl,commons:()=>LUh,endpoint:()=>VUh,type_:()=>WUh,webhook:()=>Ctl,websocket:()=>xUh});var Itl={};Yt(Itl,{AuthSchemeId:()=>UUh});function UUh(e){return e}var LUh={};var VUh={};var WUh={};var Ctl={};Yt(Ctl,{WebhookHttpMethod:()=>GUh});var GUh={Get:"GET",Post:"POST"};var xUh={};var Qtl={};Yt(Qtl,{SubpackageId:()=>t4h,WebSocketMessageId:()=>r4h,WebSocketMessageOrigin:()=>i4h,WebhookHttpMethod:()=>n4h,commons:()=>Ftl,db:()=>Ttl,read:()=>ztl,register:()=>Ntl});var Ttl={};Yt(Ttl,{endpoint:()=>HUh});var HUh={};var ztl={};Yt(ztl,{SupportedLanguage:()=>KUh,endpoint:()=>Rtl,type_:()=>JUh,webhook:()=>$Uh,websocket:()=>YUh});var Rtl={};Yt(Rtl,{SupportedLanguage:()=>KUh});var KUh={Curl:"curl",Python:"python",Javascript:"javascript",Js:"js",Node:"node",Typescript:"typescript",Ts:"ts",Go:"go",Ruby:"ruby",Csharp:"csharp"};var JUh={};var $Uh={};var YUh={};var Ntl={};Yt(Ntl,{SourceId:()=>VEB,endpoint:()=>XUh,type_:()=>ZUh,webhook:()=>kUh,websocket:()=>e4h});var XUh={};var ZUh={};var kUh={};var e4h={};function VEB(e){return e}var Ftl={};Yt(Ftl,{SubpackageId:()=>t4h,WebSocketMessageId:()=>r4h,WebSocketMessageOrigin:()=>i4h,WebhookHttpMethod:()=>n4h});function t4h(e){return e}function r4h(e){return e}var i4h={Client:"client",Server:"server"};var n4h={Get:"GET",Post:"POST"};var Ltl={};Yt(Ltl,{ApiDefinitionId:()=>a4h,ApiId:()=>c4h,Availability:()=>j4h,DocsConfigId:()=>l4h,EndpointId:()=>d4h,EndpointPathLiteral:()=>A4h,EnvironmentId:()=>f4h,FileId:()=>b4h,HttpMethod:()=>P4h,JqString:()=>g4h,OrgId:()=>u4h,PageId:()=>y4h,PropertyKey:()=>O4h,RoleId:()=>m4h,TokenId:()=>s4h,TypeId:()=>h4h,Url:()=>v4h,VersionId:()=>o4h,WebSocketId:()=>p4h,WebhookId:()=>_4h});function a4h(e){return e}function o4h(e){return e}function u4h(e){return e}function s4h(e){return e}function c4h(e){return e}function l4h(e){return e}function f4h(e){return e}function d4h(e){return e}function p4h(e){return e}function _4h(e){return e}function h4h(e){return e}function y4h(e){return e}function b4h(e){return e}function v4h(e){return e}function g4h(e){return e}function O4h(e){return e}function m4h(e){return e}function A4h(e){return e}var P4h={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE"};var j4h={Stable:"Stable",GenerallyAvailable:"GenerallyAvailable",InDevelopment:"InDevelopment",PreRelease:"PreRelease",Deprecated:"Deprecated",Beta:"Beta"};var w4h={};var Ytl={};Yt(Ytl,{latest:()=>Gtl,v1:()=>Jtl,v2:()=>$tl});var Gtl={};Yt(Gtl,{Layout:()=>S4h,MdxEngine:()=>WEB,TwitterCardSetting:()=>M4h,commons:()=>E4h,frontmatter:()=>Vtl,seo:()=>Wtl});var WEB={NextMdxRemote:"next-mdx-remote",MdxBundler:"mdx-bundler"};var E4h={};var Vtl={};Yt(Vtl,{Layout:()=>S4h});var S4h={Guide:"guide",Overview:"overview",Reference:"reference",Page:"page",Custom:"custom"};var Wtl={};Yt(Wtl,{TwitterCardSetting:()=>M4h});var M4h={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var Jtl={};Yt(Jtl,{commons:()=>Ktl,db:()=>D4h,read:()=>B4h,write:()=>xtl});var D4h={};var B4h={};var xtl={};Yt(xtl,{DocsRegistrationId:()=>xEB,FilePath:()=>GEB});function GEB(e){return e}function xEB(e){return e}var Ktl={};Yt(Ktl,{ContentAlignment:()=>T4h,FontDisplay:()=>Q4h,FontStyle:()=>F4h,HeaderPosition:()=>R4h,JsScriptStrategy:()=>N4h,ProgrammingLanguage:()=>I4h,SearchbarPlacement:()=>C4h,TabsPlacement:()=>q4h,TwitterCardSetting:()=>z4h,commons:()=>Htl});var Htl={};Yt(Htl,{ContentAlignment:()=>T4h,FontDisplay:()=>Q4h,FontStyle:()=>F4h,HeaderPosition:()=>R4h,JsScriptStrategy:()=>N4h,ProgrammingLanguage:()=>I4h,SearchbarPlacement:()=>C4h,TabsPlacement:()=>q4h,TwitterCardSetting:()=>z4h});var I4h={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 C4h={Header:"HEADER",HeaderTabs:"HEADER_TABS",Sidebar:"SIDEBAR"};var q4h={Header:"HEADER",Sidebar:"SIDEBAR"};var T4h={Center:"CENTER",Left:"LEFT"};var R4h={Fixed:"FIXED",Absolute:"ABSOLUTE"};var z4h={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var N4h={BeforeInteractive:"beforeInteractive",AfterInteractive:"afterInteractive",LazyOnload:"lazyOnload"};var F4h={Normal:"normal",Italic:"italic"};var Q4h={Auto:"auto",Block:"block",Swap:"swap",Fallback:"fallback",Optional:"optional"};var $tl={};Yt($tl,{read:()=>U4h,write:()=>L4h});var U4h={};var L4h={};var Ztl={};Yt(Ztl,{ChangelogEntryType:()=>W4h,GeneratorId:()=>HEB,GeneratorLanguage:()=>KEB,ReleaseType:()=>G4h,cli:()=>V4h,commons:()=>Xtl,versions:()=>x4h});var V4h={};var Xtl={};Yt(Xtl,{ChangelogEntryType:()=>W4h,ReleaseType:()=>G4h});var W4h={Fix:"fix",Feat:"feat",Chore:"chore",Break:"break",Internal:"internal"};var G4h={Ga:"GA",Rc:"RC"};var x4h={};function HEB(e){return e}var KEB={Python:"python",Go:"go",Java:"java",Typescript:"typescript",Ruby:"ruby",Csharp:"csharp",Php:"php",Swift:"swift",Rust:"rust"};var ktl={};Yt(ktl,{PullRequestState:()=>H4h});var H4h={Open:"open",Closed:"closed",Merged:"merged"};var rrl={};Yt(rrl,{latest:()=>erl,v1:()=>trl});var erl={};Yt(erl,{NodeId:()=>YEB,ProductId:()=>XEB,Slug:()=>JEB,TabId:()=>$EB});function JEB(e){return e}function $EB(e){return e}function YEB(e){return e}function XEB(e){return e}var trl={};Yt(trl,{NavigationV1Availability:()=>rSB,NodeId:()=>eSB,ProductId:()=>tSB,Slug:()=>ZEB,TabId:()=>kEB});function ZEB(e){return e}function kEB(e){return e}function eSB(e){return e}function tSB(e){return e}var rSB={Stable:"stable",GenerallyAvailable:"generally-available",InDevelopment:"in-development",PreRelease:"pre-release",Beta:"beta",Deprecated:"deprecated"};var nrl={};Yt(nrl,{Language:()=>K4h,VersionBump:()=>J4h,versions:()=>irl});var irl={};Yt(irl,{Language:()=>K4h,VersionBump:()=>J4h});var K4h={Go:"Go",TypeScript:"TypeScript",Java:"Java",Python:"Python",Csharp:"Csharp",Ruby:"Ruby"};var J4h={Major:"MAJOR",Minor:"MINOR",Patch:"PATCH"};var $4h={};var Y4h={};var arl={};Yt(arl,{PayloadLocation:()=>X4h});var X4h={Body:"BODY",Query:"QUERY",Path:"PATH",Headers:"HEADERS",Relative:"RELATIVE",Auth:"AUTH"};var Z4h={};var j0u=class{warnings=[];errors=[];error(t){this.errors.push(t)}warning(t){this.warnings.push(t)}};function Ko(e){return e!=null}var eLh=ue(A4a(),1);var k4h=["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 EXt(e){return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e=e.replace(/_/g," "),e=e.replace(/-/g," "),(0,eLh.default)(e,{special:k4h}).replace(/V\s(\d)/g,"V$1")}function tLh({endpoints:e,webhookEndpoints:t}){let r={};return Object.values({...e,...t}).forEach(i=>{let n=[];i.namespace?.forEach(a=>{let o=[...n,a],c=sc.api.v1.SubpackageId(o.join("."));r[c]={id:c,name:a,displayName:EXt(a)},n.push(a)})}),r}var w0u=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 rLh(e){return`#/${e.map(t=>t.replaceAll(/~/g,"~0").replaceAll(/\//g,"~1")).join("/")}`}var Ao=class extends w0u{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 ${rLh(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 Ao{},qY=class extends qC{seenSchemas;constructor(t){super(t),this.seenSchemas=new Set(t.seenSchemas)}};var iLh="x-fern-base-path",nLh="x-fern-availability",E0u="x-fern-sdk-group-name",aLh="x-fern-global-headers",oLh="x-fern-sdk-method-name";var uLh="x-fern-webhook",sLh="x-fern-access-token-locator",cLh="x-fern-basic",lLh="x-fern-username-variable-name",fLh="x-fern-password-variable-name",dLh="x-fern-bearer",pLh="x-fern-token-variable-name",_Lh="x-fern-header",hLh="x-fern-header-variable-name",yLh="x-fern-server-name",bLh="x-fern-examples";var S0u=class extends Ao{serverName;constructor(t){super(t),this.safeParse()}parse(){this.serverName=this.input[yLh]}convert(){if(this.serverName!=null)return this.serverName}};var M0u=class extends Ao{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 S0u({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:sc.EnvironmentId(t),baseUrl:this.url}}};function mYi(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 M0u({input:c,context:r,accessPath:i,pathId:["servers",`${d}`]}));return[...n,...o]}function tg(e){return typeof e=="object"&&Ko(e)&&"$ref"in e&&typeof e.$ref=="string"}function TL(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:(tg(n)&&(n=TL(n,t,r)),n)}function D0u(e,t){let r=t.components?.securitySchemes?.[e];if(r!=null)return tg(r)?TL(r,t,void 0):r}var NLh=ue(vM());var B0u=class extends Ao{username;password;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[cLh];this.username=t?.username,this.password=t?.password}convert(){return{username:this.username,password:this.password}}};var I0u=class extends Ao{passwordVariableName;constructor(t){super(t),this.safeParse()}parse(){this.passwordVariableName=this.input[fLh]}convert(){return this.passwordVariableName}};var C0u=class extends Ao{usernameVariableName;constructor(t){super(t),this.safeParse()}parse(){this.usernameVariableName=this.input[lLh]}convert(){return this.usernameVariableName}};var q0u=class extends Ao{bearerTokenVariableName;bearerTokenEnvVar;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[dLh];this.bearerTokenVariableName=t?.name,this.bearerTokenEnvVar=t?.env}convert(){return{tokenVariableName:this.bearerTokenVariableName,tokenEnvVar:this.bearerTokenEnvVar}}};var T0u=class extends Ao{tokenVariableName;constructor(t){super(t),this.safeParse()}parse(){this.tokenVariableName=this.input[pLh]}convert(){return this.tokenVariableName}};function vLh(e){return typeof e=="object"&&e!=null&&"in"in e&&e.in==="header"}var gLh="x-bearer-format",OLh="x-code-samples",mLh="x-codeSamples";var R0u=class extends Ao{bearerFormat;constructor(t){super(t),this.safeParse()}parse(){this.bearerFormat=this.input[gLh]}convert(){return this.bearerFormat}};var z0u=class extends Ao{headerVariableName;headerEnvVar;headerPrefix;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[_Lh];this.headerVariableName=t?.name,this.headerEnvVar=t?.env,this.headerPrefix=t?.prefix}convert(){return{name:this.headerVariableName,env:this.headerEnvVar,prefix:this.headerPrefix}}};var N0u=class extends Ao{headerVariableName;constructor(t){super(t),this.safeParse()}parse(){this.headerVariableName=this.input[hLh]}convert(){return this.headerVariableName}};function ALh(e){return e.type==="apiKey"}var ela=class extends Ao{headerName;headerBearerFormatNode;headerAuthNode;headerVariableNameNode;constructor(t){super(t),this.safeParse()}parse(){ALh(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 N0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerBearerFormatNode=new R0u({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 F0u(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function tla(e){return typeof e=="string"||typeof e=="symbol"?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function sOn(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(sOn).join(",");let t=String(e);return t==="0"&&Object.is(Number(e),-0)?"-0":t}function Q0u(e){if(Array.isArray(e))return e.map(tla);if(typeof e=="symbol")return[e];e=sOn(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 ZYa(e,t,r){if(e==null)return r;switch(typeof t){case"string":{if(T3o(t))return r;let i=e[t];return i===void 0?F0u(t)?ZYa(e,Q0u(t),r):r:i}case"number":case"symbol":{typeof t=="number"&&(t=tla(t));let i=e[t];return i===void 0?r:i}default:{if(Array.isArray(t))return iSB(e,t,r);if(Object.is(t?.valueOf(),-0)?t="-0":t=String(t),T3o(t))return r;let i=e[t];return i===void 0?r:i}}}function iSB(e,t,r){if(t.length===0)return r;let i=e;for(let n=0;n<t.length;n++){if(i==null||T3o(t[n]))return r;i=i[t[n]]}return i===void 0?r:i}function PLh(e){return function(t){return ZYa(t,e)}}function jLh(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function orl(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function srl(e,t,r){return typeof r!="function"?srl(e,t,()=>{}):url(e,t,function i(n,a,o,c,d,s){let u=r(n,a,o,c,d,s);return u!==void 0?!!u:url(n,a,i,s)},new Map)}function url(e,t,r,i){if(t===e)return!0;switch(typeof t){case"object":return nSB(e,t,r,i);case"function":return Object.keys(t).length>0?url(e,{...t},r,i):orl(e,t);default:return jLh(e)?typeof t=="string"?t==="":!0:orl(e,t)}}function nSB(e,t,r,i){if(t==null)return!0;if(Array.isArray(t))return wLh(e,t,r,i);if(t instanceof Map)return aSB(e,t,r,i);if(t instanceof Set)return oSB(e,t,r,i);let n=Object.keys(t);if(e==null||T3a(e))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(!T3a(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 aSB(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 wLh(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 oSB(e,t,r,i){return t.size===0?!0:e instanceof Set?wLh([...e],[...t],r,i):!1}function U0u(e,t){return srl(e,t,()=>{})}function ELh(e){return e=_xp(e),t=>U0u(t,e)}function SLh(e,t){return pxp(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 I3o:case B3o:case C3o:{let c=new e.constructor(e?.valueOf());return SVt(c,e),c}case q3o:{let c={};return SVt(c,e),c.length=e.length,c[Symbol.iterator]=e[Symbol.iterator],c}default:return}})}function MLh(e){return SLh(e)}var uSB=/^(?:0|[1-9]\d*)$/;function DLh(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 uSB.test(e)}}function BLh(e){return e!==null&&typeof e=="object"&&D3o(e)==="[object Arguments]"}function ILh(e,t){let r;if(Array.isArray(t)?r=t:typeof t=="string"&&F0u(t)&&e?.[t]==null?r=Q0u(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)||BLh(i))&&DLh(a)&&a<i.length))return!1;i=i[a]}return!0}function CLh(e,t){switch(typeof e){case"object":{Object.is(e?.valueOf(),-0)&&(e="-0");break}case"number":{e=tla(e);break}}return t=MLh(t),function(r){let i=ZYa(r,e);return i===void 0?ILh(r,e):t===void 0?i===void 0:U0u(i,t)}}function qLh(e){if(e==null)return P8o;switch(typeof e){case"function":return e;case"object":return Array.isArray(e)&&e.length===2?CLh(e[0],e[1]):ELh(e);case"string":case"symbol":case"number":return PLh(e)}}function L0u(e,t=P8o){return e==null?{}:I4(e,qLh(t))}function TLh(e){return bKp(sOn(e))}function RLh(e){return typeof e!="string"&&(e=sOn(e)),e.replace(/['\u2019]/g,"")}function rWt(e){return yxp(RLh(TLh(e)))}function ij(e){if(e!=null)return Array.isArray(e)?e:[e]}function V0u({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`${sSB(o)}${cSB(e)}.${lSB(i,n,a,c)}`}function sSB(e){return e?"webhook_":"endpoint_"}function cSB(e){return e!=null?ij(e)?.map(t=>rWt(t)).join("/"):""}function lSB(e,t,r,i){return e||t||rWt(r??"")||rWt(i??"")}function zLh(e){return e.length===0?!1:/^\$?(\.[\w*]+|\[['"][\w*]+['"]?\]|\[['"]?[\d*]+['"]?\]|\[[\d:]+\])*$/.test(e)}var W0u=class extends Ao{accessTokenLocator;constructor(t){super(t),this.safeParse()}parse(){this.accessTokenLocator=this.input[sLh],this.accessTokenLocator!=null&&(zLh(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 G0u=class extends Ao{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 ela({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.accessTokenLocatorNode=new W0u({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=V0u({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:sc.EndpointId(r),accessTokenLocator:sc.JqString(t),headerName:this.headerAuthNode?.convert()?.headerWireValue,tokenPrefix:this.headerAuthNode?.convert()?.prefix}}}}};var rla=class extends Ao{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 B0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicUsernameVariableNameNode=new C0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicPasswordVariableNameNode=new I0u({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 q0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.bearerTokenVariableNameNode=new T0u({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":{vLh(this.input)?(this.authScheme="header",this.headerAuthNode=new ela({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 G0u({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 NLh.UnreachableCaseError(this.authScheme);return}}};var ila=class extends Ao{authNodesMap;constructor(t){super(t),this.safeParse()}parse(){this.input.map((t,r)=>Object.keys(t).map(i=>{let n=D0u(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 rla({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(Ko))}};var x0u=class extends Ao{basePath;constructor(t){super(t),this.safeParse()}parse(){this.basePath=this.input[iLh],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 FLh(e){return"required"in e&&typeof e.required=="boolean"?e.required:!1}function QLh(e,t){return{type:"alias",value:{type:"optional",shape:e,default:t}}}function nla(e,t){return e==null?void 0:Object.entries(e).map(([i,n])=>ij(n.convert())?.map(o=>((t!=null&&!t.includes(i)||t==null&&!FLh(n))&&(o=QLh(o,o.type==="enum"?o.default:void 0)),{key:sc.PropertyKey(i),valueShape:o,description:n.description,availability:n.availability?.convert()})).filter(Ko)).filter(Ko).reduce((i,n)=>i.flatMap(a=>n.length>0?n.map(o=>[...a,o]):[[...a]]),[[]])}function H0u(e,t){return tg(e)?TL(e,t,void 0):e}function AYi(e,t){return e!=null&&e!==""?e:t!=null&&t!==""?t:void 0}function ULh(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 LLh(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 VLh=ue(vM());var crl=["decimal","decimal128","double-int","double","float","sf-decimal"],lrl=["int16","int32","int64","int8","sf-integer","uint8"],frl=["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"],drl=["beta","pre-release","in-development","generally-available","deprecated"];function TC(e,t){return tg(e)?TL(e,t,{type:"unknown","x-fern-type":"unknown",additionalProperties:!1}):e}var SSe=class extends Ao{availability;constructor(t){super(t),this.safeParse()}parse(){if(TC(this.input,this.context.document)?.deprecated)this.availability="deprecated";else{let r=this.input[nLh];r!=null&&(drl.includes(r)?this.availability=r:(this.context.errors.warning({message:`Expected one of: ${drl.join(", ")}. Received: ${r}`,path:this.accessPath}),this.availability=void 0))}}convert(){switch(this.availability){case"beta":case"pre-release":return sc.Availability.Beta;case"in-development":return sc.Availability.InDevelopment;case"generally-available":return sc.Availability.GenerallyAvailable;case"deprecated":return sc.Availability.Deprecated;case void 0:return;default:new VLh.UnreachableCaseError(this.availability);return}}};var J0u=ue(vM());function WLh(e){return typeof e=="object"&&e!=null&&"language"in e}function GLh(e){return typeof e=="object"&&e!=null&&"sdk"in e}function xLh(e){return typeof e=="object"&&e!=null&&("error"in e||"body"in e)}function HLh(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)}function K0u(e){return typeof e=="object"&&e!=null&&"event"in e}function prl(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)&&e.stream.every(K0u)}function PYi(e){return typeof e=="object"&&e!=null&&"filename"in e&&"data"in e&&typeof e.filename=="string"&&typeof e.data=="string"}function KLh(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}var $0u=class extends Ao{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[bLh]}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 PYi(o)?[n,{type:"filenameWithData",filename:o.filename,data:sc.FileId(o.data)}]:o!=null?[n,{type:"filename",value:o}]:void 0;case"files":{if(Array.isArray(o)){if(o.every(c=>PYi(c)))return[n,{type:"filenamesWithData",value:o.map(c=>({filename:c.filename,data:sc.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 J0u.UnreachableCaseError(a.multipartType);return}}).filter(Ko))};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=KLh(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 J0u.UnreachableCaseError(n.contentType);break}let o;switch(i.contentType){case"application/json":{xLh(r.response)&&(o={type:"json",value:r.response.body});break}case"text/event-stream":{prl(r.response)&&(o={type:"sse",value:r.response.stream.map(l=>({event:l.event,data:l.data}))});break}case"application/octet-stream":!prl(r.response)&&HLh(r.response)&&(o={type:"stream",value:r.response.stream});break;case void 0:break;default:new J0u.UnreachableCaseError(i.contentType);break}let c={};r["code-samples"]?.forEach(l=>{WLh(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})):GLh(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])=>[sc.PropertyKey(l),p])),s=Object.fromEntries(Object.entries(r["query-parameters"]??{}).map(([l,p])=>[sc.PropertyKey(l),p])),u=Object.fromEntries(Object.entries(r.headers??{}).map(([l,p])=>[sc.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 kYa=class extends Ao{groupName;constructor(t){super(t),this.safeParse()}parse(){this.groupName=this.input[E0u]}convert(){if(this.groupName==null)return;let t;return Array.isArray(this.groupName)?t=this.groupName:t=[this.groupName],t.map(r=>sc.api.v1.SubpackageId(rWt(r)))}};var Y0u=class extends Ao{sdkMethodName;constructor(t){super(t),this.safeParse()}parse(){this.sdkMethodName=this.input[oLh]}convert(){return this.sdkMethodName}};var X0u=class extends Ao{isWebhook;constructor(t){super(t),this.safeParse()}parse(){this.isWebhook=this.input[uLh]}convert(){return this.isWebhook}};var Z0u=class extends Ao{codeSamples;constructor(t){super(t),this.safeParse()}parse(){this.codeSamples=[...this.input[OLh]??[],...this.input[mLh]??[]],this.codeSamples.forEach(t=>{[...Object.values(sc.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 cOn=ue(vM());function _rl(e,t){return tg(e)?TL(e,t,void 0):e}function JLh(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 zF="",SXt=class extends Ao{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&&(PYi(n)||typeof n=="string");case"files":return t&&Array.isArray(n)&&n.every(a=>PYi(a)||typeof a=="string");case"property":return t;case void 0:return t&&!1;default:return new cOn.UnreachableCaseError(i.multipartType),t}},!0)}parse(){let t=this.shapes.requestBody?.schema?.example({includeOptionals:!1,override:void 0});this.resolvedRequestInput=_rl(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=_rl(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 cOn.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(K0u)){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 cOn.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 PYi(n)?[r,{type:"filenameWithData",filename:n.filename,data:sc.FileId(n.data)}]:[r,{type:"filename",value:n}];case"files":{if(Array.isArray(n)){if(n.every(a=>PYi(a)))return[r,{type:"filenamesWithData",value:n.map(a=>({filename:a.filename,data:sc.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 cOn.UnreachableCaseError(i.multipartType);return}}).filter(Ko))};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 cOn.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 cOn.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(Ko));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(Ko));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:JLh(this.path,i??{}),responseStatusCode:this.responseStatusCode,name:this.name!=null?EXt(this.name):this.summary!=null?EXt(this.summary):void 0,description:this.convertDescription(),pathParameters:i,queryParameters:n,headers:a,requestBody:t,responseBody:r,snippets:void 0}}};function $Lh(e,t){return tg(e)?TL(e,t,void 0):e}var sVh=ue(vM());var YLh="#/components/schemas/";function ala(e){if(e.$ref.startsWith(YLh))return e.$ref.replace(YLh,"")}function _4i(e){if(e!=null)return{type:"alias",value:{type:"nullable",shape:e}}}function jYi(e){return typeof e.type=="string"&&e.type==="array"}function XLh(e){return e.type==="boolean"}function ZLh(e){return e.type==="integer"}function wYi(e){return!Array.isArray(e.type)&&!jYi(e)}function kLh(e){return e!=null&&Array.isArray(e)&&e.every(t=>t.type==="null"||wYi(t)||jYi(t))}function eVh(e){return"nullable"in e&&typeof e.nullable=="boolean"}function tVh(e){return e.type==="null"}function rVh(e){return e.type==="number"}function hrl(e){return e.type==null||typeof e.type=="string"&&e.type==="object"}function iVh(e){return e.type==="string"}var k0u=class extends qY{item;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.item=new hw({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 ij(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 ewu=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 SSe({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 twu=class extends qY{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 hw({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName})}).filter(Ko)}convert(){if(this.typeNodes==null)return;let i=this.typeNodes.map(n=>ij(n.convert())?.map(o=>({displayName:n.name,shape:o,description:n.description,availability:n.availability?.convert()}))).filter(Ko).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(_4i).filter(Ko):i}example(t){return this.nullable?null:this.typeNodes?.[0]?.example(t)}};function rwu(e){return e!=null&&e.length>0?e:[void 0]}var ola=class extends qY{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 hw({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 hw({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(tg(t))return ala(t);this.properties={...this.properties,...Object.fromEntries(Object.entries(t.properties??{}).map(([i,n])=>[i,new hw({input:n,context:this.context,accessPath:this.accessPath,pathId:["allOf",r.toString(),"properties",i],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))}}).filter(Ko))),this.description=this.input.description}convertProperties(){if(this.properties!=null)return nla(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}}}]:ij(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(Ko)}convert(){let t=this.convertProperties();if(t==null)return;let r=this.convertExtraProperties();return t.flatMap(i=>rwu(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=>sc.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 hw({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 iwu=class extends qY{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 hw({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0).filter(Ko);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 hw({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(Ko);return this.isNullable&&n!=null?n.map(_4i).filter(Ko):n}let t=0,r=this.discriminated&&this.discriminant!=null&&this.discriminatedMapping!=null?{type:"discriminatedUnion",discriminant:sc.PropertyKey(this.discriminant),variants:Object.entries(this.discriminatedMapping).flatMap(([n,a])=>ij(a.convert())?.map(c=>{if(!(c==null||c.type!=="object"))return{discriminantValue:n,displayName:a.name??EXt(n),availability:a.availability?.convert(),description:a.description,...c}}).filter(Ko)).filter(Ko)}:this.undiscriminatedMapping!=null?{type:"undiscriminatedUnion",variants:this.undiscriminatedMapping.flatMap(n=>ij(n.convert())?.map(o=>{if(o==null)return;t+=1;let c=o.type==="object"?EXt(`${this.schemaName??"Variant"} ${t}`):void 0;return{displayName:n.name??(o.type==="alias"&&o.value.type==="id"?EXt(o.value.id):c),shape:o,description:n.description,availability:n.availability?.convert()}}).filter(Ko)).filter(Ko)}:void 0,i=this.isNullable?_4i(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 nwu=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 EYi=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(tg(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(Ko),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 nVh=ue(vM());function fSB(e){return lrl.includes(e)}var awu=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&&(fSB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${lrl.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 nVh.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 owu=class extends qC{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){this.displayName=this.input.title}convert(){return _4i({type:"alias",value:{type:"unknown",displayName:this.displayName}})}example(){return null}};var aVh=ue(vM());function dSB(e){return crl.includes(e)}var uwu=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&&(dSB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${crl.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 aVh.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 oVh=ue(vM());function pSB(e){return frl.includes(e)}var swu=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 oVh.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&&(pSB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${frl.join(", ")}. Received ${this.input.format}`,path:this.accessPath})),this.input.enum!=null&&(this.enum=new EYi({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 uVh=ue(vM());var cwu=class extends qC{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){(0,uVh.noop)()}convert(){return{type:"alias",value:{type:"unknown",displayName:void 0}}}example(){}};var lOn=class extends qY{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=ala(this.input);let t=TC(this.input,this.context.document);t?.enum!=null&&wYi(t)&&(this.maybeEnumConverterNode=new EYi({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:sc.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 hw({input:r,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName}).example(t)}};var hw=class e extends qY{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 SSe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),wYi(this.input)&&eVh(this.input)&&(this.nullable=this.input.nullable!=null?this.input.nullable:this.nullable),tg(this.input)){let t=ala(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 lOn({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 ewu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});else if(kLh(this.input))this.typeShapeNode=new twu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(wYi(this.input)&&(this.input.oneOf!=null||this.input.anyOf!=null))this.typeShapeNode=new iwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(hrl(this.input)&&this.input.allOf!=null)this.typeShapeNode=new ola({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(wYi(this.input)&&this.input.enum!=null)this.typeShapeNode=new EYi({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":hrl(this.input)&&(this.typeShapeNode=new ola({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"array":jYi(this.input)&&(this.typeShapeNode=new k0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"boolean":XLh(this.input)&&(this.typeShapeNode=new nwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"integer":ZLh(this.input)&&(this.typeShapeNode=new awu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"number":rVh(this.input)&&(this.typeShapeNode=new uwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"string":iVh(this.input)&&(this.typeShapeNode=new swu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"null":tVh(this.input)&&(this.typeShapeNode=new owu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}));break;case void 0:break;default:new sVh.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 ola({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 cwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),!tg(this.input)&&(!jYi(this.input)&&this.input==null||jYi(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=ij(t)?.map(i=>this.nullable?_4i(i):i).filter(Ko);return Array.isArray(t)&&t.length>1?r:r?.[0]}example(t){return this.availability?.availability!=="deprecated"?this.typeShapeNode?.example(t):void 0}};function SYi(e){if(e!=null)return nla(e,Object.entries(e??{}).map(([t,r])=>r.required?t:void 0).filter(Ko))}var MXt=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;tg(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 SSe({input:r,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=new hw({input:r,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:t});let i=$Lh(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 cVh(e,t){return tg(e)?TL(e,t,void 0):e}var yrl=ue(vM());function lwu(e){let{uniqueId:t,type:r,contextTypes:i,description:n,availability:a}=e;i[sc.TypeId(t)]={name:t,shape:r,description:n,availability:a}}var lVh=ue(mnc(),1),ula=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=lVh.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 _SB(e){return typeof e.securitySchemes=="object"&&e.securitySchemes!=null}var fwu=class extends Ao{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 hw({input:r,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:new Set,nullable:void 0,schemaName:t})]))),_SB(this.input)&&this.input.securitySchemes!=null&&(this.securitySchemes=Object.fromEntries(Object.entries(this.input.securitySchemes??{}).map(([t,r],i)=>{let n;if(tg(r)?n=D0u(r.$ref,this.context.document):n=r,n!=null)return[t,new rla({input:n,context:this.context,accessPath:this.accessPath,pathId:["securitySchemes",`${i}`]})]}).filter(Ko)))}convert(){return{auths:this.securitySchemes!=null?Object.fromEntries(Object.entries(this.securitySchemes??{}).map(([t,r])=>{let i=r.convert();if(i!=null)return[sc.api.latest.AuthSchemeId(t),i]}).filter(Ko)):void 0,types:this.typeSchemas!=null?Object.fromEntries(Object.entries(this.typeSchemas).map(([t,r])=>{let i=r.name??t,n=ij(r.convert());return n==null?[t,void 0]:[sc.TypeId(t),{name:i,shape:n[0],description:r.description,availability:void 0}]}).filter(([t,r])=>Ko(r))):void 0}}};var dwu=class extends hw{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. ${tg(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 pwu=class extends Ao{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 SSe({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=tg(this.input.schema)?new lOn({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=ula.parse(t);n?.containsJSON()?(this.contentType="json",this.schema=this.schema??new hw({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 dwu({input:o,context:this.context,accessPath:this.accessPath,pathId:`schema.${a}`,seenSchemas:new Set,nullable:void 0,schemaName:a})]}).filter(Ko))):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?{[zF]:{value:this.input.example}}:{},...this.input.examples},r!=null&&Object.keys(this.examples).length===0&&(this.examples={[zF]:{value:r}})}convertJsonLike(){let t=this.schema?.convert();return t==null?void 0:ij(t)?.map(i=>{let n=i.type;switch(n){case"object":case"alias":return i;case"enum":case"undiscriminatedUnion":case"discriminatedUnion":{let a=rWt([this.method,this.path,this.contentType,"request"].join("_"));return lwu({uniqueId:a,type:i,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:sc.TypeId(a),default:i.type==="enum"&&i.default!=null?{type:"enum",value:i.default}:void 0}}}case void 0:return;default:new yrl.UnreachableCaseError(n);return}}).filter(Ko)}convert(){if(this.schema instanceof lOn)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:sc.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:sc.PropertyKey(i),isOptional:this.requiredFields?.includes(i)==null,contentType:n.contentType,description:n.description,availability:n.availability?.convert()}];case"property":{let a=ij(n.convert()),o=n.multipartType;return a?.map(c=>({type:o,key:sc.PropertyKey(i),contentType:n.contentType,exploded:void 0,valueShape:c,description:n.description,availability:n.availability?.convert()}))}case void 0:return[];default:return new yrl.UnreachableCaseError(n.multipartType),[]}}).filter(Ko).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 _wu=class extends Ao{description;requestBodiesByContentType;constructor(t){super(t),this.safeParse(t)}parse({method:t,path:r}){let i=cVh(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 pwu({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])=>ij(r.convert())?.map(n=>({description:this.description,contentType:t,body:n}))).filter(Ko)}convertToWebhookPayload(){return Object.values(this.requestBodiesByContentType??{}).flatMap(t=>ij(t.convert())?.map(i=>{if(!(i.type!=="alias"&&i.type!=="object"))return{description:this.description,shape:i}})).filter(Ko)}webhookExample(){return{payload:this.requestBodiesByContentType?.["application/json"]?.schema?.example({includeOptionals:!0,override:void 0})}}};var fVh={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 dVh(e,t){if(tg(e)){let r=TL(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var hwu=ue(vM());var pVh="application/json";var _Vh="application/octet-stream";function hVh(e,t){return e===t||t===zF||e===zF}var eXa=class extends Ao{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)hVh(c,a)&&(i.add(c),this.examples?.push(new SXt({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,AYi(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 SXt({input:{requestExample:u,responseExample:l},context:this.context,accessPath:this.accessPath,pathId:s!=null&&s!==""?["examples",s]:"examples"},this.path,this.statusCode,AYi(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 SXt({input:{requestExample:s,responseExample:u},context:this.context,accessPath:this.accessPath,pathId:d!=null&&d!==""?["examples",d]:"examples"},this.path,this.statusCode,AYi(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 SXt({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,AYi(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[zF];if(a!=null)for(let o of a)this.examples?.push(new SXt({input:{requestExample:n,responseExample:o},context:this.context,accessPath:this.accessPath,pathId:i!=null&&i!==""?["examples",i]:"examples"},this.path,this.statusCode,AYi(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=ula.parse(t);if(c?.isJSON()||c?.isEventStream())this.contentType=pVh,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 hw({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=_Vh,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 hw({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=L0u(this.input.examples,c=>[c])),this.input.example!=null&&Object.keys(r).length===0&&(r[zF]??=[],r[zF]=[{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=L0u(i.examples,c=>[c])),i.example!=null&&Object.keys(r).length===0&&(r[zF]??=[],r[zF]?.push({value:i.example}))),Object.keys(r).length===0){let c=this.schema?.example({includeOptionals:!0,override:void 0});r[zF]??=[],r[zF]?.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!==zF).map(([d,s])=>[c,d,s]));let o=Object.entries(r).filter(([c,d])=>!n.has(c)&&Ko(d)&&c!==zF);Object.keys(r).every(c=>c===zF)||this.matchExamplesByIndex(a,o),!n.has(zF)&&this.examples.length===0&&this.addGlobalFallbackExample(this.requests,r),this.examples.length===0&&(this.examples=void 0)}convertStreamingFormat(){switch(this.streamingFormat){case"json":return ij(this.schema?.convert())?.map(r=>({type:"stream",terminator:"[DATA]",shape:r}));case"sse":return{type:"streamingText"};case void 0:return;default:new hwu.UnreachableCaseError(this.streamingFormat);return}}convertJsonLike(){return ij(this.schema?.convert())?.map(r=>{let i=r.type;switch(i){case"alias":return r;case"discriminatedUnion":case"undiscriminatedUnion":case"enum":{let n=rWt([this.method,this.path,this.statusCode,"response"].join("_"));return lwu({uniqueId:n,type:r,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:sc.TypeId(n),default:r.type==="enum"&&r.default!=null?{type:"enum",value:r.default}:void 0}}}case"object":return r;default:new hwu.UnreachableCaseError(i);return}}).filter(Ko)}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 hwu.UnreachableCaseError(this.contentType);return}else return this.unsupportedContentType!=null?this.convertJsonLike():void 0}};var tXa=class extends Ao{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=dVh(this.input,this.context.document);if(r==null){this.context.errors.error({message:tg(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 MXt({input:n,context:this.context,accessPath:this.accessPath,pathId:"headers",parameterName:i})}),r.content==null?(this.responses??=[],this.responses.push(new eXa({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 eXa({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(Ko)}};var ywu=class extends Ao{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 tXa({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 tXa({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 rwu(SYi(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(Ko))})))}).filter(Ko)}convertResponseObjectToErrors(){return Object.entries(this.errorsByStatusCode??{}).flatMap(([t,r])=>r.responses?.flatMap(i=>{let n=i.schema,a=ij(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??fVh[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(Ko)})).filter(Ko)})).filter(Ko)}convert(){return{responses:this.convertResponseObjectToHttpResponses(),errors:this.convertResponseObjectToErrors()}}};var MYi=class extends Ao{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 SXt({input:{requestExample:t,responseExample:void 0},context:this.context,accessPath:this.accessPath,pathId:"examples"},this.path,200,AYi(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 SSe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),this.servers=mYi(this.servers,this.input.servers,this.context,this.accessPath),this.isWebhook=new X0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}).isWebhook||this.isWebhook,this.input.parameters?.map((i,n)=>{if(tg(i)){let a=H0u(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 MXt({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 MXt({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 MXt({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 Z0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-code-samples"}),this.requests=this.input.requestBody!=null?new _wu({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 ywu({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 ila({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"})),this.namespaces=[new kYa({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 kYa({input:{[E0u]:i},context:this.context,accessPath:this.accessPath,pathId:["tags",`${n}`]})));let r=new Y0u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-sdk-method-name"});this.endpointIds=this.namespaces.map(i=>V0u({namespace:ij(i?.groupName),path:this.path,method:this.method,sdkMethodName:r.sdkMethodName,operationId:this.input.operationId,displayName:this.displayName,isWebhook:this.isWebhook})).filter(Ko),this.xFernExamplesNode=new $0u({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(Ko)}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:sc.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(Ko),n=LLh(this.xFernExamplesNode?.convert(),[...i??[],...t?.flatMap(u=>u.examples)??[]])?.map(u=>({...u,snippets:ULh(u.snippets,this.redocExamplesNode?.convert())}));if(this.isWebhook)return this.endpointIds.map((u,l)=>{if(!(this.method!=="POST"&&this.method!=="GET"))return{id:sc.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:SYi(this.queryParameters)?.flat(),headers:SYi(this.requestHeaders)?.flat(),payloads:this.requests?.convertToWebhookPayload(),examples:[this.requests?.webhookExample()].filter(Ko)}}).filter(Ko);let a=this.servers?.map(u=>u.convert()).filter(Ko),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(Ko);return this.endpointIds.map((u,l)=>({id:sc.EndpointId(u),description:this.description,availability:this.availability?.convert(),namespace:this.namespaces?.[l]?.convert()?.map(p=>sc.api.v1.SubpackageId(p)),displayName:this.displayName,operationId:this.operationId,method:this.method,path:o,auth:c?.map(p=>sc.api.latest.AuthSchemeId(p)),defaultEnvironment:a?.[0]?.id,environments:a,pathParameters:SYi(this.pathParameters)?.flat(),queryParameters:SYi(this.queryParameters)?.flat(),requestHeaders:SYi(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 sla=class extends Ao{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=mYi(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 MYi({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 MYi({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 MYi({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 MYi({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 MYi({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(Ko)}};function bwu(e){return"payloads"in e}var vwu=class extends Ao{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 sla({input:a,context:this.context,accessPath:this.accessPath,pathId:n,servers:mYi(t,a.servers,this.context,this.accessPath),globalAuth:r,basePath:i,isWebhook:void 0})}).filter(Ko)}convert(){if(this.paths==null)return;let t={},r={};return this.paths.forEach(i=>{let n=i.convert();n?.forEach(a=>{bwu(a)?r[sc.WebhookId(a.id)]=a:t[sc.EndpointId(a.id)]=a})}),{endpoints:t,webhookEndpoints:r}}};var gwu=class extends Ao{globalHeaders;requiredProperties;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[aLh]?.map(r=>{let{header:i,...n}=r;return(n.optional!=null&&!n.optional||H0u(n,this.context.document)?.required)&&(this.requiredProperties??=[],this.requiredProperties?.push(i)),[i,new MXt({input:n,context:this.context,accessPath:this.accessPath,pathId:this.pathId,parameterName:i})]});t!=null&&(this.globalHeaders=Object.fromEntries(t))}convert(){return nla(this.globalHeaders,this.requiredProperties)?.flat()}};function yVh(e,t){if(tg(e)){let r=TL(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var Owu=class extends Ao{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=yVh(a,this.context.document);if(o!=null)return new sla({input:o,context:this.context,accessPath:this.accessPath,pathId:n,servers:t,globalAuth:r,basePath:i,isWebhook:!0})}).filter(Ko)}convert(){return this.webhooks?.reduce((t,r)=>(r.convert()?.forEach(i=>{bwu(i)&&(t[sc.WebhookId(i.id)]=i)}),t),{})}};var mwu=class extends Ao{paths;webhooks;components;auth;globalHeaders;constructor(t){super(t),this.safeParse()}parse(){let t=mYi(void 0,this.input.servers,this.context,this.accessPath);this.input.security!=null&&(this.auth=new ila({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"}));let r=new x0u({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 Owu({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 fwu({input:this.input.components,context:this.context,accessPath:this.accessPath,pathId:"components"})),this.globalHeaders=new gwu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-global-headers"})}convert(){let t=Nve(),{webhookEndpoints:r,endpoints:i}=this.paths?.convert()??{},n={...this.webhooks?.convert()??{},...r??{}},a=tLh({endpoints:i,webhookEndpoints:n}),{types:o,auths:c}=this.components?.convert()??{};return{id:sc.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 brl(e,t){if(e instanceof ySe){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof jS))return;let r=new x8t(e.absoluteFilePath),i=await vSe({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 j0u,generatedTypes:{}},d=new mwu({input:o.value,context:c,accessPath:[],pathId:e.workspaceName??"openapi parser"});a=j$n(a,d.convert())}return a}var TKh=ue(Orl(),1),RKh=ue(cEu(),1),qSu=require("fs/promises"),zKh=ue(require("http"),1),NKh=ue(require("path"),1);var O6h=require("events"),_Eu=ue(require("fs"),1),OOn=ue(require("path"),1);var r6h=ue(require("os"),1),i6h=300,RYi=20,jXa=1e7,n6h=r6h.default.platform();var z1B=n6h==="darwin",Uil=n6h==="win32",zYi=z1B||Uil,a6h=3e3,o6h=2e4,Lil=1250;var CXt;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(CXt||(CXt={}));var gOn;(function(e){e.CHANGE="change",e.RENAME="rename"})(gOn||(gOn={}));var wXa;(function(e){e.CHANGE="change",e.ERROR="error"})(wXa||(wXa={}));var nf;(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"})(nf||(nf={}));var Qx;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(Qx||(Qx={}));var N1B=(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},lEu=N1B;var xil=ue(require("fs"),1),dEu=ue(require("path"),1);var dm=ue(require("fs"),1),RL=require("util");var y4i=(e,t)=>function(...i){return e.apply(void 0,i).catch(t)},qXt=(e,t)=>function(...i){try{return e.apply(void 0,i)}catch(n){return t(n)}};var Vil=ue(require("process"),1),u6h=Vil.default.getuid?!Vil.default.getuid():!1,s6h=1e4,NY=()=>{};var EXa={isChangeErrorOk:e=>{if(!EXa.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!u6h&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!EXa.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(!EXa.isNodeError(e))throw e;if(!EXa.isChangeErrorOk(e))throw e}},RC=EXa;var Wil=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=s6h,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()}}}}},c6h=new Wil;var b4i=(e,t)=>function(i){return function n(...a){return c6h.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)})}},v4i=(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 F1B={attempt:{chmod:y4i((0,RL.promisify)(dm.default.chmod),RC.onChangeError),chown:y4i((0,RL.promisify)(dm.default.chown),RC.onChangeError),close:y4i((0,RL.promisify)(dm.default.close),NY),fsync:y4i((0,RL.promisify)(dm.default.fsync),NY),mkdir:y4i((0,RL.promisify)(dm.default.mkdir),NY),realpath:y4i((0,RL.promisify)(dm.default.realpath),NY),stat:y4i((0,RL.promisify)(dm.default.stat),NY),unlink:y4i((0,RL.promisify)(dm.default.unlink),NY),chmodSync:qXt(dm.default.chmodSync,RC.onChangeError),chownSync:qXt(dm.default.chownSync,RC.onChangeError),closeSync:qXt(dm.default.closeSync,NY),existsSync:qXt(dm.default.existsSync,NY),fsyncSync:qXt(dm.default.fsync,NY),mkdirSync:qXt(dm.default.mkdirSync,NY),realpathSync:qXt(dm.default.realpathSync,NY),statSync:qXt(dm.default.statSync,NY),unlinkSync:qXt(dm.default.unlinkSync,NY)},retry:{close:b4i((0,RL.promisify)(dm.default.close),RC.isRetriableError),fsync:b4i((0,RL.promisify)(dm.default.fsync),RC.isRetriableError),open:b4i((0,RL.promisify)(dm.default.open),RC.isRetriableError),readFile:b4i((0,RL.promisify)(dm.default.readFile),RC.isRetriableError),rename:b4i((0,RL.promisify)(dm.default.rename),RC.isRetriableError),stat:b4i((0,RL.promisify)(dm.default.stat),RC.isRetriableError),write:b4i((0,RL.promisify)(dm.default.write),RC.isRetriableError),writeFile:b4i((0,RL.promisify)(dm.default.writeFile),RC.isRetriableError),closeSync:v4i(dm.default.closeSync,RC.isRetriableError),fsyncSync:v4i(dm.default.fsyncSync,RC.isRetriableError),openSync:v4i(dm.default.openSync,RC.isRetriableError),readFileSync:v4i(dm.default.readFileSync,RC.isRetriableError),renameSync:v4i(dm.default.renameSync,RC.isRetriableError),statSync:v4i(dm.default.statSync,RC.isRetriableError),writeSync:v4i(dm.default.writeSync,RC.isRetriableError),writeFileSync:v4i(dm.default.writeFileSync,RC.isRetriableError)}},l6h=F1B;var fEu=ue(require("fs"),1),SXa=ue(require("path"),1);var Gil=()=>{};var Q1B=()=>{let e=Gil,t=Gil,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}},f6h=Q1B;var U1B=()=>{let{promise:e,resolve:t,isPending:r}=f6h(),i=0,n=()=>{i+=1},a=()=>{i-=1,!i&&t()};return(()=>{n(),queueMicrotask(a)})(),{promise:e,isPending:r,increment:n,decrement:a}},d6h=U1B;var p6h={then:e=>{e()}};var _6h=e=>Array.isArray(e)?e:[e],h6h=e=>typeof e=="function";var L1B=(e,t)=>{let r=t?.followSymlinks??!1,i=t?.depth??1/0,n=t?.limit??1/0,a=t?.ignore??[],o=_6h(a).map(W=>h6h(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}=d6h(),B=0,R=(W,x,Ee,se)=>{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),!(se>=i)&&(B>=n||$(x,se+1)))},T=(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,se)=>{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&&(se>=i||B>=n||de(x,se+1)))},z=(W,x,Ee,se,Oe)=>{d.aborted||c(x)||(se.isDirectory()?R(W,x,Ee,Oe):se.isFile()?T(W,x,Ee):se.isSymbolicLink()&&q(W,x,Ee,Oe))},N=(W,x,Ee,se)=>{if(d.aborted)return;let Oe=x===SXa.default.sep?"":SXa.default.sep,Fe=Ee.name,ae=`${x}${Oe}${Fe}`;c(ae)||(Ee.isDirectory()?R(W,ae,Fe,se):Ee.isFile()?T(W,ae,Fe):Ee.isSymbolicLink()&&q(W,ae,Fe,se))},H=(W,x,Ee,se)=>{for(let Oe=0,Fe=Ee.length;Oe<Fe;Oe++)N(W,x,Ee[Oe],se)},$=(W,x)=>{d.aborted||x>i||B>=n||(w(),fEu.default.readdir(W,{withFileTypes:!0},(Ee,se)=>{if(Ee||d.aborted||!se.length)return D();(s(se)||p6h).then(()=>{let Fe=m[W]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};H(Fe,W,se,x),D()})}))},de=(W,x)=>{w(),fEu.default.realpath(W,(Ee,se)=>{if(Ee||d.aborted)return D();fEu.default.stat(se,(Oe,Fe)=>{if(Oe||d.aborted)return D();let ae=SXa.default.basename(se),re=m[W]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};z(re,se,ae,Fe,x),D()})})};return(async(W,x=1)=>(W=SXa.default.normalize(W),g.add(W),$(W,x),await M,d.aborted?A:j))(e)},y6h=L1B;var TXt={lang:{debounce:lEu,attempt:e=>{try{return e()}catch(t){return TXt.lang.castError(t)}},castArray:e=>TXt.lang.isArray(e)?e:[e],castError:e=>TXt.lang.isError(e)?e:TXt.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(TXt.lang.isNaN(e))return TXt.lang.isNaN(t);if(TXt.lang.isPrimitive(e)||TXt.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(dEu.default.sep).length-1),getRealPath:(e,t)=>{try{return t?xil.default.realpathSync.native(e):xil.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===dEu.default.sep&&t.length-e.length>dEu.default.sep.length,poll:(e,t=o6h)=>l6h.retry.stat(t)(e,{bigint:!0}).catch(TXt.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 y6h(e,{depth:r,limit:i,ignore:t,signal:n});return[o.directories,o.files]}}}},xp=TXt;var pEu=ue(require("path"),1);var Hil=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||xp.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=i6h){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=xp.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===nf.CHANGE&&c===nf.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===nf.ADD_DIR?await this.eventsPopulateAddDir(t,n,r,i):o===nf.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??RYi:Math.min(1,this.options.depth??RYi),o=this.options.limit??jXa,[c,d]=await xp.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())xp.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(nf.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!zYi&&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(nf.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(nf.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(pEu.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(nf.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(pEu.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(nf.UNLINK_DIR,t))}onTargetEvent(t){let[r,i]=t;r===nf.ADD?this.onTargetAdd(i):r===nf.ADD_DIR?this.onTargetAddDir(i):r===nf.CHANGE?this.onTargetChange(i):r===nf.UNLINK?this.onTargetUnlink(i):r===nf.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=gOn.CHANGE,r){if(this.watcher.isClosed())return;let i=pEu.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){Uil&&t.code==="EPERM"?this.onWatcherChange(gOn.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(wXa.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(wXa.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(gOn.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&zYi&&this.options.native!==!1?this.options.depth??RYi:Math.min(1,this.options.depth??RYi),i=this.options.limit??jXa,[n,a]=await xp.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(gOn.CHANGE,c,t)}))}}},b6h=Hil;var Ux={interval:100,intervalId:void 0,fns:new Map,init:()=>{Ux.intervalId||(Ux.intervalId=setInterval(Ux.resolve,Ux.interval))},reset:()=>{Ux.intervalId&&(clearInterval(Ux.intervalId),delete Ux.intervalId)},add:(e,t)=>{Ux.fns.set(e,Date.now()+t),Ux.init()},remove:e=>{Ux.fns.delete(e)},resolve:()=>{if(!Ux.fns.size)return Ux.reset();let e=Date.now();for(let[t,r]of Ux.fns)r>=e||(Ux.remove(t),t())}},MXa=Ux;var DXa=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=Lil){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(xp.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),MXa.remove(s)},s=()=>{d(),c()};MXa.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=Lil){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),MXa.remove(s)},s=()=>{d(),c()};MXa.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,nf.ADD,CXt.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,nf.ADD_DIR,CXt.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,nf.UNLINK,CXt.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,nf.UNLINK_DIR,CXt.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}}};DXa.DIR_EVENTS={add:nf.ADD_DIR,rename:nf.RENAME_DIR,unlink:nf.UNLINK_DIR};DXa.FILE_EVENTS={add:nf.ADD,change:nf.CHANGE,rename:nf.RENAME,unlink:nf.UNLINK};var v6h=DXa;var Kil=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(xp.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let i=this.map.get(t);if(xp.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(xp.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(xp.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let i=this.map.get(t);return xp.lang.isSet(i)?i.has(r):i===r}return!1}set(t,r){if(this.map.has(t)){let i=this.map.get(t);xp.lang.isSet(i)?i.add(r):i!==r&&this.map.set(t,new Set([i,r]))}else this.map.set(t,r);return this}},Jil=Kil;var $il=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}},g6h=$il;var Yil=class{constructor(){this.inos={},this.paths=new Jil,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 xp.fs.poll(t,r);if(!(!i||!(i.isFile()||i.isDirectory())))return new g6h(i)}reset(){this.inos={},this.paths=new Jil,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,nf.ADD,n),[nf.ADD];if(n.isDirectory())return this.updateIno(t,nf.ADD_DIR,n),[nf.ADD_DIR]}else if(i&&!n){if(i.isFile())return this.updateIno(t,nf.UNLINK,i),[nf.UNLINK];if(i.isDirectory())return this.updateIno(t,nf.UNLINK_DIR,i),[nf.UNLINK_DIR]}else if(i&&n){if(i.isFile()){if(n.isFile())return i.ino===n.ino&&!i.size&&!n.size?[]:(this.updateIno(t,nf.CHANGE,n),[nf.CHANGE]);if(n.isDirectory())return this.updateIno(t,nf.UNLINK,i),this.updateIno(t,nf.ADD_DIR,n),[nf.UNLINK,nf.ADD_DIR]}else if(i.isDirectory()){if(n.isFile())return this.updateIno(t,nf.UNLINK_DIR,i),this.updateIno(t,nf.ADD,n),[nf.UNLINK_DIR,nf.ADD];if(n.isDirectory())return i.ino===n.ino?[]:(this.updateIno(t,nf.UNLINK_DIR,i),this.updateIno(t,nf.ADD_DIR,n),[nf.UNLINK_DIR,nf.ADD_DIR])}}return[]}updateIno(t,r,i){let n=this.inos[r]=this.inos[r]||(this.inos[r]={}),a=i.isFile()?CXt.FILE:CXt.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)}}},Xil=Yil;var Zil=class e extends O6h.EventEmitter{constructor(t,r,i){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(Qx.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(n=>this.on(Qx.CLOSE,n)),this._readyWait=new Promise(n=>this.on(Qx.READY,n)),this._locker=new v6h(this),this._roots=new Set,this._poller=new Xil,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&&(xp.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(Qx.CLOSE))}error(t){if(this.isClosed())return!1;let r=xp.lang.castError(t);return this.emit(Qx.ERROR,r)}event(t,r,i){return this.isClosed()?!1:(this.emit(Qx.ALL,t,r,i),this.emit(t,r,i))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(Qx.READY))}pollerExists(t,r){for(let i of this._pollers)if(i.targetPath===t&&xp.lang.isShallowEqual(i.options,r))return!0;return!1}subwatcherExists(t,r){for(let i of this._subwatchers)if(i.targetPath===t&&xp.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)xp.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 b6h(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=xp.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=OOn.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??RYi))&&u.handler===i&&(!u.filePath||u.filePath===n)&&u.options.ignore===r.ignore&&!!u.options.native==!!r.native&&(!r.recursive||u.options.recursive&&zYi&&u.options.native!==!1)))return!0;if(!zYi)break;let s=OOn.default.dirname(t);if(o===s)break;o=s}return!1}async watchDirectories(t,r,i,n,a){if(this.isClosed())return;t=xp.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||zYi&&r.native!==!1?r:{...r,recursive:!1},u={watcher:_Eu.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=OOn.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||zYi&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,i,n,a));{r={...r,recursive:!0};let o=r.depth??RYi,c=r.limit??jXa,[d]=await xp.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=xp.fs.getDepth(t);for(let l of d){let p=xp.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(Qx.CLOSE,d),o.watchFile(t,r,a)},d=()=>{this._subwatchers.delete(n),this.removeListener(Qx.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=OOn.default.dirname(t);return this.watchDirectory(n,r,i,t)}async watchPollingOnce(t,r,i){if(this.isClosed())return;let n=!1,a=new Xil,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 xp.lang.noop;if(this.pollerExists(t,r))return xp.lang.noop;let n={...r,interval:r.pollingInterval??a6h},a={targetPath:t,options:r},o=()=>{this._pollers.add(a),this.on(Qx.CLOSE,c),_Eu.default.watchFile(t,n,i)},c=()=>{this._pollers.delete(a),this.removeListener(Qx.CLOSE,c),_Eu.default.unwatchFile(t,i)};return xp.lang.attempt(o),()=>xp.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=xp.lang.uniq(t).sort(),t.every((a,o)=>t.every((c,d)=>d===o||!xp.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=OOn.default.resolve(t),this.isIgnored(t,r.ignore)))return;let n=await xp.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=OOn.default.dirname(t);return(await xp.fs.poll(a,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,i):this.watchUnknownTarget(t,r,i)}}async watch(t,r,i=xp.lang.noop){if(xp.lang.isFunction(t))return this.watch([],{},t);if(xp.lang.isUndefined(t))return this.watch([],r,i);if(xp.lang.isFunction(r))return this.watch(t,{},r);if(xp.lang.isUndefined(r))return this.watch(t,{},i);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let n=xp.lang.castArray(t);n.forEach(a=>this._roots.add(a)),await this.watchPaths(n,r,i),!this.isClosed()&&(i!==xp.lang.noop&&this.on(Qx.ALL,i),r.readdirMap=void 0,this.ready())}},hEu=Zil;Eru();var jla=require("fs/promises"),m6h=require("os"),A6h=ue(require("path"),1),V1B=".fern",W1B="logs";function G1B(){return"cli@3.49.8"}var BXa=class{logFilePath=null;initialized=!1;sessionStartTime;constructor(){this.sessionStartTime=Date.now()}async initialize(){if(this.initialized)return;let t=qt(jr.of((0,m6h.homedir)()),xe.of(V1B)),r=qt(t,xe.of(W1B));await gi(r)||await(0,jla.mkdir)(r,{recursive:!0});let n=`${new Date().toISOString().replace(/[:.]/g,"-")}.debug.log`;this.logFilePath=qt(r,xe.of(n));let a=["================================================================================","Fern Docs Dev Debug Log",`Session started: ${new Date().toISOString()}`,`Log file: ${A6h.default.basename(this.logFilePath)}`,"================================================================================",""].join(`
|
|
1950
1950
|
`);await(0,jla.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)+`
|
|
1951
1951
|
`;try{await(0,jla.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:G1B(),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 wal=ue(unl(),1),_Kh=ue(oSu(),1),FY=require("fs/promises"),hKh=require("os"),yKh=ue(w4(),1),bKh=ue(dKh(),1),PSu=process.platform==="win32",jal=Rt.cyan("[docs]:"),lFB="etag",fFB=23,pKh=e=>e.padEnd(fFB," "),dFB="preview",pFB="app-preview",_FB="bundle",hFB=".next",yFB="standalone",bFB=".fern",vFB="packages/fern-docs/bundle/.next/server/instrumentation.js",gFB=".npmrc",OFB=".pnpmfile.cjs",mFB="pnpm-workspace.yaml",AFB='Cannot find matching keyid: {"signatures":';function PFB(){return qt(jr.of((0,hKh.homedir)()),xe.of(bFB))}function Lla({app:e=!1}){return qt(PFB(),xe.of(e?pFB:dFB))}function xYi({app:e=!1}){return qt(Lla({app:e}),xe.of(e?hFB:_FB))}function eZa({app:e=!1}){return qt(xYi({app:e}),xe.of(yFB))}function jFB({app:e=!1}){return qt(eZa({app:e}),xe.of(vFB))}function wFB({app:e=!1}){return qt(eZa({app:e}),xe.of(mFB))}function EFB({app:e=!1}){return qt(eZa({app:e}),xe.of(OFB))}function SFB({app:e=!1}){return qt(eZa({app:e}),xe.of(gFB))}function SOn(e){return new Error(`${e}. Please reach out to support@buildwithfern.com.`)}function MFB({app:e=!1}){return qt(Lla({app:e}),xe.of(lFB))}var DFB=`module.exports = {
|
|
1952
1952
|
hooks: {
|