fern-api 3.30.1 → 3.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +4 -4
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1145,7 +1145,7 @@ ${mC_.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&Ijc(th
|
|
|
1145
1145
|
`+m_n.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?m_n.default.cyan(IC_(t,this.opt.mask)):m_n.default.italic(m_n.default.dim("[hidden]")):this.opt.mask?IC_(t,this.opt.mask):m_n.default.italic(m_n.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 c7o=ce(eR(),1);var Iq_=ce(d0c(),1),u7o=require("child_process"),ckn=require("fs"),o7o=ce(require("path"),1),Cq_=ce(require("os"),1),qq_=require("crypto"),Y0c=ce(Dq_(),1);var i7o=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var NWa=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var n7o=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var a7o=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function s7o(e="",t,r){let i=new X0c(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 Bq_(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function zKM(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 X0c=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=zKM(t).map(n=>n.replace("\\ "," ")),i=r.shift();this.editor={args:r,bin:i}}createTemporaryFile(){try{let t=this.fileOptions.dir??Cq_.default.tmpdir(),r=(0,qq_.randomUUID)(),i=Bq_(this.fileOptions.prefix),n=Bq_(this.fileOptions.postfix),a=`${i}${r}${n}`,o=o7o.default.resolve(t,a),c=o7o.default.resolve(t)+o7o.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,ckn.writeFileSync)(this.tempFile,this.text,d)}catch(t){throw new i7o(t)}}readTemporaryFile(){try{let t=(0,ckn.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,Iq_.detect)(t)??"utf8";Y0c.default.encodingExists(r)||(r="utf8"),this.text=Y0c.default.decode(t,r)}}catch(t){throw new n7o(t)}}removeTemporaryFile(){try{(0,ckn.unlinkSync)(this.tempFile)}catch(t){throw new a7o(t)}}launchEditor(){try{let t=(0,u7o.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new NWa(t)}}launchEditorAsync(t){try{(0,u7o.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",i=>{this.lastExitStatus=i,setImmediate(t)})}catch(r){throw new NWa(r)}}};var Tq_=ce(ive(),1);var FWa=class extends tR{_run(t){this.done=t,this.editorResult=new Tq_.Subject;let r=F4(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"?c7o.default.dim("Received"):c7o.default.dim("Press <enter> to launch your preferred editor."),t&&(r=c7o.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),s7o(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 Qq_=require("stream");var Nq_=ce(require("readline"),1),Fq_=ce(zq_(),1),E_n=class{constructor(t){this.rl||=Nq_.default.createInterface(FKM(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 FKM(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 Fq_.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var QWa=class extends E_n{constructor(t={}){super(t),this.log=new Qq_.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return mWa(this.rl,this.bottomBar.split(`
|
|
1146
1146
|
`).length),this}updateBottomBar(t){return mWa(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+`
|
|
1147
1147
|
`}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&&IHo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var kO=ce(ive(),1),Vq_=ce(W8a(),1);var l7o=ce(ive(),1),Uq_=ce(W8a(),1),f7o=function(e,t,r){return typeof e[t]!="function"?(0,l7o.of)(e):(0,l7o.from)((0,Uq_.default)(e[t])(r).then(i=>(e[t]=i,e)))};var Lq_={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}},lkn=class extends E_n{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,kO.from)(t):(0,kO.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,kO.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,kO.from)([t]),this.process=i.pipe((0,kO.concatMap)(this.processQuestion.bind(this)),(0,kO.publish)()),this.process.connect(),this.process.pipe((0,kO.reduce)((n,a)=>(Lq_.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,kO.defer)(()=>(0,kO.of)(t).pipe((0,kO.concatMap)(this.setDefaultType.bind(this)),(0,kO.concatMap)(this.filterIfRunnable.bind(this)),(0,kO.concatMap)(()=>f7o(t,"message",this.answers)),(0,kO.concatMap)(()=>f7o(t,"default",this.answers)),(0,kO.concatMap)(()=>f7o(t,"choices",this.answers)),(0,kO.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,kO.defer)(()=>(0,kO.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,kO.defer)(()=>(0,kO.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&Lq_.get(this.answers,t.name)!==void 0)return kO.EMPTY;if(t.when===!1)return kO.EMPTY;if(typeof t.when!="function")return(0,kO.of)(t);let{answers:r}=this;return(0,kO.defer)(()=>(0,kO.from)((0,Vq_.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,kO.filter)(i=>i!=null)))}};function Wq_(e){let t=function(r,i){let n;try{n=new lkn(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",jWa),this.registerPrompt("input",A_n),this.registerPrompt("number",wWa),this.registerPrompt("confirm",EWa),this.registerPrompt("rawlist",SWa),this.registerPrompt("expand",MWa),this.registerPrompt("checkbox",DWa),this.registerPrompt("password",BWa),this.registerPrompt("editor",FWa)},t.restoreDefaultPrompts(),t}var k0c=Wq_();function UKM(e,t){k0c.registerPrompt(e,t)}function LKM(){k0c.restoreDefaultPrompts()}var VKM={prompt:k0c,ui:{BottomBar:QWa,Prompt:lkn},createPromptModule:Wq_,registerPrompt:UKM,restoreDefaultPrompts:LKM,Separator:d$},d7o=VKM;var fkn=require("path");function Hq_(){let e=WKM();return async t=>{for(let r of t)r.module=e(r.filename);return t}}function WKM(e=process.argv[1]?(0,fkn.dirname)(process.argv[1]):process.cwd(),t=fkn.sep==="\\"){let r=t?Gq_(e):e;return i=>{if(!i)return;let n=t?Gq_(i):i,{dir:a,base:o,ext:c}=fkn.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 Gq_(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var ewc=e=>{if("flags"in e){let t=xq_(e.flags),r=Kq_(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,Jq_(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,GKM(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function GKM(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 xq_=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,S_n(r)]).filter(([,t])=>t!==void 0)),Kq_=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?Jq_(i):void 0]}))};var S_n=e=>e===void 0?void 0:e.variant??e.enabled,Jq_=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};var p7o="0123456789abcdef",_7o=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+=p7o.charAt(this.bytes[r]>>>4),t+=p7o.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+=p7o.charAt(this.bytes[r]>>>4),t+=p7o.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}},twc=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??HKM()}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 _7o.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,_7o.ofInner(t)}},HKM=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())}),$q_,HJt=()=>xKM().toString(),xKM=()=>($q_||($q_=new twc)).generate();var KKM=["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"],Yq_=function(e,t=[]){if(!e)return!1;let r=e.toLowerCase();return KKM.concat(t).some(i=>{let n=i.toLowerCase();return r.indexOf(n)!==-1})};var _$=(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 $KM=Array.isArray,Xq_=Object.prototype,DA9=Xq_.hasOwnProperty,rwc=Xq_.toString,Zq_=$KM||function(e){return rwc.call(e)==="[object Array]"};var dkn=e=>e===void 0,UWa=e=>rwc.call(e)=="[object String]",kq_=e=>UWa(e)&&e.trim().length===0;var e1_=e=>rwc.call(e)=="[object Number]";var iwc=e=>e instanceof Error;function YKM(e,t){try{return e instanceof t}catch{return!1}}function LWa(e){return e===null||typeof e!="object"}function M_n(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function t1_(e){return M_n(e,"ErrorEvent")}function h7o(e){return!dkn(Event)&&YKM(e,Event)}function r1_(e){return M_n(e,"Object")}function VWa(e,t,r,i,n){return t>r&&(i.warn("min cannot be greater than max."),t=r),e1_(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),VWa(n||r,t,r,i))}var XKM=864e5,y7o=class{constructor(t){this._buckets={},this._onBucketRateLimited=t._onBucketRateLimited,this._bucketSize=VWa(t.bucketSize,0,100,t._logger),this._refillRate=VWa(t.refillRate,0,this._bucketSize,t._logger),this._refillInterval=VWa(t.refillInterval,0,XKM,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 b7o=class{add(t){let r=HJt();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 ZKM(e=console){return{log:e.log.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),debug:e.debug.bind(e)}}var i1_=(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=>i1_(`${e} ${a}`,t,r)}},kKM=e=>e();function n1_(e,t=kKM){return i1_(e,t,ZKM())}var _kn="Mobile",g7o="iOS",pkn="Android",a1_="Tablet",LA9=pkn+" "+a1_;var eJM="Apple",VA9=eJM+" Watch",o1_="Safari",O7o="BlackBerry",u1_="Samsung",tJM=u1_+"Browser",rJM=u1_+" Internet",A7o="Chrome",iJM=A7o+" OS",nJM=A7o+" "+g7o,s1_="Internet Explorer",aJM=s1_+" "+_kn,awc="Opera",WA9=awc+" Mini",c1_="Edge",oJM="Microsoft "+c1_,owc="Firefox",uJM=owc+" "+g7o,uwc="Nintendo",swc="PlayStation",v7o="Xbox",sJM=pkn+" "+_kn,cJM=_kn+" "+o1_,WWa="Windows",lJM=WWa+" Phone";var l1_="Generic",GA9=l1_+" "+_kn.toLowerCase(),HA9=l1_+" "+a1_.toLowerCase(),fJM="Konqueror",IG="(\\d+(\\.\\d+)?)",nwc=new RegExp("Version/"+IG),xA9=new RegExp(v7o,"i"),KA9=new RegExp(swc+" \\w+","i"),JA9=new RegExp(uwc+" \\w+","i"),dJM=new RegExp(O7o+"|PlayBook|BB10","i"),pJM={"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 $A9={[aJM]:[new RegExp("rv:"+IG)],[oJM]:[new RegExp(c1_+"?\\/"+IG)],[A7o]:[new RegExp("("+A7o+"|CrMo)\\/"+IG)],[nJM]:[new RegExp("CriOS\\/"+IG)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+IG)],[o1_]:[nwc],[cJM]:[nwc],[awc]:[new RegExp("("+awc+"|OPR)\\/"+IG)],[owc]:[new RegExp(owc+"\\/"+IG)],[uJM]:[new RegExp("FxiOS\\/"+IG)],[fJM]:[new RegExp("Konqueror[:/]?"+IG,"i")],[O7o]:[new RegExp(O7o+" "+IG),nwc],[sJM]:[new RegExp("android\\s"+IG,"i")],[rJM]:[new RegExp(tJM+"\\/"+IG)],[s1_]:[new RegExp("(rv:|MSIE )"+IG)],Mozilla:[new RegExp("rv:"+IG)]};var YA9=[[new RegExp(v7o+"; "+v7o+" (.*?)[);]","i"),e=>[v7o,e&&e[1]||""]],[new RegExp(uwc,"i"),[uwc,""]],[new RegExp(swc,"i"),[swc,""]],[dJM,[O7o,""]],[new RegExp(WWa,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[lJM,""];if(new RegExp(_kn).test(t)&&!/IEMobile\b/.test(t))return[WWa+" "+_kn,""];let r=/Windows NT ([0-9.]+)/i.exec(t);if(r&&r[1]){let i=r[1],n=pJM[i]||"";return/arm/i.test(t)&&(n="RT"),[WWa,n]}return[WWa,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){let t=[e[3],e[4],e[5]||"0"];return[g7o,t.join(".")]}return[g7o,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=dkn(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+pkn+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+pkn+")","i"),e=>{if(e&&e[2]){let t=[e[2],e[3],e[4]||"0"];return[pkn,t.join(".")]}return[pkn,""]}],[/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/,[iJM,""]],[/Linux|debian/i,["Linux",""]]];var f1_="utf8";function d1_(e,t){if(!e||typeof e!="string"||_JM(e))throw new Error(t)}function _JM(e){return e.trim().length===0}function p1_(e){return e?.replace(/\/+$/,"")}async function _1_(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 m7o(){return new Date().toISOString()}function D_n(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var h1_=e=>e instanceof Error;function cwc(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var P7o=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 y1_(){return"CompressionStream"in globalThis}async function lwc(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 hkn=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()}},GWa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function b1_(e){if(e instanceof hkn){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 fwc(e){return typeof e=="object"&&(e instanceof hkn||e instanceof GWa)}function v1_(e){return typeof e=="object"&&e instanceof hkn&&e.status===413}var HWa=class{constructor(t,r={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new b7o,this._events=new P7o,this._isInitialized=!1,d1_(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=p1_(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:fwc},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=n1_("[PostHog]",this.logMsgIfDebug.bind(this)),this.disableCompression=!y1_()||(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(_$.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(_$.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(_$.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=>ewc(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=S_n(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(_$.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(_$.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(_$.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(_$.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this._logger.info("Queue is full, the oldest event is dropped.")),a.push({message:n}),this.setPersistedProperty(_$.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=D_n(()=>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:m7o()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),o=`${this.host}/batch/`,c=this.disableCompression?null:await lwc(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:m7o(),uuid:i?.uuid?i.uuid:HJt()};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 b1_(t)})}async flush(){let t=cwc([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),cwc([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(_$.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(_$.Queue)||[]).slice(n.length);this.setPersistedProperty(_$.Queue,h),t=h},c={api_key:this.apiKey,batch:a,sent_at:m7o()};this.historicalMigration&&(c.historical_migration=!0);let d=JSON.stringify(c),s=`${this.host}/batch/`,u=this.disableCompression?null:await lwc(d,this.isDebug),l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",...u!==null&&{"Content-Encoding":"gzip"}},body:u||d},p={retryCheck:_=>v1_(_)?!1:fwc(_)};try{await this.fetchWithRetry(s,l,p)}catch(_){if(v1_(_)&&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 GWa||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,f1_)}catch{a instanceof Blob?o=a.size:o=new TextEncoder().encode(a).length}return await _1_(async()=>{let c=null;try{c=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(s){throw new GWa(s)}if(!(r.mode==="no-cors")&&(c.status<200||c.status>=400))throw new hkn(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(_$.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!fwc(n))throw n;await b1_(n)}};return Promise.race([new Promise((n,a)=>{D_n(()=>{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 h$={};Zt(h$,{DOMExceptionCoercer:()=>pwc,ErrorCoercer:()=>_wc,ErrorEventCoercer:()=>hwc,ErrorPropertiesBuilder:()=>dwc,EventCoercer:()=>vwc,ObjectCoercer:()=>bwc,PrimitiveCoercer:()=>gwc,PromiseRejectionEventCoercer:()=>Owc,ReduceableCache:()=>Awc,StringCoercer:()=>ywc,chromeStackLineParser:()=>A1_,createStackParser:()=>MJM,geckoStackLineParser:()=>P1_,nodeStackLineParser:()=>S1_,opera10StackLineParser:()=>j1_,opera11StackLineParser:()=>w1_,reverseAndStripFrames:()=>B1_,winjsStackLineParser:()=>m1_});var j7o,g1_,w7o;function O1_(e){let t=globalThis._posthogChunkIds;if(!t)return;let r=Object.keys(t);return w7o&&r.length===g1_||(g1_=r.length,w7o=r.reduce((i,n)=>{j7o||(j7o={});let a=j7o[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,j7o[n]=[s,u];break}}}return i},{})),w7o}var hJM=4,dwc=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&&Zq_(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:O1_(this.stackParser)}}buildCoercingContext(t,r,i=0){let n=(o,c)=>{if(c<=hJM){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 U4="?";function xJt(e,t,r,i,n){let a={platform:e,filename:t,function:r==="<anonymous>"?U4:r,in_app:!0};return dkn(i)||(a.lineno=i),dkn(n)||(a.colno=n),a}var E7o=(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]:U4,r?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]};var yJM=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,bJM=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,vJM=/\((\S*)(?::(\d+))(?::(\d+))\)/,A1_=(e,t)=>{let r=yJM.exec(e);if(r){let[,n,a,o]=r;return xJt(t,n,U4,+a,+o)}let i=bJM.exec(e);if(i){if(i[2]&&i[2].indexOf("eval")===0){let c=vJM.exec(i[2]);c&&(i[2]=c[1],i[3]=c[2],i[4]=c[3])}let[a,o]=E7o(i[1]||U4,i[2]);return xJt(t,o,a,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}};var gJM=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i,m1_=(e,t)=>{let r=gJM.exec(e);return r?xJt(t,r[2],r[1]||U4,+r[3],r[4]?+r[4]:void 0):void 0};var OJM=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,AJM=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,P1_=(e,t)=>{let r=OJM.exec(e);if(r){if(r[3]&&r[3].indexOf(" > eval")>-1){let o=AJM.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]||U4;return[a,n]=E7o(a,n),xJt(t,n,a,r[4]?+r[4]:void 0,r[5]?+r[5]:void 0)}};var mJM=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,j1_=(e,t)=>{let r=mJM.exec(e);return r?xJt(t,r[2],r[3]||U4,+r[1]):void 0},PJM=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i,w1_=(e,t)=>{let r=PJM.exec(e);return r?xJt(t,r[5],r[3]||r[4]||U4,+r[1],+r[2]):void 0};var jJM=/^\s*[-]{4,}$/,wJM=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,S1_=(e,t)=>{let r=e.match(wJM);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||U4,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:E1_(r[3]),colno:E1_(r[4]),in_app:EJM(d||"",s),platform:t}}if(e.match(jJM))return{filename:e,platform:t}};function EJM(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 E1_(e){return parseInt(e||"",10)||void 0}var M1_=/\(error: (.*)\)/,D1_=50;function B1_(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,D1_).map(r=>({...r,filename:r.filename||SJM(t).filename,function:r.function||U4}))}function SJM(e){return e[e.length-1]||{}}function MJM(e,...t){return(r,i=0)=>{let n=[],a=r.split(`
|
|
1148
|
-
`);for(let o=i;o<a.length;o++){let c=a[o];if(c.length>1024)continue;let d=M1_.test(c)?c.replace(M1_,"$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>=D1_)break}}return B1_(n)}}var pwc=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,r){let i=UWa(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 M_n(t,"DOMException")}isDOMError(t){return M_n(t,"DOMError")}};var _wc=class{match(t){return iwc(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 hwc=class{constructor(){}match(t){return t1_(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 DJM=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,ywc=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(DJM);return n&&(r=n[1],i=n[2]),[r,i]}};var I1_=["fatal","error","warning","log","info","debug"];function S7o(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 bwc=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 h7o(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=S7o(t);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${i}`}isSeverityLevel(t){return UWa(t)&&!kq_(t)&&I1_.indexOf(t)>=0}getErrorPropertyFromObject(t){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(h1_(i))return i}}getObjectClassName(t){try{let r=Object.getPrototypeOf(t);return r?r.constructor.name:void 0}catch{return}}};var vwc=class{match(t){return h7o(t)}coerce(t,r){let i=t.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${S7o(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var gwc=class{match(t){return LWa(t)}coerce(t,r){return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var Owc=class{match(t){return M_n(t,"PromiseRejectionEvent")}coerce(t,r){let i=this.getUnhandledRejectionReason(t);return LWa(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(LWa(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 Awc=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 T1_=require("fs"),R1_=require("readline"),M7o=new h$.ReduceableCache(25),z1_=new h$.ReduceableCache(20),mwc=7,BJM=1e3,IJM=1e4;async function N1_(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"||RJM(o)||zJM(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(z1_.get(n))continue;let a=t[n];if(!a)continue;a.sort((d,s)=>d-s);let o=FJM(a);if(o.every(d=>NJM(n,d)))continue;let c=QJM(M7o,n,{});i.push(CJM(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&qJM(e,M7o),M7o.reduce(),e}function CJM(e,t,r){return new Promise(i=>{let n=(0,T1_.createReadStream)(e),a=(0,R1_.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(){z1_.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]=UJM(_,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 qJM(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;TJM(r.lineno,r,i)}}function TJM(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=F1_(e);n<e;n++){let a=r[n];if(a===void 0)return void C1_(t);t.pre_context.push(a)}if(r[e]===void 0)return void C1_(t);t.context_line=r[e];let i=Q1_(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 C1_(e){delete e.pre_context,delete e.context_line,delete e.post_context}function RJM(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function zJM(e){return e.lineno!==void 0&&e.lineno>IJM||e.colno!==void 0&&e.colno>BJM}function NJM(e,t){let r=M7o.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 FJM(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=q1_(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+mwc:(n.push(i),i=q1_(a)),t++}return n}function q1_(e){return[F1_(e),Q1_(e)]}function F1_(e){return Math.max(1,e-mwc)}function Q1_(e){return e+mwc}function QJM(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function UJM(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 LJM(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 U1_(e,t){globalThis.process?.on("uncaughtException",LJM(e,t))}function L1_(e){globalThis.process?.on("unhandledRejection",t=>e(t,{mechanism:{type:"onunhandledrejection",handled:!1}}))}var VJM=2e3,SFi=class e{constructor(t,r,i){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this._logger=i,this._rateLimiter=new y7o({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||HJt(),properties:{...o,...a}}}startAutocaptureIfEnabled(){this.isEnabled()&&(U1_(this.onException.bind(this),this.onFatalError.bind(this)),L1_(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(VJM),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};var V1_="5.17.4";async function W1_(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 WJM=6e4,GJM=1152921504606847e3,HJM=["is_not"],ykn=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},v0=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},KJt=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},D7o=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 KJt||d instanceof v0?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 KJt||p instanceof v0?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 v0("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 v0("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 v0("Feature flags not available for dependency evaluation");if(!("dependency_chain"in t))throw new v0(`Flag dependency property for '${a}' is missing required 'dependency_chain' field`);let o=t.dependency_chain;if(!Array.isArray(o))throw new v0(`Flag dependency property for '${a}' has an invalid 'dependency_chain' (expected array, got ${typeof o})`);if(o.length===0)throw new v0(`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 v0(`Error evaluating flag dependency '${d}' for flag '${a}': ${l}`)}else n[d]=!1;else throw new v0(`Missing flag dependency '${d}' for flag '${a}'`)}if(n[d]==null)throw new v0(`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 KJt)throw u;if(u instanceof v0)c=!0;else throw u}if(d!==void 0)return d;if(c)throw new v0("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"?J1_(d,n,this.cohorts,this.debugMode):s==="flag"?await this.evaluateFlagDependency(d,r,n,a):K1_(d,n,c),!u)return!1}if(o==null)return!0}return!(o!=null&&await G1_(t.key,r)>o/100)}async getMatchingVariant(t,r){let i=await G1_(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(WJM,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 ykn(`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 ykn(`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 ykn(`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 ykn&&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=D_n(()=>{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 G1_(e,t,r=""){let i=await W1_(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/GJM}function K1_(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 v0("Operator is_not_set is not supported")}else throw new v0(`Property ${i} not found in propertyValues`);let o=t[i];if(o==null&&!HJM.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 H1_(String(n))&&String(o).match(String(n))!==null;case"not_regex":return H1_(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 v0("Date operations cannot be performed on boolean values");let s=KJM(String(n));if(s==null&&(s=x1_(n)),s==null)throw new v0(`Invalid date: ${n}`);let u=x1_(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new v0(`Unknown operator: ${a}`)}}function xJM(e,t){if(!(e in t))throw new KJt(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function J1_(e,t,r,i=!1){let n=String(e.value);xJM(n,r);let a=r[n];return $1_(a,t,r,i)}function $1_(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=$1_(c,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof KJt)throw d;if(d instanceof v0)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new v0("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=J1_(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=K1_(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 KJt)throw d;if(d instanceof v0)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new v0("can't match cohort without a given cohort property value");return n==="AND"}function H1_(e){try{return new RegExp(e),!0}catch{return!1}}function x1_(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 v0(`${e} is in an invalid date format`)}throw new v0(`The date provided ${e} must be a string, number, or date object`)}function KJM(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 B7o=class{getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}constructor(){this._memoryStorage={}}};var JJM=100,Y1_=3e4,$JM=5e4,I7o=class extends HWa{constructor(t,r={}){if(super(t,r),this._memoryStorage=new B7o,this.options=r,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,JJM):Y1_,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 D7o({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 SFi(this,r,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||$JM}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 V1_}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=Y1_){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=S_n(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 KJt||y instanceof v0)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=D_n(()=>{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(r1_(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(SFi.buildEventMessage(t,{syntheticException:n},r,i).then(a=>this.capture(a)))}async captureExceptionImmediate(t,r,i){let n=new Error("PostHog syntheticException");this.addPendingPromise(SFi.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=HJt(),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,A]of Object.entries(y))b[`$feature/${O}`]=A;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"&&Yq_(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 X1_=require("async_hooks"),C7o=class{constructor(){this.storage=new X1_.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 Z1_="posthog-node";function YJM(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[Pwc.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 Pwc=class{static#e=this.POSTHOG_ID_TAG="posthog_distinct_id";constructor(t,r,i,n,a){this.name=Z1_,this.name=Z1_,this.setupOnce=function(o,c){let d=c()?.getClient()?.getDsn()?.projectId;o(YJM(t,{organization:r,projectId:d,prefix:i,severityAllowList:n,sendExceptionsToPostHog:a??!0}))}}};SFi.errorPropertiesBuilder=new h$.ErrorPropertiesBuilder([new h$.EventCoercer,new h$.ErrorCoercer,new h$.ObjectCoercer,new h$.StringCoercer,new h$.PrimitiveCoercer],h$.createStackParser("node:javascript",h$.nodeStackLineParser),[Hq_(),N1_]);var bkn=class extends I7o{getLibraryId(){return"posthog-node"}initializeContext(){return new C7o}};var q7o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new bkn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.30.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var xWa=class{async sendEvent(){}async identify(){}async flush(){}};var vkn=require("fs/promises"),rT_=require("os"),iT_=require("path");var k1_=ce(require("crypto")),R7o=new Uint8Array(256),T7o=R7o.length;function jwc(){return T7o>R7o.length-16&&(k1_.default.randomFillSync(R7o),T7o=0),R7o.slice(T7o,T7o+=16)}var L4=[];for(let e=0;e<256;++e)L4.push((e+256).toString(16).slice(1));function eT_(e,t=0){return L4[e[t+0]]+L4[e[t+1]]+L4[e[t+2]]+L4[e[t+3]]+"-"+L4[e[t+4]]+L4[e[t+5]]+"-"+L4[e[t+6]]+L4[e[t+7]]+"-"+L4[e[t+8]]+L4[e[t+9]]+"-"+L4[e[t+10]]+L4[e[t+11]]+L4[e[t+12]]+L4[e[t+13]]+L4[e[t+14]]+L4[e[t+15]]}var tT_=ce(require("crypto")),wwc={randomUUID:tT_.default.randomUUID};function XJM(e,t,r){if(wwc.randomUUID&&!t&&!e)return wwc.randomUUID();e=e||{};let i=e.random||(e.rng||jwc)();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 eT_(i)}var ave=XJM;var ZJM="id",kJM=".fern",KWa=class{posthog;userId;token;constructor({token:t,posthogApiKey:r}){this.posthog=new bkn(r),this.userId=t==null?void 0:bgc(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.30.1",...t,...t.properties,usingAccessToken:!1,...r!=null?{userEmail:r}:{}}})}async flush(){await this.posthog.flush()}userEmail;async getUserEmail(){if(this.userEmail!==null){if(this.userEmail!=null)return this.userEmail;if(this.token==null){this.userEmail=null;return}try{let t=await I4({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=Ct(Cr.of((0,rT_.homedir)()),Ze.of(kJM),Ze.of(ZJM));await ji(t)||(await(0,vkn.mkdir)((0,iT_.dirname)(t),{recursive:!0}),await(0,vkn.writeFile)(t,ave())),this.persistedDistinctId=(await(0,vkn.readFile)(t)).toString()}return this.persistedDistinctId}};var Ewc;async function gkn(){return Ewc==null&&(Ewc=await e$M()),Ewc}async function e$M(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new xWa;let r=await rWo();return r!=null?new KWa({token:r,posthogApiKey:e}):await MZn()!=null?new q7o({posthogApiKey:e}):new KWa({token:void 0,posthogApiKey:e})}catch{return new xWa}}function JWa(e,t){return function(){return e.apply(t,arguments)}}var{toString:t$M}=Object.prototype,{getPrototypeOf:Mwc}=Object,{iterator:N7o,toStringTag:aT_}=Symbol,F7o=(e=>t=>{let r=t$M.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),c3t=e=>(e=e.toLowerCase(),t=>F7o(t)===e),Q7o=e=>t=>typeof t===e,{isArray:Akn}=Array,Okn=Q7o("undefined");function $Wa(e){return e!==null&&!Okn(e)&&e.constructor!==null&&!Okn(e.constructor)&&y$(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var oT_=c3t("ArrayBuffer");function r$M(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&oT_(e.buffer),t}var i$M=Q7o("string"),y$=Q7o("function"),uT_=Q7o("number"),YWa=e=>e!==null&&typeof e=="object",n$M=e=>e===!0||e===!1,z7o=e=>{if(F7o(e)!=="object")return!1;let t=Mwc(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(aT_ in e)&&!(N7o in e)},a$M=e=>{if(!YWa(e)||$Wa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},o$M=c3t("Date"),u$M=c3t("File"),s$M=c3t("Blob"),c$M=c3t("FileList"),l$M=e=>YWa(e)&&y$(e.pipe),f$M=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||y$(e.append)&&((t=F7o(e))==="formdata"||t==="object"&&y$(e.toString)&&e.toString()==="[object FormData]"))},d$M=c3t("URLSearchParams"),[p$M,_$M,h$M,y$M]=["ReadableStream","Request","Response","Headers"].map(c3t),b$M=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function XWa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),Akn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if($Wa(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 sT_(e,t){if($Wa(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 B_n=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,cT_=e=>!Okn(e)&&e!==B_n;function Swc(){let{caseless:e,skipUndefined:t}=cT_(this)&&this||{},r={},i=(n,a)=>{let o=e&&sT_(r,a)||a;z7o(r[o])&&z7o(n)?r[o]=Swc(r[o],n):z7o(n)?r[o]=Swc({},n):Akn(n)?r[o]=n.slice():(!t||!Okn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&XWa(arguments[n],i);return r}var v$M=(e,t,r,{allOwnKeys:i}={})=>(XWa(t,(n,a)=>{r&&y$(n)?e[a]=JWa(n,r):e[a]=n},{allOwnKeys:i}),e),g$M=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),O$M=(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)},A$M=(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&&Mwc(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},m$M=(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},P$M=e=>{if(!e)return null;if(Akn(e))return e;let t=e.length;if(!uT_(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},j$M=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Mwc(Uint8Array)),w$M=(e,t)=>{let i=(e&&e[N7o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},E$M=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},S$M=c3t("HTMLFormElement"),M$M=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),nT_=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),D$M=c3t("RegExp"),lT_=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};XWa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},B$M=e=>{lT_(e,(t,r)=>{if(y$(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(y$(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+"'")})}})},I$M=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return Akn(e)?i(e):i(String(e).split(t)),r},C$M=()=>{},q$M=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function T$M(e){return!!(e&&y$(e.append)&&e[aT_]==="FormData"&&e[N7o])}var R$M=e=>{let t=new Array(10),r=(i,n)=>{if(YWa(i)){if(t.indexOf(i)>=0)return;if($Wa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=Akn(i)?[]:{};return XWa(i,(o,c)=>{let d=r(o,n+1);!Okn(d)&&(a[c]=d)}),t[n]=void 0,a}}return i};return r(e,0)},z$M=c3t("AsyncFunction"),N$M=e=>e&&(YWa(e)||y$(e))&&y$(e.then)&&y$(e.catch),fT_=((e,t)=>e?setImmediate:t?((r,i)=>(B_n.addEventListener("message",({source:n,data:a})=>{n===B_n&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),B_n.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",y$(B_n.postMessage)),F$M=typeof queueMicrotask<"u"?queueMicrotask.bind(B_n):typeof process<"u"&&process.nextTick||fT_,Q$M=e=>e!=null&&y$(e[N7o]),rr={isArray:Akn,isArrayBuffer:oT_,isBuffer:$Wa,isFormData:f$M,isArrayBufferView:r$M,isString:i$M,isNumber:uT_,isBoolean:n$M,isObject:YWa,isPlainObject:z7o,isEmptyObject:a$M,isReadableStream:p$M,isRequest:_$M,isResponse:h$M,isHeaders:y$M,isUndefined:Okn,isDate:o$M,isFile:u$M,isBlob:s$M,isRegExp:D$M,isFunction:y$,isStream:l$M,isURLSearchParams:d$M,isTypedArray:j$M,isFileList:c$M,forEach:XWa,merge:Swc,extend:v$M,trim:b$M,stripBOM:g$M,inherits:O$M,toFlatObject:A$M,kindOf:F7o,kindOfTest:c3t,endsWith:m$M,toArray:P$M,forEachEntry:w$M,matchAll:E$M,isHTMLForm:S$M,hasOwnProperty:nT_,hasOwnProp:nT_,reduceDescriptors:lT_,freezeMethods:B$M,toObjectSet:I$M,toCamelCase:M$M,noop:C$M,toFiniteNumber:q$M,findKey:sT_,global:B_n,isContextDefined:cT_,isSpecCompliantForm:T$M,toJSONObject:R$M,isAsyncFn:z$M,isThenable:N$M,setImmediate:fT_,asap:F$M,isIterable:Q$M};function mkn(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)}rr.inherits(mkn,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:rr.toJSONObject(this.config),code:this.code,status:this.status}}});var dT_=mkn.prototype,pT_={};["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=>{pT_[e]={value:e}});Object.defineProperties(mkn,pT_);Object.defineProperty(dT_,"isAxiosError",{value:!0});mkn.from=(e,t,r,i,n,a)=>{let o=Object.create(dT_);rr.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 mkn.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 Ba=mkn;var _T_=ce(WXn(),1),U7o=_T_.default;function Dwc(e){return rr.isPlainObject(e)||rr.isArray(e)}function yT_(e){return rr.endsWith(e,"[]")?e.slice(0,-2):e}function hT_(e,t,r){return e?e.concat(t).map(function(n,a){return n=yT_(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function U$M(e){return rr.isArray(e)&&!e.some(Dwc)}var L$M=rr.toFlatObject(rr,{},null,function(t){return/^is[A-Z]/.test(t)});function V$M(e,t,r){if(!rr.isObject(e))throw new TypeError("target must be an object");t=t||new(U7o||FormData),r=rr.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!rr.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&rr.isSpecCompliantForm(t);if(!rr.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(rr.isDate(h))return h.toISOString();if(rr.isBoolean(h))return h.toString();if(!d&&rr.isBlob(h))throw new Ba("Blob is not supported. Use a Buffer instead.");return rr.isArrayBuffer(h)||rr.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(rr.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(rr.isArray(h)&&U$M(h)||(rr.isFileList(h)||rr.endsWith(y,"[]"))&&(v=rr.toArray(h)))return y=yT_(y),v.forEach(function(A,g){!(rr.isUndefined(A)||A===null)&&t.append(o===!0?hT_([y],g,a):o===null?y:y+"[]",s(A))}),!1}return Dwc(h)?!0:(t.append(hT_(b,y,a),s(h)),!1)}let l=[],p=Object.assign(L$M,{defaultVisitor:u,convertValue:s,isVisitable:Dwc});function _(h,y){if(!rr.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),rr.forEach(h,function(v,O){(!(rr.isUndefined(v)||v===null)&&n.call(t,v,rr.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!rr.isObject(e))throw new TypeError("data must be an object");return _(e),t}var V7i=V$M;function bT_(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function vT_(e,t){this._pairs=[],e&&V7i(e,this,t)}var gT_=vT_.prototype;gT_.append=function(t,r){this._pairs.push([t,r])};gT_.toString=function(t){let r=t?function(i){return t.call(this,i,bT_)}:bT_;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var OT_=vT_;function W$M(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function I_n(e,t,r){if(!t)return e;let i=r&&r.encode||W$M;rr.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=rr.isURLSearchParams(t)?t.toString():new OT_(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var Bwc=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){rr.forEach(this.handlers,function(i){i!==null&&t(i)})}},Iwc=Bwc;var Pkn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var jT_=ce(require("crypto"),1);var AT_=ce(require("url"),1),mT_=AT_.default.URLSearchParams;var Cwc="abcdefghijklmnopqrstuvwxyz",PT_="0123456789",wT_={DIGIT:PT_,ALPHA:Cwc,ALPHA_DIGIT:Cwc+Cwc.toUpperCase()+PT_},G$M=(e=16,t=wT_.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);jT_.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},ET_={isNode:!0,classes:{URLSearchParams:mT_,FormData:U7o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:wT_,generateString:G$M,protocols:["http","https","file","data"]};var Rwc={};Zt(Rwc,{hasBrowserEnv:()=>Twc,hasStandardBrowserEnv:()=>H$M,hasStandardBrowserWebWorkerEnv:()=>x$M,navigator:()=>qwc,origin:()=>K$M});var Twc=typeof window<"u"&&typeof document<"u",qwc=typeof navigator=="object"&&navigator||void 0,H$M=Twc&&(!qwc||["ReactNative","NativeScript","NS"].indexOf(qwc.product)<0),x$M=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",K$M=Twc&&window.location.href||"http://localhost";var om={...Rwc,...ET_};function zwc(e,t){return V7i(e,new om.classes.URLSearchParams,{visitor:function(r,i,n,a){return om.isNode&&rr.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function J$M(e){return rr.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function $$M(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 Y$M(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&&rr.isArray(n)?n.length:o,d?(rr.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!rr.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&rr.isArray(n[o])&&(n[o]=$$M(n[o])),!c)}if(rr.isFormData(e)&&rr.isFunction(e.entries)){let r={};return rr.forEachEntry(e,(i,n)=>{t(J$M(i),n,r,0)}),r}return null}var L7o=Y$M;function X$M(e,t,r){if(rr.isString(e))try{return(t||JSON.parse)(e),rr.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var Nwc={transitional:Pkn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=rr.isObject(t);if(a&&rr.isHTMLForm(t)&&(t=new FormData(t)),rr.isFormData(t))return n?JSON.stringify(L7o(t)):t;if(rr.isArrayBuffer(t)||rr.isBuffer(t)||rr.isStream(t)||rr.isFile(t)||rr.isBlob(t)||rr.isReadableStream(t))return t;if(rr.isArrayBufferView(t))return t.buffer;if(rr.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 zwc(t,this.formSerializer).toString();if((c=rr.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return V7i(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),X$M(t)):t}],transformResponse:[function(t){let r=this.transitional||Nwc.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(rr.isResponse(t)||rr.isReadableStream(t))return t;if(t&&rr.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"?Ba.from(c,Ba.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:om.classes.FormData,Blob:om.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};rr.forEach(["delete","get","head","post","put","patch"],e=>{Nwc.headers[e]={}});var jkn=Nwc;var Z$M=rr.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"]),ST_=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1148
|
+
`);for(let o=i;o<a.length;o++){let c=a[o];if(c.length>1024)continue;let d=M1_.test(c)?c.replace(M1_,"$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>=D1_)break}}return B1_(n)}}var pwc=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,r){let i=UWa(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 M_n(t,"DOMException")}isDOMError(t){return M_n(t,"DOMError")}};var _wc=class{match(t){return iwc(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 hwc=class{constructor(){}match(t){return t1_(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 DJM=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,ywc=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(DJM);return n&&(r=n[1],i=n[2]),[r,i]}};var I1_=["fatal","error","warning","log","info","debug"];function S7o(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 bwc=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 h7o(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=S7o(t);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${i}`}isSeverityLevel(t){return UWa(t)&&!kq_(t)&&I1_.indexOf(t)>=0}getErrorPropertyFromObject(t){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(h1_(i))return i}}getObjectClassName(t){try{let r=Object.getPrototypeOf(t);return r?r.constructor.name:void 0}catch{return}}};var vwc=class{match(t){return h7o(t)}coerce(t,r){let i=t.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${S7o(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var gwc=class{match(t){return LWa(t)}coerce(t,r){return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var Owc=class{match(t){return M_n(t,"PromiseRejectionEvent")}coerce(t,r){let i=this.getUnhandledRejectionReason(t);return LWa(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(LWa(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 Awc=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 T1_=require("fs"),R1_=require("readline"),M7o=new h$.ReduceableCache(25),z1_=new h$.ReduceableCache(20),mwc=7,BJM=1e3,IJM=1e4;async function N1_(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"||RJM(o)||zJM(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(z1_.get(n))continue;let a=t[n];if(!a)continue;a.sort((d,s)=>d-s);let o=FJM(a);if(o.every(d=>NJM(n,d)))continue;let c=QJM(M7o,n,{});i.push(CJM(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&qJM(e,M7o),M7o.reduce(),e}function CJM(e,t,r){return new Promise(i=>{let n=(0,T1_.createReadStream)(e),a=(0,R1_.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(){z1_.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]=UJM(_,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 qJM(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;TJM(r.lineno,r,i)}}function TJM(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=F1_(e);n<e;n++){let a=r[n];if(a===void 0)return void C1_(t);t.pre_context.push(a)}if(r[e]===void 0)return void C1_(t);t.context_line=r[e];let i=Q1_(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 C1_(e){delete e.pre_context,delete e.context_line,delete e.post_context}function RJM(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function zJM(e){return e.lineno!==void 0&&e.lineno>IJM||e.colno!==void 0&&e.colno>BJM}function NJM(e,t){let r=M7o.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 FJM(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=q1_(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+mwc:(n.push(i),i=q1_(a)),t++}return n}function q1_(e){return[F1_(e),Q1_(e)]}function F1_(e){return Math.max(1,e-mwc)}function Q1_(e){return e+mwc}function QJM(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function UJM(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 LJM(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 U1_(e,t){globalThis.process?.on("uncaughtException",LJM(e,t))}function L1_(e){globalThis.process?.on("unhandledRejection",t=>e(t,{mechanism:{type:"onunhandledrejection",handled:!1}}))}var VJM=2e3,SFi=class e{constructor(t,r,i){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this._logger=i,this._rateLimiter=new y7o({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||HJt(),properties:{...o,...a}}}startAutocaptureIfEnabled(){this.isEnabled()&&(U1_(this.onException.bind(this),this.onFatalError.bind(this)),L1_(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(VJM),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};var V1_="5.17.4";async function W1_(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 WJM=6e4,GJM=1152921504606847e3,HJM=["is_not"],ykn=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},v0=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},KJt=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},D7o=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 KJt||d instanceof v0?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 KJt||p instanceof v0?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 v0("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 v0("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 v0("Feature flags not available for dependency evaluation");if(!("dependency_chain"in t))throw new v0(`Flag dependency property for '${a}' is missing required 'dependency_chain' field`);let o=t.dependency_chain;if(!Array.isArray(o))throw new v0(`Flag dependency property for '${a}' has an invalid 'dependency_chain' (expected array, got ${typeof o})`);if(o.length===0)throw new v0(`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 v0(`Error evaluating flag dependency '${d}' for flag '${a}': ${l}`)}else n[d]=!1;else throw new v0(`Missing flag dependency '${d}' for flag '${a}'`)}if(n[d]==null)throw new v0(`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 KJt)throw u;if(u instanceof v0)c=!0;else throw u}if(d!==void 0)return d;if(c)throw new v0("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"?J1_(d,n,this.cohorts,this.debugMode):s==="flag"?await this.evaluateFlagDependency(d,r,n,a):K1_(d,n,c),!u)return!1}if(o==null)return!0}return!(o!=null&&await G1_(t.key,r)>o/100)}async getMatchingVariant(t,r){let i=await G1_(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(WJM,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 ykn(`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 ykn(`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 ykn(`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 ykn&&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=D_n(()=>{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 G1_(e,t,r=""){let i=await W1_(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/GJM}function K1_(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 v0("Operator is_not_set is not supported")}else throw new v0(`Property ${i} not found in propertyValues`);let o=t[i];if(o==null&&!HJM.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 H1_(String(n))&&String(o).match(String(n))!==null;case"not_regex":return H1_(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 v0("Date operations cannot be performed on boolean values");let s=KJM(String(n));if(s==null&&(s=x1_(n)),s==null)throw new v0(`Invalid date: ${n}`);let u=x1_(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new v0(`Unknown operator: ${a}`)}}function xJM(e,t){if(!(e in t))throw new KJt(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function J1_(e,t,r,i=!1){let n=String(e.value);xJM(n,r);let a=r[n];return $1_(a,t,r,i)}function $1_(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=$1_(c,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof KJt)throw d;if(d instanceof v0)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new v0("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=J1_(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=K1_(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 KJt)throw d;if(d instanceof v0)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new v0("can't match cohort without a given cohort property value");return n==="AND"}function H1_(e){try{return new RegExp(e),!0}catch{return!1}}function x1_(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 v0(`${e} is in an invalid date format`)}throw new v0(`The date provided ${e} must be a string, number, or date object`)}function KJM(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 B7o=class{getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}constructor(){this._memoryStorage={}}};var JJM=100,Y1_=3e4,$JM=5e4,I7o=class extends HWa{constructor(t,r={}){if(super(t,r),this._memoryStorage=new B7o,this.options=r,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,JJM):Y1_,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 D7o({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 SFi(this,r,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||$JM}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 V1_}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=Y1_){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=S_n(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 KJt||y instanceof v0)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=D_n(()=>{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(r1_(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(SFi.buildEventMessage(t,{syntheticException:n},r,i).then(a=>this.capture(a)))}async captureExceptionImmediate(t,r,i){let n=new Error("PostHog syntheticException");this.addPendingPromise(SFi.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=HJt(),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,A]of Object.entries(y))b[`$feature/${O}`]=A;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"&&Yq_(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 X1_=require("async_hooks"),C7o=class{constructor(){this.storage=new X1_.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 Z1_="posthog-node";function YJM(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[Pwc.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 Pwc=class{static#e=this.POSTHOG_ID_TAG="posthog_distinct_id";constructor(t,r,i,n,a){this.name=Z1_,this.name=Z1_,this.setupOnce=function(o,c){let d=c()?.getClient()?.getDsn()?.projectId;o(YJM(t,{organization:r,projectId:d,prefix:i,severityAllowList:n,sendExceptionsToPostHog:a??!0}))}}};SFi.errorPropertiesBuilder=new h$.ErrorPropertiesBuilder([new h$.EventCoercer,new h$.ErrorCoercer,new h$.ObjectCoercer,new h$.StringCoercer,new h$.PrimitiveCoercer],h$.createStackParser("node:javascript",h$.nodeStackLineParser),[Hq_(),N1_]);var bkn=class extends I7o{getLibraryId(){return"posthog-node"}initializeContext(){return new C7o}};var q7o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new bkn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.30.2",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var xWa=class{async sendEvent(){}async identify(){}async flush(){}};var vkn=require("fs/promises"),rT_=require("os"),iT_=require("path");var k1_=ce(require("crypto")),R7o=new Uint8Array(256),T7o=R7o.length;function jwc(){return T7o>R7o.length-16&&(k1_.default.randomFillSync(R7o),T7o=0),R7o.slice(T7o,T7o+=16)}var L4=[];for(let e=0;e<256;++e)L4.push((e+256).toString(16).slice(1));function eT_(e,t=0){return L4[e[t+0]]+L4[e[t+1]]+L4[e[t+2]]+L4[e[t+3]]+"-"+L4[e[t+4]]+L4[e[t+5]]+"-"+L4[e[t+6]]+L4[e[t+7]]+"-"+L4[e[t+8]]+L4[e[t+9]]+"-"+L4[e[t+10]]+L4[e[t+11]]+L4[e[t+12]]+L4[e[t+13]]+L4[e[t+14]]+L4[e[t+15]]}var tT_=ce(require("crypto")),wwc={randomUUID:tT_.default.randomUUID};function XJM(e,t,r){if(wwc.randomUUID&&!t&&!e)return wwc.randomUUID();e=e||{};let i=e.random||(e.rng||jwc)();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 eT_(i)}var ave=XJM;var ZJM="id",kJM=".fern",KWa=class{posthog;userId;token;constructor({token:t,posthogApiKey:r}){this.posthog=new bkn(r),this.userId=t==null?void 0:bgc(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.30.2",...t,...t.properties,usingAccessToken:!1,...r!=null?{userEmail:r}:{}}})}async flush(){await this.posthog.flush()}userEmail;async getUserEmail(){if(this.userEmail!==null){if(this.userEmail!=null)return this.userEmail;if(this.token==null){this.userEmail=null;return}try{let t=await I4({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=Ct(Cr.of((0,rT_.homedir)()),Ze.of(kJM),Ze.of(ZJM));await ji(t)||(await(0,vkn.mkdir)((0,iT_.dirname)(t),{recursive:!0}),await(0,vkn.writeFile)(t,ave())),this.persistedDistinctId=(await(0,vkn.readFile)(t)).toString()}return this.persistedDistinctId}};var Ewc;async function gkn(){return Ewc==null&&(Ewc=await e$M()),Ewc}async function e$M(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new xWa;let r=await rWo();return r!=null?new KWa({token:r,posthogApiKey:e}):await MZn()!=null?new q7o({posthogApiKey:e}):new KWa({token:void 0,posthogApiKey:e})}catch{return new xWa}}function JWa(e,t){return function(){return e.apply(t,arguments)}}var{toString:t$M}=Object.prototype,{getPrototypeOf:Mwc}=Object,{iterator:N7o,toStringTag:aT_}=Symbol,F7o=(e=>t=>{let r=t$M.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),c3t=e=>(e=e.toLowerCase(),t=>F7o(t)===e),Q7o=e=>t=>typeof t===e,{isArray:Akn}=Array,Okn=Q7o("undefined");function $Wa(e){return e!==null&&!Okn(e)&&e.constructor!==null&&!Okn(e.constructor)&&y$(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var oT_=c3t("ArrayBuffer");function r$M(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&oT_(e.buffer),t}var i$M=Q7o("string"),y$=Q7o("function"),uT_=Q7o("number"),YWa=e=>e!==null&&typeof e=="object",n$M=e=>e===!0||e===!1,z7o=e=>{if(F7o(e)!=="object")return!1;let t=Mwc(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(aT_ in e)&&!(N7o in e)},a$M=e=>{if(!YWa(e)||$Wa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},o$M=c3t("Date"),u$M=c3t("File"),s$M=c3t("Blob"),c$M=c3t("FileList"),l$M=e=>YWa(e)&&y$(e.pipe),f$M=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||y$(e.append)&&((t=F7o(e))==="formdata"||t==="object"&&y$(e.toString)&&e.toString()==="[object FormData]"))},d$M=c3t("URLSearchParams"),[p$M,_$M,h$M,y$M]=["ReadableStream","Request","Response","Headers"].map(c3t),b$M=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function XWa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),Akn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if($Wa(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 sT_(e,t){if($Wa(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 B_n=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,cT_=e=>!Okn(e)&&e!==B_n;function Swc(){let{caseless:e,skipUndefined:t}=cT_(this)&&this||{},r={},i=(n,a)=>{let o=e&&sT_(r,a)||a;z7o(r[o])&&z7o(n)?r[o]=Swc(r[o],n):z7o(n)?r[o]=Swc({},n):Akn(n)?r[o]=n.slice():(!t||!Okn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&XWa(arguments[n],i);return r}var v$M=(e,t,r,{allOwnKeys:i}={})=>(XWa(t,(n,a)=>{r&&y$(n)?e[a]=JWa(n,r):e[a]=n},{allOwnKeys:i}),e),g$M=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),O$M=(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)},A$M=(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&&Mwc(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},m$M=(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},P$M=e=>{if(!e)return null;if(Akn(e))return e;let t=e.length;if(!uT_(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},j$M=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Mwc(Uint8Array)),w$M=(e,t)=>{let i=(e&&e[N7o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},E$M=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},S$M=c3t("HTMLFormElement"),M$M=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),nT_=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),D$M=c3t("RegExp"),lT_=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};XWa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},B$M=e=>{lT_(e,(t,r)=>{if(y$(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(y$(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+"'")})}})},I$M=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return Akn(e)?i(e):i(String(e).split(t)),r},C$M=()=>{},q$M=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function T$M(e){return!!(e&&y$(e.append)&&e[aT_]==="FormData"&&e[N7o])}var R$M=e=>{let t=new Array(10),r=(i,n)=>{if(YWa(i)){if(t.indexOf(i)>=0)return;if($Wa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=Akn(i)?[]:{};return XWa(i,(o,c)=>{let d=r(o,n+1);!Okn(d)&&(a[c]=d)}),t[n]=void 0,a}}return i};return r(e,0)},z$M=c3t("AsyncFunction"),N$M=e=>e&&(YWa(e)||y$(e))&&y$(e.then)&&y$(e.catch),fT_=((e,t)=>e?setImmediate:t?((r,i)=>(B_n.addEventListener("message",({source:n,data:a})=>{n===B_n&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),B_n.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",y$(B_n.postMessage)),F$M=typeof queueMicrotask<"u"?queueMicrotask.bind(B_n):typeof process<"u"&&process.nextTick||fT_,Q$M=e=>e!=null&&y$(e[N7o]),rr={isArray:Akn,isArrayBuffer:oT_,isBuffer:$Wa,isFormData:f$M,isArrayBufferView:r$M,isString:i$M,isNumber:uT_,isBoolean:n$M,isObject:YWa,isPlainObject:z7o,isEmptyObject:a$M,isReadableStream:p$M,isRequest:_$M,isResponse:h$M,isHeaders:y$M,isUndefined:Okn,isDate:o$M,isFile:u$M,isBlob:s$M,isRegExp:D$M,isFunction:y$,isStream:l$M,isURLSearchParams:d$M,isTypedArray:j$M,isFileList:c$M,forEach:XWa,merge:Swc,extend:v$M,trim:b$M,stripBOM:g$M,inherits:O$M,toFlatObject:A$M,kindOf:F7o,kindOfTest:c3t,endsWith:m$M,toArray:P$M,forEachEntry:w$M,matchAll:E$M,isHTMLForm:S$M,hasOwnProperty:nT_,hasOwnProp:nT_,reduceDescriptors:lT_,freezeMethods:B$M,toObjectSet:I$M,toCamelCase:M$M,noop:C$M,toFiniteNumber:q$M,findKey:sT_,global:B_n,isContextDefined:cT_,isSpecCompliantForm:T$M,toJSONObject:R$M,isAsyncFn:z$M,isThenable:N$M,setImmediate:fT_,asap:F$M,isIterable:Q$M};function mkn(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)}rr.inherits(mkn,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:rr.toJSONObject(this.config),code:this.code,status:this.status}}});var dT_=mkn.prototype,pT_={};["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=>{pT_[e]={value:e}});Object.defineProperties(mkn,pT_);Object.defineProperty(dT_,"isAxiosError",{value:!0});mkn.from=(e,t,r,i,n,a)=>{let o=Object.create(dT_);rr.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 mkn.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 Ba=mkn;var _T_=ce(WXn(),1),U7o=_T_.default;function Dwc(e){return rr.isPlainObject(e)||rr.isArray(e)}function yT_(e){return rr.endsWith(e,"[]")?e.slice(0,-2):e}function hT_(e,t,r){return e?e.concat(t).map(function(n,a){return n=yT_(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function U$M(e){return rr.isArray(e)&&!e.some(Dwc)}var L$M=rr.toFlatObject(rr,{},null,function(t){return/^is[A-Z]/.test(t)});function V$M(e,t,r){if(!rr.isObject(e))throw new TypeError("target must be an object");t=t||new(U7o||FormData),r=rr.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!rr.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&rr.isSpecCompliantForm(t);if(!rr.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(rr.isDate(h))return h.toISOString();if(rr.isBoolean(h))return h.toString();if(!d&&rr.isBlob(h))throw new Ba("Blob is not supported. Use a Buffer instead.");return rr.isArrayBuffer(h)||rr.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(rr.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(rr.isArray(h)&&U$M(h)||(rr.isFileList(h)||rr.endsWith(y,"[]"))&&(v=rr.toArray(h)))return y=yT_(y),v.forEach(function(A,g){!(rr.isUndefined(A)||A===null)&&t.append(o===!0?hT_([y],g,a):o===null?y:y+"[]",s(A))}),!1}return Dwc(h)?!0:(t.append(hT_(b,y,a),s(h)),!1)}let l=[],p=Object.assign(L$M,{defaultVisitor:u,convertValue:s,isVisitable:Dwc});function _(h,y){if(!rr.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),rr.forEach(h,function(v,O){(!(rr.isUndefined(v)||v===null)&&n.call(t,v,rr.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!rr.isObject(e))throw new TypeError("data must be an object");return _(e),t}var V7i=V$M;function bT_(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function vT_(e,t){this._pairs=[],e&&V7i(e,this,t)}var gT_=vT_.prototype;gT_.append=function(t,r){this._pairs.push([t,r])};gT_.toString=function(t){let r=t?function(i){return t.call(this,i,bT_)}:bT_;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var OT_=vT_;function W$M(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function I_n(e,t,r){if(!t)return e;let i=r&&r.encode||W$M;rr.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=rr.isURLSearchParams(t)?t.toString():new OT_(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var Bwc=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){rr.forEach(this.handlers,function(i){i!==null&&t(i)})}},Iwc=Bwc;var Pkn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var jT_=ce(require("crypto"),1);var AT_=ce(require("url"),1),mT_=AT_.default.URLSearchParams;var Cwc="abcdefghijklmnopqrstuvwxyz",PT_="0123456789",wT_={DIGIT:PT_,ALPHA:Cwc,ALPHA_DIGIT:Cwc+Cwc.toUpperCase()+PT_},G$M=(e=16,t=wT_.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);jT_.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},ET_={isNode:!0,classes:{URLSearchParams:mT_,FormData:U7o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:wT_,generateString:G$M,protocols:["http","https","file","data"]};var Rwc={};Zt(Rwc,{hasBrowserEnv:()=>Twc,hasStandardBrowserEnv:()=>H$M,hasStandardBrowserWebWorkerEnv:()=>x$M,navigator:()=>qwc,origin:()=>K$M});var Twc=typeof window<"u"&&typeof document<"u",qwc=typeof navigator=="object"&&navigator||void 0,H$M=Twc&&(!qwc||["ReactNative","NativeScript","NS"].indexOf(qwc.product)<0),x$M=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",K$M=Twc&&window.location.href||"http://localhost";var om={...Rwc,...ET_};function zwc(e,t){return V7i(e,new om.classes.URLSearchParams,{visitor:function(r,i,n,a){return om.isNode&&rr.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function J$M(e){return rr.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function $$M(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 Y$M(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&&rr.isArray(n)?n.length:o,d?(rr.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!rr.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&rr.isArray(n[o])&&(n[o]=$$M(n[o])),!c)}if(rr.isFormData(e)&&rr.isFunction(e.entries)){let r={};return rr.forEachEntry(e,(i,n)=>{t(J$M(i),n,r,0)}),r}return null}var L7o=Y$M;function X$M(e,t,r){if(rr.isString(e))try{return(t||JSON.parse)(e),rr.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var Nwc={transitional:Pkn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=rr.isObject(t);if(a&&rr.isHTMLForm(t)&&(t=new FormData(t)),rr.isFormData(t))return n?JSON.stringify(L7o(t)):t;if(rr.isArrayBuffer(t)||rr.isBuffer(t)||rr.isStream(t)||rr.isFile(t)||rr.isBlob(t)||rr.isReadableStream(t))return t;if(rr.isArrayBufferView(t))return t.buffer;if(rr.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 zwc(t,this.formSerializer).toString();if((c=rr.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return V7i(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),X$M(t)):t}],transformResponse:[function(t){let r=this.transitional||Nwc.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(rr.isResponse(t)||rr.isReadableStream(t))return t;if(t&&rr.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"?Ba.from(c,Ba.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:om.classes.FormData,Blob:om.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};rr.forEach(["delete","get","head","post","put","patch"],e=>{Nwc.headers[e]={}});var jkn=Nwc;var Z$M=rr.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"]),ST_=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1149
1149
|
`).forEach(function(o){n=o.indexOf(":"),r=o.substring(0,n).trim().toLowerCase(),i=o.substring(n+1).trim(),!(!r||t[r]&&Z$M[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var MT_=Symbol("internals");function ZWa(e){return e&&String(e).trim().toLowerCase()}function V7o(e){return e===!1||e==null?e:rr.isArray(e)?e.map(V7o):String(e)}function k$M(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 eYM=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Fwc(e,t,r,i,n){if(rr.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!rr.isString(t)){if(rr.isString(i))return t.indexOf(i)!==-1;if(rr.isRegExp(i))return i.test(t)}}function tYM(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function rYM(e,t){let r=rr.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 wkn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(c,d,s){let u=ZWa(d);if(!u)throw new Error("header name must be a non-empty string");let l=rr.findKey(n,u);(!l||n[l]===void 0||s===!0||s===void 0&&n[l]!==!1)&&(n[l||d]=V7o(c))}let o=(c,d)=>rr.forEach(c,(s,u)=>a(s,u,d));if(rr.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(rr.isString(t)&&(t=t.trim())&&!eYM(t))o(ST_(t),r);else if(rr.isObject(t)&&rr.isIterable(t)){let c={},d,s;for(let u of t){if(!rr.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[s=u[0]]=(d=c[s])?rr.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=ZWa(t),t){let i=rr.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return k$M(n);if(rr.isFunction(r))return r.call(this,n,i);if(rr.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=ZWa(t),t){let i=rr.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||Fwc(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(o){if(o=ZWa(o),o){let c=rr.findKey(i,o);c&&(!r||Fwc(i,i[c],c,r))&&(delete i[c],n=!0)}}return rr.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||Fwc(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return rr.forEach(this,(n,a)=>{let o=rr.findKey(i,a);if(o){r[o]=V7o(n),delete r[a];return}let c=t?tYM(a):String(a).trim();c!==a&&delete r[a],r[c]=V7o(n),i[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return rr.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&rr.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(`
|
|
1150
1150
|
`)}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[MT_]=this[MT_]={accessors:{}}).accessors,n=this.prototype;function a(o){let c=ZWa(o);i[c]||(rYM(n,o),i[c]=!0)}return rr.isArray(t)?t.forEach(a):a(t),this}};wkn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);rr.reduceDescriptors(wkn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});rr.freezeMethods(wkn);var iD=wkn;function kWa(e,t){let r=this||jkn,i=t||r,n=iD.from(i.headers),a=i.data;return rr.forEach(e,function(c){a=c.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function e5a(e){return!!(e&&e.__CANCEL__)}function DT_(e,t,r){Ba.call(this,e??"canceled",Ba.ERR_CANCELED,t,r),this.name="CanceledError"}rr.inherits(DT_,Ba,{__CANCEL__:!0});var ove=DT_;function JJt(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new Ba("Request failed with status code "+r.status,[Ba.ERR_BAD_REQUEST,Ba.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Qwc(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Uwc(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function C_n(e,t,r){let i=!Qwc(t);return e&&(i||r==!1)?Uwc(e,t):t}var kT_=ce(Lwc(),1),eR_=ce(require("http"),1),tR_=ce(require("https"),1),rR_=ce(require("util"),1),iR_=ce(NT_(),1),DFi=ce(require("zlib"),1);var R_n="1.12.2";function a5a(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var gYM=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function eEc(e,t,r){let i=r&&r.Blob||om.classes.Blob,n=a5a(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=gYM.exec(e);if(!a)throw new Ba("Invalid URL",Ba.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 Ba("Blob is not supported",Ba.ERR_NOT_SUPPORT);return new i([s],{type:o})}return s}throw new Ba("Unsupported protocol "+n,Ba.ERR_NOT_SUPPORT)}var N_n=ce(require("stream"),1);var FT_=ce(require("stream"),1);var tEc=Symbol("internals"),rEc=class extends FT_.default.Transform{constructor(t){t=rr.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!rr.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[tEc]={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[tEc];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[tEc],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,A=0;if(a){let g=Date.now();(!n.ts||(A=g-n.ts)>=c)&&(n.ts=g,O=s-n.bytes,n.bytes=O<0?-O:0,A=0),O=s-n.bytes}if(a){if(O<=0)return setTimeout(()=>{h(null,_)},c-A);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)})}},iEc=rEc;var nR_=require("events");var UT_=ce(require("util"),1),LT_=require("stream");var{asyncIterator:QT_}=Symbol,OYM=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[QT_]?yield*e[QT_]():yield e},W7o=OYM;var AYM=om.ALPHABET.ALPHA_DIGIT+"-_",o5a=typeof TextEncoder=="function"?new TextEncoder:new UT_.default.TextEncoder,z_n=`\r
|
|
1151
1151
|
`,mYM=o5a.encode(z_n),PYM=2,nEc=class{constructor(t,r){let{escapeName:i}=this.constructor,n=rr.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${z_n}`;n?r=o5a.encode(String(r).replace(/\r?\n|\r\n?/g,z_n)):a+=`Content-Type: ${r.type||"application/octet-stream"}${z_n}`,this.headers=o5a.encode(a+z_n),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+PYM,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;rr.isTypedArray(t)?yield t:yield*W7o(t),yield mYM}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},jYM=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+om.generateString(n,AYM)}=r||{};if(!rr.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=o5a.encode("--"+a+z_n),c=o5a.encode("--"+a+"--"+z_n),d=c.byteLength,s=Array.from(e.entries()).map(([l,p])=>{let _=new nEc(l,p);return d+=_.size,_});d+=o.byteLength*s.length,d=rr.toFiniteNumber(d);let u={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(u["Content-Length"]=d),t&&t(u),LT_.Readable.from((async function*(){for(let l of s)yield o,yield*l.encode();yield c})())},VT_=jYM;var WT_=ce(require("stream"),1),aEc=class extends WT_.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)}},GT_=aEc;var wYM=(e,t)=>rr.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,HT_=wYM;function EYM(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 xT_=EYM;function SYM(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 KT_=SYM;var MFi=(e,t,r=3)=>{let i=0,n=xT_(50,250);return KT_(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)},Skn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},Mkn=e=>(...t)=>rr.asap(()=>e(...t));function oEc(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 JT_={flush:DFi.default.constants.Z_SYNC_FLUSH,finishFlush:DFi.default.constants.Z_SYNC_FLUSH},MYM={flush:DFi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:DFi.default.constants.BROTLI_OPERATION_FLUSH},$T_=rr.isFunction(DFi.default.createBrotliDecompress),{http:DYM,https:BYM}=iR_.default,IYM=/https:?/,YT_=om.protocols.map(e=>e+":"),XT_=(e,[t,r])=>(e.on("end",r).on("error",r),t);function CYM(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function aR_(e,t,r){let i=t;if(!i&&i!==!1){let n=kT_.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){aR_(a,t,a.href)}}var qYM=typeof process<"u"&&rr.kindOf(process)==="process",TYM=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)}),RYM=({address:e,family:t})=>{if(!rr.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},ZT_=(e,t)=>RYM(rr.isObject(e)?e:{address:e,family:t}),oR_=qYM&&function(t){return TYM(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 k=HT_(c,je=>rr.isArray(je)?je:[je]);c=(je,ve,H)=>{k(je,ve,(G,Ee,ue)=>{if(G)return H(G);let Oe=rr.isArray(Ee)?Ee.map(Qe=>ZT_(Qe)):[ZT_(Ee,ue)];ve.all?H(G,Oe):H(G,Oe[0].address,Oe[0].family)})}}let y=new nR_.EventEmitter,b=()=>{t.cancelToken&&t.cancelToken.unsubscribe(v),t.signal&&t.signal.removeEventListener("abort",v),y.removeAllListeners()};a((k,je)=>{p=!0,je&&(_=!0,b())});function v(k){y.emit("abort",!k||k.type?new ove(null,t,h):k)}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=C_n(t.baseURL,t.url,t.allowAbsoluteUrls),A=new URL(O,om.hasBrowserEnv?om.origin:void 0),g=A.protocol||YT_[0];if(g==="data:"){if(t.maxContentLength>-1){let je=String(t.url||O||"");if(oEc(je)>t.maxContentLength)return n(new Ba("maxContentLength size of "+t.maxContentLength+" exceeded",Ba.ERR_BAD_RESPONSE,t))}let k;if(l!=="GET")return JJt(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{k=eEc(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(je){throw Ba.from(je,Ba.ERR_BAD_REQUEST,t)}return s==="text"?(k=k.toString(u),(!u||u==="utf8")&&(k=rr.stripBOM(k))):s==="stream"&&(k=N_n.default.Readable.from(k)),JJt(i,n,{data:k,status:200,statusText:"OK",headers:new iD,config:t})}if(YT_.indexOf(g)===-1)return n(new Ba("Unsupported protocol "+g,Ba.ERR_BAD_REQUEST,t));let m=iD.from(t.headers).normalize();m.set("User-Agent","axios/"+R_n,!1);let{onUploadProgress:j,onDownloadProgress:S}=t,w=t.maxRate,D,B;if(rr.isSpecCompliantForm(o)){let k=m.getContentType(/boundary=([-_\w\d]{10,70})/i);o=VT_(o,je=>{m.set(je)},{tag:`axios-${R_n}-boundary`,boundary:k&&k[1]||void 0})}else if(rr.isFormData(o)&&rr.isFunction(o.getHeaders)){if(m.set(o.getHeaders()),!m.hasContentLength())try{let k=await rR_.default.promisify(o.getLength).call(o);Number.isFinite(k)&&k>=0&&m.setContentLength(k)}catch{}}else if(rr.isBlob(o)||rr.isFile(o))o.size&&m.setContentType(o.type||"application/octet-stream"),m.setContentLength(o.size||0),o=N_n.default.Readable.from(W7o(o));else if(o&&!rr.isStream(o)){if(!Buffer.isBuffer(o))if(rr.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(rr.isString(o))o=Buffer.from(o,"utf-8");else return n(new Ba("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Ba.ERR_BAD_REQUEST,t));if(m.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return n(new Ba("Request body larger than maxBodyLength limit",Ba.ERR_BAD_REQUEST,t))}let R=rr.toFiniteNumber(m.getContentLength());rr.isArray(w)?(D=w[0],B=w[1]):D=B=w,o&&(j||D)&&(rr.isStream(o)||(o=N_n.default.Readable.from(o,{objectMode:!1})),o=N_n.default.pipeline([o,new iEc({maxRate:rr.toFiniteNumber(D)})],rr.noop),j&&o.on("progress",XT_(o,Skn(R,MFi(Mkn(j),!1,3)))));let N;if(t.auth){let k=t.auth.username||"",je=t.auth.password||"";N=k+":"+je}if(!N&&A.username){let k=A.username,je=A.password;N=k+":"+je}N&&m.delete("authorization");let z;try{z=I_n(A.pathname+A.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(k){let je=new Error(k.message);return je.config=t,je.url=t.url,je.exists=!0,n(je)}m.set("Accept-Encoding","gzip, compress, deflate"+($T_?", br":""),!1);let F={path:z,method:l,headers:m.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:N,protocol:g,family:d,beforeRedirect:CYM,beforeRedirects:{}};!rr.isUndefined(c)&&(F.lookup=c),t.socketPath?F.socketPath=t.socketPath:(F.hostname=A.hostname.startsWith("[")?A.hostname.slice(1,-1):A.hostname,F.port=A.port,aR_(F,t.proxy,g+"//"+A.hostname+(A.port?":"+A.port:"")+F.path));let U,x=IYM.test(F.protocol);if(F.agent=x?t.httpsAgent:t.httpAgent,t.transport?U=t.transport:t.maxRedirects===0?U=x?tR_.default:eR_.default:(t.maxRedirects&&(F.maxRedirects=t.maxRedirects),t.beforeRedirect&&(F.beforeRedirects.config=t.beforeRedirect),U=x?BYM:DYM),t.maxBodyLength>-1?F.maxBodyLength=t.maxBodyLength:F.maxBodyLength=1/0,t.insecureHTTPParser&&(F.insecureHTTPParser=t.insecureHTTPParser),h=U.request(F,function(je){if(h.destroyed)return;let ve=[je],H=+je.headers["content-length"];if(S||B){let Qe=new iEc({maxRate:rr.toFiniteNumber(B)});S&&Qe.on("progress",XT_(Qe,Skn(H,MFi(Mkn(S),!0,3)))),ve.push(Qe)}let G=je,Ee=je.req||h;if(t.decompress!==!1&&je.headers["content-encoding"])switch((l==="HEAD"||je.statusCode===204)&&delete je.headers["content-encoding"],(je.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":ve.push(DFi.default.createUnzip(JT_)),delete je.headers["content-encoding"];break;case"deflate":ve.push(new GT_),ve.push(DFi.default.createUnzip(JT_)),delete je.headers["content-encoding"];break;case"br":$T_&&(ve.push(DFi.default.createBrotliDecompress(MYM)),delete je.headers["content-encoding"])}G=ve.length>1?N_n.default.pipeline(ve,rr.noop):ve[0];let ue=N_n.default.finished(G,()=>{ue(),b()}),Oe={status:je.statusCode,statusText:je.statusMessage,headers:new iD(je.headers),config:t,request:Ee};if(s==="stream")Oe.data=G,JJt(i,n,Oe);else{let Qe=[],se=0;G.on("data",function($e){Qe.push($e),se+=$e.length,t.maxContentLength>-1&&se>t.maxContentLength&&(_=!0,G.destroy(),n(new Ba("maxContentLength size of "+t.maxContentLength+" exceeded",Ba.ERR_BAD_RESPONSE,t,Ee)))}),G.on("aborted",function(){if(_)return;let $e=new Ba("stream has been aborted",Ba.ERR_BAD_RESPONSE,t,Ee);G.destroy($e),n($e)}),G.on("error",function($e){h.destroyed||n(Ba.from($e,null,t,Ee))}),G.on("end",function(){try{let $e=Qe.length===1?Qe[0]:Buffer.concat(Qe);s!=="arraybuffer"&&($e=$e.toString(u),(!u||u==="utf8")&&($e=rr.stripBOM($e))),Oe.data=$e}catch($e){return n(Ba.from($e,null,t,Oe.request,Oe))}JJt(i,n,Oe)})}y.once("abort",Qe=>{G.destroyed||(G.emit("error",Qe),G.destroy())})}),y.once("abort",k=>{n(k),h.destroy(k)}),h.on("error",function(je){n(Ba.from(je,null,t,h))}),h.on("socket",function(je){je.setKeepAlive(!0,1e3*60)}),t.timeout){let k=parseInt(t.timeout,10);if(Number.isNaN(k)){n(new Ba("error trying to parse `config.timeout` to int",Ba.ERR_BAD_OPTION_VALUE,t,h));return}h.setTimeout(k,function(){if(p)return;let ve=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",H=t.transitional||Pkn;t.timeoutErrorMessage&&(ve=t.timeoutErrorMessage),n(new Ba(ve,H.clarifyTimeoutError?Ba.ETIMEDOUT:Ba.ECONNABORTED,t,h)),v()})}if(rr.isStream(o)){let k=!1,je=!1;o.on("end",()=>{k=!0}),o.once("error",ve=>{je=!0,h.destroy(ve)}),o.on("close",()=>{!k&&!je&&v(new ove("Request stream has been aborted",t,h))}),o.pipe(h)}else h.end(o)})};var uR_=om.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,om.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(om.origin),om.navigator&&/(msie|trident)/i.test(om.navigator.userAgent)):()=>!0;var sR_=om.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let o=[e+"="+encodeURIComponent(t)];rr.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),rr.isString(i)&&o.push("path="+i),rr.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 cR_=e=>e instanceof iD?{...e}:e;function l3t(e,t){t=t||{};let r={};function i(s,u,l,p){return rr.isPlainObject(s)&&rr.isPlainObject(u)?rr.merge.call({caseless:p},s,u):rr.isPlainObject(u)?rr.merge({},u):rr.isArray(u)?u.slice():u}function n(s,u,l,p){if(rr.isUndefined(u)){if(!rr.isUndefined(s))return i(void 0,s,l,p)}else return i(s,u,l,p)}function a(s,u){if(!rr.isUndefined(u))return i(void 0,u)}function o(s,u){if(rr.isUndefined(u)){if(!rr.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(cR_(s),cR_(u),l,!0)};return rr.forEach(Object.keys({...e,...t}),function(u){let l=d[u]||n,p=l(e[u],t[u],u);rr.isUndefined(p)&&l!==c||(r[u]=p)}),r}var G7o=e=>{let t=l3t({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=iD.from(o),t.url=I_n(C_n(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),rr.isFormData(r)){if(om.hasStandardBrowserEnv||om.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(rr.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(om.hasStandardBrowserEnv&&(i&&rr.isFunction(i)&&(i=i(t)),i||i!==!1&&uR_(t.url))){let d=n&&a&&sR_.read(a);d&&o.set(n,d)}return t};var zYM=typeof XMLHttpRequest<"u",lR_=zYM&&function(e){return new Promise(function(r,i){let n=G7o(e),a=n.data,o=iD.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 A=iD.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),m={data:!c||c==="text"||c==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:A,config:e,request:b};JJt(function(S){r(S),y()},function(S){i(S),y()},m),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 Ba("Request aborted",Ba.ECONNABORTED,e,b)),b=null)},b.onerror=function(g){let m=g&&g.message?g.message:"Network Error",j=new Ba(m,Ba.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",m=n.transitional||Pkn;n.timeoutErrorMessage&&(g=n.timeoutErrorMessage),i(new Ba(g,m.clarifyTimeoutError?Ba.ETIMEDOUT:Ba.ECONNABORTED,e,b)),b=null},a===void 0&&o.setContentType(null),"setRequestHeader"in b&&rr.forEach(o.toJSON(),function(g,m){b.setRequestHeader(m,g)}),rr.isUndefined(n.withCredentials)||(b.withCredentials=!!n.withCredentials),c&&c!=="json"&&(b.responseType=n.responseType),s&&([p,h]=MFi(s,!0),b.addEventListener("progress",p)),d&&b.upload&&([l,_]=MFi(d),b.upload.addEventListener("progress",l),b.upload.addEventListener("loadend",_)),(n.cancelToken||n.signal)&&(u=A=>{b&&(i(!A||A.type?new ove(null,e,b):A),b.abort(),b=null)},n.cancelToken&&n.cancelToken.subscribe(u),n.signal&&(n.signal.aborted?u():n.signal.addEventListener("abort",u)));let O=a5a(n.url);if(O&&om.protocols.indexOf(O)===-1){i(new Ba("Unsupported protocol "+O+":",Ba.ERR_BAD_REQUEST,e));return}b.send(a||null)})};var NYM=(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 Ba?u:new ove(u instanceof Error?u.message:u))}},o=t&&setTimeout(()=>{o=null,a(new Ba(`timeout ${t} of ms exceeded`,Ba.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=()=>rr.asap(c),d}},fR_=NYM;var FYM=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},QYM=async function*(e,t){for await(let r of UYM(e))yield*FYM(r,t)},UYM=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()}},uEc=(e,t,r,i)=>{let n=QYM(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 dR_=64*1024,{isFunction:H7o}=rr,LYM=(({Request:e,Response:t})=>({Request:e,Response:t}))(rr.global),{ReadableStream:pR_,TextEncoder:_R_}=rr.global,hR_=(e,...t)=>{try{return!!e(...t)}catch{return!1}},VYM=e=>{e=rr.merge.call({skipUndefined:!0},LYM,e);let{fetch:t,Request:r,Response:i}=e,n=t?H7o(t):typeof fetch=="function",a=H7o(r),o=H7o(i);if(!n)return!1;let c=n&&H7o(pR_),d=n&&(typeof _R_=="function"?(h=>y=>h.encode(y))(new _R_):async h=>new Uint8Array(await new r(h).arrayBuffer())),s=a&&c&&hR_(()=>{let h=!1,y=new r(om.origin,{body:new pR_,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return h&&!y}),u=o&&c&&hR_(()=>rr.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 Ba(`Response type '${h}' is not supported`,Ba.ERR_NOT_SUPPORT,b)})});let p=async h=>{if(h==null)return 0;if(rr.isBlob(h))return h.size;if(rr.isSpecCompliantForm(h))return(await new r(om.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(rr.isArrayBufferView(h)||rr.isArrayBuffer(h))return h.byteLength;if(rr.isURLSearchParams(h)&&(h=h+""),rr.isString(h))return(await d(h)).byteLength},_=async(h,y)=>{let b=rr.toFiniteNumber(h.getContentLength());return b??p(y)};return async h=>{let{url:y,method:b,data:v,signal:O,cancelToken:A,timeout:g,onDownloadProgress:m,onUploadProgress:j,responseType:S,headers:w,withCredentials:D="same-origin",fetchOptions:B}=G7o(h),R=t||fetch;S=S?(S+"").toLowerCase():"text";let N=fR_([O,A&&A.toAbortSignal()],g),z=null,F=N&&N.unsubscribe&&(()=>{N.unsubscribe()}),U;try{if(j&&s&&b!=="get"&&b!=="head"&&(U=await _(w,v))!==0){let G=new r(y,{method:"POST",body:v,duplex:"half"}),Ee;if(rr.isFormData(v)&&(Ee=G.headers.get("content-type"))&&w.setContentType(Ee),G.body){let[ue,Oe]=Skn(U,MFi(Mkn(j)));v=uEc(G.body,dR_,ue,Oe)}}rr.isString(D)||(D=D?"include":"omit");let x=a&&"credentials"in r.prototype,k={...B,signal:N,method:b.toUpperCase(),headers:w.normalize().toJSON(),body:v,duplex:"half",credentials:x?D:void 0};z=a&&new r(y,k);let je=await(a?R(z,B):R(y,k)),ve=u&&(S==="stream"||S==="response");if(u&&(m||ve&&F)){let G={};["status","statusText","headers"].forEach(Qe=>{G[Qe]=je[Qe]});let Ee=rr.toFiniteNumber(je.headers.get("content-length")),[ue,Oe]=m&&Skn(Ee,MFi(Mkn(m),!0))||[];je=new i(uEc(je.body,dR_,ue,()=>{Oe&&Oe(),F&&F()}),G)}S=S||"text";let H=await l[rr.findKey(l,S)||"text"](je,h);return!ve&&F&&F(),await new Promise((G,Ee)=>{JJt(G,Ee,{data:H,headers:iD.from(je.headers),status:je.status,statusText:je.statusText,config:h,request:z})})}catch(x){throw F&&F(),x&&x.name==="TypeError"&&/Load failed|fetch/i.test(x.message)?Object.assign(new Ba("Network Error",Ba.ERR_NETWORK,h,z),{cause:x.cause||x}):Ba.from(x,x&&x.code,h,z)}}},WYM=new Map,sEc=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=WYM;for(;c--;)d=a[c],s=u.get(d),s===void 0&&u.set(d,s=c?new Map:VYM(t)),u=s;return s},DE9=sEc();var cEc={http:oR_,xhr:lR_,fetch:{get:sEc}};rr.forEach(cEc,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var yR_=e=>`- ${e}`,HYM=e=>rr.isFunction(e)||e===null||e===!1,x7o={getAdapter:(e,t)=>{e=rr.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,!HYM(i)&&(n=cEc[(c=String(i)).toLowerCase()],n===void 0))throw new Ba(`Unknown adapter '${c}'`);if(n&&(rr.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 :
|
|
@@ -1389,7 +1389,7 @@ ${g}${O}${m}${Ona}`});function Nsu({message:e,error:t,logger:r,logLevel:i=yc.Err
|
|
|
1389
1389
|
Run ${It.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1390
1390
|
Run ${It.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),H7i(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function G4c({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!srh(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+=`
|
|
1391
1391
|
${await CID(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+It.dim(c.currentVersion)+It.reset(" \u2192 ")+It.green(c.latestVersion);return n+=`
|
|
1392
|
-
`,i?H7i(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function CID(e){let r=await new urh.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 qID({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await lrh({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=xGi(u.name,l),_=await FVt({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 lrh({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=xGi(s.name,u),p=await FVt({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 lrh({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 eve({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(c==null||c.groups==null)return;let d=i!=null?yN(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 frh(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=U$(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 Lsu({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await qID({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(...frh(s,d,t.logger));else o.push(...frh(c.versions,void 0,t.logger))}return o}var gHa=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 jna=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var H4c=(()=>{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})(),drh=typeof globalThis.AbortController=="function",prh=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",_rh=typeof globalThis.ReadableStream=="function",hrh=typeof globalThis.FormData=="function",Vsu=["get","post","put","patch","head","delete"],TID=()=>{};TID();var yrh={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Wsu=2147483647,brh=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Gsu=Symbol("stop"),vrh={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},grh={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 RID=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=brh,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},Orh=(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))}}))},Arh=(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(Orh(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},mrh=(e,t,r)=>{if(!e.body)return e;let i=RID(r??e.body);return new Request(e,{duplex:"half",body:Orh(e.body,i,t)})};var wna=e=>e!==null&&typeof e=="object";var OHa=(...e)=>{for(let t of e)if((!wna(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return J4c({},...e)},x4c=(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 Hsu(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:J4c(e[r]??[],t[r]??[])}var K4c=(e={},t={})=>({beforeRequest:Hsu(e,t,"beforeRequest"),beforeRetry:Hsu(e,t,"beforeRetry"),afterResponse:Hsu(e,t,"afterResponse"),beforeError:Hsu(e,t,"beforeError")}),J4c=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(wna(n)){for(let[a,o]of Object.entries(n))wna(o)&&a in t&&(o=J4c(t[a],o)),t={...t,[a]:o};wna(n.hooks)&&(i=K4c(i,n.hooks),t.hooks=i),wna(n.headers)&&(r=x4c(r,n.headers),t.headers=r)}return t};var jrh=e=>Vsu.includes(e)?e.toUpperCase():e,zID=["get","put","head","delete","options","trace"],NID=[408,413,429,500,502,503,504],FID=[413,429,503],Prh={limit:2,methods:zID,statusCodes:NID,afterStatusCodes:FID,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},wrh=(e={})=>{if(typeof e=="number")return{...Prh,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{...Prh,...e}};async function $4c(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new jna(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function Y4c(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 Erh=(e,t)=>{let r={};for(let i in t)!(i in grh)&&!(i in vrh)&&!(i in e)&&(r[i]=t[i]);return r},Srh=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 AHa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>Wsu)throw new RangeError(`The \`timeout\` option cannot be greater than ${Wsu}`);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 gHa(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(!_rh)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return Arh(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(yrh))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:x4c(this._input.headers,r.headers),hooks:K4c({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:jrh(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:wrh(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(drh&&prh){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(H4c&&(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),Srh(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);(hrh&&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(!H4c)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=mrh(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof jna)throw t;if(t instanceof gHa){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),Wsu);if(this._retryCount<1)throw r;await Y4c(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})===Gsu)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=Erh(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):$4c(this._originalRequest,t,this.abortController,this._options)}};var X4c=e=>{let t=(r,i)=>AHa.create(r,OHa(e,i));for(let r of Vsu)t[r]=(i,n)=>AHa.create(i,OHa(e,n,{method:r}));return t.create=r=>X4c(OHa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),X4c(OHa(e,r))),t.stop=Gsu,t},QID=X4c(),Mrh=QID;var Xrh=ce(Yrh(),1);function rLc(e){let t=(0,Xrh.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Hih=ce(Gih(),1),xih=ce(Sbe(),1),hLc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},yLc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function bLc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??rLc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Hih.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 Mrh(o,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new hLc(e):l}if(t.allVersions)return s;let u=new yLc(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=xih.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 SHa(e,t){let{version:r}=await bLc(e.toLowerCase(),t);return r}async function QKi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:SHa(e.packageName,{version:t?"prerelease":"latest"})}var Kih=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],icu=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=yc.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new Usu(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.30.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${It.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new YS}failWithoutThrowing(t,r){this.didSucceed=!1,Nsu({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await gkn()).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 crh({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1392
|
+
`,i?H7i(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function CID(e){let r=await new urh.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 qID({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await lrh({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=xGi(u.name,l),_=await FVt({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 lrh({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=xGi(s.name,u),p=await FVt({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 lrh({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 eve({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(c==null||c.groups==null)return;let d=i!=null?yN(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 frh(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=U$(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 Lsu({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await qID({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(...frh(s,d,t.logger));else o.push(...frh(c.versions,void 0,t.logger))}return o}var gHa=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 jna=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var H4c=(()=>{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})(),drh=typeof globalThis.AbortController=="function",prh=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",_rh=typeof globalThis.ReadableStream=="function",hrh=typeof globalThis.FormData=="function",Vsu=["get","post","put","patch","head","delete"],TID=()=>{};TID();var yrh={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Wsu=2147483647,brh=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Gsu=Symbol("stop"),vrh={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},grh={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 RID=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=brh,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},Orh=(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))}}))},Arh=(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(Orh(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},mrh=(e,t,r)=>{if(!e.body)return e;let i=RID(r??e.body);return new Request(e,{duplex:"half",body:Orh(e.body,i,t)})};var wna=e=>e!==null&&typeof e=="object";var OHa=(...e)=>{for(let t of e)if((!wna(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return J4c({},...e)},x4c=(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 Hsu(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:J4c(e[r]??[],t[r]??[])}var K4c=(e={},t={})=>({beforeRequest:Hsu(e,t,"beforeRequest"),beforeRetry:Hsu(e,t,"beforeRetry"),afterResponse:Hsu(e,t,"afterResponse"),beforeError:Hsu(e,t,"beforeError")}),J4c=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(wna(n)){for(let[a,o]of Object.entries(n))wna(o)&&a in t&&(o=J4c(t[a],o)),t={...t,[a]:o};wna(n.hooks)&&(i=K4c(i,n.hooks),t.hooks=i),wna(n.headers)&&(r=x4c(r,n.headers),t.headers=r)}return t};var jrh=e=>Vsu.includes(e)?e.toUpperCase():e,zID=["get","put","head","delete","options","trace"],NID=[408,413,429,500,502,503,504],FID=[413,429,503],Prh={limit:2,methods:zID,statusCodes:NID,afterStatusCodes:FID,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},wrh=(e={})=>{if(typeof e=="number")return{...Prh,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{...Prh,...e}};async function $4c(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new jna(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function Y4c(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 Erh=(e,t)=>{let r={};for(let i in t)!(i in grh)&&!(i in vrh)&&!(i in e)&&(r[i]=t[i]);return r},Srh=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 AHa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>Wsu)throw new RangeError(`The \`timeout\` option cannot be greater than ${Wsu}`);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 gHa(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(!_rh)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return Arh(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(yrh))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:x4c(this._input.headers,r.headers),hooks:K4c({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:jrh(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:wrh(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(drh&&prh){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(H4c&&(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),Srh(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);(hrh&&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(!H4c)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=mrh(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof jna)throw t;if(t instanceof gHa){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),Wsu);if(this._retryCount<1)throw r;await Y4c(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})===Gsu)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=Erh(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):$4c(this._originalRequest,t,this.abortController,this._options)}};var X4c=e=>{let t=(r,i)=>AHa.create(r,OHa(e,i));for(let r of Vsu)t[r]=(i,n)=>AHa.create(i,OHa(e,n,{method:r}));return t.create=r=>X4c(OHa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),X4c(OHa(e,r))),t.stop=Gsu,t},QID=X4c(),Mrh=QID;var Xrh=ce(Yrh(),1);function rLc(e){let t=(0,Xrh.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Hih=ce(Gih(),1),xih=ce(Sbe(),1),hLc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},yLc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function bLc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??rLc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Hih.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 Mrh(o,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new hLc(e):l}if(t.allVersions)return s;let u=new yLc(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=xih.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 SHa(e,t){let{version:r}=await bLc(e.toLowerCase(),t);return r}async function QKi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:SHa(e.packageName,{version:t?"prerelease":"latest"})}var Kih=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],icu=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=yc.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new Usu(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.30.2"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${It.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new YS}failWithoutThrowing(t,r){this.didSucceed=!1,Nsu({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await gkn()).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 crh({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1393
1393
|
`)||(r+=`
|
|
1394
1394
|
`),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=M2s(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 pHa(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 YS}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await gkn()).sendEvent(t)}logger=zHt((t,...r)=>this.log(t,...r));stderr=zHt((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=Jih(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?Jih(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=Kih[this.numTasks++%Kih.length],o=It.hex(a)(n);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===jw.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=>hGi.indexOf(n.level)>=hGi.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===yc.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 QKi({cliEnvironment:this.environment,includePreReleases:t}),i=U$(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await Lsu({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await C4c({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:It.yellow("?"),style:{answer:n=>It.cyan(n),message:n=>It.bold(n),highlight:n=>It.cyan(n)}}})}catch(i){throw i?.name==="ExitPromptError"?(this.logger.info(`
|
|
1395
1395
|
Cancelled by user.`),new YS):i}}async getInput(t){return await M4c({message:t.message,default:t.default})}};function Jih(e){return`[${e}]:`}var L3t=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 ncu(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)=>ncu.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 $ih(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 Yih(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 Xih=Function.bind,Zih=Xih.bind(Xih);function kih(e,t,r){let i=Zih(Yih,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]=Zih($ih,null).apply(null,a)})}function HCD(){let e=Symbol("Singular"),t={registry:{}},r=ncu.bind(null,t,e);return kih(r,t,e),r}function xCD(){let e={registry:{}},t=ncu.bind(null,e);return kih(t,e),t}var enh={Singular:HCD,Collection:xCD};var KCD="0.0.0-development",JCD=`octokit-endpoint.js/${KCD} ${AN()}`,$CD={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":JCD},mediaType:{format:""}};function YCD(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function XCD(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 inh(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(i=>{XCD(t[i])?i in e?r[i]=inh(e[i],t[i]):Object.assign(r,{[i]:t[i]}):Object.assign(r,{[i]:t[i]})}),r}function tnh(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function gLc(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=YCD(r.headers),tnh(r),tnh(r.headers);let i=inh(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 ZCD(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 kCD=/\{[^{}}]+\}/g;function eqD(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function tqD(e){let t=e.match(kCD);return t?t.map(eqD).reduce((r,i)=>r.concat(i),[]):[]}function rnh(e,t){let r={__proto__:null};for(let i of Object.keys(e))t.indexOf(i)===-1&&(r[i]=e[i]);return r}function nnh(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 qna(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function MHa(e,t,r){return t=e==="+"||e==="#"?nnh(t):qna(t),r?qna(r)+"="+t:t}function Cna(e){return e!=null}function vLc(e){return e===";"||e==="&"||e==="?"}function rqD(e,t,r,i){var n=e[r],a=[];if(Cna(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(MHa(t,n,vLc(t)?r:""));else if(i==="*")Array.isArray(n)?n.filter(Cna).forEach(function(o){a.push(MHa(t,o,vLc(t)?r:""))}):Object.keys(n).forEach(function(o){Cna(n[o])&&a.push(MHa(t,n[o],o))});else{let o=[];Array.isArray(n)?n.filter(Cna).forEach(function(c){o.push(MHa(t,c))}):Object.keys(n).forEach(function(c){Cna(n[c])&&(o.push(qna(c)),o.push(MHa(t,n[c].toString())))}),vLc(t)?a.push(qna(r)+"="+o.join(",")):o.length!==0&&a.push(o.join(","))}else t===";"?Cna(n)&&a.push(qna(r)):n===""&&(t==="&"||t==="?")?a.push(qna(r)+"="):n===""&&a.push("");return a}function iqD(e){return{expand:nqD.bind(null,e)}}function nqD(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(rqD(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 nnh(a)}),e==="/"?e:e.replace(/\/$/,"")}function anh(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),i=Object.assign({},e.headers),n,a=rnh(e,["method","baseUrl","url","headers","request","mediaType"]),o=tqD(r);r=iqD(r).expand(a),/^http/.test(r)||(r=e.baseUrl+r);let c=Object.keys(e).filter(u=>o.includes(u)).concat("baseUrl"),d=rnh(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=ZCD(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 aqD(e,t,r){return anh(gLc(e,t,r))}function onh(e,t){let r=gLc(e,t),i=aqD.bind(null,r);return Object.assign(i,{DEFAULTS:r,defaults:onh.bind(null,r),merge:gLc.bind(null,r),parse:anh})}var unh=onh(null,$CD);var pnh=ce(fnh(),1);var V3t=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 oqD="10.0.6",uqD={headers:{"user-agent":`octokit-request.js/${oqD} ${AN()}`}};function sqD(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 dnh(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=sqD(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 V3t(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 V3t(o.statusText,c,{response:u,request:e})}if(c===304)throw u.data=await OLc(o),new V3t("Not modified",c,{response:u,request:e});if(c>=400)throw u.data=await OLc(o),new V3t(lqD(u.data),c,{response:u,request:e});return u.data=i?await OLc(o):o.body,u}async function OLc(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(()=>"");let r=(0,pnh.safeParse)(t);if(cqD(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 cqD(e){return e.type==="application/json"||e.type==="application/scim+json"}function lqD(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 ALc(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 dnh(r.parse(o));let c=(d,s)=>dnh(r.parse(r.merge(d,s)));return Object.assign(c,{endpoint:r,defaults:ALc.bind(null,r)}),o.request.hook(c,o)},{endpoint:r,defaults:ALc.bind(null,r)})}var MA=ALc(unh,uqD);var fqD="0.0.0-development";function dqD(e){return`Request failed due to following response errors:
|
|
@@ -1406,7 +1406,7 @@ Cancelled by user.`),new YS):i}}async getInput(t){return await M4c({message:t.me
|
|
|
1406
1406
|
})
|
|
1407
1407
|
`);let s={},u=new i.Events(s);return s.on("secondary-limit",d.onSecondaryRateLimit),s.on("rate-limit",d.onRateLimit),s.on("error",l=>e.log.warn("Error in throttling-plugin limit handler",l)),d.retryLimiter.on("failed",async function(l,p){let[_,h,y]=p.args,{pathname:b}=new URL(y.url,"http://github.test");if(!(b.startsWith("/graphql")&&l.status!==401||l.status===403||l.status===429))return;let O=~~h.retryCount;h.retryCount=O,y.request.retryCount=O;let{wantRetry:A,retryAfter:g=0}=await(async function(){if(/\bsecondary rate\b/i.test(l.message)){let m=Number(l.response.headers["retry-after"])||_.fallbackSecondaryRateRetryAfter;return{wantRetry:await u.trigger("secondary-limit",m,y,e,O),retryAfter:m}}if(l.response.headers!=null&&l.response.headers["x-ratelimit-remaining"]==="0"||(l.response.data?.errors??[]).some(m=>m.type==="RATE_LIMITED")){let m=new Date(~~l.response.headers["x-ratelimit-reset"]*1e3).getTime(),j=Math.max(Math.ceil((m-Date.now())/1e3)+1,0);return{wantRetry:await u.trigger("rate-limit",j,y,e,O),retryAfter:j}}return{}})();if(A)return h.retryCount++,g*_.retryAfterBaseValue}),e.hook.wrap("request",WqD.bind(null,d)),{}}ccu.VERSION=VqD;ccu.triggersNotification=qnh;function Tnh(e){let t=e.clientType||"oauth-app",r=e.baseUrl||"https://github.com",i={clientType:t,allowSignup:e.allowSignup!==!1,clientId:e.clientId,login:e.login||null,redirectUrl:e.redirectUrl||null,state:e.state||Math.random().toString(36).substr(2),url:""};if(t==="oauth-app"){let n="scopes"in e?e.scopes:[];i.scopes=typeof n=="string"?n.split(/[,\s]+/).filter(Boolean):n}return i.url=$qD(`${r}/login/oauth/authorize`,i),i}function $qD(e,t){let r={allowSignup:"allow_signup",clientId:"client_id",login:"login",redirectUrl:"redirect_uri",scopes:"scope",state:"state"},i=e;return Object.keys(r).filter(n=>t[n]!==null).filter(n=>n!=="scopes"?!0:t.clientType==="github-app"?!1:!Array.isArray(t[n])||t[n].length>0).map(n=>[r[n],`${t[n]}`]).forEach(([n,a],o)=>{i+=o===0?"?":"&",i+=`${n}=${encodeURIComponent(a)}`}),i}function Fnh(e){let t=e.endpoint.DEFAULTS;return/^https:\/\/(api\.)?github\.com$/.test(t.baseUrl)?"https://github.com":t.baseUrl.replace("/api/v3","")}async function lcu(e,t,r){let i={baseUrl:Fnh(e),headers:{accept:"application/json"},...r},n=await e(t,i);if("error"in n.data){let a=new V3t(`${n.data.error_description} (${n.data.error}, ${n.data.error_uri})`,400,{request:e.endpoint.merge(t,i)});throw a.response=n,a}return n}function Qnh({request:e=MA,...t}){let r=Fnh(e);return Tnh({...t,baseUrl:r})}async function Unh(e){let t=e.request||MA,r=await lcu(t,"POST /login/oauth/access_token",{client_id:e.clientId,client_secret:e.clientSecret,code:e.code,redirect_uri:e.redirectUrl}),i={clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.data.access_token,scopes:r.data.scope.split(/\s+/).filter(Boolean)};if(e.clientType==="github-app"){if("refresh_token"in r.data){let n=new Date(r.headers.date).getTime();i.refreshToken=r.data.refresh_token,i.expiresAt=Rnh(n,r.data.expires_in),i.refreshTokenExpiresAt=Rnh(n,r.data.refresh_token_expires_in)}delete i.scopes}return{...r,authentication:i}}function Rnh(e,t){return new Date(e+t*1e3).toISOString()}async function Lnh(e){let t=e.request||MA,r={client_id:e.clientId};return"scopes"in e&&Array.isArray(e.scopes)&&(r.scope=e.scopes.join(" ")),lcu(t,"POST /login/device/code",r)}async function qLc(e){let t=e.request||MA,r=await lcu(t,"POST /login/oauth/access_token",{client_id:e.clientId,device_code:e.code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),i={clientType:e.clientType,clientId:e.clientId,token:r.data.access_token,scopes:r.data.scope.split(/\s+/).filter(Boolean)};if("clientSecret"in e&&(i.clientSecret=e.clientSecret),e.clientType==="github-app"){if("refresh_token"in r.data){let n=new Date(r.headers.date).getTime();i.refreshToken=r.data.refresh_token,i.expiresAt=znh(n,r.data.expires_in),i.refreshTokenExpiresAt=znh(n,r.data.refresh_token_expires_in)}delete i.scopes}return{...r,authentication:i}}function znh(e,t){return new Date(e+t*1e3).toISOString()}async function fcu(e){let r=await(e.request||MA)("POST /applications/{client_id}/token",{headers:{authorization:`basic ${btoa(`${e.clientId}:${e.clientSecret}`)}`},client_id:e.clientId,access_token:e.token}),i={clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:e.token,scopes:r.data.scopes};return r.data.expires_at&&(i.expiresAt=r.data.expires_at),e.clientType==="github-app"&&delete i.scopes,{...r,authentication:i}}async function dcu(e){let t=e.request||MA,r=await lcu(t,"POST /login/oauth/access_token",{client_id:e.clientId,client_secret:e.clientSecret,grant_type:"refresh_token",refresh_token:e.refreshToken}),i=new Date(r.headers.date).getTime(),n={clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,token:r.data.access_token,refreshToken:r.data.refresh_token,expiresAt:Nnh(i,r.data.expires_in),refreshTokenExpiresAt:Nnh(i,r.data.refresh_token_expires_in)};return{...r,authentication:n}}function Nnh(e,t){return new Date(e+t*1e3).toISOString()}async function Vnh(e){let{request:t,clientType:r,clientId:i,clientSecret:n,token:a,...o}=e,d=await(e.request||MA)("POST /applications/{client_id}/token/scoped",{headers:{authorization:`basic ${btoa(`${i}:${n}`)}`},client_id:i,access_token:a,...o}),s=Object.assign({clientType:r,clientId:i,clientSecret:n,token:d.data.token},d.data.expires_at?{expiresAt:d.data.expires_at}:{});return{...d,authentication:s}}async function IHa(e){let t=e.request||MA,r=btoa(`${e.clientId}:${e.clientSecret}`),i=await t("PATCH /applications/{client_id}/token",{headers:{authorization:`basic ${r}`},client_id:e.clientId,access_token:e.token}),n={clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:i.data.token,scopes:i.data.scopes};return i.data.expires_at&&(n.expiresAt=i.data.expires_at),e.clientType==="github-app"&&delete n.scopes,{...i,authentication:n}}async function CHa(e){let t=e.request||MA,r=btoa(`${e.clientId}:${e.clientSecret}`);return t("DELETE /applications/{client_id}/token",{headers:{authorization:`basic ${r}`},client_id:e.clientId,access_token:e.token})}async function qHa(e){let t=e.request||MA,r=btoa(`${e.clientId}:${e.clientSecret}`);return t("DELETE /applications/{client_id}/grant",{headers:{authorization:`basic ${r}`},client_id:e.clientId,access_token:e.token})}async function Gnh(e,t){let r=YqD(e,t.auth);if(r)return r;let{data:i}=await Lnh({clientType:e.clientType,clientId:e.clientId,request:t.request||e.request,scopes:t.auth.scopes||e.scopes});await e.onVerification(i);let n=await TLc(t.request||e.request,e.clientId,e.clientType,i);return e.authentication=n,n}function YqD(e,t){if(t.refresh===!0||!e.authentication)return!1;if(e.clientType==="github-app")return e.authentication;let r=e.authentication,i=("scopes"in t&&t.scopes||e.scopes).join(" "),n=r.scopes.join(" ");return i===n?r:!1}async function Wnh(e){await new Promise(t=>setTimeout(t,e*1e3))}async function TLc(e,t,r,i){try{let n={clientId:t,request:e,code:i.device_code},{authentication:a}=r==="oauth-app"?await qLc({...n,clientType:"oauth-app"}):await qLc({...n,clientType:"github-app"});return{type:"token",tokenType:"oauth",...a}}catch(n){if(!n.response)throw n;let a=n.response.data.error;if(a==="authorization_pending")return await Wnh(i.interval),TLc(e,t,r,i);if(a==="slow_down")return await Wnh(i.interval+7),TLc(e,t,r,i);throw n}}async function XqD(e,t){return Gnh(e,{auth:t})}async function ZqD(e,t,r,i){let n=t.endpoint.merge(r,i);if(/\/login\/(oauth\/access_token|device\/code)$/.test(n.url))return t(n);let{token:a}=await Gnh(e,{request:t,auth:{type:"oauth"}});return n.headers.authorization=`token ${a}`,t(n)}var kqD="0.0.0-development";function Hnh(e){let t=e.request||MA.defaults({headers:{"user-agent":`octokit-auth-oauth-device.js/${kqD} ${AN()}`}}),{request:r=t,...i}=e,n=e.clientType==="github-app"?{...i,clientType:"github-app",request:r}:{...i,clientType:"oauth-app",request:r,scopes:e.scopes||[]};if(!e.clientId)throw new Error('[@octokit/auth-oauth-device] "clientId" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)');if(!e.onVerification)throw new Error('[@octokit/auth-oauth-device] "onVerification" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)');return Object.assign(XqD.bind(null,n),{hook:ZqD.bind(null,n)})}var Knh="0.0.0-development";async function xnh(e){if("code"in e.strategyOptions){let{authentication:t}=await Unh({clientId:e.clientId,clientSecret:e.clientSecret,clientType:e.clientType,onTokenCreated:e.onTokenCreated,...e.strategyOptions,request:e.request});return{type:"token",tokenType:"oauth",...t}}if("onVerification"in e.strategyOptions){let r=await Hnh({clientType:e.clientType,clientId:e.clientId,onTokenCreated:e.onTokenCreated,...e.strategyOptions,request:e.request})({type:"oauth"});return{clientSecret:e.clientSecret,...r}}if("token"in e.strategyOptions)return{type:"token",tokenType:"oauth",clientId:e.clientId,clientSecret:e.clientSecret,clientType:e.clientType,onTokenCreated:e.onTokenCreated,...e.strategyOptions};throw new Error("[@octokit/auth-oauth-user] Invalid strategy options")}async function RLc(e,t={}){if(e.authentication||(e.authentication=e.clientType==="oauth-app"?await xnh(e):await xnh(e)),e.authentication.invalid)throw new Error("[@octokit/auth-oauth-user] Token is invalid");let r=e.authentication;if("expiresAt"in r&&(t.type==="refresh"||new Date(r.expiresAt)<new Date)){let{authentication:i}=await dcu({clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,refreshToken:r.refreshToken,request:e.request});e.authentication={tokenType:"oauth",type:"token",...i}}if(t.type==="refresh"){if(e.clientType==="oauth-app")throw new Error("[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens");if(!r.hasOwnProperty("expiresAt"))throw new Error("[@octokit/auth-oauth-user] Refresh token missing");await e.onTokenCreated?.(e.authentication,{type:t.type})}if(t.type==="check"||t.type==="reset"){let i=t.type==="check"?fcu:IHa;try{let{authentication:n}=await i({clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:e.authentication.token,request:e.request});return e.authentication={tokenType:"oauth",type:"token",...n},t.type==="reset"&&await e.onTokenCreated?.(e.authentication,{type:t.type}),e.authentication}catch(n){throw n.status===404&&(n.message="[@octokit/auth-oauth-user] Token is invalid",e.authentication.invalid=!0),n}}if(t.type==="delete"||t.type==="deleteAuthorization"){let i=t.type==="delete"?CHa:qHa;try{await i({clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:e.authentication.token,request:e.request})}catch(n){if(n.status!==404)throw n}return e.authentication.invalid=!0,e.authentication}return e.authentication}var e1D=/\/applications\/[^/]+\/(token|grant)s?/;function THa(e){return e&&e1D.test(e)}async function t1D(e,t,r,i={}){let n=t.endpoint.merge(r,i);if(/\/login\/(oauth\/access_token|device\/code)$/.test(n.url))return t(n);if(THa(n.url)){let o=btoa(`${e.clientId}:${e.clientSecret}`);return n.headers.authorization=`basic ${o}`,t(n)}let{token:a}=e.clientType==="oauth-app"?await RLc({...e,request:t}):await RLc({...e,request:t});return n.headers.authorization="token "+a,t(n)}function sW({clientId:e,clientSecret:t,clientType:r="oauth-app",request:i=MA.defaults({headers:{"user-agent":`octokit-auth-oauth-app.js/${Knh} ${AN()}`}}),onTokenCreated:n,...a}){let o=Object.assign({clientType:r,clientId:e,clientSecret:t,onTokenCreated:n,strategyOptions:a,request:i});return Object.assign(RLc.bind(null,o),{hook:t1D.bind(null,o)})}sW.VERSION=Knh;async function r1D(e,t){if(t.type==="oauth-app")return{type:"oauth-app",clientId:e.clientId,clientSecret:e.clientSecret,clientType:e.clientType,headers:{authorization:`basic ${btoa(`${e.clientId}:${e.clientSecret}`)}`}};if("factory"in t){let{type:n,...a}={...t,...e};return t.factory(a)}let r={clientId:e.clientId,clientSecret:e.clientSecret,request:e.request,...t};return(e.clientType==="oauth-app"?await sW({...r,clientType:e.clientType}):await sW({...r,clientType:e.clientType}))()}async function i1D(e,t,r,i){let n=t.endpoint.merge(r,i);if(/\/login\/(oauth\/access_token|device\/code)$/.test(n.url))return t(n);if(e.clientType==="github-app"&&!THa(n.url))throw new Error(`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${n.method} ${n.url}" is not supported.`);let a=btoa(`${e.clientId}:${e.clientSecret}`);n.headers.authorization=`basic ${a}`;try{return await t(n)}catch(o){throw o.status!==401||(o.message=`[@octokit/auth-oauth-app] "${n.method} ${n.url}" does not support clientId/clientSecret basic authentication.`),o}}var n1D="0.0.0-development";function pcu(e){let t=Object.assign({request:MA.defaults({headers:{"user-agent":`octokit-auth-oauth-app.js/${n1D} ${AN()}`}}),clientType:"oauth-app"},e);return Object.assign(r1D.bind(null,t),{hook:i1D.bind(null,t)})}async function hcu({appId:e,privateKey:t,timeDifference:r,createJwt:i}){try{if(i){let{jwt:o,expiresAt:c}=await i(e,r);return{type:"app",token:o,appId:e,expiresAt:c}}let n={id:e,privateKey:t};r&&Object.assign(n,{now:Math.floor(Date.now()/1e3)+r});let a=await Shc(n);return{type:"app",token:a.token,appId:a.appId,expiresAt:new Date(a.expiration*1e3).toISOString()}}catch(n){throw t==="-----BEGIN RSA PRIVATE KEY-----"?new Error("The 'privateKey` option contains only the first line '-----BEGIN RSA PRIVATE KEY-----'. If you are setting it using a `.env` file, make sure it is set on a single line with newlines replaced by '\n'"):n}}function o1D(){return new VVo(15e3,1e3*60*59)}async function u1D(e,t){let r=zLc(t),i=await e.get(r);if(!i)return;let[n,a,o,c,d,s]=i.split("|"),u=t.permissions||d.split(/,/).reduce((l,p)=>(/!$/.test(p)?l[p.slice(0,-1)]="write":l[p]="read",l),{});return{token:n,createdAt:a,expiresAt:o,permissions:u,repositoryIds:t.repositoryIds,repositoryNames:t.repositoryNames,singleFileName:s,repositorySelection:c}}async function s1D(e,t,r){let i=zLc(t),n=t.permissions?"":Object.keys(r.permissions).map(o=>`${o}${r.permissions[o]==="write"?"!":""}`).join(","),a=[r.token,r.createdAt,r.expiresAt,r.repositorySelection,n,r.singleFileName].join("|");await e.set(i,a)}function zLc({installationId:e,permissions:t={},repositoryIds:r=[],repositoryNames:i=[]}){let n=Object.keys(t).sort().map(c=>t[c]==="read"?c:`${c}!`).join(","),a=r.sort().join(","),o=i.join(",");return[e,a,o,n].filter(Boolean).join("|")}function Jnh({installationId:e,token:t,createdAt:r,expiresAt:i,repositorySelection:n,permissions:a,repositoryIds:o,repositoryNames:c,singleFileName:d}){return Object.assign({type:"token",tokenType:"installation",token:t,installationId:e,permissions:a,createdAt:r,expiresAt:i,repositorySelection:n},o?{repositoryIds:o}:null,c?{repositoryNames:c}:null,d?{singleFileName:d}:null)}async function $nh(e,t,r){let i=Number(t.installationId||e.installationId);if(!i)throw new Error("[@octokit/auth-app] installationId option is required for installation authentication.");if(t.factory){let{type:a,factory:o,oauthApp:c,...d}={...e,...t};return o(d)}let n=r||e.request;return c1D(e,{...t,installationId:i},n)}var _cu=new Map;function c1D(e,t,r){let i=zLc(t);if(_cu.has(i))return _cu.get(i);let n=l1D(e,t,r).finally(()=>_cu.delete(i));return _cu.set(i,n),n}async function l1D(e,t,r){if(!t.refresh){let O=await u1D(e.cache,t);if(O){let{token:A,createdAt:g,expiresAt:m,permissions:j,repositoryIds:S,repositoryNames:w,singleFileName:D,repositorySelection:B}=O;return Jnh({installationId:t.installationId,token:A,createdAt:g,expiresAt:m,permissions:j,repositorySelection:B,repositoryIds:S,repositoryNames:w,singleFileName:D})}}let i=await hcu(e),n={installation_id:t.installationId,mediaType:{previews:["machine-man"]},headers:{authorization:`bearer ${i.token}`}};t.repositoryIds&&Object.assign(n,{repository_ids:t.repositoryIds}),t.repositoryNames&&Object.assign(n,{repositories:t.repositoryNames}),t.permissions&&Object.assign(n,{permissions:t.permissions});let{data:{token:a,expires_at:o,repositories:c,permissions:d,repository_selection:s,single_file:u}}=await r("POST /app/installations/{installation_id}/access_tokens",n),l=d||{},p=s||"all",_=c?c.map(O=>O.id):void 0,h=c?c.map(O=>O.name):void 0,y=new Date().toISOString(),b={token:a,createdAt:y,expiresAt:o,repositorySelection:p,permissions:l,repositoryIds:_,repositoryNames:h};u&&Object.assign(n,{singleFileName:u}),await s1D(e.cache,t,b);let v={installationId:t.installationId,token:a,createdAt:y,expiresAt:o,repositorySelection:p,permissions:l,repositoryIds:_,repositoryNames:h};return u&&Object.assign(v,{singleFileName:u}),Jnh(v)}async function f1D(e,t){switch(t.type){case"app":return hcu(e);case"oauth-app":return e.oauthApp({type:"oauth-app"});case"installation":return $nh(e,{...t,type:"installation"});case"oauth-user":return e.oauthApp(t);default:throw new Error(`Invalid auth type: ${t.type}`)}}var d1D=["/app","/app/hook/config","/app/hook/deliveries","/app/hook/deliveries/{delivery_id}","/app/hook/deliveries/{delivery_id}/attempts","/app/installations","/app/installations/{installation_id}","/app/installations/{installation_id}/access_tokens","/app/installations/{installation_id}/suspended","/app/installation-requests","/marketplace_listing/accounts/{account_id}","/marketplace_listing/plan","/marketplace_listing/plans","/marketplace_listing/plans/{plan_id}/accounts","/marketplace_listing/stubbed/accounts/{account_id}","/marketplace_listing/stubbed/plan","/marketplace_listing/stubbed/plans","/marketplace_listing/stubbed/plans/{plan_id}/accounts","/orgs/{org}/installation","/repos/{owner}/{repo}/installation","/users/{username}/installation"];function p1D(e){let r=`^(?:${e.map(i=>i.split("/").map(n=>n.startsWith("{")?"(?:.+?)":n).join("/")).map(i=>`(?:${i})`).join("|")})$`;return new RegExp(r,"i")}var _1D=p1D(d1D);function h1D(e){return!!e&&_1D.test(e.split("?")[0])}var y1D=5*1e3;function b1D(e){return!(e.message.match(/'Expiration time' claim \('exp'\) must be a numeric value representing the future time at which the assertion expires/)||e.message.match(/'Issued at' claim \('iat'\) must be an Integer representing the time that the assertion was issued/))}async function v1D(e,t,r,i){let n=t.endpoint.merge(r,i),a=n.url;if(/\/login\/oauth\/access_token$/.test(a))return t(n);if(h1D(a.replace(t.endpoint.DEFAULTS.baseUrl,""))){let{token:d}=await hcu(e);n.headers.authorization=`bearer ${d}`;let s;try{s=await t(n)}catch(u){if(b1D(u)||typeof u.response.headers.date>"u")throw u;let l=Math.floor((Date.parse(u.response.headers.date)-Date.parse(new Date().toString()))/1e3);e.log.warn(u.message),e.log.warn(`[@octokit/auth-app] GitHub API time and system time are different by ${l} seconds. Retrying request with the difference accounted for.`);let{token:p}=await hcu({...e,timeDifference:l});return n.headers.authorization=`bearer ${p}`,t(n)}return s}if(THa(a)){let d=await e.oauthApp({type:"oauth-app"});return n.headers.authorization=d.headers.authorization,t(n)}let{token:o,createdAt:c}=await $nh(e,{},t.defaults({baseUrl:n.baseUrl}));return n.headers.authorization=`token ${o}`,Ynh(e,t,n,c)}async function Ynh(e,t,r,i,n=0){let a=+new Date-+new Date(i);try{return await t(r)}catch(o){if(o.status!==401)throw o;if(a>=y1D)throw n>0&&(o.message=`After ${n} retries within ${a/1e3}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`),o;++n;let c=n*1e3;return e.log.warn(`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${n}, wait: ${c/1e3}s)`),await new Promise(d=>setTimeout(d,c)),Ynh(e,t,r,i,n)}}var g1D="8.1.2";function Tna(e){if(!e.appId)throw new Error("[@octokit/auth-app] appId option is required");if(!e.privateKey&&!e.createJwt)throw new Error("[@octokit/auth-app] privateKey option is required");if(e.privateKey&&e.createJwt)throw new Error("[@octokit/auth-app] privateKey and createJwt options are mutually exclusive");if("installationId"in e&&!e.installationId)throw new Error("[@octokit/auth-app] installationId is set to a falsy value");let t=e.log||{};typeof t.warn!="function"&&(t.warn=console.warn.bind(console));let r=e.request||MA.defaults({headers:{"user-agent":`octokit-auth-app.js/${g1D} ${AN()}`}}),i=Object.assign({request:r,cache:o1D()},e,e.installationId?{installationId:Number(e.installationId)}:{},{log:t,oauthApp:pcu({clientType:"github-app",clientId:e.clientId||"",clientSecret:e.clientSecret||"",request:r})});return Object.assign(f1D.bind(null,i),{hook:v1D.bind(null,i)})}async function O1D(e){return{type:"unauthenticated",reason:e}}function A1D(e){return e.status!==403||!e.response?!1:e.response.headers["x-ratelimit-remaining"]==="0"}var m1D=/\babuse\b/i;function P1D(e){return e.status!==403?!1:m1D.test(e.message)}async function j1D(e,t,r,i){let n=t.endpoint.merge(r,i);return t(n).catch(a=>{throw a.status===404?(a.message=`Not found. May be due to lack of authentication. Reason: ${e}`,a):A1D(a)?(a.message=`API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${e}`,a):P1D(a)?(a.message=`You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${e}`,a):a.status===401?(a.message=`Unauthorized. "${n.method} ${n.url}" failed most likely due to lack of authentication. Reason: ${e}`,a):(a.status>=400&&a.status<500&&(a.message=a.message.replace(/\.?$/,`. May be caused by lack of authentication (${e}).`)),a)})}var ubn=function(t){if(!t||!t.reason)throw new Error("[@octokit/auth-unauthenticated] No reason passed to createUnauthenticatedAuth");return Object.assign(O1D.bind(null,t.reason),{hook:j1D.bind(null,t.reason)})};var Xnh="8.0.3";function Znh(e,t,r){if(Array.isArray(t)){for(let i of t)Znh(e,i,r);return}e.eventHandlers[t]||(e.eventHandlers[t]=[]),e.eventHandlers[t].push(r)}var w1D=UKi.defaults({userAgent:`octokit-oauth-app.js/${Xnh} ${AN()}`});async function BQi(e,t){let{name:r,action:i}=t;if(e.eventHandlers[`${r}.${i}`])for(let n of e.eventHandlers[`${r}.${i}`])await n(t);if(e.eventHandlers[r])for(let n of e.eventHandlers[r])await n(t)}async function E1D(e,t){return e.octokit.auth({type:"oauth-user",...t,async factory(r){let i=new e.Octokit({authStrategy:sW,auth:r}),n=await i.auth({type:"get"});return await BQi(e,{name:"token",action:"created",token:n.token,scopes:n.scopes,authentication:n,octokit:i}),i}})}function S1D(e,t){let r={clientId:e.clientId,request:e.octokit.request,...t,allowSignup:e.allowSignup??t.allowSignup,redirectUrl:t.redirectUrl??e.redirectUrl,scopes:t.scopes??e.defaultScopes};return Qnh({clientType:e.clientType,...r})}async function M1D(e,t){let r=await e.octokit.auth({type:"oauth-user",...t});return await BQi(e,{name:"token",action:"created",token:r.token,scopes:r.scopes,authentication:r,octokit:new e.Octokit({authStrategy:sW,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.token,scopes:r.scopes,refreshToken:r.refreshToken,expiresAt:r.expiresAt,refreshTokenExpiresAt:r.refreshTokenExpiresAt}})}),{authentication:r}}async function D1D(e,t){let r=await fcu({clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t});return Object.assign(r.authentication,{type:"token",tokenType:"oauth"}),r}async function B1D(e,t){let r={clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t};if(e.clientType==="oauth-app"){let a=await IHa({clientType:"oauth-app",...r}),o=Object.assign(a.authentication,{type:"token",tokenType:"oauth"});return await BQi(e,{name:"token",action:"reset",token:a.authentication.token,scopes:a.authentication.scopes||void 0,authentication:o,octokit:new e.Octokit({authStrategy:sW,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:a.authentication.token,scopes:a.authentication.scopes}})}),{...a,authentication:o}}let i=await IHa({clientType:"github-app",...r}),n=Object.assign(i.authentication,{type:"token",tokenType:"oauth"});return await BQi(e,{name:"token",action:"reset",token:i.authentication.token,authentication:n,octokit:new e.Octokit({authStrategy:sW,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:i.authentication.token}})}),{...i,authentication:n}}async function I1D(e,t){if(e.clientType==="oauth-app")throw new Error("[@octokit/oauth-app] app.refreshToken() is not supported for OAuth Apps");let r=await dcu({clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,refreshToken:t.refreshToken}),i=Object.assign(r.authentication,{type:"token",tokenType:"oauth"});return await BQi(e,{name:"token",action:"refreshed",token:r.authentication.token,authentication:i,octokit:new e.Octokit({authStrategy:sW,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.authentication.token}})}),{...r,authentication:i}}async function C1D(e,t){if(e.clientType==="oauth-app")throw new Error("[@octokit/oauth-app] app.scopeToken() is not supported for OAuth Apps");let r=await Vnh({clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t}),i=Object.assign(r.authentication,{type:"token",tokenType:"oauth"});return await BQi(e,{name:"token",action:"scoped",token:r.authentication.token,authentication:i,octokit:new e.Octokit({authStrategy:sW,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.authentication.token}})}),{...r,authentication:i}}async function q1D(e,t){let r={clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t},i=e.clientType==="oauth-app"?await CHa({clientType:"oauth-app",...r}):await CHa({clientType:"github-app",...r});return await BQi(e,{name:"token",action:"deleted",token:t.token,octokit:new e.Octokit({authStrategy:ubn,auth:{reason:'Handling "token.deleted" event. The access for the token has been revoked.'}})}),i}async function T1D(e,t){let r={clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t},i=e.clientType==="oauth-app"?await qHa({clientType:"oauth-app",...r}):await qHa({clientType:"github-app",...r});return await BQi(e,{name:"token",action:"deleted",token:t.token,octokit:new e.Octokit({authStrategy:ubn,auth:{reason:'Handling "token.deleted" event. The access for the token has been revoked.'}})}),await BQi(e,{name:"authorization",action:"deleted",token:t.token,octokit:new e.Octokit({authStrategy:ubn,auth:{reason:'Handling "authorization.deleted" event. The access for the app has been revoked.'}})}),i}var ycu=class{static VERSION=Xnh;static defaults(e){return class extends this{constructor(...r){super({...e,...r[0]})}}}constructor(e){let t=e.Octokit||w1D;this.type=e.clientType||"oauth-app";let r=new t({authStrategy:pcu,auth:{clientType:this.type,clientId:e.clientId,clientSecret:e.clientSecret}}),i={clientType:this.type,clientId:e.clientId,clientSecret:e.clientSecret,defaultScopes:e.defaultScopes||[],allowSignup:e.allowSignup,baseUrl:e.baseUrl,redirectUrl:e.redirectUrl,log:e.log,Octokit:t,octokit:r,eventHandlers:{}};this.on=Znh.bind(null,i),this.octokit=r,this.getUserOctokit=E1D.bind(null,i),this.getWebFlowAuthorizationUrl=S1D.bind(null,i),this.createToken=M1D.bind(null,i),this.checkToken=D1D.bind(null,i),this.resetToken=B1D.bind(null,i),this.refreshToken=I1D.bind(null,i),this.scopeToken=C1D.bind(null,i),this.deleteToken=q1D.bind(null,i),this.deleteAuthorization=T1D.bind(null,i)}type;on;octokit;getUserOctokit;getWebFlowAuthorizationUrl;createToken;checkToken;resetToken;refreshToken;scopeToken;deleteToken;deleteAuthorization};var knh=require("crypto"),tah=require("crypto"),NLc=require("buffer"),eah="6.0.0";async function bcu(e,t){if(!e||!t)throw new TypeError("[@octokit/webhooks-methods] secret & payload required for sign()");if(typeof t!="string")throw new TypeError("[@octokit/webhooks-methods] payload must be a string");let r="sha256";return`${r}=${(0,knh.createHmac)(r,e).update(t).digest("hex")}`}bcu.VERSION=eah;async function RHa(e,t,r){if(!e||!t||!r)throw new TypeError("[@octokit/webhooks-methods] secret, eventPayload & signature required");if(typeof t!="string")throw new TypeError("[@octokit/webhooks-methods] eventPayload must be a string");let i=NLc.Buffer.from(r),n=NLc.Buffer.from(await bcu(e,t));return i.length!==n.length?!1:(0,tah.timingSafeEqual)(i,n)}RHa.VERSION=eah;async function rah(e,t,r,i){if(await RHa(e,t,r))return!0;if(i!==void 0)for(let a of i){let o=await RHa(a,t,r);if(o)return o}return!1}var aah=(e={})=>(typeof e.debug!="function"&&(e.debug=()=>{}),typeof e.info!="function"&&(e.info=()=>{}),typeof e.warn!="function"&&(e.warn=console.warn.bind(console)),typeof e.error!="function"&&(e.error=console.error.bind(console)),e),R1D=["branch_protection_configuration","branch_protection_configuration.disabled","branch_protection_configuration.enabled","branch_protection_rule","branch_protection_rule.created","branch_protection_rule.deleted","branch_protection_rule.edited","check_run","check_run.completed","check_run.created","check_run.requested_action","check_run.rerequested","check_suite","check_suite.completed","check_suite.requested","check_suite.rerequested","code_scanning_alert","code_scanning_alert.appeared_in_branch","code_scanning_alert.closed_by_user","code_scanning_alert.created","code_scanning_alert.fixed","code_scanning_alert.reopened","code_scanning_alert.reopened_by_user","commit_comment","commit_comment.created","create","custom_property","custom_property.created","custom_property.deleted","custom_property.promote_to_enterprise","custom_property.updated","custom_property_values","custom_property_values.updated","delete","dependabot_alert","dependabot_alert.auto_dismissed","dependabot_alert.auto_reopened","dependabot_alert.created","dependabot_alert.dismissed","dependabot_alert.fixed","dependabot_alert.reintroduced","dependabot_alert.reopened","deploy_key","deploy_key.created","deploy_key.deleted","deployment","deployment.created","deployment_protection_rule","deployment_protection_rule.requested","deployment_review","deployment_review.approved","deployment_review.rejected","deployment_review.requested","deployment_status","deployment_status.created","discussion","discussion.answered","discussion.category_changed","discussion.closed","discussion.created","discussion.deleted","discussion.edited","discussion.labeled","discussion.locked","discussion.pinned","discussion.reopened","discussion.transferred","discussion.unanswered","discussion.unlabeled","discussion.unlocked","discussion.unpinned","discussion_comment","discussion_comment.created","discussion_comment.deleted","discussion_comment.edited","fork","github_app_authorization","github_app_authorization.revoked","gollum","installation","installation.created","installation.deleted","installation.new_permissions_accepted","installation.suspend","installation.unsuspend","installation_repositories","installation_repositories.added","installation_repositories.removed","installation_target","installation_target.renamed","issue_comment","issue_comment.created","issue_comment.deleted","issue_comment.edited","issues","issues.assigned","issues.closed","issues.deleted","issues.demilestoned","issues.edited","issues.labeled","issues.locked","issues.milestoned","issues.opened","issues.pinned","issues.reopened","issues.transferred","issues.typed","issues.unassigned","issues.unlabeled","issues.unlocked","issues.unpinned","issues.untyped","label","label.created","label.deleted","label.edited","marketplace_purchase","marketplace_purchase.cancelled","marketplace_purchase.changed","marketplace_purchase.pending_change","marketplace_purchase.pending_change_cancelled","marketplace_purchase.purchased","member","member.added","member.edited","member.removed","membership","membership.added","membership.removed","merge_group","merge_group.checks_requested","merge_group.destroyed","meta","meta.deleted","milestone","milestone.closed","milestone.created","milestone.deleted","milestone.edited","milestone.opened","org_block","org_block.blocked","org_block.unblocked","organization","organization.deleted","organization.member_added","organization.member_invited","organization.member_removed","organization.renamed","package","package.published","package.updated","page_build","personal_access_token_request","personal_access_token_request.approved","personal_access_token_request.cancelled","personal_access_token_request.created","personal_access_token_request.denied","ping","project","project.closed","project.created","project.deleted","project.edited","project.reopened","project_card","project_card.converted","project_card.created","project_card.deleted","project_card.edited","project_card.moved","project_column","project_column.created","project_column.deleted","project_column.edited","project_column.moved","projects_v2","projects_v2.closed","projects_v2.created","projects_v2.deleted","projects_v2.edited","projects_v2.reopened","projects_v2_item","projects_v2_item.archived","projects_v2_item.converted","projects_v2_item.created","projects_v2_item.deleted","projects_v2_item.edited","projects_v2_item.reordered","projects_v2_item.restored","projects_v2_status_update","projects_v2_status_update.created","projects_v2_status_update.deleted","projects_v2_status_update.edited","public","pull_request","pull_request.assigned","pull_request.auto_merge_disabled","pull_request.auto_merge_enabled","pull_request.closed","pull_request.converted_to_draft","pull_request.demilestoned","pull_request.dequeued","pull_request.edited","pull_request.enqueued","pull_request.labeled","pull_request.locked","pull_request.milestoned","pull_request.opened","pull_request.ready_for_review","pull_request.reopened","pull_request.review_request_removed","pull_request.review_requested","pull_request.synchronize","pull_request.unassigned","pull_request.unlabeled","pull_request.unlocked","pull_request_review","pull_request_review.dismissed","pull_request_review.edited","pull_request_review.submitted","pull_request_review_comment","pull_request_review_comment.created","pull_request_review_comment.deleted","pull_request_review_comment.edited","pull_request_review_thread","pull_request_review_thread.resolved","pull_request_review_thread.unresolved","push","registry_package","registry_package.published","registry_package.updated","release","release.created","release.deleted","release.edited","release.prereleased","release.published","release.released","release.unpublished","repository","repository.archived","repository.created","repository.deleted","repository.edited","repository.privatized","repository.publicized","repository.renamed","repository.transferred","repository.unarchived","repository_advisory","repository_advisory.published","repository_advisory.reported","repository_dispatch","repository_dispatch.sample.collected","repository_import","repository_ruleset","repository_ruleset.created","repository_ruleset.deleted","repository_ruleset.edited","repository_vulnerability_alert","repository_vulnerability_alert.create","repository_vulnerability_alert.dismiss","repository_vulnerability_alert.reopen","repository_vulnerability_alert.resolve","secret_scanning_alert","secret_scanning_alert.created","secret_scanning_alert.publicly_leaked","secret_scanning_alert.reopened","secret_scanning_alert.resolved","secret_scanning_alert.validated","secret_scanning_alert_location","secret_scanning_alert_location.created","secret_scanning_scan","secret_scanning_scan.completed","security_advisory","security_advisory.published","security_advisory.updated","security_advisory.withdrawn","security_and_analysis","sponsorship","sponsorship.cancelled","sponsorship.created","sponsorship.edited","sponsorship.pending_cancellation","sponsorship.pending_tier_change","sponsorship.tier_changed","star","star.created","star.deleted","status","sub_issues","sub_issues.parent_issue_added","sub_issues.parent_issue_removed","sub_issues.sub_issue_added","sub_issues.sub_issue_removed","team","team.added_to_repository","team.created","team.deleted","team.edited","team.removed_from_repository","team_add","watch","watch.started","workflow_dispatch","workflow_job","workflow_job.completed","workflow_job.in_progress","workflow_job.queued","workflow_job.waiting","workflow_run","workflow_run.completed","workflow_run.in_progress","workflow_run.requested"];function z1D(e,t={}){if(typeof e!="string")throw new TypeError("eventName must be of type string");if(e==="*")throw new TypeError('Using the "*" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.onAny() method instead');if(e==="error")throw new TypeError('Using the "error" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.onError() method instead');if(t.onUnknownEventName!=="ignore"&&!R1D.includes(e)){if(t.onUnknownEventName!=="warn")throw new TypeError(`"${e}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`);(t.log||console).warn(`"${e}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`)}}function FLc(e,t,r){e.hooks[t]||(e.hooks[t]=[]),e.hooks[t].push(r)}function oah(e,t,r){if(Array.isArray(t)){t.forEach(i=>oah(e,i,r));return}z1D(t,{onUnknownEventName:"warn",log:e.log}),FLc(e,t,r)}function N1D(e,t){FLc(e,"*",t)}function F1D(e,t){FLc(e,"error",t)}function iah(e,t){let r;try{r=e(t)}catch(i){console.log('FATAL: Error occurred in "error" event handler'),console.log(i)}r&&r.catch&&r.catch(i=>{console.log('FATAL: Error occurred in "error" event handler'),console.log(i)})}function Q1D(e,t,r){let i=[e.hooks[r],e.hooks["*"]];return t&&i.unshift(e.hooks[`${r}.${t}`]),[].concat(...i.filter(Boolean))}function U1D(e,t){let r=e.hooks.error||[];if(t instanceof Error){let o=Object.assign(new AggregateError([t],t.message),{event:t});return r.forEach(c=>iah(c,o)),Promise.reject(o)}if(!t||!t.name){let o=new Error("Event name not passed");throw new AggregateError([o],o.message)}if(!t.payload){let o=new Error("Event name not passed");throw new AggregateError([o],o.message)}let i=Q1D(e,"action"in t.payload?t.payload.action:null,t.name);if(i.length===0)return Promise.resolve();let n=[],a=i.map(o=>{let c=Promise.resolve(t);return e.transform&&(c=c.then(e.transform)),c.then(d=>o(d)).catch(d=>n.push(Object.assign(d,{event:t})))});return Promise.all(a).then(()=>{if(n.length===0)return;let o=new AggregateError(n,n.map(c=>c.message).join(`
|
|
1408
1408
|
`));throw Object.assign(o,{event:t}),r.forEach(c=>iah(c,o)),o})}function uah(e,t,r){if(Array.isArray(t)){t.forEach(i=>uah(e,i,r));return}if(e.hooks[t]){for(let i=e.hooks[t].length-1;i>=0;i--)if(e.hooks[t][i]===r){e.hooks[t].splice(i,1);return}}}function L1D(e){let t={hooks:{},log:aah(e&&e.log)};return e&&e.transform&&(t.transform=e.transform),{on:oah.bind(null,t),onAny:N1D.bind(null,t),onError:F1D.bind(null,t),removeListener:uah.bind(null,t),receive:U1D.bind(null,t)}}async function V1D(e,t){if(!await rah(e.secret,t.payload,t.signature,e.additionalSecrets).catch(()=>!1)){let n=new Error("[@octokit/webhooks] signature does not match event payload and secret");return n.event=t,n.status=400,e.eventHandler.receive(n)}let i;try{i=JSON.parse(t.payload)}catch(n){throw n.message="Invalid JSON",n.status=400,new AggregateError([n],n.message)}return e.eventHandler.receive({id:t.id,name:t.name,payload:i})}var nah=new TextDecoder("utf-8",{fatal:!1}),okG=nah.decode.bind(nah);var sah=class{sign;verify;on;onAny;onError;removeListener;receive;verifyAndReceive;constructor(e){if(!e||!e.secret)throw new Error("[@octokit/webhooks] options.secret required");let t={eventHandler:L1D(e),secret:e.secret,additionalSecrets:e.additionalSecrets,hooks:{},log:aah(e.log)};this.sign=bcu.bind(null,e.secret),this.verify=RHa.bind(null,e.secret),this.on=t.eventHandler.on,this.onAny=t.eventHandler.onAny,this.onError=t.eventHandler.onError,this.removeListener=t.eventHandler.removeListener,this.receive=t.eventHandler.receive,this.verifyAndReceive=V1D.bind(null,t)}};var W1D="16.1.2";function G1D(e,t){return new sah({secret:t.secret,transform:async r=>{if(!("installation"in r.payload)||typeof r.payload.installation!="object"){let a=new e.constructor({authStrategy:ubn,auth:{reason:'"installation" key missing in webhook event payload'}});return{...r,octokit:a}}let i=r.payload.installation.id,n=await e.auth({type:"installation",installationId:i,factory(a){return new a.octokit.constructor({...a.octokitOptions,authStrategy:Tna,auth:{...a,installationId:i}})}});return n.hook.before("request",a=>{a.headers["x-github-delivery"]=r.id}),{...r,octokit:n}}})}async function cah(e,t){return e.octokit.auth({type:"installation",installationId:t,factory(r){let i={...r.octokitOptions,authStrategy:Tna,auth:{...r,installationId:t}};return new r.octokit.constructor(i)}})}function H1D(e){return Object.assign(x1D.bind(null,e),{iterator:lah.bind(null,e)})}async function x1D(e,t){let r=lah(e)[Symbol.asyncIterator](),i=await r.next();for(;!i.done;)await t(i.value),i=await r.next()}function lah(e){return{async*[Symbol.asyncIterator](){let t=scu.iterator(e.octokit,"GET /app/installations");for await(let{data:r}of t)for(let i of r)yield{octokit:await cah(e,i.id),installation:i}}}}function K1D(e){return Object.assign(J1D.bind(null,e),{iterator:fah.bind(null,e)})}async function J1D(e,t,r){let i=fah(e,r?t:void 0)[Symbol.asyncIterator](),n=await i.next();for(;!n.done;)r?await r(n.value):await t(n.value),n=await i.next()}function $1D(e,t){return{async*[Symbol.asyncIterator](){yield{octokit:await e.getInstallationOctokit(t)}}}}function fah(e,t){return{async*[Symbol.asyncIterator](){let r=t?$1D(e,t.installationId):e.eachInstallation.iterator();for await(let{octokit:i}of r){let n=scu.iterator(i,"GET /installation/repositories");for await(let{data:a}of n)for(let o of a)yield{octokit:i,repository:o}}}}}function Y1D(e){let t;return async function(i={}){t||(t=X1D(e));let n=await t,a=new URL(n);return i.target_id!==void 0&&(a.pathname+="/permissions",a.searchParams.append("target_id",i.target_id.toFixed())),i.state!==void 0&&a.searchParams.append("state",i.state),a.href}}async function X1D(e){let{data:t}=await e.octokit.request("GET /app");if(!t)throw new Error("[@octokit/app] unable to fetch metadata for app");return`${t.html_url}/installations/new`}var dah=class{static VERSION=W1D;static defaults(e){return class extends this{constructor(...r){super({...e,...r[0]})}}}octokit;webhooks;oauth;getInstallationOctokit;eachInstallation;eachRepository;getInstallationUrl;log;constructor(e){let t=e.Octokit||UKi,r=Object.assign({appId:e.appId,privateKey:e.privateKey},e.oauth?{clientId:e.oauth.clientId,clientSecret:e.oauth.clientSecret}:{}),i={authStrategy:Tna,auth:r};"log"in e&&typeof e.log<"u"&&(i.log=e.log),this.octokit=new t(i),this.log=Object.assign({debug:()=>{},info:()=>{},warn:console.warn.bind(console),error:console.error.bind(console)},e.log),e.webhooks?this.webhooks=G1D(this.octokit,e.webhooks):Object.defineProperty(this,"webhooks",{get(){throw new Error("[@octokit/app] webhooks option not set")}}),e.oauth?this.oauth=new ycu({...e.oauth,clientType:"github-app",Octokit:t}):Object.defineProperty(this,"oauth",{get(){throw new Error("[@octokit/app] oauth.clientId / oauth.clientSecret options are not set")}}),this.getInstallationOctokit=cah.bind(null,this),this.eachInstallation=H1D(this),this.eachRepository=K1D(this),this.getInstallationUrl=Y1D(this)}};var Z1D="0.0.0-development",vcu=UKi.plugin(BLc,ELc,Snh,ILc,ccu).defaults({userAgent:`octokit.js/${Z1D}`,throttle:{onRateLimit:k1D,onSecondaryRateLimit:eTD}});function k1D(e,t,r){if(r.log.warn(`Request quota exhausted for request ${t.method} ${t.url}`),t.request.retryCount===0)return r.log.info(`Retrying after ${e} seconds!`),!0}function eTD(e,t,r){if(r.log.warn(`SecondaryRateLimit detected for request ${t.method} ${t.url}`),t.request.retryCount===0)return r.log.info(`Retrying after ${e} seconds!`),!0}var DkG=dah.defaults({Octokit:vcu}),BkG=ycu.defaults({Octokit:vcu});var pah=ce(Sbe(),1);async function QLc({packageName:e,generatorInvocation:t}){if(t.language==null||e==null)return;let r=await tTD({packageName:e,language:t.language,githubRepository:oTD(t)});return r==null?void 0:pah.default.inc(r,"patch")??void 0}async function tTD({packageName:e,language:t,githubRepository:r}){let i;switch(t){case"typescript":i=await rTD(e);break;case"python":i=await iTD(e);break;case"csharp":case"go":case"java":case"ruby":case"php":case"swift":break}return i!=null||r!=null&&(i=await nTD(r)),i}async function rTD(e){try{return await SHa(e)}catch{return}}async function iTD(e){try{let t=await fetch(`https://pypi.org/pypi/${e}/json`);return t.ok?(await t.json()).info.version:void 0}catch{return}}async function nTD(e){try{let{owner:t,repo:r}=aTD(e);return(await new vcu().rest.repos.listTags({owner:t,repo:r,per_page:1})).data?.[0]?.name}catch{return}}function aTD(e){let[t,r]=e.split("/");if(t==null||r==null)throw new Error(`Invalid github repository: ${e}`);return{owner:t,repo:r}}function oTD(e){if(e.outputMode.type==="githubV2")return`${e.outputMode.githubV2.owner}/${e.outputMode.githubV2.repo}`}var W$=class extends L3t{definition;sources;type="fern";constructor({definition:t,sources:r,...i}){super(i),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var uTD={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!0,respectReadonlySchemas:!1,respectNullableSchemas:!0,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!0,useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,wrapReferencesToNullableInOptional:!1,coerceOptionalSchemasToNullable:!1,groupEnvironmentsByHost:!1,removeDiscriminantsFromSchemas:_n.RemoveDiscriminantsFromSchemas.Always};function sTD(e){let{defaults:t,options:r,overrides:i,overrideOnly:n=new Set,undefinedIfAbsent:a=new Set}=e,o={};for(let c of Object.keys(t))n.has(c)?o[c]=i?.[c]!==void 0?i[c]:t[c]:a.has(c)?o[c]=i?.[c]!==void 0?i[c]:r?.[c]!==void 0?r[c]:void 0:o[c]=i?.[c]??r?.[c]??t[c];return o}function sbn({options:e,overrides:t}){return sTD({defaults:uTD,options:e,overrides:t})}var cW={openapi:e=>({...e,type:"openapi",_visit:function(t){return cW._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return cW._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"openapi":return t.openapi(e);case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var Rna={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return Rna._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var tF={basic:e=>({...e,type:"basic",_visit:function(t){return tF._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return tF._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return tF._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return tF._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return tF._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"query":return t.query(e);case"oauth":return t.oauth(e);default:return t._other(e)}}};var ml={primitive:e=>({value:e,type:"primitive",_visit:function(t){return ml._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ml._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return ml._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return ml._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return ml._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return ml._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return ml._visit(this,t)}}),null:e=>({...e,type:"null",_visit:function(t){return ml._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return ml._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e.value);case"object":return t.object(e);case"array":return t.array(e.value);case"map":return t.map(e.value);case"enum":return t.enum(e.value);case"literal":return t.literal(e.value);case"oneOf":return t.oneOf(e.value);case"null":return t.null(e);case"unknown":return t.unknown(e.value);default:return t._other(e)}}};var po={int:e=>({value:e,type:"int",_visit:function(t){return po._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return po._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return po._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return po._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return po._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return po._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return po._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return po._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return po._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return po._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return po._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e.value);case"int64":return t.int64(e.value);case"uint":return t.uint(e.value);case"uint64":return t.uint64(e.value);case"float":return t.float(e.value);case"double":return t.double(e.value);case"string":return t.string(e.value);case"datetime":return t.datetime(e.value);case"date":return t.date(e.value);case"base64":return t.base64(e.value);case"boolean":return t.boolean(e.value);default:return t._other(e)}}};var LKi={boolean:e=>({value:e,type:"boolean",_visit:function(t){return LKi._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return LKi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var VKi={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return VKi._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return VKi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undiscriminated":return t.undiscriminated(e.value);default:return t._other(e)}}};var gcu={};Zt(gcu,{Availability:()=>rF,CustomCodeSample:()=>k$t,EndpointExample:()=>gEe,EndpointResponseExample:()=>OEe,HttpMethod:()=>nF,LiteralSchemaValue:()=>Ww,MultipartRequestPropertyEncoding:()=>VLc,MultipartSchema:()=>eYt,OneOfSchema:()=>tYt,Pagination:()=>Tve,PrimitiveSchemaValue:()=>Th,Request:()=>W3t,Response:()=>eL,RetriesConfiguration:()=>zHa,Schema:()=>ic,SupportedSdkLanguage:()=>iF,WebhookHttpMethod:()=>LLc,WebsocketMessageOrigin:()=>ULc});var ULc={Client:"client",Server:"server",_visit:(e,t)=>{switch(e){case ULc.Client:return t.client();case ULc.Server:return t.server();default:return t._other()}}};var LLc={Get:"GET",Post:"POST",_visit:(e,t)=>{switch(e){case LLc.Get:return t.get();case LLc.Post:return t.post();default:return t._other()}}};var rF={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case rF.GenerallyAvailable:return t.generallyAvailable();case rF.Beta:return t.beta();case rF.Deprecated:return t.deprecated();default:return t._other()}}};var zHa={disabled:e=>({value:e,type:"disabled",_visit:function(t){return zHa._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"disabled":return t.disabled(e.value);default:return t._other(e)}}};var Tve={cursor:e=>({...e,type:"cursor",_visit:function(t){return Tve._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return Tve._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return Tve._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var k$t={language:e=>({...e,type:"language",_visit:function(t){return k$t._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return k$t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"language":return t.language(e);case"sdk":return t.sdk(e);default:return t._other(e)}}};var iF={Curl:"curl",Python:"python",Javascript:"javascript",Typescript:"typescript",Go:"go",Ruby:"ruby",Csharp:"csharp",Java:"java",Js:"js",Node:"node",Ts:"ts",Nodets:"nodets",Golang:"golang",Dotnet:"dotnet",Jvm:"jvm",_visit:(e,t)=>{switch(e){case iF.Curl:return t.curl();case iF.Python:return t.python();case iF.Javascript:return t.javascript();case iF.Typescript:return t.typescript();case iF.Go:return t.go();case iF.Ruby:return t.ruby();case iF.Csharp:return t.csharp();case iF.Java:return t.java();case iF.Js:return t.js();case iF.Node:return t.node();case iF.Ts:return t.ts();case iF.Nodets:return t.nodets();case iF.Golang:return t.golang();case iF.Dotnet:return t.dotnet();case iF.Jvm:return t.jvm();default:return t._other()}}};var gEe={unknown:e=>({value:e,type:"unknown",_visit:function(t){return gEe._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return gEe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"unknown":return t.unknown(e.value);case"full":return t.full(e);default:return t._other(e)}}};var OEe={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return OEe._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return OEe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var nF={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case nF.Get:return t.get();case nF.Post:return t.post();case nF.Put:return t.put();case nF.Patch:return t.patch();case nF.Delete:return t.delete();case nF.Head:return t.head();case nF.Options:return t.options();case nF.Trace:return t.trace();default:return t._other()}}};var W3t={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return W3t._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return W3t._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return W3t._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return W3t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);case"formUrlEncoded":return t.formUrlEncoded(e);default:return t._other(e)}}};var VLc={Json:"json",Form:"form",_visit:(e,t)=>{switch(e){case VLc.Json:return t.json();case VLc.Form:return t.form();default:return t._other()}}};var eYt={file:e=>({...e,type:"file",_visit:function(t){return eYt._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return eYt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e.value);default:return t._other(e)}}};var eL={file:e=>({...e,type:"file",_visit:function(t){return eL._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return eL._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return eL._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return eL._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return eL._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return eL._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return eL._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var ic={primitive:e=>({...e,type:"primitive",_visit:function(t){return ic._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ic._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return ic._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return ic._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return ic._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return ic._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return ic._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return ic._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return ic._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return ic._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return ic._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var Th={int:e=>({...e,type:"int",_visit:function(t){return Th._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Th._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Th._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Th._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Th._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Th._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Th._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Th._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Th._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Th._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Th._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint();case"uint64":return t.uint64();case"float":return t.float();case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime();case"date":return t.date();case"base64":return t.base64();case"boolean":return t.boolean(e);default:return t._other(e)}}};var Ww={boolean:e=>({value:e,type:"boolean",_visit:function(t){return Ww._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Ww._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var tYt={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return tYt._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return tYt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var ZG={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return ZG._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return ZG._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return ZG._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return ZG._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);case"formUrlEncoded":return t.formUrlEncoded(e);default:return t._other(e)}}};var O0={file:e=>({...e,type:"file",_visit:function(t){return O0._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return O0._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return O0._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return O0._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return O0._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return O0._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return O0._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var ai={primitive:e=>({...e,type:"primitive",_visit:function(t){return ai._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ai._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return ai._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return ai._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return ai._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return ai._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return ai._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return ai._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return ai._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return ai._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return ai._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var Rve={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return Rve._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return Rve._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var Jn={int:e=>({...e,type:"int",_visit:function(t){return Jn._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Jn._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return Jn._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return Jn._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return Jn._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return Jn._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Jn._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Jn._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return Jn._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return Jn._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Jn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint(e);case"uint64":return t.uint64(e);case"float":return t.float(e);case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime(e);case"date":return t.date(e);case"base64":return t.base64(e);case"boolean":return t.boolean(e);default:return t._other(e)}}};var nc={};Zt(nc,{AllOfPropertyConflict:()=>uaa,ArraySchema:()=>zlu,ArraySchemaWithExample:()=>dfu,Availability:()=>Dcu,Base64WithExample:()=>ufu,BasicSecurityScheme:()=>Icu,BearerSecurityScheme:()=>Ccu,BooleanSchema:()=>Dlu,BooleanWithExample:()=>sfu,BytesResponse:()=>Yna,CasingOverrides:()=>Rcu,CommonProperty:()=>Glu,CommonPropertyWithExample:()=>Afu,CursorPagination:()=>dlu,CustomCodeSample:()=>llu,CustomCodeSampleLanguage:()=>ulu,CustomCodeSampleSdk:()=>clu,CustomPagination:()=>_lu,DateWithExample:()=>ofu,DatetimeWithExample:()=>afu,DiscriminatedOneOfSchema:()=>Vlu,DiscriminatedOneOfSchemaWithExample:()=>gfu,DoubleSchema:()=>Slu,DoubleWithExample:()=>ifu,Encoding:()=>Mcu,Endpoint:()=>hlu,EndpointExample:()=>taa,EndpointResponseExample:()=>olu,EndpointSdkName:()=>nYt,EndpointSecurity:()=>Vna,EndpointWithExample:()=>Wah,EnumSchema:()=>Qna,EnumSchemaWithExample:()=>lfu,EnumValue:()=>xKi,ErrorExample:()=>tlu,FernExample:()=>ilu,FileResponse:()=>Jna,FileSchema:()=>Jcu,FloatWithExample:()=>rfu,FormUrlEncodedRequest:()=>kcu,FullEndpointExample:()=>flu,FullExample:()=>VP,FullObjectExample:()=>Wcu,FullOneOfExample:()=>Hcu,GlobalHeader:()=>Clu,GlobalSecurity:()=>Ilu,Header:()=>JKi,HeaderExample:()=>eaa,HeaderSecurityScheme:()=>qcu,HeaderWithExample:()=>XKi,HttpEndpointServer:()=>Zna,HttpError:()=>rlu,HttpErrorWithExample:()=>Xlu,HttpMethod:()=>Wna,IdempotencyHeader:()=>qlu,Int64WithExample:()=>klu,IntSchema:()=>wlu,IntWithExample:()=>Zlu,JsonRequest:()=>Zcu,JsonRequestWithExample:()=>Jlu,JsonResponse:()=>$na,JsonResponseWithExample:()=>laa,KeyValuePair:()=>Gcu,LiteralExample:()=>Lcu,LiteralSchema:()=>oaa,LiteralSchemaValue:()=>Tlu,LongSchema:()=>Elu,MapSchema:()=>Nlu,MapSchemaWithExample:()=>pfu,MultipartRequest:()=>Kna,MultipartRequestProperty:()=>Xcu,MultipartRequestPropertyEncoding:()=>Ycu,MultipartSchema:()=>$cu,NamedFullExample:()=>mEe,Namespace:()=>zcu,NamespaceId:()=>Ucu,NullExample:()=>Vcu,NullableSchema:()=>Qlu,NullableSchemaWithExample:()=>hfu,OauthSecurityScheme:()=>Fcu,ObjectProperty:()=>Llu,ObjectPropertyConflictInfo:()=>saa,ObjectPropertyWithExample:()=>vfu,ObjectSchema:()=>Rlu,ObjectSchemaWithExample:()=>yfu,OctetStreamRequest:()=>xna,OffsetPagination:()=>plu,OneOfSchema:()=>Ulu,OneOfSchemaWithExample:()=>bfu,OpenApiIntermediateRepresentation:()=>Lah,OpenApiSource:()=>jcu,OptionalSchema:()=>Flu,OptionalSchemaWithExample:()=>_fu,Pagination:()=>raa,ParseFormUrlEncodedRequest:()=>$lu,ParseMultipartRequest:()=>Klu,ParseOctetStreamRequest:()=>xlu,PathParameter:()=>Gna,PathParameterExample:()=>nlu,PathParameterWithExample:()=>Hlu,PrimitiveExample:()=>Lna,PrimitiveSchema:()=>YKi,PrimitiveSchemaValue:()=>Blu,PrimitiveSchemaValueWithExample:()=>cfu,PrimitiveSchemaWithExample:()=>daa,PropertyKey:()=>Una,ProtobufEncoding:()=>Scu,ProtobufSource:()=>wcu,QueryParameter:()=>Hna,QueryParameterExample:()=>kna,QueryParameterWithExample:()=>caa,QuerySecurityScheme:()=>Tcu,ReferencedSchema:()=>aYt,Request:()=>elu,RequestWithExample:()=>Ylu,Response:()=>Xna,ResponseWithExample:()=>faa,RetriesConfiguration:()=>iaa,Schema:()=>Dd,SchemaId:()=>kG,SchemaWithExample:()=>tA,Schemas:()=>jlu,SdkGroup:()=>Ncu,SdkGroupInfo:()=>xcu,SdkGroupName:()=>KKi,SecurityScheme:()=>Qcu,SecuritySchemeId:()=>HKi,Server:()=>UHa,Source:()=>Ecu,StatusCode:()=>rYt,StreamingResponseExample:()=>alu,StringSchema:()=>Mlu,StringSchemaWithExample:()=>nfu,SupportedSdkLanguage:()=>slu,Tag:()=>Bcu,TagId:()=>eH,Tags:()=>Kcu,TextResponse:()=>$Ki,Uint64WithExample:()=>tfu,UintWithExample:()=>efu,UnDiscriminatedOneOfSchema:()=>Wlu,UnDiscriminatedOneOfSchemaWithExample:()=>Ofu,UnknownSchemaWithExample:()=>ffu,Webhook:()=>ylu,WebhookExampleCall:()=>aaa,WebhookHttpMethod:()=>naa,WebhookWithExample:()=>Gah,WebsocketChannel:()=>Plu,WebsocketHandshake:()=>blu,WebsocketHandshakeWithExample:()=>Vah,WebsocketMessageExample:()=>Alu,WebsocketMessageOrigin:()=>vlu,WebsocketMessageSchema:()=>glu,WebsocketServer:()=>Olu,WebsocketSessionExample:()=>mlu,WithAvailability:()=>Vu,WithDescription:()=>Ni,WithEncoding:()=>G$,WithInline:()=>eA,WithName:()=>yf,WithNamespace:()=>Xl,WithSdkGroupName:()=>bp,WithSdkMethodName:()=>iYt,WithSource:()=>Eu,WithStatusCode:()=>AEe,WithTitle:()=>yp,commons:()=>KLc,example:()=>JLc,finalIr:()=>$Lc,parseIr:()=>YLc});var KLc={};Zt(KLc,{BasicSecurityScheme:()=>Icu,BearerSecurityScheme:()=>Ccu,Encoding:()=>Mcu,HeaderSecurityScheme:()=>qcu,Namespace:()=>zcu,NamespaceId:()=>Ucu,OauthSecurityScheme:()=>Fcu,OpenApiSource:()=>jcu,ProtobufEncoding:()=>Scu,ProtobufSource:()=>wcu,QuerySecurityScheme:()=>Tcu,SchemaId:()=>kG,SdkGroup:()=>Ncu,SdkGroupName:()=>KKi,SecurityScheme:()=>Qcu,SecuritySchemeId:()=>HKi,Server:()=>UHa,Source:()=>Ecu,StatusCode:()=>rYt,Tag:()=>Bcu,TagId:()=>eH,WithAvailability:()=>Vu,WithDescription:()=>Ni,WithEncoding:()=>G$,WithInline:()=>eA,WithName:()=>yf,WithNamespace:()=>Xl,WithSdkGroupName:()=>bp,WithSdkMethodName:()=>iYt,WithSource:()=>Eu,WithStatusCode:()=>AEe,WithTitle:()=>yp});var L={};Zt(L,{JsonError:()=>zna,ParseError:()=>Nna,any:()=>Mah,bigint:()=>hah,boolean:()=>Dah,booleanLiteral:()=>Sah,date:()=>yah,discriminant:()=>Fah,enum_:()=>Acu,getObjectLikeUtils:()=>G3t,getObjectUtils:()=>cbn,getSchemaUtils:()=>LP,isProperty:()=>GKi,lazy:()=>bah,lazyObject:()=>jah,list:()=>Pcu,number:()=>Bah,object:()=>mcu,objectWithoutOptionalProperties:()=>Pah,optional:()=>WLc,property:()=>gah,record:()=>Tah,set:()=>Rah,string:()=>Iah,stringLiteral:()=>Eah,transform:()=>GLc,undiscriminatedUnion:()=>Nah,union:()=>Uah,unknown:()=>Cah,withParsedProperties:()=>xLc});var Rh={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function hm(e,t){return`Expected ${t}. Received ${cTD(e)}.`}function cTD(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function aF(e){return{...e,json:_ah(e.json),parse:_ah(e.parse)}}function _ah(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1409
|
-
`)),{ok:!0,value:t}):i}}function Ocu(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var zna=class e extends Error{errors;constructor(t){super(t.map(Ocu).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var Nna=class e extends Error{errors;constructor(t){super(t.map(Ocu).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function LP(e){return{optional:()=>WLc(e),transform:t=>GLc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new Nna(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new zna(i.errors)}}}function WLc(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:()=>Rh.OPTIONAL};return{...t,...LP(t)}}function GLc(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,...LP(r)}}function hah(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:hm(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:hm(t,"bigint")}]},getType:()=>Rh.BIGINT};return{...aF(e),...LP(e)}}var lTD=/^([+-]?\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 yah(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:hm(t,"string")}]}:lTD.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:hm(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:hm(t,"Date object")}]},getType:()=>Rh.DATE};return{...aF(e),...LP(e)}}function lW(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...aF(r),...LP(r)}}}function Acu(e){let t=new Set(e);return lW(Rh.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:hm(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:hm(i,"enum")}]}:{ok:!0,value:i})()}function bah(e){let t=HLc(e);return{...t,...LP(t)}}function HLc(e){return{parse:(t,r)=>Fna(e).parse(t,r),json:(t,r)=>Fna(e).json(t,r),getType:()=>Fna(e).getType()}}function Fna(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function NHa(e){return Object.entries(e)}function FHa(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function WKi(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 QHa(e){return Object.keys(e)}function vah(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function G3t(e){return{withParsedProperties:t=>xLc(e,t)}}function xLc(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(!WKi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:hm(i,"object")}]};let a=new Set(Object.keys(t)),o=FHa(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(o,n)},getType:()=>e.getType()};return{...r,...LP(r),...G3t(r)}}function gah(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function GKi(e){return e.isProperty}function mcu(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>GKi(i)?i.rawKey:r),_getParsedProperties:()=>QHa(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of NHa(e)){let d=GKi(c)?c.rawKey:o,s=GKi(c)?c.valueSchema:c,u={rawKey:d,parsedKey:o,valueSchema:s};n[d]=u,mah(s)&&a.push(d)}return Oah({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 NHa(e)){let c=GKi(o)?o.valueSchema:o;mah(c)&&n.push(a)}return Oah({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return GKi(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:()=>Rh.OBJECT};return{...aF(t),...LP(t),...G3t(t),...cbn(t)}}function Oah({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!WKi(e))return{ok:!1,errors:[{path:a,message:hm(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 cbn(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>Aah({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>Aah({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>Rh.OBJECT};return{...r,...LP(r),...G3t(r),...cbn(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:()=>Rh.OBJECT};return{...t,...LP(t),...G3t(t),...cbn(t)}}}}function Aah({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,o]=vah(QHa(t),s=>n.has(s)),c=r(FHa(t,o)),d=i(FHa(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 mah(e){return!fTD(e)}function fTD(e){switch(e.getType()){case Rh.ANY:case Rh.UNKNOWN:case Rh.OPTIONAL:return!0;default:return!1}}function Pah(e){return mcu(e)}function jah(e){let t={...HLc(e),_getRawProperties:()=>Fna(e)._getRawProperties(),_getParsedProperties:()=>Fna(e)._getParsedProperties()};return{...t,...LP(t),...G3t(t),...cbn(t)}}function Pcu(e){let t={parse:(r,i)=>wah(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>wah(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>Rh.LIST};return{...aF(t),...LP(t)}}function wah(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:hm(e,"list"),path:[]}]}}function Eah(e){return lW(Rh.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:hm(r,`"${e}"`)}]})()}function Sah(e){return lW(Rh.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:hm(r,`${e.toString()}`)}]})()}var Mah=lW(Rh.ANY,e=>({ok:!0,value:e}));var Dah=lW(Rh.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:hm(e,"boolean")}]});var Bah=lW(Rh.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:hm(e,"number")}]});var Iah=lW(Rh.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:hm(e,"string")}]});var Cah=lW(Rh.UNKNOWN,e=>({ok:!0,value:e}));function Tah(e,t){let r={parse:(i,n)=>qah({value:i,isKeyNumeric:e.getType()===Rh.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)=>qah({value:i,isKeyNumeric:e.getType()===Rh.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:()=>Rh.RECORD};return{...aF(r),...LP(r)}}function qah({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return WKi(e)?NHa(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:hm(e,"object")}]}}function Rah(e){let t=Pcu(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:hm(i,"Set")}]},getType:()=>Rh.SET};return{...aF(r),...LP(r)}}function Nah(e){let t={parse:(r,i)=>zah((n,a)=>n.parse(r,a),e,i),json:(r,i)=>zah((n,a)=>n.json(r,a),e,i),getType:()=>Rh.UNDISCRIMINATED_UNION};return{...aF(t),...LP(t)}}function zah(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 Fah(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Uah(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=Acu(QHa(t)),a={parse:(o,c)=>Qah({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)=>Qah({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:()=>Rh.UNION};return{...aF(a),...LP(a),...G3t(a)}}function Qah({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!WKi(e))return{ok:!1,errors:[{path:c,message:hm(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 yp=L.objectWithoutOptionalProperties({title:L.string().optional()});var jcu=L.objectWithoutOptionalProperties({file:L.string()});var wcu=L.objectWithoutOptionalProperties({file:L.string()});var Ecu=L.union("type",{openapi:jcu,protobuf:wcu}).transform({transform:e=>{switch(e.type){case"openapi":return cW.openapi(e);case"protobuf":return cW.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Eu=L.objectWithoutOptionalProperties({source:Ecu.optional()});var Scu=L.objectWithoutOptionalProperties({typeName:L.string()});var Mcu=L.union("type",{protobuf:Scu}).transform({transform:e=>{switch(e.type){case"protobuf":return Rna.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var G$=L.objectWithoutOptionalProperties({encoding:Mcu.optional()});var Ni=L.objectWithoutOptionalProperties({description:L.string().optional()});var Dcu=L.enum_(["GenerallyAvailable","Beta","Deprecated"]);var Vu=L.objectWithoutOptionalProperties({availability:Dcu.optional()});var rYt=L.number();var AEe=L.objectWithoutOptionalProperties({statusCode:rYt.optional()});var yf=L.objectWithoutOptionalProperties({nameOverride:L.string().optional(),generatedName:L.string()});var eA=L.objectWithoutOptionalProperties({inline:L.boolean().optional()});var kG=L.string();var eH=L.string();var Bcu=L.objectWithoutOptionalProperties({id:eH}).extend(Ni);var HKi=L.string();var Icu=L.objectWithoutOptionalProperties({usernameVariableName:L.string().optional(),usernameEnvVar:L.string().optional(),passwordVariableName:L.string().optional(),passwordEnvVar:L.string().optional()});var Ccu=L.objectWithoutOptionalProperties({tokenVariableName:L.string().optional(),tokenEnvVar:L.string().optional()});var qcu=L.objectWithoutOptionalProperties({headerName:L.string(),prefix:L.string().optional(),headerVariableName:L.string().optional(),headerEnvVar:L.string().optional()});var Tcu=L.objectWithoutOptionalProperties({queryParameterName:L.string()});var Rcu=L.objectWithoutOptionalProperties({snake:L.string().optional(),camel:L.string().optional(),screamingSnake:L.string().optional(),pascal:L.string().optional()});var xKi=L.objectWithoutOptionalProperties({nameOverride:L.string().optional(),generatedName:L.string(),value:L.string(),casing:Rcu.optional()}).extend(Ni).extend(Vu);var zcu=L.objectWithoutOptionalProperties({type:L.stringLiteral("namespace"),name:L.string()});var Ncu=L.undiscriminatedUnion([L.string(),zcu]);var KKi=L.list(Ncu);var bp=L.objectWithoutOptionalProperties({groupName:KKi.optional()});var Xl=L.objectWithoutOptionalProperties({namespace:L.string().optional()});var Qna=L.objectWithoutOptionalProperties({default:xKi.optional(),values:L.list(xKi)}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(Eu).extend(yp).extend(eA);var Fcu=L.objectWithoutOptionalProperties({scopesEnum:Qna.optional()});var Qcu=L.union("type",{basic:Icu,bearer:Ccu,header:qcu,query:Tcu,oauth:Fcu}).transform({transform:e=>{switch(e.type){case"basic":return tF.basic(e);case"bearer":return tF.bearer(e);case"header":return tF.header(e);case"query":return tF.query(e);case"oauth":return tF.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var UHa=L.objectWithoutOptionalProperties({name:L.string().optional(),url:L.string(),audiences:L.list(L.string()).optional()}).extend(Ni);var Ucu=L.string();var iYt=L.objectWithoutOptionalProperties({sdkMethodName:L.string().optional()});var JLc={};Zt(JLc,{FullExample:()=>VP,FullObjectExample:()=>Wcu,FullOneOfExample:()=>Hcu,KeyValuePair:()=>Gcu,LiteralExample:()=>Lcu,NullExample:()=>Vcu,PrimitiveExample:()=>Lna,PropertyKey:()=>Una});var Una=L.string();var Lna=L.union("type",{int:L.object({value:L.number()}),int64:L.object({value:L.number()}),uint:L.object({value:L.number()}),uint64:L.object({value:L.number()}),float:L.object({value:L.number()}),double:L.object({value:L.number()}),string:L.object({value:L.string()}),datetime:L.object({value:L.string()}),date:L.object({value:L.string()}),base64:L.object({value:L.string()}),boolean:L.object({value:L.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return po.int(e.value);case"int64":return po.int64(e.value);case"uint":return po.uint(e.value);case"uint64":return po.uint64(e.value);case"float":return po.float(e.value);case"double":return po.double(e.value);case"string":return po.string(e.value);case"datetime":return po.datetime(e.value);case"date":return po.date(e.value);case"base64":return po.base64(e.value);case"boolean":return po.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Lcu=L.union("type",{boolean:L.object({value:L.boolean()}),string:L.object({value:L.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return LKi.boolean(e.value);case"string":return LKi.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Vcu=L.objectWithoutOptionalProperties({});var VP=L.union("type",{primitive:L.object({value:Lna}),object:L.lazyObject(()=>Wcu),array:L.object({value:L.list(L.lazy(()=>VP))}),map:L.object({value:L.list(L.lazyObject(()=>Gcu))}),enum:L.object({value:L.string()}),literal:L.object({value:Lcu}),oneOf:L.object({value:L.lazy(()=>Hcu)}),null:Vcu,unknown:L.object({value:L.lazy(()=>VP)})}).transform({transform:e=>{switch(e.type){case"primitive":return ml.primitive(e.value);case"object":return ml.object(e);case"array":return ml.array(e.value);case"map":return ml.map(e.value);case"enum":return ml.enum(e.value);case"literal":return ml.literal(e.value);case"oneOf":return ml.oneOf(e.value);case"null":return ml.null(e);case"unknown":return ml.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Wcu=L.objectWithoutOptionalProperties({properties:L.record(Una,L.lazy(()=>VP))});var Gcu=L.objectWithoutOptionalProperties({key:Lna,value:L.lazy(()=>VP)});var Hcu=L.union("type",{discriminated:L.object({value:L.record(Una,L.lazy(()=>VP))}),undiscriminated:L.object({value:L.lazy(()=>VP)})}).transform({transform:e=>{switch(e.type){case"discriminated":return VKi.discriminated(e.value);case"undiscriminated":return VKi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var $Lc={};Zt($Lc,{AllOfPropertyConflict:()=>uaa,ArraySchema:()=>zlu,Availability:()=>Dcu,BooleanSchema:()=>Dlu,BytesResponse:()=>Yna,CasingOverrides:()=>Rcu,CommonProperty:()=>Glu,CursorPagination:()=>dlu,CustomCodeSample:()=>llu,CustomCodeSampleLanguage:()=>ulu,CustomCodeSampleSdk:()=>clu,CustomPagination:()=>_lu,DiscriminatedOneOfSchema:()=>Vlu,DoubleSchema:()=>Slu,Endpoint:()=>hlu,EndpointExample:()=>taa,EndpointResponseExample:()=>olu,EndpointSdkName:()=>nYt,EndpointSecurity:()=>Vna,EnumSchema:()=>Qna,EnumValue:()=>xKi,ErrorExample:()=>tlu,FernExample:()=>ilu,FileResponse:()=>Jna,FileSchema:()=>Jcu,FormUrlEncodedRequest:()=>kcu,FullEndpointExample:()=>flu,GlobalHeader:()=>Clu,GlobalSecurity:()=>Ilu,Header:()=>JKi,HeaderExample:()=>eaa,HttpEndpointServer:()=>Zna,HttpError:()=>rlu,HttpMethod:()=>Wna,IdempotencyHeader:()=>qlu,IntSchema:()=>wlu,JsonRequest:()=>Zcu,JsonResponse:()=>$na,LiteralSchema:()=>oaa,LiteralSchemaValue:()=>Tlu,LongSchema:()=>Elu,MapSchema:()=>Nlu,MultipartRequest:()=>Kna,MultipartRequestProperty:()=>Xcu,MultipartRequestPropertyEncoding:()=>Ycu,MultipartSchema:()=>$cu,NullableSchema:()=>Qlu,ObjectProperty:()=>Llu,ObjectPropertyConflictInfo:()=>saa,ObjectSchema:()=>Rlu,OctetStreamRequest:()=>xna,OffsetPagination:()=>plu,OneOfSchema:()=>Ulu,OpenApiIntermediateRepresentation:()=>Lah,OptionalSchema:()=>Flu,Pagination:()=>raa,PathParameter:()=>Gna,PathParameterExample:()=>nlu,PrimitiveSchema:()=>YKi,PrimitiveSchemaValue:()=>Blu,QueryParameter:()=>Hna,QueryParameterExample:()=>kna,ReferencedSchema:()=>aYt,Request:()=>elu,Response:()=>Xna,RetriesConfiguration:()=>iaa,Schema:()=>Dd,Schemas:()=>jlu,SdkGroupInfo:()=>xcu,StreamingResponseExample:()=>alu,StringSchema:()=>Mlu,SupportedSdkLanguage:()=>slu,Tags:()=>Kcu,TextResponse:()=>$Ki,UnDiscriminatedOneOfSchema:()=>Wlu,Webhook:()=>ylu,WebhookExampleCall:()=>aaa,WebhookHttpMethod:()=>naa,WebsocketChannel:()=>Plu,WebsocketHandshake:()=>blu,WebsocketMessageExample:()=>Alu,WebsocketMessageOrigin:()=>vlu,WebsocketMessageSchema:()=>glu,WebsocketServer:()=>Olu,WebsocketSessionExample:()=>mlu});var xcu=L.objectWithoutOptionalProperties({summary:L.string().optional(),description:L.string().optional()});var Kcu=L.objectWithoutOptionalProperties({tagsById:L.record(eH,Bcu),orderedTagIds:L.list(eH).optional()});var Vna=L.list(L.record(HKi,L.list(L.string())));var Wna=L.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var Gna=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>Dd),variableReference:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ni).extend(Vu).extend(Eu);var Hna=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>Dd),parameterNameOverride:L.string().optional()}).extend(Ni).extend(Vu).extend(Eu);var JKi=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>Dd),env:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ni).extend(Vu).extend(Eu);var nYt=L.objectWithoutOptionalProperties({groupName:KKi,methodName:L.string()});var xna=L.objectWithoutOptionalProperties({contentType:L.string().optional()}).extend(Ni).extend(Eu);var Jcu=L.objectWithoutOptionalProperties({isOptional:L.boolean(),isArray:L.boolean()}).extend(Ni);var $cu=L.union("type",{file:Jcu,json:L.object({value:L.lazy(()=>Dd)})}).transform({transform:e=>{switch(e.type){case"file":return eYt.file(e);case"json":return eYt.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Ycu=L.enum_(["json","form"]);var Xcu=L.objectWithoutOptionalProperties({key:L.string(),schema:$cu,contentType:L.string().optional(),exploded:L.boolean().optional(),encoding:Ycu.optional()}).extend(Ni);var Kna=L.objectWithoutOptionalProperties({name:L.string().optional(),properties:L.list(Xcu)}).extend(Ni).extend(Eu);var Zcu=L.objectWithoutOptionalProperties({schema:L.lazy(()=>Dd),contentType:L.string().optional(),additionalProperties:L.boolean()}).extend(Ni).extend(Eu);var kcu=L.objectWithoutOptionalProperties({schema:L.lazy(()=>Dd),contentType:L.string().optional(),additionalProperties:L.boolean()}).extend(Ni).extend(Eu);var elu=L.union("type",{octetStream:xna,multipart:Kna,json:Zcu,formUrlEncoded:kcu}).transform({transform:e=>{switch(e.type){case"octetStream":return W3t.octetStream(e);case"multipart":return W3t.multipart(e);case"json":return W3t.json(e);case"formUrlEncoded":return W3t.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var Jna=L.objectWithoutOptionalProperties({}).extend(Ni).extend(Eu).extend(AEe);var $na=L.objectWithoutOptionalProperties({schema:L.lazy(()=>Dd),responseProperty:L.string().optional()}).extend(Ni).extend(Eu).extend(AEe);var $Ki=L.objectWithoutOptionalProperties({}).extend(Ni).extend(Eu).extend(AEe);var Yna=L.objectWithoutOptionalProperties({}).extend(Ni).extend(Eu).extend(AEe);var Xna=L.union("type",{file:Jna,json:$na,text:$Ki,bytes:Yna,streamingSse:$na,streamingText:$Ki,streamingJson:$na}).transform({transform:e=>{switch(e.type){case"file":return eL.file(e);case"json":return eL.json(e);case"text":return eL.text(e);case"bytes":return eL.bytes(e);case"streamingSse":return eL.streamingSse(e);case"streamingText":return eL.streamingText(e);case"streamingJson":return eL.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var tlu=L.objectWithoutOptionalProperties({name:L.string().optional(),description:L.string().optional(),example:L.lazy(()=>VP)});var rlu=L.objectWithoutOptionalProperties({schema:L.lazy(()=>Dd).optional(),examples:L.list(tlu).optional()}).extend(Ni).extend(yf).extend(Eu);var Zna=L.objectWithoutOptionalProperties({name:L.string().optional(),url:L.string().optional(),audiences:L.list(L.string()).optional()});var ilu=L.unknown();var nlu=L.objectWithoutOptionalProperties({name:L.string(),parameterNameOverride:L.string().optional(),value:L.lazy(()=>VP)});var kna=L.objectWithoutOptionalProperties({name:L.string(),value:L.lazy(()=>VP)});var eaa=L.objectWithoutOptionalProperties({name:L.string(),value:L.lazy(()=>VP)});var alu=L.objectWithoutOptionalProperties({sse:L.boolean(),events:L.list(L.lazy(()=>VP))});var olu=L.union("type",{withStreaming:alu,withoutStreaming:L.object({value:L.lazy(()=>VP)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return OEe.withStreaming(e);case"withoutStreaming":return OEe.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var ulu=L.objectWithoutOptionalProperties({name:L.string().optional(),language:L.string(),code:L.string(),install:L.string().optional()}).extend(Ni);var slu=L.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var clu=L.objectWithoutOptionalProperties({name:L.string().optional(),sdk:slu,code:L.string()}).extend(Ni);var llu=L.union("type",{language:ulu,sdk:clu}).transform({transform:e=>{switch(e.type){case"language":return k$t.language(e);case"sdk":return k$t.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var flu=L.objectWithoutOptionalProperties({name:L.string().optional(),pathParameters:L.list(nlu).optional(),queryParameters:L.list(kna).optional(),headers:L.list(eaa).optional(),request:L.lazy(()=>VP).optional(),response:olu.optional(),codeSamples:L.list(llu)}).extend(Ni);var taa=L.union("type",{unknown:L.object({value:ilu}),full:flu}).transform({transform:e=>{switch(e.type){case"unknown":return gEe.unknown(e.value);case"full":return gEe.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var dlu=L.objectWithoutOptionalProperties({cursor:L.string(),nextCursor:L.property("next_cursor",L.string()),results:L.string()});var plu=L.objectWithoutOptionalProperties({offset:L.string(),results:L.string(),step:L.string().optional(),hasNextPage:L.string().optional()});var _lu=L.objectWithoutOptionalProperties({results:L.string()});var raa=L.union("type",{cursor:dlu,offset:plu,custom:_lu}).transform({transform:e=>{switch(e.type){case"cursor":return Tve.cursor(e);case"offset":return Tve.offset(e);case"custom":return Tve.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var iaa=L.union("type",{disabled:L.object({value:L.boolean().optional()})}).transform({transform:e=>{switch(e.type){case"disabled":return zHa.disabled(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var hlu=L.objectWithoutOptionalProperties({authed:L.boolean(),security:Vna.optional(),internal:L.boolean().optional(),idempotent:L.boolean().optional(),method:Wna,audiences:L.list(L.string()),path:L.string(),summary:L.string().optional(),operationId:L.string().optional(),tags:L.list(eH),pathParameters:L.list(Gna),queryParameters:L.list(Hna),headers:L.list(JKi),sdkName:nYt.optional(),generatedRequestName:L.string(),requestNameOverride:L.string().optional(),request:elu.optional(),response:Xna.optional(),errors:L.record(rYt,rlu),servers:L.list(Zna),examples:L.list(taa),pagination:raa.optional(),retries:iaa.optional()}).extend(Ni).extend(Vu).extend(Eu).extend(Xl);var naa=L.enum_(["GET","POST"]);var aaa=L.objectWithoutOptionalProperties({name:L.string().optional(),payload:L.lazy(()=>VP)}).extend(Ni);var ylu=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),sdkName:nYt.optional(),method:naa,summary:L.string().optional(),operationId:L.string(),tags:L.list(eH),headers:L.list(JKi),generatedPayloadName:L.string(),payload:L.lazy(()=>Dd),response:Xna.optional(),examples:L.list(aaa)}).extend(Ni).extend(Eu).extend(Xl);var blu=L.objectWithoutOptionalProperties({queryParameters:L.list(Hna),headers:L.list(JKi),pathParameters:L.list(Gna)});var vlu=L.enum_(["client","server"]);var glu=L.objectWithoutOptionalProperties({name:L.string(),origin:vlu,body:L.lazy(()=>Dd),methodName:L.string().optional()});var Olu=L.objectWithoutOptionalProperties({name:L.string(),url:L.string()});var Alu=L.objectWithoutOptionalProperties({messageType:L.string(),payload:L.lazy(()=>VP)}).extend(Ni);var mlu=L.objectWithoutOptionalProperties({name:L.string().optional(),queryParameters:L.list(kna).optional(),headers:L.list(eaa).optional(),messages:L.list(Alu)}).extend(Ni);var Plu=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),path:L.string(),groupName:KKi,summary:L.string().optional(),handshake:blu,messages:L.list(glu),servers:L.list(Olu),examples:L.list(mlu)}).extend(Ni).extend(Eu);var jlu=L.objectWithoutOptionalProperties({rootSchemas:L.record(kG,L.lazy(()=>Dd)),namespacedSchemas:L.record(Ucu,L.record(kG,L.lazy(()=>Dd)))});var wlu=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional()});var Elu=L.objectWithoutOptionalProperties({default:L.number().optional()});var Slu=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional()});var Mlu=L.objectWithoutOptionalProperties({default:L.string().optional(),pattern:L.string().optional(),format:L.string().optional(),minLength:L.number().optional(),maxLength:L.number().optional()});var Dlu=L.objectWithoutOptionalProperties({default:L.boolean().optional()});var Blu=L.union("type",{int:wlu,int64:Elu,uint:L.object({}),uint64:L.object({}),float:L.object({}),double:Slu,string:Mlu,datetime:L.object({}),date:L.object({}),base64:L.object({}),boolean:Dlu}).transform({transform:e=>{switch(e.type){case"int":return Th.int(e);case"int64":return Th.int64(e);case"uint":return Th.uint();case"uint64":return Th.uint64();case"float":return Th.float();case"double":return Th.double(e);case"string":return Th.string(e);case"datetime":return Th.datetime();case"date":return Th.date();case"base64":return Th.base64();case"boolean":return Th.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var YKi=L.objectWithoutOptionalProperties({schema:Blu}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp);var Ilu=L.list(L.record(HKi,L.list(L.string())));var Clu=L.objectWithoutOptionalProperties({header:L.string(),name:L.string().optional(),optional:L.boolean().optional(),env:L.string().optional(),schema:L.lazy(()=>Dd).optional()});var qlu=L.objectWithoutOptionalProperties({header:L.string(),name:L.string().optional(),env:L.string().optional(),schema:L.lazy(()=>Dd).optional()});var Lah=L.objectWithoutOptionalProperties({apiVersion:L.unknown().optional(),title:L.string().optional(),description:L.string().optional(),basePath:L.string().optional(),servers:L.list(UHa),websocketServers:L.list(UHa),groups:L.record(L.string(),xcu),tags:Kcu,hasEndpointsMarkedInternal:L.boolean(),endpoints:L.list(hlu),webhooks:L.list(ylu),channels:L.record(L.string(),Plu),groupedSchemas:jlu,variables:L.record(L.string(),YKi),nonRequestReferencedSchemas:L.set(kG),securitySchemes:L.record(HKi,Qcu),security:Ilu.optional(),globalHeaders:L.list(Clu).optional(),idempotencyHeaders:L.list(qlu).optional()});var aYt=L.objectWithoutOptionalProperties({schema:kG}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(Eu).extend(yp);var Tlu=L.union("type",{boolean:L.object({value:L.boolean()}),string:L.object({value:L.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Ww.boolean(e.value);case"string":return Ww.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var oaa=L.objectWithoutOptionalProperties({value:Tlu}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp);var Dd=L.union("type",{primitive:YKi,object:L.lazyObject(()=>Rlu),array:L.lazyObject(()=>zlu),map:L.lazyObject(()=>Nlu),optional:L.lazyObject(()=>Flu),enum:Qna,reference:aYt,literal:oaa,oneOf:L.object({value:L.lazy(()=>Ulu)}),nullable:L.lazyObject(()=>Qlu),unknown:yf}).transform({transform:e=>{switch(e.type){case"primitive":return ic.primitive(e);case"object":return ic.object(e);case"array":return ic.array(e);case"map":return ic.map(e);case"optional":return ic.optional(e);case"enum":return ic.enum(e);case"reference":return ic.reference(e);case"literal":return ic.literal(e);case"oneOf":return ic.oneOf(e.value);case"nullable":return ic.nullable(e);case"unknown":return ic.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var uaa=L.objectWithoutOptionalProperties({propertyKey:L.string(),allOfSchemaIds:L.list(kG),conflictingTypeSignatures:L.boolean()});var Rlu=L.objectWithoutOptionalProperties({allOf:L.list(aYt),properties:L.list(L.lazyObject(()=>Llu)),allOfPropertyConflicts:L.list(uaa),additionalProperties:L.boolean()}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(Eu).extend(yp).extend(eA);var saa=L.objectWithoutOptionalProperties({differentSchema:L.boolean()});var Llu=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>Dd),readonly:L.boolean().optional(),writeonly:L.boolean().optional(),conflict:L.record(kG,saa),generatedName:L.string(),nameOverride:L.string().optional(),audiences:L.list(L.string())}).extend(Vu);var zlu=L.objectWithoutOptionalProperties({value:L.lazy(()=>Dd)}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp).extend(eA);var Nlu=L.objectWithoutOptionalProperties({key:YKi,value:L.lazy(()=>Dd)}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(G$).extend(yp).extend(eA);var Flu=L.objectWithoutOptionalProperties({value:L.lazy(()=>Dd)}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp).extend(eA);var Qlu=L.objectWithoutOptionalProperties({value:L.lazy(()=>Dd)}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp).extend(eA);var Ulu=L.union("type",{discriminated:L.lazyObject(()=>Vlu),undiscriminated:L.lazyObject(()=>Wlu)}).transform({transform:e=>{switch(e.type){case"discriminated":return tYt.discriminated(e);case"undiscriminated":return tYt.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Vlu=L.objectWithoutOptionalProperties({discriminantProperty:L.string(),commonProperties:L.list(L.lazyObject(()=>Glu)),schemas:L.record(L.string(),L.lazy(()=>Dd))}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(G$).extend(Eu).extend(yp).extend(eA);var Glu=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>Dd)});var Wlu=L.objectWithoutOptionalProperties({schemas:L.list(L.lazy(()=>Dd))}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(G$).extend(Eu).extend(yp).extend(eA);var YLc={};Zt(YLc,{ArraySchemaWithExample:()=>dfu,Base64WithExample:()=>ufu,BooleanWithExample:()=>sfu,CommonPropertyWithExample:()=>Afu,DateWithExample:()=>ofu,DatetimeWithExample:()=>afu,DiscriminatedOneOfSchemaWithExample:()=>gfu,DoubleWithExample:()=>ifu,EndpointWithExample:()=>Wah,EnumSchemaWithExample:()=>lfu,FloatWithExample:()=>rfu,HeaderWithExample:()=>XKi,HttpErrorWithExample:()=>Xlu,Int64WithExample:()=>klu,IntWithExample:()=>Zlu,JsonRequestWithExample:()=>Jlu,JsonResponseWithExample:()=>laa,MapSchemaWithExample:()=>pfu,NamedFullExample:()=>mEe,NullableSchemaWithExample:()=>hfu,ObjectPropertyWithExample:()=>vfu,ObjectSchemaWithExample:()=>yfu,OneOfSchemaWithExample:()=>bfu,OptionalSchemaWithExample:()=>_fu,ParseFormUrlEncodedRequest:()=>$lu,ParseMultipartRequest:()=>Klu,ParseOctetStreamRequest:()=>xlu,PathParameterWithExample:()=>Hlu,PrimitiveSchemaValueWithExample:()=>cfu,PrimitiveSchemaWithExample:()=>daa,QueryParameterWithExample:()=>caa,RequestWithExample:()=>Ylu,ResponseWithExample:()=>faa,SchemaWithExample:()=>tA,StringSchemaWithExample:()=>nfu,Uint64WithExample:()=>tfu,UintWithExample:()=>efu,UnDiscriminatedOneOfSchemaWithExample:()=>Ofu,UnknownSchemaWithExample:()=>ffu,WebhookWithExample:()=>Gah,WebsocketHandshakeWithExample:()=>Vah});var mEe=L.objectWithoutOptionalProperties({name:L.string().optional(),value:L.unknown()}).extend(Ni);var caa=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>tA),parameterNameOverride:L.string().optional(),explode:L.boolean().optional()}).extend(Ni).extend(Vu).extend(Eu);var XKi=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>tA),env:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ni).extend(Vu).extend(Eu);var Vah=L.objectWithoutOptionalProperties({queryParameters:L.list(caa),headers:L.list(XKi)});var Hlu=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>tA),variableReference:L.string().optional(),parameterNameOverride:L.string().optional(),explode:L.boolean().optional()}).extend(Ni).extend(Vu).extend(Eu);var xlu=L.objectWithoutOptionalProperties({}).extend(xna).extend(iYt);var Klu=L.objectWithoutOptionalProperties({}).extend(Kna).extend(iYt);var Jlu=L.objectWithoutOptionalProperties({schema:L.lazy(()=>tA),contentType:L.string().optional(),fullExamples:L.list(mEe).optional(),additionalProperties:L.boolean()}).extend(Ni).extend(Eu).extend(iYt);var $lu=L.objectWithoutOptionalProperties({schema:L.lazy(()=>tA),contentType:L.string().optional(),fullExamples:L.list(mEe).optional(),additionalProperties:L.boolean()}).extend(Ni).extend(Eu).extend(iYt);var Ylu=L.union("type",{octetStream:xlu,multipart:Klu,json:Jlu,formUrlEncoded:$lu}).transform({transform:e=>{switch(e.type){case"octetStream":return ZG.octetStream(e);case"multipart":return ZG.multipart(e);case"json":return ZG.json(e);case"formUrlEncoded":return ZG.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var laa=L.objectWithoutOptionalProperties({schema:L.lazy(()=>tA),responseProperty:L.string().optional(),fullExamples:L.list(mEe).optional()}).extend(Ni).extend(Eu).extend(AEe);var faa=L.union("type",{file:Jna,json:laa,text:$Ki,bytes:Yna,streamingSse:laa,streamingText:$Ki,streamingJson:laa}).transform({transform:e=>{switch(e.type){case"file":return O0.file(e);case"json":return O0.json(e);case"text":return O0.text(e);case"bytes":return O0.bytes(e);case"streamingSse":return O0.streamingSse(e);case"streamingText":return O0.streamingText(e);case"streamingJson":return O0.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Xlu=L.objectWithoutOptionalProperties({statusCode:rYt,schema:L.lazy(()=>tA),fullExamples:L.list(mEe).optional()}).extend(Ni).extend(yf).extend(Eu);var Wah=L.objectWithoutOptionalProperties({authed:L.boolean(),security:Vna.optional(),internal:L.boolean().optional(),idempotent:L.boolean().optional(),method:Wna,audiences:L.list(L.string()),path:L.string(),summary:L.string().optional(),operationId:L.string().optional(),tags:L.list(eH),pathParameters:L.list(Hlu),queryParameters:L.list(caa),headers:L.list(XKi),sdkName:nYt.optional(),generatedRequestName:L.string(),requestNameOverride:L.string().optional(),request:Ylu.optional(),response:faa.optional(),errors:L.record(rYt,Xlu),servers:L.list(Zna),examples:L.list(taa),pagination:raa.optional(),retries:iaa.optional()}).extend(Ni).extend(Vu).extend(Eu).extend(Xl);var Gah=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),sdkName:nYt.optional(),method:naa,summary:L.string().optional(),operationId:L.string(),tags:L.list(eH),headers:L.list(XKi),generatedPayloadName:L.string(),payload:L.lazy(()=>tA),response:faa.optional(),examples:L.list(aaa)}).extend(Ni).extend(Eu).extend(Xl);var Zlu=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional(),example:L.number().optional()});var klu=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var efu=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var tfu=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var rfu=L.objectWithoutOptionalProperties({example:L.number().optional()});var ifu=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional(),example:L.number().optional()});var nfu=L.objectWithoutOptionalProperties({default:L.string().optional(),pattern:L.string().optional(),format:L.string().optional(),minLength:L.number().optional(),maxLength:L.number().optional(),example:L.string().optional()});var afu=L.objectWithoutOptionalProperties({example:L.string().optional()});var ofu=L.objectWithoutOptionalProperties({example:L.string().optional()});var ufu=L.objectWithoutOptionalProperties({example:L.string().optional()});var sfu=L.objectWithoutOptionalProperties({default:L.boolean().optional(),example:L.boolean().optional()});var cfu=L.union("type",{int:Zlu,int64:klu,uint:efu,uint64:tfu,float:rfu,double:ifu,string:nfu,datetime:afu,date:ofu,base64:ufu,boolean:sfu}).transform({transform:e=>{switch(e.type){case"int":return Jn.int(e);case"int64":return Jn.int64(e);case"uint":return Jn.uint(e);case"uint64":return Jn.uint64(e);case"float":return Jn.float(e);case"double":return Jn.double(e);case"string":return Jn.string(e);case"datetime":return Jn.datetime(e);case"date":return Jn.date(e);case"base64":return Jn.base64(e);case"boolean":return Jn.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var daa=L.objectWithoutOptionalProperties({schema:cfu}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp);var lfu=L.objectWithoutOptionalProperties({default:xKi.optional(),values:L.list(xKi),example:L.string().optional()}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(Eu).extend(yp).extend(eA);var ffu=L.objectWithoutOptionalProperties({example:L.unknown()}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp);var tA=L.union("type",{primitive:daa,object:L.lazyObject(()=>yfu),array:L.lazyObject(()=>dfu),map:L.lazyObject(()=>pfu),optional:L.lazyObject(()=>_fu),enum:lfu,reference:aYt,literal:oaa,oneOf:L.object({value:L.lazy(()=>bfu)}),nullable:L.lazyObject(()=>hfu),unknown:ffu}).transform({transform:e=>{switch(e.type){case"primitive":return ai.primitive(e);case"object":return ai.object(e);case"array":return ai.array(e);case"map":return ai.map(e);case"optional":return ai.optional(e);case"enum":return ai.enum(e);case"reference":return ai.reference(e);case"literal":return ai.literal(e);case"oneOf":return ai.oneOf(e.value);case"nullable":return ai.nullable(e);case"unknown":return ai.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var dfu=L.objectWithoutOptionalProperties({value:L.lazy(()=>tA),example:L.list(L.unknown()).optional()}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp).extend(eA);var pfu=L.objectWithoutOptionalProperties({key:daa,value:L.lazy(()=>tA),example:L.unknown().optional()}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(G$).extend(yp).extend(eA);var _fu=L.objectWithoutOptionalProperties({value:L.lazy(()=>tA)}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp).extend(eA);var hfu=L.objectWithoutOptionalProperties({value:L.lazy(()=>tA)}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp).extend(eA);var yfu=L.objectWithoutOptionalProperties({allOf:L.list(aYt),properties:L.list(L.lazyObject(()=>vfu)),allOfPropertyConflicts:L.list(uaa),fullExamples:L.list(mEe).optional(),additionalProperties:L.boolean()}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(Eu).extend(yp).extend(eA);var vfu=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>tA),readonly:L.boolean().optional(),writeonly:L.boolean().optional(),audiences:L.list(L.string()),conflict:L.record(kG,saa),nameOverride:L.string().optional(),generatedName:L.string()}).extend(Vu);var bfu=L.union("type",{discriminated:L.lazyObject(()=>gfu),undiscriminated:L.lazyObject(()=>Ofu)}).transform({transform:e=>{switch(e.type){case"discriminated":return Rve.discriminated(e);case"undiscriminated":return Rve.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var gfu=L.objectWithoutOptionalProperties({discriminantProperty:L.string(),commonProperties:L.list(L.lazyObject(()=>Afu)),schemas:L.record(L.string(),L.lazy(()=>tA))}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(G$).extend(Eu).extend(yp).extend(eA);var Afu=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>tA)});var Ofu=L.objectWithoutOptionalProperties({schemas:L.list(L.lazy(()=>tA))}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(G$).extend(Eu).extend(yp).extend(eA);var Hah=/^(\d+)/,paa=/^[a-zA-Z][a-zA-Z0-9_]*$/,xah={"<":"LESS_THAN",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL_TO","<=":"LESS_THAN_OR_EQUAL_TO","!=":"NOT_EQUALS","=":"EQUAL_TO","==":"EQUAL_TO","*":"ALL","":"EMPTY",'""':"EMPTY_STRING","-":"HYPHEN","|":"PIPE",".":"DOT","/":"SLASH"};function lbn(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let o=Math.floor(e/10),c=e%10;return c===0?i[o]:`${i[o]}_${t[c]}`}if(e<1e3){let o=Math.floor(e/100),c=e%100;return c===0?`${t[o]}_hundred`:`${t[o]}_hundred_${lbn(c)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${lbn(a)}`}function LHa(e){let t=e.match(Hah);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=lbn(n);return i.length>0?`${a}_${i}`:a}}}function _aa(e){let t=LHa(e),r=xah[e];return t!=null?F0(nu(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":F0(nu(e)))}function H$(e,t){return e.type==="primitive"&&t.type==="primitive"?Kah(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?dTD(e.values,t.values):e.type==="array"&&t.type==="array"?H$(e.value,t.value):e.type==="unknown"&&t.type==="unknown"?!0:e.type==="reference"&&t.type==="reference"?e.schema===t.schema:e.type==="optional"&&t.type==="optional"?H$(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?pTD(e.value,t.value):e.type==="object"&&t.type==="object"?_TD(e,t):e.type==="map"&&t.type==="map"?Kah(e.key.schema,t.key.schema)&&H$(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function Kah(e,t){return e.type===t.type}function dTD(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return NT(r,i)}function pTD(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,i])=>{let n=t.schemas[r];return n==null?!1:H$(i,n)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,i)=>{let n=t.schemas[i];return n==null?!1:H$(r,n)}):!1}function _TD(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(i=>[i.key,i.schema]));return Object.entries(t.properties).every(([i,n])=>{let a=r[i];return a==null?!1:H$(a,n.schema)})}function hM(e){switch(e){case rF.Deprecated:return"deprecated";case rF.Beta:return"pre-release";case rF.GenerallyAvailable:return"generally-available";default:return}}function hTD(e){let t=e.find(i=>typeof i=="object"&&i.type==="namespace"),r=e.filter(i=>typeof i=="string"||i.type!=="namespace");return t?[t,...r]:r}function Jah(e){let t=e?hTD(e):void 0;if(t==null||t.length===0)return Rln;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(nu(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(nu(n.name)):r.push(n.name,Rln);break}default:gt(n.type)}else gt(n);return r.join("/")}function H3t(e){return ns.of(`${Jah(e)}.yml`)}function XLc({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Rln:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,Jah(r))}function $ah({sdkName:e,namespaceOverride:t}){return ns.of(`${XLc({sdkName:e,namespaceOverride:t})}.yml`)}function Yah({location:e,namespaceOverride:t}){return t!=null?PB(ns.of(t),e):e}function mfu(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:gt(e.type)}}function IQi(e){switch(e.type){case"object":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":case"primitive":return e.groupName??void 0;case"oneOf":return e.value.groupName??void 0;case"unknown":return;default:gt(e)}}function Gy(e){return typeof e=="string"?e:e.type}function haa(e){if(typeof e!="string")return e.docs}function VHa(e){if(typeof e!="string")return e.default}function ZLc(e){if(typeof e!="string")return e.validation}function yaa(e){let t=e.match(/^optional<\s*nullable<\s*(.+)\s*>\s*>$/);if(t!=null&&t[1]!=null)return t[1].trim();let r=e.match(/^nullable<\s*(.+)\s*>$/);return r!=null&&r[1]!=null?r[1].trim():e}function Zah(e){let t=Gy(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?Xah(e):{...e,type:Xah(e.type)}}function Xah(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function fbn(e){return Gy(e).startsWith("optional<")?e:typeof e=="string"?kah(e):{...e,type:kah(e.type)}}function kah(e){return e.startsWith("optional<")?e:`optional<${e}>`}var yTD=-2147483648,bTD=2147483647,vTD=-17976931348623157e292,gTD=17976931348623157e292;function Pl({schema:e,fileContainingReference:t,declarationFile:r=t,context:i,namespace:n,declarationDepth:a}){switch(i.shouldMarkSchemaAsReferenced()&&i.markSchemaAsReferenced(e,n),e.type){case"primitive":return Pfu(e);case"array":return tVc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return rVc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return eVc({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return nVc();case"optional":return jfu({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return iVc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return MTD({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,aVc(e);case"object":return DTD({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return BTD({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:gt(e)}}function Pfu(e){switch(e.schema.type){case"string":return mTD({description:e.description,schema:e.schema});case"int":return PTD({description:e.description,schema:e.schema});case"float":return jTD({description:e.description,schema:e.schema});case"double":return wTD({description:e.description,schema:e.schema});case"boolean":return OTD({description:e.description,schema:e.schema});case"int64":return ATD({description:e.description,schema:e.schema})}let t=e.schema._visit({int:()=>"integer",int64:()=>"long",uint:()=>"uint",uint64:()=>"uint64",float:()=>"double",double:()=>"double",string:()=>"string",datetime:()=>"datetime",date:()=>"date",base64:()=>"base64",boolean:()=>"boolean",_other:()=>"unknown"});return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:hM(e.availability)}:{}}}function OTD({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function ATD({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function mTD({description:e,schema:t}){let r="string",i=ETD(t);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function PTD({description:e,schema:t}){let r="integer",i=eoh(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function jTD({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function wTD({description:e,schema:t}){let r="double",i=eoh(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function ETD(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=STD(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function STD(e){switch(e){case"date":case"date-time":case"password":case"byte":case"bytes":case"binary":case"email":case"uuid":case"uri":case"hostname":case"ipv4":case"ipv6":return e;default:return}}function eoh(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:o}=e;if(r=kLc(r,t),i=kLc(i,t),n=kLc(n,t),!(r==null&&i==null&&a==null&&o==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:o,multipleOf:n}}function kLc(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[yTD,bTD]:[vTD,gTD];return e<r||e>i?void 0:e}function eVc({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=ITD(n)??e.schema,o=IQi(n),c=CTD(n),s=wfu({context:r,fileContainingReference:t,declarationFile:H3t(o),type:a});return n.type==="nullable"&&(s=r.options.wrapReferencesToNullableInOptional?`optional<${s}>`:`nullable<${s}>`),n.type==="optional"&&!s.startsWith("optional<")&&(s=`optional<${s}>`),e.description==null&&c==null?s:{type:s,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:hM(e.availability)}:{}}}function tVc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Pl({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=`list<${Gy(o)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:hM(e.availability)}:{},type:c}}function rVc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Pfu(e.key),c=Pl({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),d=e.encoding!=null?mfu(e.encoding):void 0,s=`map<${Gy(o)}, ${Gy(c)}>`;if(e.description==null&&d==null&&e.title==null)return s;let u={type:s};return e.description!=null&&(u.docs=e.description),e.encoding!=null&&(u.encoding=d),e.availability!=null&&(u.availability=hM(e.availability)),u}function iVc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.options.respectNullableSchemas)return jfu({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let o=Pl({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=Gy(o),d=haa(o),s=VHa(o),u=ZLc(o),l=Zah(c);if(i.options.wrapReferencesToNullableInOptional&&(l=fbn(l)),e.availability==null&&e.description==null&&d==null&&s==null&&u==null&&e.title==null)return l;let p=typeof l=="string"?{type:l}:l;return(e.description!=null||d!=null)&&(p.docs=e.description??d),s!=null&&(p.default=s),u!=null&&(p.validation=u),e.availability!=null&&(p.availability=hM(e.availability)),p}function jfu({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Pl({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=Gy(o),d=haa(o),s=VHa(o),u=ZLc(o),l=fbn(c);if(e.availability==null&&e.description==null&&d==null&&s==null&&u==null&&e.title==null)return l;let p=typeof l=="string"?{type:l}:l;return(e.description!=null||d!=null)&&(p.docs=e.description??d),s!=null&&(p.default=s),u!=null&&(p.validation=u),e.availability!=null&&(p.availability=hM(e.availability)),p}function nVc(){return"unknown"}function aVc(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:gt(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:hM(e.availability)}:{}}}function MTD({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=WHa(e,n),o=e.nameOverride??e.generatedName;i.builder.addType(r,{name:o,schema:a.schema});let c=wfu({type:o,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return c;let d={type:c};return e.description!=null&&(d.docs=e.description),e.default!=null&&(d.default=e.default.value),e.availability!=null&&(d.availability=hM(e.availability)),d}function DTD({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=oVc({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:o.schema});let d=wfu({type:c,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:hM(e.availability)}:{}}}function BTD({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=uVc({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:o.schema});let d=wfu({type:c,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{...e.title!=null?{"display-name":e.title}:{},type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:hM(e.availability)}:{}}}function wfu({type:e,fileContainingReference:t,declarationFile:r,context:i}){if(r===t)return e;let n=i.builder.addImport({file:t,fileToImport:r});return n!=null?`${n}.${e}`:e}function ITD(e){return ic._visit(e,{primitive:t=>t.nameOverride??t.generatedName,object:t=>t.nameOverride??t.generatedName,array:t=>t.nameOverride??t.generatedName,map:t=>t.nameOverride??t.generatedName,enum:t=>t.nameOverride??t.generatedName,reference:t=>t.nameOverride??t.generatedName,literal:t=>t.nameOverride??t.generatedName,oneOf:t=>t.nameOverride??t.generatedName,optional:t=>t.nameOverride??t.generatedName,nullable:t=>t.nameOverride??t.generatedName,unknown:t=>t.nameOverride??t.generatedName,_other:()=>{}})}function CTD(e){return ic._visit(e,{primitive:t=>t.title,object:t=>t.title,array:t=>t.title,map:t=>t.title,enum:t=>t.title,reference:t=>t.title,literal:t=>t.title,oneOf:t=>t.title,optional:t=>t.title,nullable:t=>t.title,unknown:t=>{},_other:()=>{}})}var bR;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(bR||(bR={}));function CQi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:gt(e)}}function roh({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=RTD(e);break;case"array":a=qTD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=TTD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=zTD({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=FTD(e.nameOverride,e.generatedName);break;case"optional":a=noh({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=NTD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=WHa(e,n);break;case"literal":a=QTD(e,e.nameOverride,e.generatedName);break;case"object":a=oVc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=uVc({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:gt(e)}return a}function oVc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(bR.Request)&&t.options.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),o=!1,c={},d=new Set;for(let _ of e.properties){if(_.readonly&&(o=!0),a&&_.readonly)continue;if(Object.keys(_.conflict).length>0){if(Object.entries(_.conflict).every(([g,m])=>!m.differentSchema))continue;Object.entries(_.conflict).forEach(([g])=>{sVc({property:_.key,schemaId:g,context:t,namespace:i}).forEach(j=>{d.add(j)})})}let h=Pl({schema:_.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),y=_.audiences,b=_.nameOverride,v=hM(_.availability),O=WTD(_);c[_.key]=VTD({typeReference:h,audiences:y,name:b,availability:v,propertyAccess:O})}let s=new Set;for(let _ of e.allOfPropertyConflicts)_.allOfSchemaIds.forEach(h=>d.add(h)),_.conflictingTypeSignatures&&s.add(_.propertyKey);let u=[];for(let _ of e.allOf){let h=Efu({schema:_.schema,context:t,namespace:i});if(h==null||d.has(_.schema)||d.has(h))continue;let y=Pl({schema:ic.reference(_),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(yaa(Gy(y)))}for(let _ of d){let h=baa(t,_,i);for(let y of h.properties)c[y.key]==null&&(s.has(y.key)&&(c[y.key]="unknown"),c[y.key]=Pl({schema:y.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let y of h.allOf){if(d.has(y.schema))continue;let b=Pl({schema:ic.reference(y),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(yaa(Gy(b)))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([_,h])=>LTD(_)?[_,typeof h=="string"?{type:h,name:`_${_}`}:{...h,name:`_${_}`}]:[_,h]))};u.length>0&&(l.extends=u),e.additionalProperties&&(l["extra-properties"]=!0),e.availability!=null&&(l.availability=hM(e.availability)),e.source!=null&&(l.source=CQi(e.source)),l.inline=cVc(e,n);let p=e.nameOverride??e.generatedName;return{name:o&&t.options.respectReadonlySchemas&&!a?`${p}Read`:p,schema:l}}function sVc({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return sVc({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:o}=baa(r,t,i),c=a.some(s=>s.key===e),d=[...o.flatMap(s=>sVc({property:e,context:r,schemaId:s.schema,namespace:i}))];if(c||d.length>0)return[t,...d]}return[]}function ioh(e,t,r){return t.type==="object"?{properties:t.properties,allOf:t.allOf}:t.type==="reference"?baa(e,t.schema,r):t.type==="nullable"?ioh(e,t.value,r):{properties:[],allOf:[]}}function baa(e,t,r){let i=e.getSchema(t,r);return i==null?{properties:[],allOf:[]}:ioh(e,i,r)}function qTD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:tVc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function TTD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:rVc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function RTD(e){let t=Pfu(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...i}=t;return{name:e.nameOverride??e.generatedName,schema:{...i}}}function toh(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function WHa(e,t){let r={enum:e.values.map(a=>{let o=a.nameOverride??a.generatedName,c=a.value;if(o===c&&a.description==null&&(a.casing==null||toh(a.casing)))return o;let d={value:a.value};if(o!==c&&(d.name=o),a.description!=null&&(d.docs=a.description),a.casing!=null&&!toh(a.casing)){let s={},u=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,u=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,u=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,u=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,u=!0),u&&(d.casing=s)}return d})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=cVc(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?CQi(e.source):void 0};for(let a of r.enum){let o=typeof a=="string"?a:a.name??a.value;i.has(o.toLowerCase())||(n.enum.push(a),i.add(o.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function zTD({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:eVc({schema:e,context:t,fileContainingReference:r,namespace:i})}}function NTD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.options.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:iVc({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:noh({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function noh({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:jfu({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function FTD(e,t){return{name:e??t,schema:nVc()}}function QTD(e,t,r){return{name:t??r,schema:aVc(e)}}function uVc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?mfu(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=Pl({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let d={};for(let[s,u]of Object.entries(e.schemas))d[s]=Pl({schema:u,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?hM(e.availability):void 0,union:d,encoding:a,source:e.source!=null?CQi(e.source):void 0}}}let o=[];for(let c of e.schemas)o.push(Pl({schema:c,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:o,encoding:a,source:e.source!=null?CQi(e.source):void 0,inline:cVc(e,n)}}}var UTD=/^[0-9]/;function LTD(e){return UTD.test(e)}function Efu({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?Efu({context:t,schema:i.schema,namespace:r}):e}function VTD({typeReference:e,audiences:t,name:r,availability:i,propertyAccess:n}){return t.length===0&&r==null&&i==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{},...n!=null?{access:n}:{}}}function cVc(e,t){return e.inline===!0||t>0?!0:void 0}function WTD(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return WB.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return WB.ObjectPropertyAccess.WriteOnly}}function aoh(e){let t=e.replace(/^x-|^X-/,"");return nu(t)}function ooh(e){if(e.authOverrides!=null){for(let[r,i]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:i});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,i]of Object.entries(e.ir.securitySchemes))if(i.type==="basic"){let n={scheme:"basic"};i.usernameVariableName!=null&&(n.username===void 0?n.username={name:i.usernameVariableName}:n.username.name=i.usernameVariableName),i.usernameEnvVar!=null&&(n.username===void 0?n.username={env:i.usernameEnvVar}:n.username.env=i.usernameEnvVar),i.passwordVariableName!=null&&(n.password===void 0?n.password={name:i.passwordVariableName}:n.password.name=i.passwordVariableName),i.passwordEnvVar!=null&&(n.password===void 0?n.password={env:i.passwordEnvVar}:n.password.env=i.passwordEnvVar),e.builder.addAuthScheme({name:r,schema:n}),t||(e.builder.setAuth(r),t=!0)}else if(i.type==="bearer"){let n={scheme:"bearer"};i.tokenVariableName!=null&&(n.token===void 0?n.token={name:i.tokenVariableName}:n.token.name=i.tokenVariableName),i.tokenEnvVar!=null&&(n.token===void 0?n.token={env:i.tokenEnvVar}:n.token.env=i.tokenEnvVar),e.builder.addAuthScheme({name:r,schema:n}),t||(e.builder.setAuth(r),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??aoh(i.headerName),env:i.headerEnvVar}});else{let n={header:i.headerName,name:i.headerVariableName??"apiKey",type:"string"};i.headerEnvVar!=null&&(n.env=i.headerEnvVar),i.prefix!=null&&(n.prefix=i.prefix),e.builder.addAuthScheme({name:r,schema:n}),e.builder.setAuth(r),t=!0}else if(i.type==="oauth"){let n={scheme:"bearer"};e.builder.addAuthScheme({name:r,schema:n}),t||(e.builder.setAuth(r),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(ns.of("__package__.yml"),{name:"OauthScope",schema:WHa(i.scopesEnum,0).schema})}}function oYt({header:e,context:t,fileContainingReference:r,namespace:i}){let n=Pl({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=Gy(n),o=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:nu(o);if(e.description==null&&e.name===c&&e.env==null&&e.availability==null)return a;let d={type:a};return c!==e.name&&(d.name=c),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=hM(e.availability)),d}function Sfu({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=Pl({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return Gy(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:Gy(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=hM(e.availability)),a}function Dfu({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=lVc({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=Gy(n.value),o=VHa(n.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let c={type:a};return o!=null&&(c.default=o),n.allowMultiple&&(c["allow-multiple"]=!0),e.description!=null&&(c.docs=e.description),e.parameterNameOverride!=null&&(c.name=e.parameterNameOverride),e.availability!=null&&(c.availability=hM(e.availability)),GTD(n.value)&&n.value.validation!==void 0&&(c.validation=n.value.validation),c.default==null&&c["allow-multiple"]==null&&c.docs==null&&c.name==null&&c.availability==null&&c.validation==null?a:c}function lVc({schema:e,context:t,fileContainingReference:r,namespace:i}){if(e.type==="reference"){let n=t.getSchema(e.schema,i);if(n==null)return;if(n.type==="array")return{value:Pl({schema:ic.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:ns.of(Qb),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,d]of Object.entries(n.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(o=!0),d.type==="literal"&&d.value.type==="string"&&(paa.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:_aa(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[c,d]=n.value.schemas;if(c!=null&&d!=null&&Mfu({array:c,primitive:d}))return{value:Pl({schema:ic.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&d!=null&&Mfu({array:c,primitive:d}))return{value:Pl({schema:ic.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[c,d]of Object.entries(n.value.schemas))return lVc({schema:d,context:t,fileContainingReference:r,namespace:i})}else if(t.options.objectQueryParameters)return{value:Pl({schema:e,context:t,fileContainingReference:r,declarationFile:ns.of(Qb),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){let n=e.type==="optional"?ic.optional:ic.nullable;if(e.value.type==="reference"){let a=t.getSchema(e.value.schema,i);if(a==null)return;if(a.type==="array")return{value:Pl({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a.value,description:e.description??a.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:ns.of(Qb),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.options.objectQueryParameters)return{value:Pl({schema:e,context:t,fileContainingReference:r,declarationFile:ns.of(Qb),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:Pl({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,d]of Object.entries(e.value.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(o=!0),d.type==="literal"&&d.value.type==="string"&&(paa.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:_aa(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[c,d]=e.value.value.schemas;if(c!=null&&d!=null&&Mfu({array:c,primitive:d}))return{value:Pl({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&d!=null&&Mfu({array:d,primitive:c}))return{value:Pl({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}if(t.options.objectQueryParameters)return{value:Pl({schema:e,context:t,fileContainingReference:r,declarationFile:ns.of(Qb),namespace:i,declarationDepth:0}),allowMultiple:!1};for(let[c,d]of Object.entries(e.value.value.schemas))return lVc({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.options.objectQueryParameters?{value:Pl({schema:e,context:t,fileContainingReference:r,declarationFile:ns.of(Qb),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:Pl({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:Pl({schema:ic.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:Pl({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function Mfu({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function GTD(e){return typeof e=="object"&&e!==null&&"type"in e}function uoh({websocketExample:e,context:t}){let r={messages:[]};e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=HTD(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=xTD({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=ZKi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function HTD(e){let t={};return e.forEach(r=>{let i=ZKi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function xTD({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=ZKi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function ZKi(e){switch(e.type){case"primitive":return soh(e.value);case"object":return coh(e.properties);case"array":return KTD(e.value);case"map":return JTD(e.value);case"oneOf":return $TD(e.value);case"enum":return e.value;case"literal":return YTD(e.value);case"unknown":return ZKi(e.value);case"null":return null;default:gt(e)}}function soh(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:gt(e)}}function coh(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,ZKi(r)]))}function KTD(e){return e.map(t=>ZKi(t))}function JTD(e){return Object.fromEntries(e.map(t=>[soh(t.key),ZKi(t.value)]))}function $TD(e){return e.type==="discriminated"?coh(e.value):ZKi(e.value)}function YTD(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:gt(e)}}function GHa(e){try{let r=new URL(e).pathname.split("/").filter(i=>i.length>0);if(r.length>0)return r[r.length-1]}catch{}}function Bfu(e){try{return new URL(e).protocol.replace(":","")}catch{return}}function Ifu(e,t,r=!1){let i=GHa(t);return r&&i!=null?i:e!=null&&i!=null?`${e}_${i}`:i??e??"websocket"}function qQi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function Cfu(e,t){return t??(e?.groupName!=null?qQi(e.groupName):void 0)}function loh({channel:e,context:t,declarationFile:r}){let i=e.servers[0],n=i!=null?t.options.groupEnvironmentsByHost?t.getUrlId(i.url)??Ifu(i.name,i.url,!0):i.name:void 0;t.logger.debug(`[buildChannel] Channel path="${e.path}", server name="${i?.name}", server url="${i?.url}", resolved urlId="${n}" (from collision map: ${t.getUrlId(i?.url??"")!=null})`);let a={path:e.path,url:n,auth:!1};e.audiences!=null&&e.audiences.length>0&&(a.audiences=e.audiences),e.summary!=null&&(a["display-name"]=e.summary),e.description!=null&&(a.docs=e.description);let o=qQi(e.groupName),c={};if(e.handshake.pathParameters.length>0)for(let u of e.handshake.pathParameters)c[u.name]=Sfu({pathParameter:u,context:t,fileContainingReference:r,namespace:o});Object.keys(c).length>0&&(a["path-parameters"]=c);let d={};if(e.handshake.queryParameters.length>0)for(let u of e.handshake.queryParameters){let l=Dfu({queryParameter:u,context:t,fileContainingReference:r,namespace:o});l!=null&&(d[u.name]=l)}Object.keys(d).length>0&&(a["query-parameters"]=d);let s={};if(e.handshake.headers.length>0)for(let u of e.handshake.headers){let l=oYt({header:u,context:t,fileContainingReference:r,namespace:o});s[u.name]=l}Object.keys(s).length>0&&(a.headers=s),t.builder.addChannel(r,{channel:a});for(let u of e.messages){let l={origin:u.origin,body:Pl({schema:u.body,context:t,fileContainingReference:r,namespace:o,declarationDepth:0})};u.methodName!=null&&(l["method-name"]=u.methodName),t.builder.addChannelMessage(r,{messageId:u.name,message:l})}for(let u of e.examples){let l=uoh({context:t,websocketExample:u});t.builder.addChannelExample(r,{example:l})}}function fVc(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var PEe="Base",poh="Default";function foh(e){try{return new URL(e).hostname}catch{return}}function doh(e){return e??poh}function XTD(e,t){let r=new Map;for(let i of e){if(fVc(i)||!("url"in i)||!i.url)continue;let n=foh(i.url)??i.url;r.has(n)||r.set(n,{environmentName:doh(i.name),httpServers:[],websocketServers:[]}),r.get(n)?.httpServers.push({name:i.name,url:i.url,audiences:i.audiences})}for(let i of t){let n=foh(i.url)??i.url;r.has(n)||r.set(n,{environmentName:doh(i.name),httpServers:[],websocketServers:[]}),r.get(n)?.websocketServers.push(i)}return r}function dbn(e){return Object.entries(e).reduce((t,[r,i])=>(jve(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function _oh(e){if(e.environmentOverrides!=null){for(let[v,O]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:v,schema:O});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[],i=e.ir.servers.some(v=>fVc(v)),n=e.ir.servers;for(let v of n)if(fVc(v)){let O={urls:{}};for(let[A,g]of Object.entries(v.urls))O.urls[A]=g.url;v.name&&(t[v.name]=O)}else if("url"in v&&v.url){let O=v.audiences?{url:v.url,audiences:v.audiences}:v.url;if(v.name==null){r.push(O);continue}t[v.name]=O}let a={},o={},c=[];for(let v of e.ir.endpoints)for(let O of v.servers){if(O.url==null&&O.name!=null){a[O.name]||(a[O.name]=[]);continue}if(O.url==null)continue;let A=O.audiences?{url:O.url,audiences:O.audiences}:O.url;if(O.name==null){c.push(A);continue}a[O.name]||(a[O.name]=[]),a[O.name]?.push({url:O.url,audiences:O.audiences}),o[O.name]=A}let d={},s=[];for(let v of e.ir.websocketServers){e.logger.debug(`[buildEnvironments] Processing WebSocket server: name="${v.name}", url="${v.url}"`);let O=v.audiences?{url:v.url,audiences:v.audiences}:v.url;if(v.name==null){s.push(O);continue}d[v.name]=O}let u=Object.keys(t).length,l=u>0,p=Object.keys(o).length>0,_=Object.keys(a).some(v=>a[v]?.length===0),h=Object.keys(d).length>0;if(e.options.groupEnvironmentsByHost&&h&&(l||e.ir.servers.length>0)){let v=Object.entries(d).map(([A,g])=>({name:A,url:typeof g=="string"?g:g.url,audiences:typeof g=="string"?void 0:g.audiences})),O=XTD(n,v);if(O.size>0){let A=!0;for(let[g,m]of O.entries()){let j={},S=[...m.httpServers.map(D=>({...D,isHttp:!0})),...m.websocketServers.map(D=>({...D,isHttp:!1}))],w=new Map;for(let D of S){let B=GHa(D.url),R=Bfu(D.url);B&&R&&(w.has(B)||w.set(B,new Set),w.get(B)?.add(R))}if(m.httpServers.length>0){let D=m.httpServers[0];D!=null&&(j[PEe]=D.url,e.setUrlId(D.url,PEe));for(let B=1;B<m.httpServers.length;B++){let R=m.httpServers[B];if(R!=null){let N=GHa(R.url),z=Bfu(R.url),F=N?w.get(N):void 0,U=F&&F.size>1,k=U&&z!=="https"?`${N}_${z}`:N||`Http${B+1}`;e.logger.debug(`[buildEnvironments] HTTP server: url="${R.url}", pathSegment="${N}", protocol="${z}", hasCollision=${U}, urlId="${k}"`),j[k]=R.url,e.setUrlId(R.url,k)}}}for(let D of m.websocketServers){let B=GHa(D.url),R=Bfu(D.url),N=B?w.get(B):void 0,z=N&&N.size>1,F=z?`${B}_${R}`:Ifu(D.name,D.url,!0);e.logger.debug(`[buildEnvironments] WebSocket server: name="${D.name}", url="${D.url}", pathSegment="${B}", protocol="${R}", hasCollision=${z}, urlId="${F}"`),j[F]=D.url,e.setUrlId(D.url,F)}if(Object.keys(j).length>1)e.builder.addEnvironment({name:m.environmentName,schema:{urls:j}});else if(Object.keys(j).length===1){let D=Object.values(j)[0];D!=null&&e.builder.addEnvironment({name:m.environmentName,schema:D})}A&&(e.builder.setDefaultEnvironment(m.environmentName),Object.keys(j).length>1&&e.builder.setDefaultUrl(PEe),A=!1)}return}}if(!l&&!p&&h&&e.ir.servers.length===0){for(let[v,O]of Object.entries(d))e.builder.addEnvironment({name:v,schema:O});e.builder.setDefaultEnvironment(Object.keys(d)[0]),e.builder.setDefaultUrl(PEe);return}if(c.length>0&&e.logger.debug(`Skipping endpoint level servers ${c.map(v=>typeof v=="string"?v:v.url).join(", ")} because x-fern-server-name was not provided.`),!l){let v=e.ir.servers[0]?.url,O=e.ir.servers[0]?.audiences;if(v!=null){let A=O?{url:v,audiences:O}:v;t[poh]=A}}let y=Object.values(t).map(v=>typeof v=="string"?v:jve(v)?Object.values(v.urls)[0]:v.url),b=r.filter(v=>{let O=typeof v=="string"?v:v.url;return!y.includes(O)});if(b.length>0&&e.logger.debug(`Skipping top level servers ${b.map(v=>typeof v=="string"?v:v.url).join(", ")} because x-fern-server-name was not provided.`),i){let v=!0;for(let[O,A]of Object.entries(t))if(e.builder.addEnvironment({name:O,schema:A}),v){if(e.builder.setDefaultEnvironment(O),jve(A)){let g=Object.keys(A.urls)[0];g&&e.builder.setDefaultUrl(g)}v=!1}return}if(!p&&!_){let v=!0;for(let[O,A]of Object.entries(t))if(v){if(h){let g=typeof A=="string"?A:jve(A)?Object.values(A.urls)[0]:A.url;e.builder.addEnvironment({name:O,schema:{urls:{[PEe]:g??"",...dbn(d)}}})}else e.builder.addEnvironment({name:O,schema:A});e.builder.setDefaultEnvironment(O),v=!1}else if(h){let g=typeof A=="string"?A:jve(A)?Object.values(A.urls)[0]:A.url;e.builder.addEnvironment({name:O,schema:{urls:{[PEe]:g??"",...dbn(d)}}})}else e.builder.addEnvironment({name:O,schema:A});h&&e.builder.setDefaultUrl(PEe)}else if(u===1){let v=Object.keys(t)[0],O=Object.values(t)[0],A=typeof O=="string"?O:jve(O)?Object.values(O.urls)[0]:O.url;e.builder.addEnvironment({name:v,schema:{urls:{[PEe]:A??"",...dbn(o),...dbn(d)}}}),e.builder.setDefaultEnvironment(v),e.builder.setDefaultUrl(PEe)}else{let v=new Map;for(let O of e.ir.endpoints)for(let A of O.servers)if(A.url!=null&&A.name!=null){v.has(A.name)||v.set(A.name,new Map);let g=A.url.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",m=v.get(A.name);m&&m.set(g,A.url)}if(v.size>0){let O=!0;for(let[A,g]of Object.entries(t)){let m=typeof g=="string"?g:jve(g)?Object.values(g.urls)[0]:g.url;if(!m)continue;let j=m.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",S={[PEe]:m};for(let[w,D]of v.entries()){let B=D.get(j)||D.get("production")||D.values().next().value;B&&(S[w]=B)}h&&Object.assign(S,dbn(d)),Object.keys(S).length>1?e.builder.addEnvironment({name:A,schema:{urls:S}}):e.builder.addEnvironment({name:A,schema:m}),O&&(e.builder.setDefaultEnvironment(A),O=!1)}v.size>0&&e.builder.setDefaultUrl(PEe)}else{let O=!0;for(let[A,g]of Object.entries(t)){if(h||Object.keys(o).length>0){let m=typeof g=="string"?g:jve(g)?Object.values(g.urls)[0]:g.url;e.builder.addEnvironment({name:A,schema:{urls:{[PEe]:m??"",...dbn(o),...dbn(d)}}})}else e.builder.addEnvironment({name:A,schema:g});O&&(e.builder.setDefaultEnvironment(A),O=!1)}}}}var dVc=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},ZTD=.75,kTD=new Set("authorization");function hoh(e){if(e.globalHeaderOverrides!=null){for(let[r,i]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:i});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,i]of Object.entries(t)){let n="optional<string>";if(i.name==null&&i.env==null&&typeof i.schema=="string")n=i.schema;else if(i!=null){let a=i.schema?IQi(i.schema):void 0,o=a!=null?qQi(a):void 0,c=ns.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?Gy(Pl({schema:i.schema,context:e,fileContainingReference:o?PB(ns.of(nu(o)),c):c,namespace:o,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.options.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(kTD.has(a.name.toLowerCase()))continue;let o=r[a.name];if(o==null){let c=t[a.name],d=oYt({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:ns.of(AB),context:e,namespace:void 0});o=new dVc(d),r[a.name]=o}o.increment()}let i=e.ir.endpoints.length*ZTD;for(let[n,a]of Object.entries(r)){let o=t[n],c=a.count===e.ir.endpoints.length,d=a.count>=i;o==null&&(c?e.builder.addGlobalHeader({name:n,schema:a.schema}):d&&e.builder.addGlobalHeader({name:n,schema:fbn(a.schema)}))}}}function yoh(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?IQi(t.schema):void 0,i=r!=null?qQi(r):void 0,n=oYt({header:{...t,schema:t.schema??ic.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:Th.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0})}),name:t.name??t.header,parameterNameOverride:void 0,description:void 0,availability:void 0,source:void 0},fileContainingReference:ns.of(AB),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:fbn(n)})}}function fW(e){switch(e.type){case"primitive":return voh(e.value);case"object":return goh(e.properties);case"array":return Ooh(e.value);case"map":return tRD(e.value);case"oneOf":return rRD(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return iRD(e.value);case"unknown":return fW(e.value);case"null":return null;default:gt(e)}}function boh(e){switch(e.type){case"withStreaming":return e.sse?{stream:eRD(e.events)}:{stream:Ooh(e.events)};case"withoutStreaming":return{body:fW(e.value)};default:gt(e)}}function voh(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:gt(e)}}function goh(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,fW(r)]))}function eRD(e){return e.map(t=>({event:"",data:fW(t)}))}function Ooh(e){return e.map(t=>fW(t))}function tRD(e){return Object.fromEntries(e.map(t=>[voh(t.key),fW(t.value)]))}function rRD(e){return e.type==="discriminated"?goh(e.value):fW(e.value)}function iRD(e){switch(e.type){case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"boolean":return e.value;default:gt(e)}}function Aoh({endpointExample:e,context:t}){let r={};if(e.type!=="full")return e.value;e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.pathParameters!=null&&e.pathParameters.length>0&&(r["path-parameters"]=nRD(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=aRD(e.queryParameters));let i=e.headers!=null&&e.headers.length>0,n=t.builder.getGlobalHeaders(),a=Object.keys(n).length>0,o=new Set(e.headers?.map(c=>c.name)??[]);if(i||a){let c=[];if(e.headers!=null)for(let d of e.headers)d.name!==t.builder.getAuthHeaderName()&&c.push(d);for(let[d,s]of Object.entries(n))if(!o.has(d))if(s!=null&&typeof s=="object"&&s.type!=null){let u=YI({type:s.type,_default:void 0,validation:void 0,visitor:{primitive:l=>l.toString(),map:l=>l.toString(),list:l=>l,optional:l=>l,nullable:l=>l,set:l=>l,named:l=>l,literal:l=>{if(l.type==="string")return l.string;if(l.type==="boolean")return l.boolean.toString()},unknown:Bt}});u!=null&&c.push({name:d,value:ml.literal(LKi.string(u))})}else c.push({name:d,value:ml.primitive(po.string(d))});r.headers=oRD({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=fW(e.request)),e.response!=null&&(r.response=boh(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(c=>c.type==="language"?{name:c.name??void 0,docs:c.description??void 0,language:c.language,code:c.code,install:c.install??void 0}:{name:c.name??void 0,docs:c.description??void 0,sdk:c.sdk,code:c.code}).filter(As)),r}function nRD(e){let t={};return e.forEach(r=>{let i=fW(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function aRD(e){let t={};return e.forEach(r=>{let i=fW(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function oRD({context:e,namedFullExamples:t}){let r={};return t.forEach(i=>{let n=fW(i.value);n!=null&&(r[i.name]=n)}),r}function moh(e){return nF._visit(e,{get:()=>WB.HttpMethodSchema.Get,post:()=>WB.HttpMethodSchema.Post,put:()=>WB.HttpMethodSchema.Put,patch:()=>WB.HttpMethodSchema.Patch,delete:()=>WB.HttpMethodSchema.Delete,head:()=>WB.HttpMethodSchema.Head,options:()=>{throw new Error("OPTIONS is unsupported")},trace:()=>{throw new Error("TRACE is unsupported")},_other:()=>{throw new Error("Unknown http method is unsupported")}})}function Poh(e){return e==="POST"||e==="PUT"||e==="PATCH"}function joh({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,o=e.path,c=Cfu(e.sdkName,e.namespace),d={};for(let b of e.pathParameters)b.parameterNameOverride&&(o=o.replace(b.name,b.parameterNameOverride)),d[b.parameterNameOverride??b.name]=Sfu({pathParameter:b,context:r,fileContainingReference:t,namespace:c}),a.add(b.name);let s={};for(let b of e.queryParameters){let v=Dfu({queryParameter:b,context:r,fileContainingReference:t,namespace:c});v!=null&&(s[b.name]=v,a.add(b.name))}let u;if(e.pagination!=null)switch(e.pagination.type){case"cursor":u={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":u={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":u={type:"custom",results:e.pagination.results};break;default:gt(e.pagination)}let l={path:o,method:moh(e.method),auth:uRD({endpoint:e,context:r}),docs:e.description??void 0,pagination:u,source:e.source!=null?CQi(e.source):void 0};!fRD({context:r,request:e.request})&&Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let p={},_=r.builder.getGlobalHeaderNames(),h=r.builder.getAuthHeaderName();h!=null&&_.add(h);let y=e.headers.filter(b=>!_.has(b.name));for(let b of y){let v=oYt({header:b,context:r,fileContainingReference:t,namespace:c});p[b.name]=v,a.add(typeof v=="string"?b.name:v.name??b.name)}if(e.request!=null){r.setInState(bR.Request);let b=lRD({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.options.inlinePathParameters&&Object.keys(d).length>0?d:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(i),headers:Object.keys(p).length>0?p:void 0,usedNames:a,namespace:c});l.request=b.value,n=[...n,...b.schemaIdsToExclude??[]],r.unsetInState(bR.Request)}else{let b=r.options.inlinePathParameters&&Object.keys(d).length>0,v=Object.keys(s).length>0,O=Object.keys(p).length>0,A={};(b||v||O)&&(A.name=e.requestNameOverride??e.generatedRequestName),b&&(A["path-parameters"]=d),v&&(A["query-parameters"]=s),O&&(A.headers=p),Object.keys(A).length>0&&(l.request=A)}if(e.response!=null&&e.response._visit({json:b=>{let v=Pl({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:b.description??void 0,type:Gy(v)},b.statusCode!=null&&(l.response["status-code"]=b.statusCode),b.responseProperty!=null&&(l.response.property=b.responseProperty)},streamingJson:b=>{let v=Pl({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:Gy(v),format:"json"}},streamingSse:b=>{let v=Pl({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:Gy(v),format:"sse"}},file:b=>{l.response={docs:b.description??void 0,type:"file","status-code":b.statusCode}},bytes:b=>{l.response={docs:b.description??void 0,type:"bytes","status-code":b.statusCode}},streamingText:b=>{l["response-stream"]={docs:b.description??void 0,type:"text"}},text:b=>{l.response={docs:b.description??void 0,type:"text","status-code":b.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let b=r.getDefaultServerName(),v=e.servers[0];v==null?b!=null&&(l.url=b):l.url=v.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=hM(e.availability)),Object.entries(e.errors).forEach(([b,v])=>{let O=v.generatedName,A=ns.of(Qb);r.builder.enableUniqueErrorsPerEndpoint&&(O=`${e.generatedRequestName}${v.generatedName}`,v.schema!=null&&(v.schema.type!=="reference"&&v.schema.type!=="oneOf"?v.schema.generatedName=`${e.generatedRequestName}${v.schema.generatedName}`:v.schema.type==="oneOf"&&(v.schema.value.generatedName=`${e.generatedRequestName}${v.schema.value.generatedName}`)));let g={"status-code":parseInt(b)},m=Yah({location:woh,namespaceOverride:c});if(v.schema!=null){let w=Pl({schema:v.schema,context:r,fileContainingReference:m,declarationFile:m,namespace:c,declarationDepth:0});g.type=Gy(w),g.docs=v.description}r.builder.addError(m,{name:O,schema:r.isErrorUnknownSchema(parseInt(b))?{...g,type:"unknown"}:g}),l.errors==null&&(l.errors=[]);let j=r.builder.addImport({file:t,fileToImport:m});l.errors.push(j!=null?`${j}.${O}`:O),g.type!=null&&v.examples?.forEach(w=>{let D={value:fW(w.example),name:w.name,docs:w.description};r.builder.addErrorExample(m,{name:O,example:D})})}),e.examples.length>0&&(l.examples=sRD({endpointExamples:e.examples,context:r})),e.retries!=null&&(l.retries=cRD({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[pVc,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:n}}function uRD({endpoint:e,context:t}){if(e.security==null)return t.authOverrides?.auth!=null?!0:t.ir.security==null?void 0:t.ir.security.length>0?!0:void 0;if(e.security.length!==0)return JSON.stringify(e.security)===JSON.stringify(t.ir.security)?!0:e.security}function sRD({endpointExamples:e,context:t}){return e.map(r=>{try{return Aoh({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function cRD({retries:e}){if(e!=null)switch(e.type){case"disabled":return{disabled:e.value??void 0};default:gt(e)}}function lRD({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:o,queryParameters:c,nonRequestReferencedSchemas:d,headers:s,usedNames:u,namespace:l}){if(i.type==="json"||i.type==="formUrlEncoded"){let p=i.schema.type==="reference"?i.schema.schema:void 0,_=i.schema.type==="reference"?r.getSchema(i.schema.schema,l):i.schema;if(_?.type!=="object"||p!=null&&d.includes(p)){let m=Pl({schema:i.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),j={schemaIdsToExclude:[],value:{body:m}},S=Object.keys(o??{}).length>0,w=Object.keys(c??{}).length>0,D=Object.keys(s??{}).length>0;return S&&(j.value["path-parameters"]=o),w&&(j.value["query-parameters"]=c),D&&(j.value.headers=s),(S||w||D)&&(j.value.name=n??a),i.contentType!=null&&(j.value["content-type"]=i.contentType),i.description!=null&&(j.value.docs=i.description),j}let h=new Map;for(let m of _.allOf){let j=r.getSchema(m.schema,l);if(j==null)continue;let S=IQi(j),w=H3t(S),{properties:D}=baa(r,m.schema,l);for(let B of D)h.set(B.key,w)}let y=Object.fromEntries(_.properties.filter(m=>m.readonly==null?!0:!(Poh(e.method)&&m.readonly)).map(m=>{let j=h.get(m.key)??t,S=Pl({schema:m.schema,fileContainingReference:t,declarationFile:j,context:r,namespace:l,declarationDepth:1}),w=m.nameOverride??m.key,D=hM(m.availability);if(!u.has(w)&&m.audiences.length<=0)return u.add(w),m.nameOverride!=null?[m.key,{type:Gy(S),docs:haa(S),name:m.nameOverride,availability:D}]:[m.key,D?{...typeof S=="string"?{type:S}:S,availability:D}:S];let B={type:Gy(S),docs:haa(S)};return u.has(w)&&(B.name=m.generatedName),m.audiences.length>0&&(B.audiences=m.audiences),D!=null&&(B.availability=D),u.add(w),[m.key,B]})),b=new Set,v=new Set;for(let m of _.allOfPropertyConflicts)m.allOfSchemaIds.forEach(j=>b.add(j)),m.conflictingTypeSignatures&&v.add(m.propertyKey);let O=[];for(let m of _.allOf){let j=Efu({schema:m.schema,context:r,namespace:l});if(j==null||b.has(m.schema)||b.has(j))continue;let S=Pl({schema:ic.reference(m),fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),w=yaa(Gy(S));w!=="unknown"&&O.push(w)}for(let m of b){let j=baa(r,m,l),S=r.getSchema(m,l),w=S!=null?H3t(IQi(S)):t;for(let D of j.properties)y[D.key]==null&&(v.has(D.key)?y[D.key]="unknown":y[D.key]=Pl({schema:D.schema,fileContainingReference:t,declarationFile:w,context:r,namespace:l,declarationDepth:1}));for(let D of j.allOf){if(b.has(D.schema))continue;let B=Pl({schema:ic.reference(D),fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),R=yaa(Gy(B));R!=="unknown"&&!O.includes(R)&&O.push(R)}}let A={properties:y};O.length>0&&(A.extends=O),i.additionalProperties&&(A["extra-properties"]=!0);let g={name:n??_.nameOverride??_.generatedName,"path-parameters":o,"query-parameters":c,headers:s,body:A};return i.contentType!=null&&(g["content-type"]=i.contentType),i.description!=null&&(g.docs=i.description),{schemaIdsToExclude:p!=null?[p]:[],value:g}}else if(i.type==="octetStream"){let p={body:"bytes","content-type":i.contentType??xO.APPLICATION_OCTET_STREAM,"query-parameters":c};return c!=null&&(p.name=n??a),i.description!=null&&(p.docs=i.description),{schemaIdsToExclude:[],value:p}}else if(i.type==="multipart"){let p=Object.fromEntries(i.properties.map(_=>{if(_.schema.type==="file"){let h=_.schema.isArray?"list<file>":"file";if(h=_.schema.isOptional?`optional<${h}>`:h,_.description!=null||_.contentType!=null){let y={type:h};if(_.description!=null&&(y.docs=_.description),_.contentType!=null){let b=_.contentType.split(",")[0];y["content-type"]=b}return[_.key,y]}return[_.key,h]}else{let h=Pl({schema:_.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(_.contentType||_.exploded||_.encoding){let y=typeof h=="string"?{type:h}:h;_.contentType!=null&&(y["content-type"]=_.contentType),_.encoding==="form"?y.style="form":_.encoding==="json"?y.style="json":_.exploded&&(y.style="exploded"),h=y}return[_.key,h]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":o,"query-parameters":c,headers:s,body:{properties:p},"content-type":xO.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else gt(i)}function fRD({context:e,request:t}){if(!e.options.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:gt(t)}}function dRD({location:e,namespaceOverride:t}){return t!=null?{...e,file:PB(ns.of(t),e.file)}:e}function pRD(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:ns.of(`${nu(r)}.yml`),endpointId:e.summary!=null?nu(e.summary):nu(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:ns.of(Qb),endpointId:nu(e.summary)}:{file:ns.of(Qb),endpointId:nu(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:ns.of(Qb),endpointId:i};let n=HHa(r),a=HHa(i);if(NT(n,a))return{file:ns.of("__package__.yml"),endpointId:r};let o=yRD({operationId:i,tag:r,path:e.path,method:e.method});if(o!=null)return o;let c=[];for(let d=0;d<n.length;++d){let s=n[d];if(s!=null&&s===a[d])c.push(s);else{let u=nu(r);return{file:ns.of(`${u}.yml`),endpointId:i,tag:r}}}if(c.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:ns.of(nu(c.join("_"))+".yml"),endpointId:nu(a.slice(c.length).join("_")),tag:r}}function xHa(e){let t=e.tags[0];if(e.sdkName!=null){let r=XLc({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:ns.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return dRD({namespaceOverride:e.namespace,location:pRD(e)})}function HHa(e){let t;return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)?t=e.split(/(?=[A-Z])/):t=e.split(/[^a-zA-Z0-9]+/),t=t.map(r=>r.toLowerCase()),t=jje(t),t}var _RD=new RegExp("[^a-zA-Z0-9{}]+"),hRD=new RegExp("[{}]","g");function yRD({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(_RD).join("_").replaceAll(hRD,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:ns.of(nu(t)+".yml"),endpointId:nu(e.slice(0,-1*a.length)),tag:t}}function Eoh(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:o,file:c,tag:d}=xHa(a),s=c.split(".")[0];s!=null&&t.add(s);let u;if(a.sdkName!=null){let _=e.ir.groups;for(let h of a.sdkName.groupName){let y=typeof h=="string"?h:h.name,b=_[y];if(b==null)break;if(b.summary!=null||b.description!=null){u=_[y];break}}}let l=d==null?void 0:i.tagsById[d];e.setInState(bR.Endpoint),e.setEndpointMethod(a.method);let p=joh({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(bR.Endpoint),n=[...n,...p.schemaIdsToExclude],e.builder.addEndpoint(c,{name:o,schema:p.value,source:a.source!=null?CQi(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(c,{"display-name":u?.summary??l?.id,docs:u?.description??l?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function Soh(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?qQi(r.groupName):void 0,n=Pl({schema:ic.primitive(r),context:e,fileContainingReference:ns.of(Qb),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:Gy(n),docs:r.description??void 0}})}}function Moh(e){for(let t of e.ir.webhooks){let r=gRD({webhook:t,context:e});if(r==null)continue;let i=Cfu(t.sdkName,t.namespace),n={};for(let o of t.headers)n[o.name]=oYt({header:o,context:e,fileContainingReference:r.file,namespace:i});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:n,payload:Pl({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(o=>({docs:o.description,name:o.name,payload:fW(o.payload)})):void 0};t.response!=null&&t.response._visit({json:o=>{let c=Pl({schema:o.schema,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0});a.response={docs:o.description??void 0,type:Gy(c)},o.statusCode!=null&&(a.response["status-code"]=o.statusCode)},file:o=>{a.response={docs:o.description??void 0,type:"file","status-code":o.statusCode}},bytes:o=>{a.response={docs:o.description??void 0,type:"bytes","status-code":o.statusCode}},text:o=>{a.response={docs:o.description??void 0,type:"text","status-code":o.statusCode}},streamingJson:o=>{let c=Pl({schema:o.schema,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0});a["response-stream"]={docs:o.description??void 0,type:Gy(c),format:"json"}},streamingSse:o=>{let c=Pl({schema:o.schema,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0});a["response-stream"]={docs:o.description??void 0,type:Gy(c),format:"sse"}},streamingText:o=>{a["response-stream"]={docs:o.description??void 0,type:"text"}},_other:()=>{throw new Error("Unrecognized Response type: "+t.response?.type)}}),e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function bRD({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:PB(ns.of(t),e.file)}:e}function vRD({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:ns.of(Qb),endpointId:i};let n=HHa(r),a=HHa(i);if(NT(n,a))return{file:ns.of("__package__.yml"),endpointId:r};let o=[];for(let c=0;c<n.length;++c){let d=n[c];if(d!=null&&d===a[c])o.push(d);else{let s=nu(r);return{file:ns.of(`${s}.yml`),endpointId:i,tag:r}}}if(o.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:ns.of(nu(o.join("_"))+".yml"),endpointId:nu(a.slice(o.length).join("_")),tag:r}}function gRD({webhook:e,context:t}){return e.sdkName!=null?{file:$ah({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:bRD({namespaceOverride:e.namespace,location:vRD({webhook:e,context:t})})}var ORD=ns.of(Qb);function Boh(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return Doh({namespace:e.namespace,groupName:e.groupName});case"oneOf":return Doh({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return ORD;default:gt(e)}}function Doh({namespace:e,groupName:t}){return e!=null&&t!=null?H3t([{type:"namespace",name:e},...t]):e!=null?H3t([{type:"namespace",name:e}]):H3t(t)}var pVc="external",woh=ns.of(Qb);function Ioh({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let o=Boh(a),c=roh({schema:a,context:i,declarationFile:o,namespace:r,declarationDepth:0});if(SKi(c.schema)){let d=Gy(c.schema);if(d===(c.name??n)||d===`optional<${c.name??n}>`||d===`nullable<${c.name??n}>`||d===`optional<nullable<${c.name??n}>>`)continue}i.builder.addType(o,{name:c.name??n,schema:c.schema})}}function Coh(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),_oh(e),hoh(e),yoh(e),ooh(e),Soh(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(pVc);let t=Eoh(e),r=t.sdkGroups;e.setInState(bR.Webhook),Moh(e),e.unsetInState(bR.Webhook),e.setInState(bR.Channel);for(let n of Object.values(e.ir.channels)){let a=H3t(n.groupName);loh({channel:n,context:e,declarationFile:a})}e.unsetInState(bR.Channel);let i=ARD({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});Ioh({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))Ioh({schemas:a,schemaIdsToExclude:i,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.optimizeServiceAuth(),e.builder.build()}function ARD({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}var KHa=class{context;constructor(t){this.context=t}};var qfu=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[o,c]of Object.entries(i.files)){let d=n!=null?ns.of(`${n}${"/"}${o}`):ns.of(o);t[d]=c}let a=Object.keys(i.directories).sort();for(let o of a){let c=n!=null?`${n}${"/"}${o}`:o,d=i.directories[o];r(d,c)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split("/"))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[ns.of(t[0])]??={};let[r,...i]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(i)}};var pbn=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new qfu,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":i,"display-name":n,docs:a}){let o=this.getOrCreateFile(t);o.service==null&&(o.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(o.service.auth=r),i!=null&&(o.service["base-path"]=i),n!=null&&(o.service["display-name"]=n),a!=null&&(o.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return x$t(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let i of Object.values(this.rootApiFile["auth-schemes"]))qoh(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(qoh(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}getGlobalHeaders(){return this.rootApiFile.headers??{}}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??nu((Lje(r)+"/"+ofn(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===ns.of(AB))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=qzo(Lje(xJn.of(`/${t}`)),xJn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=qzo(Lje(xJn.of(`/${t}`)),xJn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===ns.of(AB))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(c=>NT(c,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=PB(n,r.path))}addChannelExample(t,{example:r}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.examples==null&&(i.channel.examples=[]),i.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:i}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.messages[r]=i}optimizeServiceAuth(){let t=[this.packageMarkerFile,...Object.values(this.root.getAllFiles())];for(let r of t){if(r.service==null)continue;let i=Object.values(r.service.endpoints);if(i.length===0)continue;if(i.every(a=>a.auth===!0)){r.service.auth=!0;for(let a of Object.values(r.service.endpoints))delete a.auth}}}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([n,a])=>[n,{...a,path:PB(r,a.path)}]))});for(let n of Object.values(t))n.service!=null&&(n.service={...n.service,endpoints:Object.fromEntries(Object.entries(n.service.endpoints).map(([a,o])=>[a,{...o,path:PB(r,o.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===Qb?this.packageMarkerFile:this.root.getOrCreateFile(t)}getVersionHeader(){if(this.rootApiFile.version!=null)return typeof this.rootApiFile.version.header=="string"?this.rootApiFile.version.header:this.rootApiFile.version.header.value}};function qoh(e){return e?.header!=null}var Tfu=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;options;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;urlIdMap=new Map;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:o}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=o,this.globalHeaderOverrides=a,this.options=sbn({options:i}),this.enableUniqueErrorsPerEndpoint=this.options.enableUniqueErrorsPerEndpoint,this.referencedSchemaIds=this.options.onlyIncludeReferencedSchemas?new Set:void 0,this.builder=new pbn(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let c={};if(!this.enableUniqueErrorsPerEndpoint)for(let d of r.endpoints)for(let[s,u]of Object.entries(d.errors)){let l=parseInt(s),p=c[l];p==null&&u.schema!=null?c[l]=u.schema:p!=null&&u.schema!=null&&H$(p,u.schema)||this.unknownSchema.add(l)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}setUrlId(t,r){this.urlIdMap.set(t,r)}getUrlId(t){return this.urlIdMap.get(t)}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.options.onlyIncludeReferencedSchemas&&this.isInAnyState(bR.Channel,bR.Endpoint,bR.Webhook)}markSchemaAsReferenced(t,r){switch(t.type){case"primitive":return;case"object":this.markObjectSchemaAsReferenced(t,r);return;case"array":this.markSchemaAsReferenced(t.value,r);return;case"map":this.markSchemaAsReferenced(t.value,r);return;case"optional":this.markSchemaAsReferenced(t.value,r);return;case"reference":this.markSchemaIdAsReferenced(t.schema,r);return;case"oneOf":this.markOneofSchemaAsReferenced(t.value,r);return;case"nullable":this.markSchemaAsReferenced(t.value,r);return;case"enum":return;case"literal":return;case"unknown":return;default:gt(t)}}markObjectSchemaAsReferenced(t,r){for(let i of t.allOf)this.markSchemaIdAsReferenced(i.schema,r);for(let i of t.properties)this.markSchemaAsReferenced(i.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let i of Object.values(t.schemas))this.markSchemaAsReferenced(i,r);return;case"undiscriminated":for(let i of t.schemas)this.markSchemaAsReferenced(i,r);return;default:gt(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let i=this.getSchema(t,r);i!=null&&this.markSchemaAsReferenced(i,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function _Vc(e){let t=new Tfu(e);return Coh(t)}function mRD(e){return myn(e,{single:t=>[typeof t=="string"?t:t.scheme],any:t=>t.any.map(r=>typeof r=="string"?r:r.scheme),endpointSecurity:()=>[]})}function PRD(e,t){if(e==null)return;let r=mRD(t),i={};for(let n of r)e[n]!=null&&(i[n]=e[n]);return Object.keys(i).length>0?i:void 0}var Rfu=class{args;constructor(t){this.args=t}buildAuthOverrides(t,r){let i=this.args.generatorsConfiguration?.api?.["auth-schemes"],n=this.args.generatorsConfiguration?.api?.auth,a=t??n;if(a==null)return;let o=r!=null||i!=null?{...i,...r}:void 0,c=PRD(o,a);return{auth:a,"auth-schemes":c}}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=_Vc({taskContext:t,ir:r,options:sbn({options:i,overrides:this.args}),authOverrides:this.buildAuthOverrides(i?.auth,i?.authSchemes),environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:n??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:Bi.dump(a.rootApiFile)},namedDefinitionFiles:{...gn(a.definitionFiles,o=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Bi.dump(o),contents:o})),[ns.of(Qb)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Bi.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var JHa=class extends L3t{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;coerceEnumsToLiterals;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;resolveAliases;groupEnvironmentsByHost;removeDiscriminantsFromSchemas;defaultIntegerFormat;converter;constructor(t){super(t),this.inlinePathParameters=t.inlinePathParameters,this.objectQueryParameters=t.objectQueryParameters,this.onlyIncludeReferencedSchemas=t.onlyIncludeReferencedSchemas,this.respectReadonlySchemas=t.respectReadonlySchemas,this.respectNullableSchemas=t.respectNullableSchemas,this.wrapReferencesToNullableInOptional=t.wrapReferencesToNullableInOptional,this.coerceOptionalSchemasToNullable=t.coerceOptionalSchemasToNullable,this.coerceEnumsToLiterals=t.coerceEnumsToLiterals,this.exampleGeneration=t.exampleGeneration,this.useBytesForBinaryResponse=t.useBytesForBinaryResponse,this.respectForwardCompatibleEnums=t.respectForwardCompatibleEnums,this.inlineAllOfSchemas=t.inlineAllOfSchemas,this.resolveAliases=t.resolveAliases,this.groupEnvironmentsByHost=t.groupEnvironmentsByHost,this.removeDiscriminantsFromSchemas=t.removeDiscriminantsFromSchemas,this.defaultIntegerFormat=t.defaultIntegerFormat,this.converter=new Rfu(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:i},n){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:i},n);return this.converter.convert({context:t,ir:a,settings:n,absoluteFilePath:r})}async toFernWorkspace({context:t},r,i){let n=await this.getDefinition({context:t},r);return new W$({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion})}};var tL={BEARER_FORMAT:"x-bearer-format",ENUM_VAR_NAMES:"x-enum-varnames",INTERNAL:"x-internal",EXAMPLES:"x-examples",TAGS:"x-tags",REDOCLY_CODE_SAMPLES_KEBAB:"x-code-samples",REDOCLY_CODE_SAMPLES_CAMEL:"x-codeSamples"};var vaa={of(e){return e}};var Toh={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},hVc={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:Toh,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},Ki={SOURCE:vaa.of("source"),SDK_NAMESPACE:vaa.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:vaa.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:vaa.of("x-fern-sdk-group-name"),REQUEST_NAME_V1:"x-request-name",REQUEST_NAME_V2:"x-fern-request-name",TYPE_NAME:"x-fern-type-name",BOOLEAN_LITERAL:"x-fern-boolean-literal",SERVER_NAME_V1:"x-name",SERVER_NAME_V2:"x-fern-server-name",BASE_PATH:"x-fern-base-path",GROUPS:vaa.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",RETRIES:"x-fern-retries",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport",IS_DISCRIMINATED:"x-fern-discriminated",EXPLORER_ENABLED:"x-fern-explorer-enabled"};var jRD={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!1,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!1,respectReadonlySchemas:!1,respectNullableSchemas:!0,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!0,preserveSchemaIds:!1,objectQueryParameters:!0,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!0,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!1,preserveSingleSchemaOneOf:!1,inlineAllOfSchemas:!1,resolveAliases:!1,groupMultiApiEnvironments:!1,groupEnvironmentsByHost:!1,wrapReferencesToNullableInOptional:!1,coerceOptionalSchemasToNullable:!1,removeDiscriminantsFromSchemas:_n.RemoveDiscriminantsFromSchemas.Always,defaultIntegerFormat:_n.DefaultIntegerFormat.Int32};function wRD(e){let{defaults:t,options:r,overrides:i,overrideOnly:n=new Set,undefinedIfAbsent:a=new Set}=e,o={};for(let c of Object.keys(t))n.has(c)?o[c]=i?.[c]!==void 0?i[c]:t[c]:a.has(c)?o[c]=i?.[c]!==void 0?i[c]:r?.[c]!==void 0?r[c]:void 0:o[c]=i?.[c]??r?.[c]??t[c];return o}function jEe({options:e,overrides:t}){return wRD({defaults:jRD,options:e,overrides:t,overrideOnly:new Set(["disableExamples","preserveSchemaIds"]),undefinedIfAbsent:new Set(["exampleGeneration","defaultFormParameterEncoding"])})}var Roh={naming:"v1"};function Ci(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function $Ha(e,t,r,i,n=[]){try{let a=Ci(e,t);if(a!=null)return r.parse(a)}catch{let o=jje(n).join(" -> ");i.error(`${o.length>0?`${o}: `:""}Failed to parse ${t}`)}}function _bn(e){let t=Ci(e,"examples");if(t!=null){if(Array.isArray(t))return t;if(typeof t=="object"&&t!==null)return Object.values(t).map(r=>typeof r=="object"&&r!==null&&"value"in r?r.value:r)}return[]}function zoh({schema:e,logger:t}){return Ci(e,Ki.ENCODING)??void 0}function Noh(e){return Ci(e,Ki.FERN_ENUM)}function Foh({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let o=Ci(i,Ki.SDK_NAMESPACE),c=Ci(i,Ki.SDK_GROUP_NAME),d=Ci(i,Ki.TYPE_DEFINITION);if(d!=null)return YHa({fernType:d,nameOverride:e,generatedName:t,title:r,description:n,availability:a,namespace:o,groupName:typeof c=="string"?[c]:c})}function YHa({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c}){return YI({type:e,_default:void 0,validation:void 0,visitor:{primitive:d=>{switch(d.v1){case"BASE_64":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.base64({example:void 0})});case"BOOLEAN":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.boolean({default:void 0,example:void 0})});case"DATE":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.date({example:void 0})});case"DATE_TIME":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.datetime({example:void 0})});case"FLOAT":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.float({example:void 0})});case"DOUBLE":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.double({default:void 0,minimum:void 0,maximum:void 0,exclusiveMinimum:void 0,exclusiveMaximum:void 0,multipleOf:void 0,example:void 0})});case"UINT":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.uint({default:void 0,example:void 0})});case"INTEGER":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.int({default:void 0,minimum:void 0,maximum:void 0,exclusiveMinimum:void 0,exclusiveMaximum:void 0,multipleOf:void 0,example:void 0})});case"UINT_64":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.uint64({default:void 0,example:void 0})});case"LONG":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:gt(d.v1)}},unknown:()=>ai.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,namespace:o,groupName:c}),map:({keyType:d,valueType:s})=>d?.type==="primitive"&&s!=null?ai.map({nameOverride:t,generatedName:r,title:i,key:d,value:s,description:n,availability:a,namespace:o,groupName:c,encoding:void 0,example:void 0,inline:void 0}):void 0,list:d=>d!=null?ai.array({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,optional:d=>d!=null?ai.optional({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,nullable:d=>d!=null?ai.nullable({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,set:d=>d!=null?ai.array({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,literal:d=>ai.literal({nameOverride:t,generatedName:r,title:i,value:d._visit({string:s=>Ww.string(s),boolean:s=>Ww.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,namespace:o,groupName:c}),named:d=>ai.reference({schema:d,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,source:cW.openapi({file:"<memory>"})})}})}function Qoh(e){let t=Ci(e,Ki.SOURCE);if(t!=null)return t.endsWith(".proto")?cW.protobuf({file:t}):cW.openapi({file:t})}function hbn(e){if(e!=null&&typeof e=="boolean")return e}function wn(e){return e?.$ref!=null}function Uoh({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:d,context:s,namespace:u,groupName:l,example:p,encoding:_,source:h}){return n===void 0&&(n=s.options.additionalPropertiesDefaultsTo),yVc({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:d,description:a,availability:o,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Jn.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:typeof n=="boolean"||XHa(n,s.options)?ai.unknown({...ERD(n),generatedName:`${t}Value`}):Loh(Zl(n,!1,s.options.optionalAdditionalProperties?d:!1,s,[...i,"Value"],h,u,void 0,void 0,void 0)),namespace:u,groupName:l,example:p,encoding:_})}function Loh(e){switch(e.type){case"array":case"enum":case"map":case"object":e.inline=!0;break;case"literal":case"primitive":case"reference":case"unknown":break;case"nullable":case"optional":e.inline=!0,e.value=Loh(e.value);break;case"oneOf":e.value.inline=!0;break;default:gt(e)}return e}function yVc({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsOptional:a,wrapAsNullable:o,description:c,availability:d,namespace:s,groupName:u,example:l,encoding:p}){let _=ai.map({nameOverride:e,generatedName:t,title:r,description:c,availability:d,key:i,value:n,namespace:s,groupName:u,encoding:p,example:l,inline:void 0});return o&&(_=ai.nullable({nameOverride:e,generatedName:t,title:r,value:_,description:c,availability:d,namespace:s,groupName:u,inline:void 0})),a&&(_=ai.optional({nameOverride:e,generatedName:t,title:r,value:_,description:c,availability:d,namespace:s,groupName:u,inline:void 0})),_}function XHa(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:wn(e)||"type"in e&&e.type!=null||"oneOf"in e&&e.oneOf!=null||"anyOf"in e&&e.anyOf!=null?!1:"allOf"in e&&e.allOf!=null?!e.allOf.some(i=>wn(i)?!0:i.type!=null||i.properties!=null||i.allOf!=null||i.oneOf!=null||i.anyOf!=null||i.enum!=null||"items"in i||i.additionalProperties!=null):!("enum"in e&&e.enum!=null)}function ERD(e){let t={nameOverride:void 0,generatedName:"",title:void 0,description:void 0,availability:void 0,example:void 0,namespace:void 0,groupName:void 0};return e==null||typeof e=="boolean"||wn(e)||typeof e!="object"||(e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description)),t}function Voh({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:d,context:s,namespace:u,groupName:l,example:p,source:_}){let h=n==null?ai.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:l}):Zl(n,!1,!1,s,[...i,"Item"],_,u);return SRD({nameOverride:e,generatedName:t,title:r,namespace:u,groupName:l,itemSchema:h,wrapAsOptional:c,wrapAsNullable:d,description:a,availability:o,example:p})}function SRD({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,namespace:d,groupName:s,example:u}){let l=ai.array({nameOverride:e,generatedName:t,title:r,value:i,description:o,availability:c,namespace:d,groupName:s,example:u,inline:void 0});return a&&(l=ai.nullable({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),n&&(l=ai.optional({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),l}function dW(e){switch(Ci(e,Ki.AVAILABILITY)){case"deprecated":return rF.Deprecated;case"beta":return rF.Beta;case"generally-available":return rF.GenerallyAvailable;default:break}if(!wn(e)&&e.deprecated)return rF.Deprecated}function bVc({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:o,required:c,wrapAsOptional:d,wrapAsNullable:s,discriminator:u,context:l,namespace:p,groupName:_,encoding:h,source:y}){let b=u.propertyName,v=Object.fromEntries(Object.entries(u.mapping??{}).map(([A,g])=>{let m=TQi({$ref:g},!1,!1,l,[g],h,y,p);return l.markReferencedByDiscriminatedUnion({$ref:g},b,1),[A,m]})),O=Object.entries(n).filter(([A])=>A!==b).map(([A,g])=>{let m=c!=null&&c.includes(A),[j,S]=l.options.coerceOptionalSchemasToNullable?[!1,!m]:[!m,!1],w=Zl(g,j,S,l,[...i,A],y,p);return{key:A,schema:w}});return Woh({nameOverride:e,generatedName:t,title:r,wrapAsOptional:d,wrapAsNullable:s,properties:O,description:a,availability:o,discriminant:b,subtypes:v,namespace:p,groupName:_,source:y})}function vVc({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:o,required:c,wrapAsOptional:d,wrapAsNullable:s,discriminant:u,variants:l,context:p,namespace:_,groupName:h,encoding:y,source:b}){let v=Object.fromEntries(Object.entries(l).map(([A,g])=>{if(wn(g)){let m=TQi(g,!1,!1,p,[g.$ref],y,b,_);return p.markReferencedByDiscriminatedUnion(g,u,1),[A,m]}else{let m=gaa(g,!1,!1,p,[...i,A],y,b,_,new Set([u]));return[A,m]}})),O=Object.entries(n).filter(([A])=>A!==u).map(([A,g])=>{let m=c!=null&&c.includes(A),[j,S]=p.options.coerceOptionalSchemasToNullable?[!1,!m]:[!m,!1],w=Zl(g,j,S,p,[...i,A],b,_);return{key:A,schema:w}});return Woh({nameOverride:e,generatedName:t,title:r,wrapAsOptional:d,wrapAsNullable:s,properties:O,description:a,availability:o,discriminant:u,subtypes:v,namespace:_,groupName:h,source:b})}function Woh({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,properties:a,description:o,availability:c,discriminant:d,subtypes:s,namespace:u,groupName:l,source:p}){let _=ai.oneOf(Rve.discriminated({description:o,availability:c,discriminantProperty:d,nameOverride:e,generatedName:t,title:r,schemas:s,commonProperties:a,namespace:u,groupName:l,encoding:void 0,source:p,inline:void 0}));return n&&(_=ai.nullable({nameOverride:e,generatedName:t,title:r,value:_,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),i&&(_=ai.optional({nameOverride:e,generatedName:t,title:r,value:_,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),_}function Goh(e){if(e.proto!=null)return Rna.protobuf({typeName:e.proto.type})}function kKi({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:o,description:c,availability:d,wrapAsOptional:s,wrapAsNullable:u,namespace:l,groupName:p,context:_,source:h,inline:y}){let b=DRD(n??[]),v=new Set(a),O=Array.from(v).map((g,m)=>{let j=i?.[g],S=b[m],w=paa.test(g),D=j?.name??S,B=w?g:_aa(g);return D!=null&&!paa.test(D)&&(_?.logger.warn(`Enum name override ${D} is not a valid name. Falling back on ${B}.`),D=void 0),{nameOverride:D,generatedName:B,value:g,description:j?.description,availability:d,casing:{snake:j?.casing?.snake??void 0,pascal:j?.casing?.pascal??void 0,screamingSnake:j?.casing?.screamingSnake??void 0,camel:j?.casing?.camel??void 0}}}),A=o!=null?O.find(g=>g.value===o):void 0;return MRD({wrapAsOptional:s,wrapAsNullable:u,nameOverride:e,generatedName:t,title:r,values:O,_default:A,description:c,availability:d,namespace:l,groupName:p,source:h,inline:y})}function MRD({wrapAsOptional:e,wrapAsNullable:t,nameOverride:r,generatedName:i,title:n,values:a,_default:o,description:c,availability:d,namespace:s,groupName:u,source:l,inline:p}){let _=ai.enum({nameOverride:r,generatedName:i,title:n,values:a,description:c,availability:d,default:o,example:void 0,namespace:s,groupName:u,source:l,inline:p});return t&&(_=ai.nullable({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:d,namespace:s,groupName:u,inline:p})),e&&(_=ai.optional({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:d,namespace:s,groupName:u,inline:p})),_}function DRD(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(i=>i[r]===t[r]);)r++;return e.map(i=>i.substring(r))}function Hoh({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:u,availability:l,wrapAsOptional:p,wrapAsNullable:_,example:h,namespace:y,groupName:b,defaultIntegerFormat:v=_n.DefaultIntegerFormat.Int32}){let O=i??v,A=(()=>{switch(O){case _n.DefaultIntegerFormat.Int64:return Jn.int64({default:n,example:h});case _n.DefaultIntegerFormat.Uint32:return Jn.uint({default:n,example:h});case _n.DefaultIntegerFormat.Uint64:return Jn.uint64({default:n,example:h});default:return Jn.int({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:h})}})();return pW({nameOverride:e,generatedName:t,title:r,primitive:A,wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}function BRD(e){return typeof e=="string"?Ww.string(e):typeof e=="boolean"?Ww.boolean(e):Ww.string(`${e}`)}function xoh({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,value:a,description:o,availability:c,namespace:d,groupName:s}){let u=ai.literal({nameOverride:e,generatedName:t,title:r,value:BRD(a),description:o,availability:c,namespace:d,groupName:s});return n&&(u=ai.nullable({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),i&&(u=ai.optional({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),u}function gVc({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:u,availability:l,wrapAsOptional:p,wrapAsNullable:_,example:h,namespace:y,groupName:b}){return i==null||i==="double"?pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.double({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="float"?pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="int32"?pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.int({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="int64"?pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.int64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint32"?pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.uint({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint64"?pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.uint64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="time-delta"?pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}var IRD={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},CRD={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="responses",applyStrategy:e=>{let t=[e[3]??""];return e=e.slice(4),{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},qRD={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="parameters",applyStrategy:e=>{let t=[e[3]??""];return e=e.slice(4),e[0]==="schema"&&(e=e.slice(1)),{refUnderProcessing:e,newBreadcrumbs:t}}},TRD={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},RRD={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},zRD={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},NRD={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},FRD={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function ZHa(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[IRD,CRD,qRD,TRD,RRD,zRD,NRD,FRD],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:o,newBreadcrumbs:c}=a.applyStrategy(t);t=o,r=[...r,...c]}}while(t.join("")!==n.join(""));return r}function f1(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:F0(nu(n))).join("");return/^\d/.test(i)?LHa(i)??i:i}function Koh(e){let t=e.join("_");return nu(t)}function DA(e){switch(e.type){case"object":return ic.object({allOf:e.allOf,properties:e.properties.map(t=>URD(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:e.inline});case"array":return ic.array({description:e.description,availability:e.availability,value:DA(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return ic.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,source:e.source,inline:e.inline});case"literal":return ic.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"nullable":return ic.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:DA(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return ic.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:DA(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return ic.primitive({description:e.description,availability:e.availability,schema:Joh(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return ic.map({description:e.description,availability:e.availability,key:ic.primitive({description:e.key.description,availability:e.key.availability,schema:Joh(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:DA(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return ic.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return ic.oneOf(QRD(e.value));case"unknown":return ic.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:gt(e)}}function QRD(e){switch(e.type){case"discriminated":return tYt.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:DA(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,DA(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return tYt.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>DA(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:gt(e)}}function Joh(e){switch(e.type){case"string":return Th.string(e);case"base64":return Th.base64();case"boolean":return Th.boolean(e);case"date":return Th.date();case"datetime":return Th.datetime();case"double":return Th.double(e);case"float":return Th.float();case"int":return Th.int(e);case"int64":return Th.int64(e);case"uint":return Th.uint();case"uint64":return Th.uint64();default:gt(e)}}function URD(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:DA(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function zfu(e,t){return H$(DA(e),DA(t))}function $oh({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:o,wrapAsOptional:c,wrapAsNullable:d,allOf:s,context:u,propertiesToExclude:l,namespace:p,groupName:_,fullExamples:h,additionalProperties:y,availability:b,source:v}){let O=[...o??[]],A={...Yoh({properties:n,breadcrumbs:i,context:u})},g=[],m=[];for(let B of s)if(!u.options.inlineAllOfSchemas&&wn(B)){let R=u.resolveSchemaReference(B);if(R.discriminator!=null&&R.discriminator.mapping!=null)continue;if(R.oneOf!=null||R.anyOf!=null){let z=R.oneOf??R.anyOf;if(z!=null){for(let F of z){let U=wn(F)?u.resolveSchemaReference(F):F,x=Zl(U,!1,!1,u.DUMMY,i,v,p);x.type==="object"&&g.push(...x.properties.map(k=>k.schema.type!=="optional"&&k.schema.type!=="nullable"?{...k,schema:ai.optional({nameOverride:void 0,generatedName:"",title:void 0,value:k.schema,description:void 0,availability:k.availability,namespace:void 0,groupName:void 0,inline:void 0})}:k))}continue}}let N=eJi(B);if(N==null)continue;m.push({schemaId:N,convertedSchema:OVc(B,[N],v,u.options.preserveSchemaIds),properties:Xoh({schema:B,context:u,breadcrumbs:i,source:v,namespace:p})}),u.markSchemaAsReferencedByNonRequest(N)}else if(wn(B)){let R=u.resolveSchemaReference(B),N=Zl(R,!1,!1,u,i,v,p);N.type==="object"&&g.push(...N.properties)}else{let R=B.required??[];g=g.map(z=>(z.schema.type==="optional"||z.schema.type==="nullable")&&R.includes(z.key)?{...z,schema:z.schema.value}:z);let N=Zl(B,!1,!1,u,i,v,p);N.type==="object"&&g.push(...N.properties)}let j={};for(let B of m)for(let[R,N]of Object.entries(B.properties)){let z=j[R];z!=null?(z.schemaIds.push(B.schemaId),z.schemas.some(U=>zfu(U,N))||z.schemas.push(N)):j[R]={schemaIds:[B.schemaId],schemas:[N]}}let S=[];for(let[B,R]of Object.entries(j))R.schemaIds.length>1&&S.push({propertyKey:B,allOfSchemaIds:R.schemaIds,conflictingTypeSignatures:R.schemas.length>1});let w=Object.fromEntries(Object.entries(A).filter(([B,R])=>!(!wn(R)&&R.type==="null"))),D=Object.entries(w).map(([B,R])=>{let N=Ci(R,Ki.AUDIENCES)??[],z=dW(R),F=wn(R)?!1:R.readOnly,U=wn(R)?!1:R.writeOnly,k=!(O.includes(B)&&!F),je=Ci(R,Ki.FERN_PROPERTY_NAME),ve=[...i,B],H=Koh(ve),G=Zl(R,k,!1,u,ve,v,p),Ee={};for(let ue of m){let Oe=ue.properties[B];Oe!=null&&!zfu(G,Oe)?Ee[ue.schemaId]={differentSchema:!0}:Oe!=null&&(Ee[ue.schemaId]={differentSchema:!1})}return{key:B,schema:G,nameOverride:je,audiences:N,conflict:Ee,generatedName:H,availability:z,readonly:F,writeonly:U}});return D.push(...g.map(B=>{let R=B.conflict;for(let N of m){let z=N.properties[B.key];z!=null&&!zfu(B.schema,z)?R[N.schemaId]={differentSchema:!0}:z!=null&&(R[N.schemaId]={differentSchema:!1})}return{...B,conflict:R}})),LRD({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:d,properties:D.filter(B=>!l.has(B.key)),description:a,allOf:m.map(B=>B.convertedSchema),allOfPropertyConflicts:S,namespace:p,groupName:_,fullExamples:h,additionalProperties:y,availability:b,source:v,context:u})}function LRD({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,properties:a,description:o,allOf:c,allOfPropertyConflicts:d,namespace:s,groupName:u,fullExamples:l,additionalProperties:p,availability:_,source:h,context:y}){let b=ai.object({description:o,properties:a,nameOverride:e,generatedName:t,title:r,allOf:c,allOfPropertyConflicts:d,namespace:s,groupName:u,fullExamples:l,additionalProperties:XHa(p,y.options),availability:_,source:h,inline:void 0});return n&&(b=ai.nullable({nameOverride:e,generatedName:t,title:r,value:b,description:o,availability:_,namespace:s,groupName:u,inline:void 0})),i&&(b=ai.optional({nameOverride:e,generatedName:t,title:r,value:b,description:o,availability:_,namespace:s,groupName:u,inline:void 0})),b}function Yoh({properties:e,breadcrumbs:t,context:r}){return Object.fromEntries(Object.entries(e).filter(([i,n])=>{let a=Ci(n,Ki.IGNORE);return a&&r.logger.debug(`Property ${t.join(".")}.${i} is marked with x-fern-ignore. Skipping.`),!a}))}function Xoh({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[o,c]=wn(e)?[t.resolveSchemaReference(e),ZHa(e.$ref)]:[e,r];for(let d of o.allOf??[])a={...a,...Xoh({schema:d,context:t,breadcrumbs:c,source:i,namespace:n})};for(let[d,s]of Object.entries(Yoh({properties:o.properties??{},breadcrumbs:r,context:t}))){let u=Zl(s,!1,!1,t,[...c,d],i,n);a[d]=u}return a}function tJi({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsOptional:o,wrapAsNullable:c,context:d,subtypes:s,namespace:u,groupName:l,encoding:p,source:_,subtypeSuffixOverrides:h}){let y=GRD({schemas:s}),b=s.flatMap((O,A)=>{if(!wn(O)&&O.enum!=null&&d.options.coerceEnumsToLiterals&&O.type==="string")return O.enum.map(m=>ai.literal({nameOverride:void 0,generatedName:f1([t,m],d.options.preserveSchemaIds),title:void 0,value:Ww.string(String(m)),namespace:u,groupName:void 0,description:void 0,availability:m.availability}));let g=y[A];if(h!=null){let m=h[A];m!=null&&"name"in m&&(g=m.name)}return[Zl(O,!1,!1,d,[...i,g??`${A}`],_,u)]}),v=VRD(b);return WRD({uniqueSubtypes:v,nameOverride:e,generatedName:t,title:r,wrapAsOptional:o,wrapAsNullable:c,description:n,availability:a,namespace:u,groupName:l,context:d,encoding:p,source:_})}function VRD(e){let t=[];for(let r=0;r<e.length;++r){let i=e[r],n=!1;for(let a=r+1;a<e.length;++a){let o=e[a];if(i!=null&&o!=null&&H$(i,o)){n=!0;break}}i!=null&&!n&&t.push(i)}return t}function WRD({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,namespace:d,groupName:s,context:u,encoding:l,source:p}){if(Object.entries(e).every(([h,y])=>y.type==="literal")){let h={},y=[];return Object.entries(e).forEach(([b,v])=>{v.type==="literal"&&v.value.type==="string"&&(y.push(v.value.value),v.description!=null&&(h[v.value.value]={description:v.description}))}),kKi({nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,fernEnum:h,enumVarNames:void 0,enumValues:y,_default:void 0,namespace:d,groupName:s,context:u,source:p,inline:void 0})}if(e.length===1&&e[0]!=null&&!u.options.preserveSingleSchemaOneOf){let h=e[0];return a&&(h=ai.nullable({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),n&&(h=ai.optional({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),h}return Zoh({nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,subtypes:e,namespace:d,groupName:s,encoding:l,source:p})}function AVc({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsOptional:a,wrapAsNullable:o,context:c,namespace:d,groupName:s,discriminator:u,encoding:l,source:p}){let _=Object.entries(u.mapping??{}).map(([b,v],O)=>{let A={$ref:v},g=TQi(A,!1,!1,c,[v],l,p,d);return c.markSchemaWithDiscriminantValue(A,u.propertyName,b),g.type==="object"&&(g.properties={[u.propertyName]:ai.literal({nameOverride:void 0,generatedName:f1([t,b],c.options.preserveSchemaIds),title:void 0,value:Ww.string(b),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...g.properties.filter(m=>m.key!==u.propertyName)}),g}),h=[];for(let b=0;b<_.length;++b){let v=_[b],O=!1;for(let A=b+1;A<_.length;++A){let g=_[A];if(v!=null&&g!=null&&H$(v,g)){O=!0;break}}v!=null&&!O&&h.push(v)}if(Object.entries(h).every(([b,v])=>v.type==="literal")){let b={},v=[];return Object.entries(h).forEach(([O,A])=>{A.type==="literal"&&A.value.type==="string"&&(v.push(A.value.value),A.description!=null&&(b[A.value.value]={description:A.description}))}),kKi({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:i,availability:n,fernEnum:b,enumVarNames:void 0,enumValues:v,_default:void 0,namespace:d,groupName:s,context:c,source:p,inline:void 0})}return h.length===1&&h[0]!=null&&!c.options.preserveSingleSchemaOneOf?h[0]:Zoh({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:i,availability:n,subtypes:h,namespace:d,groupName:s,encoding:l,source:p})}function GRD({schemas:e}){let t={},r=0;for(let n of e){if(!wn(n)){if(n.properties!=null&&Object.entries(n.properties).length>0){let a=Object.keys(n.properties),o={},c=a;for(let[d,s]of Object.entries(t)){let u=LCo(s,a);c=LCo(c,s),o[d]=u}o[r]=c,t=o}}r++}return e.map((n,a)=>{let o=t[a];if(o!=null&&o.length>0){let c=o.sort();if(c[0]!=null)return c[0]}return lbn(a)??`${a}`})}function Zoh({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,description:a,availability:o,subtypes:c,namespace:d,groupName:s,encoding:u,source:l}){let p=ai.oneOf(Rve.undiscriminated({description:a,availability:o,nameOverride:e,generatedName:t,title:r,schemas:c,namespace:d,groupName:s,encoding:u,source:l,inline:void 0}));return n&&(p=ai.nullable({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:d,groupName:s,inline:void 0})),i&&(p=ai.optional({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:d,groupName:s,inline:void 0})),p}function Oaa(e){if(e.default!=null&&typeof e.default=="string")return e.default}function Nfu({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=_bn(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function koh({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=_bn(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function uYt({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=_bn(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function euh({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=_bn(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var ybn="#/components/schemas/";function nuh(e,t){let r=wn(e)?t.resolveSchemaReference(e):e;switch(r.type){case"boolean":case"number":case"integer":return!0;case"string":return r.enum==null;case"array":return nuh(r.items,t);case"object":return!1;case void 0:return!1;default:return t.logger.warn("Unhandled schema type. Will not inline this schema",JSON.stringify(r)),!1}}function HRD(e,t,r){return r.options.resolveAliases?typeof r.options.resolveAliases=="object"&&r.options.resolveAliases.except?.includes(e)?!1:nuh(t,r):!1}function Zl(e,t,r,i,n,a,o,c=!1,d=new Set,s){let u=Qoh(e)??a,l=kRD({schema:e,logger:i.logger}),p=s;if(wn(e)){let _=xRD(e);_!==void 0&&(p=_)}if(wn(e)){let _=eJi(e);return _!=null?HRD(_,e,i)?gaa(i.resolveSchemaReference(e),t,r,i,ZHa(e.$ref),l,u,o,d,c,p):(c?i.markSchemaAsReferencedByRequest(_):i.markSchemaAsReferencedByNonRequest(_),TQi(e,t,r,i,n,l,u,o)):gaa(i.resolveSchemaReference(e),t,r,i,ZHa(e.$ref),l,u,o,d,c,p)}return gaa(e,t,r,i,n,l,u,o,d,c,s)}function xRD(e){if("example"in e&&e.example!==void 0){let t=e.example;if(typeof t=="string"||typeof t=="number"||typeof t=="boolean"||Array.isArray(t))return t}if("examples"in e){let t=e.examples;if(Array.isArray(t)&&t.length>0){let r=t[0];if(typeof r=="string"||typeof r=="number"||typeof r=="boolean"||Array.isArray(r))return r}}}function TQi(e,t,r,i,n,a,o,c){let d=e.$ref.includes("properties")?gaa(i.resolveSchemaReference(e),t,r,i,n,a,o,c,new Set):ai.reference(OVc(e,n,o,i.options.preserveSchemaIds));if(r===!1){let s=i.resolveSchemaReference(e);(s.nullable===!0||Array.isArray(s.type)&&s.type.length>=2&&s.type.includes("null"))&&(r=!0)}return r&&(d=ai.nullable({title:void 0,nameOverride:void 0,generatedName:f1(n,i.options.preserveSchemaIds),value:d,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),t&&(d=ai.optional({title:void 0,nameOverride:void 0,generatedName:f1(n,i.options.preserveSchemaIds),value:d,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),d}function KRD(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function gaa(e,t,r,i,n,a,o,c,d=new Set,s=!1,u){typeof e=="string"&&(e={type:e});let l=Ci(e,Ki.TYPE_NAME)??(i.options.useTitlesAsName?KRD(e.title):void 0),p=Ci(e,Ki.SDK_GROUP_NAME)??Ci(e,tL.TAGS)?.[0],_=(typeof p=="string"?[p]:p)??[];_=i.resolveGroupName(_);let h=f1(n,i.options.preserveSchemaIds),y=e.title,b=e.description,v=dW(e),O=[];e.example!=null&&O.push({name:void 0,value:e.example,description:void 0});let A=Ci(e,tL.EXAMPLES);A!=null&&Object.keys(A).length>0&&O.push(...Object.entries(A).map(([j,S])=>({name:S?.summary??j,value:S.value,description:S.description})));let g=_bn(e);g!=null&&Object.keys(g).length>0&&O.push(...g.map(j=>({name:void 0,value:j,description:void 0})));let m=Foh({schema:e,description:b,title:y,nameOverride:l,generatedName:h,availability:v});if(m!=null){let j=m;return r&&(j=ai.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:j})),t&&(j=ai.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:j})),j}try{if(Array.isArray(e.type)){let w=e.type.indexOf("null"),D=w!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&D)e.type.splice(w,1),e.type=e.type[0],e.nullable=!0;else if(D&&(e.type.splice(w,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let B=new Set([...e.oneOf,...e.type]);e.oneOf=[...B]}}if(r=r||e.nullable===!0,"const"in e&&(e.enum=[e.const]),e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(e.enum=e.enum.filter(D=>D!==null),!Ufu(e.enum))return pW({nameOverride:l,generatedName:h,title:y,primitive:Jn.string({default:Oaa(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:uYt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v});let w=Noh(e);return i.options.coerceEnumsToLiterals&&e.enum.length===1&&e.enum[0]!=null&&w==null?xoh({nameOverride:l,generatedName:h,title:y,wrapAsOptional:t,wrapAsNullable:r,value:e.enum[0],description:b,availability:v,namespace:c,groupName:_}):kKi({nameOverride:l,generatedName:h,title:y,fernEnum:w,enumVarNames:Ci(e,[tL.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:_,context:i,source:o,inline:void 0})}if(Ufu(e.type)&&e.type.length>1){let w=e.type.includes("null"),D=e.type.filter(B=>B!=="null").map(B=>({type:B,nullable:w}));return tJi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:D,namespace:c,groupName:_,encoding:a,source:o})}if(e.type==="boolean"){let w=Ci(e,Ki.BOOLEAN_LITERAL);return w!=null?ruh({nameOverride:l,generatedName:h,title:y,literal:Ww.boolean(w),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):pW({nameOverride:l,generatedName:h,title:y,primitive:Jn.boolean({default:JRD(e.default),example:koh({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_})}if(e.type==="number")return gVc({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:hbn(e.exclusiveMinimum),exclusiveMaximum:hbn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Nfu({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="integer")return Hoh({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:hbn(e.exclusiveMinimum),exclusiveMaximum:hbn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Nfu({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_,defaultIntegerFormat:i.options.defaultIntegerFormat});if(e.type==="float")return gVc({nameOverride:l,generatedName:h,title:y,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:hbn(e.exclusiveMinimum),exclusiveMaximum:hbn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Nfu({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="string"){if(e.format==="date-time")return pW({nameOverride:l,generatedName:h,title:y,primitive:Jn.datetime({example:uYt({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_});if(e.format==="date"&&i.options.typeDatesAsStrings===!1)return pW({nameOverride:l,generatedName:h,title:y,primitive:Jn.date({example:uYt({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_});if(e.format==="json-string"){let D=ai.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:void 0});return r&&(D=ai.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),t&&(D=ai.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),D}let w=ouh(e,"const");return w!=null?ruh({nameOverride:l,generatedName:h,title:y,literal:Ww.string(w),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):pW({nameOverride:l,generatedName:h,title:y,primitive:Jn.string({default:Oaa(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:uYt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v})}if(e.type==="array")return Voh({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,item:e.items,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,example:euh({schema:e,logger:i.logger,fallback:u}),source:o});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&Ffu(e)&&tuh(e))return Uoh({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,additionalProperties:e.additionalProperties,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,example:e.example,source:o});if(e.oneOf!=null&&e.oneOf.length>0&&Ci(e,Ki.IS_DISCRIMINATED)===!1)return tJi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:e.oneOf,namespace:c,groupName:_,encoding:a,source:o});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return i.options.discriminatedUnionV2?AVc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,discriminator:e.discriminator,encoding:a,source:o}):bVc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,source:o});if(e.oneOf!=null&&e.oneOf.length>0){let w=Ci(e,Ki.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return i.options.discriminatedUnionV2||w?AVc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,discriminator:e.discriminator,encoding:a,source:o}):bVc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,source:o});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(i.options.preserveSingleSchemaOneOf)return tJi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:e.oneOf.filter(B=>wn(B)||B.type!=="null"),encoding:a,namespace:c,groupName:_,source:o});let D=Zl(e.oneOf[0],t,r,i,n,o,c,s);return sYt(D,b,c,_)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let N=e.oneOf[0],z=e.oneOf[1];if(!wn(N)&&N.type==="null"){let F=Zl(z,t,!0,i,n,o,c);return sYt(F,b,c,_)}else if(!wn(z)&&z.type==="null"){let F=Zl(N,t,!0,i,n,o,c);return sYt(F,b,c,_)}}let D=YRD({schemas:e.oneOf});if(D!=null)return kKi({nameOverride:l,generatedName:h,title:y,fernEnum:void 0,enumVarNames:void 0,enumValues:D,_default:e.default,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:_,context:i,source:o,inline:void 0});let B=iuh({schemas:e.oneOf,context:i});if(B!=null&&!i.options.discriminatedUnionV2&&!w)return vVc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},required:e.required,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,discriminant:B.discriminant,variants:B.schemas,context:i,namespace:c,groupName:_,encoding:a,source:o});let R=e.oneOf.filter(N=>!wn(N)&&N.type==="null").length>0;return tJi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||R,context:i,subtypes:e.oneOf.filter(N=>wn(N)||N.type!=="null"),encoding:a,namespace:c,groupName:_,source:o})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let B=Zl(e.anyOf[0],t,r,i,n,o,c,s);return sYt(B,b,c,_)}if(e.anyOf.length===2){let[B,R]=e.anyOf;if(B!=null&&R!=null){if(!wn(B)&&B.type==="null"){let N=Zl(R,t,!0,i,n,o,c);return sYt(N,b,c,_)}else if(!wn(R)&&R.type==="null"){let N=Zl(B,t,!0,i,n,o,c);return sYt(N,b,c,_)}}}let w=iuh({schemas:e.anyOf,context:i});if(w!=null&&!i.options.discriminatedUnionV2)return vVc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},required:e.required,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,discriminant:w.discriminant,variants:w.schemas,context:i,namespace:c,groupName:_,encoding:a,source:o});let D=e.anyOf.filter(B=>!wn(B)&&B.type==="null").length>0;return tJi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||D,context:i,subtypes:e.anyOf.filter(B=>wn(B)||B.type!=="null"),encoding:a,namespace:c,groupName:_,source:o})}if(e.allOf!=null||e.properties!=null){let w=[];for(let B of e.allOf??[])(wn(B)||Object.keys(B).length>0)&&w.push(B);if((e.properties==null||Ffu(e))&&w.length===1&&w[0]!=null&&(e.additionalProperties==null||e.additionalProperties===!1)){let B=Zl(w[0],t,r,i,n,o,c,s);return sYt(B,b,c,_)}let D=w.filter(B=>{let R=Qfu(B);return R||i.logger.debug(`Skipping non-object allOf element: ${JSON.stringify(B)}`),R});if((e.properties==null||Ffu(e))&&D.length===1&&D[0]!=null&&(e.additionalProperties==null||e.additionalProperties===!1)){let B=Zl(D[0],t,r,i,n,o,c,s);return sYt(B,b,c,_)}return $oh({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},description:b,required:e.required,wrapAsOptional:t,wrapAsNullable:r,allOf:D,context:i,propertiesToExclude:d,namespace:c,groupName:_,fullExamples:O,additionalProperties:e.additionalProperties,availability:v,encoding:a,source:o})}if(e.type==="object"&&$RD(e)&&tuh(e)&&Ffu(e))return yVc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,keySchema:{nameOverride:void 0,generatedName:`${h}Key`,title:void 0,description:void 0,availability:void 0,schema:Jn.string({default:Oaa(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:uYt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_},valueSchema:ai.unknown({nameOverride:void 0,generatedName:`${h}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:c,groupName:_}),namespace:c,groupName:_,encoding:a,example:e.example});e.type!=null&&i.logger.warn(`Failed to parse an OpenAPI schema at the following location: ${n.join("->")}. Coercing to unknown.`);let j=e.example??e.default,S=ai.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:j});return r&&(S=ai.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:S})),t&&(S=ai.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:S})),S}catch(j){return i.logger.debug(`Error converting schema: ${j.message}
|
|
1409
|
+
`)),{ok:!0,value:t}):i}}function Ocu(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var zna=class e extends Error{errors;constructor(t){super(t.map(Ocu).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var Nna=class e extends Error{errors;constructor(t){super(t.map(Ocu).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function LP(e){return{optional:()=>WLc(e),transform:t=>GLc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new Nna(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new zna(i.errors)}}}function WLc(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:()=>Rh.OPTIONAL};return{...t,...LP(t)}}function GLc(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,...LP(r)}}function hah(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:hm(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:hm(t,"bigint")}]},getType:()=>Rh.BIGINT};return{...aF(e),...LP(e)}}var lTD=/^([+-]?\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 yah(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:hm(t,"string")}]}:lTD.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:hm(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:hm(t,"Date object")}]},getType:()=>Rh.DATE};return{...aF(e),...LP(e)}}function lW(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...aF(r),...LP(r)}}}function Acu(e){let t=new Set(e);return lW(Rh.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:hm(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:hm(i,"enum")}]}:{ok:!0,value:i})()}function bah(e){let t=HLc(e);return{...t,...LP(t)}}function HLc(e){return{parse:(t,r)=>Fna(e).parse(t,r),json:(t,r)=>Fna(e).json(t,r),getType:()=>Fna(e).getType()}}function Fna(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function NHa(e){return Object.entries(e)}function FHa(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function WKi(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 QHa(e){return Object.keys(e)}function vah(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function G3t(e){return{withParsedProperties:t=>xLc(e,t)}}function xLc(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(!WKi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:hm(i,"object")}]};let a=new Set(Object.keys(t)),o=FHa(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(o,n)},getType:()=>e.getType()};return{...r,...LP(r),...G3t(r)}}function gah(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function GKi(e){return e.isProperty}function mcu(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>GKi(i)?i.rawKey:r),_getParsedProperties:()=>QHa(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of NHa(e)){let d=GKi(c)?c.rawKey:o,s=GKi(c)?c.valueSchema:c,u={rawKey:d,parsedKey:o,valueSchema:s};n[d]=u,mah(s)&&a.push(d)}return Oah({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 NHa(e)){let c=GKi(o)?o.valueSchema:o;mah(c)&&n.push(a)}return Oah({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return GKi(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:()=>Rh.OBJECT};return{...aF(t),...LP(t),...G3t(t),...cbn(t)}}function Oah({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!WKi(e))return{ok:!1,errors:[{path:a,message:hm(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 cbn(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>Aah({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>Aah({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>Rh.OBJECT};return{...r,...LP(r),...G3t(r),...cbn(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:()=>Rh.OBJECT};return{...t,...LP(t),...G3t(t),...cbn(t)}}}}function Aah({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,o]=vah(QHa(t),s=>n.has(s)),c=r(FHa(t,o)),d=i(FHa(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 mah(e){return!fTD(e)}function fTD(e){switch(e.getType()){case Rh.ANY:case Rh.UNKNOWN:case Rh.OPTIONAL:return!0;default:return!1}}function Pah(e){return mcu(e)}function jah(e){let t={...HLc(e),_getRawProperties:()=>Fna(e)._getRawProperties(),_getParsedProperties:()=>Fna(e)._getParsedProperties()};return{...t,...LP(t),...G3t(t),...cbn(t)}}function Pcu(e){let t={parse:(r,i)=>wah(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>wah(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>Rh.LIST};return{...aF(t),...LP(t)}}function wah(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:hm(e,"list"),path:[]}]}}function Eah(e){return lW(Rh.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:hm(r,`"${e}"`)}]})()}function Sah(e){return lW(Rh.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:hm(r,`${e.toString()}`)}]})()}var Mah=lW(Rh.ANY,e=>({ok:!0,value:e}));var Dah=lW(Rh.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:hm(e,"boolean")}]});var Bah=lW(Rh.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:hm(e,"number")}]});var Iah=lW(Rh.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:hm(e,"string")}]});var Cah=lW(Rh.UNKNOWN,e=>({ok:!0,value:e}));function Tah(e,t){let r={parse:(i,n)=>qah({value:i,isKeyNumeric:e.getType()===Rh.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)=>qah({value:i,isKeyNumeric:e.getType()===Rh.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:()=>Rh.RECORD};return{...aF(r),...LP(r)}}function qah({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return WKi(e)?NHa(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:hm(e,"object")}]}}function Rah(e){let t=Pcu(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:hm(i,"Set")}]},getType:()=>Rh.SET};return{...aF(r),...LP(r)}}function Nah(e){let t={parse:(r,i)=>zah((n,a)=>n.parse(r,a),e,i),json:(r,i)=>zah((n,a)=>n.json(r,a),e,i),getType:()=>Rh.UNDISCRIMINATED_UNION};return{...aF(t),...LP(t)}}function zah(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 Fah(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Uah(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=Acu(QHa(t)),a={parse:(o,c)=>Qah({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)=>Qah({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:()=>Rh.UNION};return{...aF(a),...LP(a),...G3t(a)}}function Qah({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!WKi(e))return{ok:!1,errors:[{path:c,message:hm(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 yp=L.objectWithoutOptionalProperties({title:L.string().optional()});var jcu=L.objectWithoutOptionalProperties({file:L.string()});var wcu=L.objectWithoutOptionalProperties({file:L.string()});var Ecu=L.union("type",{openapi:jcu,protobuf:wcu}).transform({transform:e=>{switch(e.type){case"openapi":return cW.openapi(e);case"protobuf":return cW.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Eu=L.objectWithoutOptionalProperties({source:Ecu.optional()});var Scu=L.objectWithoutOptionalProperties({typeName:L.string()});var Mcu=L.union("type",{protobuf:Scu}).transform({transform:e=>{switch(e.type){case"protobuf":return Rna.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var G$=L.objectWithoutOptionalProperties({encoding:Mcu.optional()});var Ni=L.objectWithoutOptionalProperties({description:L.string().optional()});var Dcu=L.enum_(["GenerallyAvailable","Beta","Deprecated"]);var Vu=L.objectWithoutOptionalProperties({availability:Dcu.optional()});var rYt=L.number();var AEe=L.objectWithoutOptionalProperties({statusCode:rYt.optional()});var yf=L.objectWithoutOptionalProperties({nameOverride:L.string().optional(),generatedName:L.string()});var eA=L.objectWithoutOptionalProperties({inline:L.boolean().optional()});var kG=L.string();var eH=L.string();var Bcu=L.objectWithoutOptionalProperties({id:eH}).extend(Ni);var HKi=L.string();var Icu=L.objectWithoutOptionalProperties({usernameVariableName:L.string().optional(),usernameEnvVar:L.string().optional(),passwordVariableName:L.string().optional(),passwordEnvVar:L.string().optional()});var Ccu=L.objectWithoutOptionalProperties({tokenVariableName:L.string().optional(),tokenEnvVar:L.string().optional()});var qcu=L.objectWithoutOptionalProperties({headerName:L.string(),prefix:L.string().optional(),headerVariableName:L.string().optional(),headerEnvVar:L.string().optional()});var Tcu=L.objectWithoutOptionalProperties({queryParameterName:L.string()});var Rcu=L.objectWithoutOptionalProperties({snake:L.string().optional(),camel:L.string().optional(),screamingSnake:L.string().optional(),pascal:L.string().optional()});var xKi=L.objectWithoutOptionalProperties({nameOverride:L.string().optional(),generatedName:L.string(),value:L.string(),casing:Rcu.optional()}).extend(Ni).extend(Vu);var zcu=L.objectWithoutOptionalProperties({type:L.stringLiteral("namespace"),name:L.string()});var Ncu=L.undiscriminatedUnion([L.string(),zcu]);var KKi=L.list(Ncu);var bp=L.objectWithoutOptionalProperties({groupName:KKi.optional()});var Xl=L.objectWithoutOptionalProperties({namespace:L.string().optional()});var Qna=L.objectWithoutOptionalProperties({default:xKi.optional(),values:L.list(xKi)}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(Eu).extend(yp).extend(eA);var Fcu=L.objectWithoutOptionalProperties({scopesEnum:Qna.optional()});var Qcu=L.union("type",{basic:Icu,bearer:Ccu,header:qcu,query:Tcu,oauth:Fcu}).transform({transform:e=>{switch(e.type){case"basic":return tF.basic(e);case"bearer":return tF.bearer(e);case"header":return tF.header(e);case"query":return tF.query(e);case"oauth":return tF.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var UHa=L.objectWithoutOptionalProperties({name:L.string().optional(),url:L.string(),audiences:L.list(L.string()).optional()}).extend(Ni);var Ucu=L.string();var iYt=L.objectWithoutOptionalProperties({sdkMethodName:L.string().optional()});var JLc={};Zt(JLc,{FullExample:()=>VP,FullObjectExample:()=>Wcu,FullOneOfExample:()=>Hcu,KeyValuePair:()=>Gcu,LiteralExample:()=>Lcu,NullExample:()=>Vcu,PrimitiveExample:()=>Lna,PropertyKey:()=>Una});var Una=L.string();var Lna=L.union("type",{int:L.object({value:L.number()}),int64:L.object({value:L.number()}),uint:L.object({value:L.number()}),uint64:L.object({value:L.number()}),float:L.object({value:L.number()}),double:L.object({value:L.number()}),string:L.object({value:L.string()}),datetime:L.object({value:L.string()}),date:L.object({value:L.string()}),base64:L.object({value:L.string()}),boolean:L.object({value:L.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return po.int(e.value);case"int64":return po.int64(e.value);case"uint":return po.uint(e.value);case"uint64":return po.uint64(e.value);case"float":return po.float(e.value);case"double":return po.double(e.value);case"string":return po.string(e.value);case"datetime":return po.datetime(e.value);case"date":return po.date(e.value);case"base64":return po.base64(e.value);case"boolean":return po.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Lcu=L.union("type",{boolean:L.object({value:L.boolean()}),string:L.object({value:L.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return LKi.boolean(e.value);case"string":return LKi.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Vcu=L.objectWithoutOptionalProperties({});var VP=L.union("type",{primitive:L.object({value:Lna}),object:L.lazyObject(()=>Wcu),array:L.object({value:L.list(L.lazy(()=>VP))}),map:L.object({value:L.list(L.lazyObject(()=>Gcu))}),enum:L.object({value:L.string()}),literal:L.object({value:Lcu}),oneOf:L.object({value:L.lazy(()=>Hcu)}),null:Vcu,unknown:L.object({value:L.lazy(()=>VP)})}).transform({transform:e=>{switch(e.type){case"primitive":return ml.primitive(e.value);case"object":return ml.object(e);case"array":return ml.array(e.value);case"map":return ml.map(e.value);case"enum":return ml.enum(e.value);case"literal":return ml.literal(e.value);case"oneOf":return ml.oneOf(e.value);case"null":return ml.null(e);case"unknown":return ml.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Wcu=L.objectWithoutOptionalProperties({properties:L.record(Una,L.lazy(()=>VP))});var Gcu=L.objectWithoutOptionalProperties({key:Lna,value:L.lazy(()=>VP)});var Hcu=L.union("type",{discriminated:L.object({value:L.record(Una,L.lazy(()=>VP))}),undiscriminated:L.object({value:L.lazy(()=>VP)})}).transform({transform:e=>{switch(e.type){case"discriminated":return VKi.discriminated(e.value);case"undiscriminated":return VKi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var $Lc={};Zt($Lc,{AllOfPropertyConflict:()=>uaa,ArraySchema:()=>zlu,Availability:()=>Dcu,BooleanSchema:()=>Dlu,BytesResponse:()=>Yna,CasingOverrides:()=>Rcu,CommonProperty:()=>Glu,CursorPagination:()=>dlu,CustomCodeSample:()=>llu,CustomCodeSampleLanguage:()=>ulu,CustomCodeSampleSdk:()=>clu,CustomPagination:()=>_lu,DiscriminatedOneOfSchema:()=>Vlu,DoubleSchema:()=>Slu,Endpoint:()=>hlu,EndpointExample:()=>taa,EndpointResponseExample:()=>olu,EndpointSdkName:()=>nYt,EndpointSecurity:()=>Vna,EnumSchema:()=>Qna,EnumValue:()=>xKi,ErrorExample:()=>tlu,FernExample:()=>ilu,FileResponse:()=>Jna,FileSchema:()=>Jcu,FormUrlEncodedRequest:()=>kcu,FullEndpointExample:()=>flu,GlobalHeader:()=>Clu,GlobalSecurity:()=>Ilu,Header:()=>JKi,HeaderExample:()=>eaa,HttpEndpointServer:()=>Zna,HttpError:()=>rlu,HttpMethod:()=>Wna,IdempotencyHeader:()=>qlu,IntSchema:()=>wlu,JsonRequest:()=>Zcu,JsonResponse:()=>$na,LiteralSchema:()=>oaa,LiteralSchemaValue:()=>Tlu,LongSchema:()=>Elu,MapSchema:()=>Nlu,MultipartRequest:()=>Kna,MultipartRequestProperty:()=>Xcu,MultipartRequestPropertyEncoding:()=>Ycu,MultipartSchema:()=>$cu,NullableSchema:()=>Qlu,ObjectProperty:()=>Llu,ObjectPropertyConflictInfo:()=>saa,ObjectSchema:()=>Rlu,OctetStreamRequest:()=>xna,OffsetPagination:()=>plu,OneOfSchema:()=>Ulu,OpenApiIntermediateRepresentation:()=>Lah,OptionalSchema:()=>Flu,Pagination:()=>raa,PathParameter:()=>Gna,PathParameterExample:()=>nlu,PrimitiveSchema:()=>YKi,PrimitiveSchemaValue:()=>Blu,QueryParameter:()=>Hna,QueryParameterExample:()=>kna,ReferencedSchema:()=>aYt,Request:()=>elu,Response:()=>Xna,RetriesConfiguration:()=>iaa,Schema:()=>Dd,Schemas:()=>jlu,SdkGroupInfo:()=>xcu,StreamingResponseExample:()=>alu,StringSchema:()=>Mlu,SupportedSdkLanguage:()=>slu,Tags:()=>Kcu,TextResponse:()=>$Ki,UnDiscriminatedOneOfSchema:()=>Wlu,Webhook:()=>ylu,WebhookExampleCall:()=>aaa,WebhookHttpMethod:()=>naa,WebsocketChannel:()=>Plu,WebsocketHandshake:()=>blu,WebsocketMessageExample:()=>Alu,WebsocketMessageOrigin:()=>vlu,WebsocketMessageSchema:()=>glu,WebsocketServer:()=>Olu,WebsocketSessionExample:()=>mlu});var xcu=L.objectWithoutOptionalProperties({summary:L.string().optional(),description:L.string().optional()});var Kcu=L.objectWithoutOptionalProperties({tagsById:L.record(eH,Bcu),orderedTagIds:L.list(eH).optional()});var Vna=L.list(L.record(HKi,L.list(L.string())));var Wna=L.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var Gna=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>Dd),variableReference:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ni).extend(Vu).extend(Eu);var Hna=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>Dd),parameterNameOverride:L.string().optional()}).extend(Ni).extend(Vu).extend(Eu);var JKi=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>Dd),env:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ni).extend(Vu).extend(Eu);var nYt=L.objectWithoutOptionalProperties({groupName:KKi,methodName:L.string()});var xna=L.objectWithoutOptionalProperties({contentType:L.string().optional()}).extend(Ni).extend(Eu);var Jcu=L.objectWithoutOptionalProperties({isOptional:L.boolean(),isArray:L.boolean()}).extend(Ni);var $cu=L.union("type",{file:Jcu,json:L.object({value:L.lazy(()=>Dd)})}).transform({transform:e=>{switch(e.type){case"file":return eYt.file(e);case"json":return eYt.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Ycu=L.enum_(["json","form"]);var Xcu=L.objectWithoutOptionalProperties({key:L.string(),schema:$cu,contentType:L.string().optional(),exploded:L.boolean().optional(),encoding:Ycu.optional()}).extend(Ni);var Kna=L.objectWithoutOptionalProperties({name:L.string().optional(),properties:L.list(Xcu)}).extend(Ni).extend(Eu);var Zcu=L.objectWithoutOptionalProperties({schema:L.lazy(()=>Dd),contentType:L.string().optional(),additionalProperties:L.boolean()}).extend(Ni).extend(Eu);var kcu=L.objectWithoutOptionalProperties({schema:L.lazy(()=>Dd),contentType:L.string().optional(),additionalProperties:L.boolean()}).extend(Ni).extend(Eu);var elu=L.union("type",{octetStream:xna,multipart:Kna,json:Zcu,formUrlEncoded:kcu}).transform({transform:e=>{switch(e.type){case"octetStream":return W3t.octetStream(e);case"multipart":return W3t.multipart(e);case"json":return W3t.json(e);case"formUrlEncoded":return W3t.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var Jna=L.objectWithoutOptionalProperties({}).extend(Ni).extend(Eu).extend(AEe);var $na=L.objectWithoutOptionalProperties({schema:L.lazy(()=>Dd),responseProperty:L.string().optional()}).extend(Ni).extend(Eu).extend(AEe);var $Ki=L.objectWithoutOptionalProperties({}).extend(Ni).extend(Eu).extend(AEe);var Yna=L.objectWithoutOptionalProperties({}).extend(Ni).extend(Eu).extend(AEe);var Xna=L.union("type",{file:Jna,json:$na,text:$Ki,bytes:Yna,streamingSse:$na,streamingText:$Ki,streamingJson:$na}).transform({transform:e=>{switch(e.type){case"file":return eL.file(e);case"json":return eL.json(e);case"text":return eL.text(e);case"bytes":return eL.bytes(e);case"streamingSse":return eL.streamingSse(e);case"streamingText":return eL.streamingText(e);case"streamingJson":return eL.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var tlu=L.objectWithoutOptionalProperties({name:L.string().optional(),description:L.string().optional(),example:L.lazy(()=>VP)});var rlu=L.objectWithoutOptionalProperties({schema:L.lazy(()=>Dd).optional(),examples:L.list(tlu).optional()}).extend(Ni).extend(yf).extend(Eu);var Zna=L.objectWithoutOptionalProperties({name:L.string().optional(),url:L.string().optional(),audiences:L.list(L.string()).optional()});var ilu=L.unknown();var nlu=L.objectWithoutOptionalProperties({name:L.string(),parameterNameOverride:L.string().optional(),value:L.lazy(()=>VP)});var kna=L.objectWithoutOptionalProperties({name:L.string(),value:L.lazy(()=>VP)});var eaa=L.objectWithoutOptionalProperties({name:L.string(),value:L.lazy(()=>VP)});var alu=L.objectWithoutOptionalProperties({sse:L.boolean(),events:L.list(L.lazy(()=>VP))});var olu=L.union("type",{withStreaming:alu,withoutStreaming:L.object({value:L.lazy(()=>VP)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return OEe.withStreaming(e);case"withoutStreaming":return OEe.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var ulu=L.objectWithoutOptionalProperties({name:L.string().optional(),language:L.string(),code:L.string(),install:L.string().optional()}).extend(Ni);var slu=L.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var clu=L.objectWithoutOptionalProperties({name:L.string().optional(),sdk:slu,code:L.string()}).extend(Ni);var llu=L.union("type",{language:ulu,sdk:clu}).transform({transform:e=>{switch(e.type){case"language":return k$t.language(e);case"sdk":return k$t.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var flu=L.objectWithoutOptionalProperties({name:L.string().optional(),pathParameters:L.list(nlu).optional(),queryParameters:L.list(kna).optional(),headers:L.list(eaa).optional(),request:L.lazy(()=>VP).optional(),response:olu.optional(),codeSamples:L.list(llu)}).extend(Ni);var taa=L.union("type",{unknown:L.object({value:ilu}),full:flu}).transform({transform:e=>{switch(e.type){case"unknown":return gEe.unknown(e.value);case"full":return gEe.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var dlu=L.objectWithoutOptionalProperties({cursor:L.string(),nextCursor:L.property("next_cursor",L.string()),results:L.string()});var plu=L.objectWithoutOptionalProperties({offset:L.string(),results:L.string(),step:L.string().optional(),hasNextPage:L.string().optional()});var _lu=L.objectWithoutOptionalProperties({results:L.string()});var raa=L.union("type",{cursor:dlu,offset:plu,custom:_lu}).transform({transform:e=>{switch(e.type){case"cursor":return Tve.cursor(e);case"offset":return Tve.offset(e);case"custom":return Tve.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var iaa=L.union("type",{disabled:L.object({value:L.boolean().optional()})}).transform({transform:e=>{switch(e.type){case"disabled":return zHa.disabled(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var hlu=L.objectWithoutOptionalProperties({authed:L.boolean(),security:Vna.optional(),internal:L.boolean().optional(),idempotent:L.boolean().optional(),method:Wna,audiences:L.list(L.string()),path:L.string(),summary:L.string().optional(),operationId:L.string().optional(),tags:L.list(eH),pathParameters:L.list(Gna),queryParameters:L.list(Hna),headers:L.list(JKi),sdkName:nYt.optional(),generatedRequestName:L.string(),requestNameOverride:L.string().optional(),request:elu.optional(),response:Xna.optional(),errors:L.record(rYt,rlu),servers:L.list(Zna),examples:L.list(taa),pagination:raa.optional(),retries:iaa.optional()}).extend(Ni).extend(Vu).extend(Eu).extend(Xl);var naa=L.enum_(["GET","POST"]);var aaa=L.objectWithoutOptionalProperties({name:L.string().optional(),payload:L.lazy(()=>VP)}).extend(Ni);var ylu=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),sdkName:nYt.optional(),method:naa,summary:L.string().optional(),operationId:L.string(),tags:L.list(eH),headers:L.list(JKi),generatedPayloadName:L.string(),payload:L.lazy(()=>Dd),response:Xna.optional(),examples:L.list(aaa)}).extend(Ni).extend(Eu).extend(Xl);var blu=L.objectWithoutOptionalProperties({queryParameters:L.list(Hna),headers:L.list(JKi),pathParameters:L.list(Gna)});var vlu=L.enum_(["client","server"]);var glu=L.objectWithoutOptionalProperties({name:L.string(),origin:vlu,body:L.lazy(()=>Dd),methodName:L.string().optional()});var Olu=L.objectWithoutOptionalProperties({name:L.string(),url:L.string()});var Alu=L.objectWithoutOptionalProperties({messageType:L.string(),payload:L.lazy(()=>VP)}).extend(Ni);var mlu=L.objectWithoutOptionalProperties({name:L.string().optional(),queryParameters:L.list(kna).optional(),headers:L.list(eaa).optional(),messages:L.list(Alu)}).extend(Ni);var Plu=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),path:L.string(),groupName:KKi,summary:L.string().optional(),handshake:blu,messages:L.list(glu),servers:L.list(Olu),examples:L.list(mlu)}).extend(Ni).extend(Eu);var jlu=L.objectWithoutOptionalProperties({rootSchemas:L.record(kG,L.lazy(()=>Dd)),namespacedSchemas:L.record(Ucu,L.record(kG,L.lazy(()=>Dd)))});var wlu=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional()});var Elu=L.objectWithoutOptionalProperties({default:L.number().optional()});var Slu=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional()});var Mlu=L.objectWithoutOptionalProperties({default:L.string().optional(),pattern:L.string().optional(),format:L.string().optional(),minLength:L.number().optional(),maxLength:L.number().optional()});var Dlu=L.objectWithoutOptionalProperties({default:L.boolean().optional()});var Blu=L.union("type",{int:wlu,int64:Elu,uint:L.object({}),uint64:L.object({}),float:L.object({}),double:Slu,string:Mlu,datetime:L.object({}),date:L.object({}),base64:L.object({}),boolean:Dlu}).transform({transform:e=>{switch(e.type){case"int":return Th.int(e);case"int64":return Th.int64(e);case"uint":return Th.uint();case"uint64":return Th.uint64();case"float":return Th.float();case"double":return Th.double(e);case"string":return Th.string(e);case"datetime":return Th.datetime();case"date":return Th.date();case"base64":return Th.base64();case"boolean":return Th.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var YKi=L.objectWithoutOptionalProperties({schema:Blu}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp);var Ilu=L.list(L.record(HKi,L.list(L.string())));var Clu=L.objectWithoutOptionalProperties({header:L.string(),name:L.string().optional(),optional:L.boolean().optional(),env:L.string().optional(),schema:L.lazy(()=>Dd).optional()});var qlu=L.objectWithoutOptionalProperties({header:L.string(),name:L.string().optional(),env:L.string().optional(),schema:L.lazy(()=>Dd).optional()});var Lah=L.objectWithoutOptionalProperties({apiVersion:L.unknown().optional(),title:L.string().optional(),description:L.string().optional(),basePath:L.string().optional(),servers:L.list(UHa),websocketServers:L.list(UHa),groups:L.record(L.string(),xcu),tags:Kcu,hasEndpointsMarkedInternal:L.boolean(),endpoints:L.list(hlu),webhooks:L.list(ylu),channels:L.record(L.string(),Plu),groupedSchemas:jlu,variables:L.record(L.string(),YKi),nonRequestReferencedSchemas:L.set(kG),securitySchemes:L.record(HKi,Qcu),security:Ilu.optional(),globalHeaders:L.list(Clu).optional(),idempotencyHeaders:L.list(qlu).optional()});var aYt=L.objectWithoutOptionalProperties({schema:kG}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(Eu).extend(yp);var Tlu=L.union("type",{boolean:L.object({value:L.boolean()}),string:L.object({value:L.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Ww.boolean(e.value);case"string":return Ww.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var oaa=L.objectWithoutOptionalProperties({value:Tlu}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp);var Dd=L.union("type",{primitive:YKi,object:L.lazyObject(()=>Rlu),array:L.lazyObject(()=>zlu),map:L.lazyObject(()=>Nlu),optional:L.lazyObject(()=>Flu),enum:Qna,reference:aYt,literal:oaa,oneOf:L.object({value:L.lazy(()=>Ulu)}),nullable:L.lazyObject(()=>Qlu),unknown:yf}).transform({transform:e=>{switch(e.type){case"primitive":return ic.primitive(e);case"object":return ic.object(e);case"array":return ic.array(e);case"map":return ic.map(e);case"optional":return ic.optional(e);case"enum":return ic.enum(e);case"reference":return ic.reference(e);case"literal":return ic.literal(e);case"oneOf":return ic.oneOf(e.value);case"nullable":return ic.nullable(e);case"unknown":return ic.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var uaa=L.objectWithoutOptionalProperties({propertyKey:L.string(),allOfSchemaIds:L.list(kG),conflictingTypeSignatures:L.boolean()});var Rlu=L.objectWithoutOptionalProperties({allOf:L.list(aYt),properties:L.list(L.lazyObject(()=>Llu)),allOfPropertyConflicts:L.list(uaa),additionalProperties:L.boolean()}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(Eu).extend(yp).extend(eA);var saa=L.objectWithoutOptionalProperties({differentSchema:L.boolean()});var Llu=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>Dd),readonly:L.boolean().optional(),writeonly:L.boolean().optional(),conflict:L.record(kG,saa),generatedName:L.string(),nameOverride:L.string().optional(),audiences:L.list(L.string())}).extend(Vu);var zlu=L.objectWithoutOptionalProperties({value:L.lazy(()=>Dd)}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp).extend(eA);var Nlu=L.objectWithoutOptionalProperties({key:YKi,value:L.lazy(()=>Dd)}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(G$).extend(yp).extend(eA);var Flu=L.objectWithoutOptionalProperties({value:L.lazy(()=>Dd)}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp).extend(eA);var Qlu=L.objectWithoutOptionalProperties({value:L.lazy(()=>Dd)}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp).extend(eA);var Ulu=L.union("type",{discriminated:L.lazyObject(()=>Vlu),undiscriminated:L.lazyObject(()=>Wlu)}).transform({transform:e=>{switch(e.type){case"discriminated":return tYt.discriminated(e);case"undiscriminated":return tYt.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Vlu=L.objectWithoutOptionalProperties({discriminantProperty:L.string(),commonProperties:L.list(L.lazyObject(()=>Glu)),schemas:L.record(L.string(),L.lazy(()=>Dd))}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(G$).extend(Eu).extend(yp).extend(eA);var Glu=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>Dd)});var Wlu=L.objectWithoutOptionalProperties({schemas:L.list(L.lazy(()=>Dd))}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(G$).extend(Eu).extend(yp).extend(eA);var YLc={};Zt(YLc,{ArraySchemaWithExample:()=>dfu,Base64WithExample:()=>ufu,BooleanWithExample:()=>sfu,CommonPropertyWithExample:()=>Afu,DateWithExample:()=>ofu,DatetimeWithExample:()=>afu,DiscriminatedOneOfSchemaWithExample:()=>gfu,DoubleWithExample:()=>ifu,EndpointWithExample:()=>Wah,EnumSchemaWithExample:()=>lfu,FloatWithExample:()=>rfu,HeaderWithExample:()=>XKi,HttpErrorWithExample:()=>Xlu,Int64WithExample:()=>klu,IntWithExample:()=>Zlu,JsonRequestWithExample:()=>Jlu,JsonResponseWithExample:()=>laa,MapSchemaWithExample:()=>pfu,NamedFullExample:()=>mEe,NullableSchemaWithExample:()=>hfu,ObjectPropertyWithExample:()=>vfu,ObjectSchemaWithExample:()=>yfu,OneOfSchemaWithExample:()=>bfu,OptionalSchemaWithExample:()=>_fu,ParseFormUrlEncodedRequest:()=>$lu,ParseMultipartRequest:()=>Klu,ParseOctetStreamRequest:()=>xlu,PathParameterWithExample:()=>Hlu,PrimitiveSchemaValueWithExample:()=>cfu,PrimitiveSchemaWithExample:()=>daa,QueryParameterWithExample:()=>caa,RequestWithExample:()=>Ylu,ResponseWithExample:()=>faa,SchemaWithExample:()=>tA,StringSchemaWithExample:()=>nfu,Uint64WithExample:()=>tfu,UintWithExample:()=>efu,UnDiscriminatedOneOfSchemaWithExample:()=>Ofu,UnknownSchemaWithExample:()=>ffu,WebhookWithExample:()=>Gah,WebsocketHandshakeWithExample:()=>Vah});var mEe=L.objectWithoutOptionalProperties({name:L.string().optional(),value:L.unknown()}).extend(Ni);var caa=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>tA),parameterNameOverride:L.string().optional(),explode:L.boolean().optional()}).extend(Ni).extend(Vu).extend(Eu);var XKi=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>tA),env:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ni).extend(Vu).extend(Eu);var Vah=L.objectWithoutOptionalProperties({queryParameters:L.list(caa),headers:L.list(XKi)});var Hlu=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>tA),variableReference:L.string().optional(),parameterNameOverride:L.string().optional(),explode:L.boolean().optional()}).extend(Ni).extend(Vu).extend(Eu);var xlu=L.objectWithoutOptionalProperties({}).extend(xna).extend(iYt);var Klu=L.objectWithoutOptionalProperties({}).extend(Kna).extend(iYt);var Jlu=L.objectWithoutOptionalProperties({schema:L.lazy(()=>tA),contentType:L.string().optional(),fullExamples:L.list(mEe).optional(),additionalProperties:L.boolean()}).extend(Ni).extend(Eu).extend(iYt);var $lu=L.objectWithoutOptionalProperties({schema:L.lazy(()=>tA),contentType:L.string().optional(),fullExamples:L.list(mEe).optional(),additionalProperties:L.boolean()}).extend(Ni).extend(Eu).extend(iYt);var Ylu=L.union("type",{octetStream:xlu,multipart:Klu,json:Jlu,formUrlEncoded:$lu}).transform({transform:e=>{switch(e.type){case"octetStream":return ZG.octetStream(e);case"multipart":return ZG.multipart(e);case"json":return ZG.json(e);case"formUrlEncoded":return ZG.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var laa=L.objectWithoutOptionalProperties({schema:L.lazy(()=>tA),responseProperty:L.string().optional(),fullExamples:L.list(mEe).optional()}).extend(Ni).extend(Eu).extend(AEe);var faa=L.union("type",{file:Jna,json:laa,text:$Ki,bytes:Yna,streamingSse:laa,streamingText:$Ki,streamingJson:laa}).transform({transform:e=>{switch(e.type){case"file":return O0.file(e);case"json":return O0.json(e);case"text":return O0.text(e);case"bytes":return O0.bytes(e);case"streamingSse":return O0.streamingSse(e);case"streamingText":return O0.streamingText(e);case"streamingJson":return O0.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Xlu=L.objectWithoutOptionalProperties({statusCode:rYt,schema:L.lazy(()=>tA),fullExamples:L.list(mEe).optional()}).extend(Ni).extend(yf).extend(Eu);var Wah=L.objectWithoutOptionalProperties({authed:L.boolean(),security:Vna.optional(),internal:L.boolean().optional(),idempotent:L.boolean().optional(),method:Wna,audiences:L.list(L.string()),path:L.string(),summary:L.string().optional(),operationId:L.string().optional(),tags:L.list(eH),pathParameters:L.list(Hlu),queryParameters:L.list(caa),headers:L.list(XKi),sdkName:nYt.optional(),generatedRequestName:L.string(),requestNameOverride:L.string().optional(),request:Ylu.optional(),response:faa.optional(),errors:L.record(rYt,Xlu),servers:L.list(Zna),examples:L.list(taa),pagination:raa.optional(),retries:iaa.optional()}).extend(Ni).extend(Vu).extend(Eu).extend(Xl);var Gah=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),sdkName:nYt.optional(),method:naa,summary:L.string().optional(),operationId:L.string(),tags:L.list(eH),headers:L.list(XKi),generatedPayloadName:L.string(),payload:L.lazy(()=>tA),response:faa.optional(),examples:L.list(aaa)}).extend(Ni).extend(Eu).extend(Xl);var Zlu=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional(),example:L.number().optional()});var klu=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var efu=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var tfu=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var rfu=L.objectWithoutOptionalProperties({example:L.number().optional()});var ifu=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional(),example:L.number().optional()});var nfu=L.objectWithoutOptionalProperties({default:L.string().optional(),pattern:L.string().optional(),format:L.string().optional(),minLength:L.number().optional(),maxLength:L.number().optional(),example:L.string().optional()});var afu=L.objectWithoutOptionalProperties({example:L.string().optional()});var ofu=L.objectWithoutOptionalProperties({example:L.string().optional()});var ufu=L.objectWithoutOptionalProperties({example:L.string().optional()});var sfu=L.objectWithoutOptionalProperties({default:L.boolean().optional(),example:L.boolean().optional()});var cfu=L.union("type",{int:Zlu,int64:klu,uint:efu,uint64:tfu,float:rfu,double:ifu,string:nfu,datetime:afu,date:ofu,base64:ufu,boolean:sfu}).transform({transform:e=>{switch(e.type){case"int":return Jn.int(e);case"int64":return Jn.int64(e);case"uint":return Jn.uint(e);case"uint64":return Jn.uint64(e);case"float":return Jn.float(e);case"double":return Jn.double(e);case"string":return Jn.string(e);case"datetime":return Jn.datetime(e);case"date":return Jn.date(e);case"base64":return Jn.base64(e);case"boolean":return Jn.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var daa=L.objectWithoutOptionalProperties({schema:cfu}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp);var lfu=L.objectWithoutOptionalProperties({default:xKi.optional(),values:L.list(xKi),example:L.string().optional()}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(Eu).extend(yp).extend(eA);var ffu=L.objectWithoutOptionalProperties({example:L.unknown()}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp);var tA=L.union("type",{primitive:daa,object:L.lazyObject(()=>yfu),array:L.lazyObject(()=>dfu),map:L.lazyObject(()=>pfu),optional:L.lazyObject(()=>_fu),enum:lfu,reference:aYt,literal:oaa,oneOf:L.object({value:L.lazy(()=>bfu)}),nullable:L.lazyObject(()=>hfu),unknown:ffu}).transform({transform:e=>{switch(e.type){case"primitive":return ai.primitive(e);case"object":return ai.object(e);case"array":return ai.array(e);case"map":return ai.map(e);case"optional":return ai.optional(e);case"enum":return ai.enum(e);case"reference":return ai.reference(e);case"literal":return ai.literal(e);case"oneOf":return ai.oneOf(e.value);case"nullable":return ai.nullable(e);case"unknown":return ai.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var dfu=L.objectWithoutOptionalProperties({value:L.lazy(()=>tA),example:L.list(L.unknown()).optional()}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp).extend(eA);var pfu=L.objectWithoutOptionalProperties({key:daa,value:L.lazy(()=>tA),example:L.unknown().optional()}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(G$).extend(yp).extend(eA);var _fu=L.objectWithoutOptionalProperties({value:L.lazy(()=>tA)}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp).extend(eA);var hfu=L.objectWithoutOptionalProperties({value:L.lazy(()=>tA)}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(yp).extend(eA);var yfu=L.objectWithoutOptionalProperties({allOf:L.list(aYt),properties:L.list(L.lazyObject(()=>vfu)),allOfPropertyConflicts:L.list(uaa),fullExamples:L.list(mEe).optional(),additionalProperties:L.boolean()}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(Eu).extend(yp).extend(eA);var vfu=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>tA),readonly:L.boolean().optional(),writeonly:L.boolean().optional(),audiences:L.list(L.string()),conflict:L.record(kG,saa),nameOverride:L.string().optional(),generatedName:L.string()}).extend(Vu);var bfu=L.union("type",{discriminated:L.lazyObject(()=>gfu),undiscriminated:L.lazyObject(()=>Ofu)}).transform({transform:e=>{switch(e.type){case"discriminated":return Rve.discriminated(e);case"undiscriminated":return Rve.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var gfu=L.objectWithoutOptionalProperties({discriminantProperty:L.string(),commonProperties:L.list(L.lazyObject(()=>Afu)),schemas:L.record(L.string(),L.lazy(()=>tA))}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(G$).extend(Eu).extend(yp).extend(eA);var Afu=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>tA)});var Ofu=L.objectWithoutOptionalProperties({schemas:L.list(L.lazy(()=>tA))}).extend(bp).extend(Xl).extend(yf).extend(Ni).extend(Vu).extend(G$).extend(Eu).extend(yp).extend(eA);var Hah=/^(\d+)/,paa=/^[a-zA-Z][a-zA-Z0-9_]*$/,xah={"<":"LESS_THAN",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL_TO","<=":"LESS_THAN_OR_EQUAL_TO","!=":"NOT_EQUALS","=":"EQUAL_TO","==":"EQUAL_TO","*":"ALL","":"EMPTY",'""':"EMPTY_STRING","-":"HYPHEN","|":"PIPE",".":"DOT","/":"SLASH"};function lbn(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let o=Math.floor(e/10),c=e%10;return c===0?i[o]:`${i[o]}_${t[c]}`}if(e<1e3){let o=Math.floor(e/100),c=e%100;return c===0?`${t[o]}_hundred`:`${t[o]}_hundred_${lbn(c)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${lbn(a)}`}function LHa(e){let t=e.match(Hah);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=lbn(n);return i.length>0?`${a}_${i}`:a}}}function _aa(e){let t=LHa(e),r=xah[e];return t!=null?F0(nu(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":F0(nu(e)))}function H$(e,t){return e.type==="primitive"&&t.type==="primitive"?Kah(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?dTD(e.values,t.values):e.type==="array"&&t.type==="array"?H$(e.value,t.value):e.type==="unknown"&&t.type==="unknown"?!0:e.type==="reference"&&t.type==="reference"?e.schema===t.schema:e.type==="optional"&&t.type==="optional"?H$(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?pTD(e.value,t.value):e.type==="object"&&t.type==="object"?_TD(e,t):e.type==="map"&&t.type==="map"?Kah(e.key.schema,t.key.schema)&&H$(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function Kah(e,t){return e.type===t.type}function dTD(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return NT(r,i)}function pTD(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,i])=>{let n=t.schemas[r];return n==null?!1:H$(i,n)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,i)=>{let n=t.schemas[i];return n==null?!1:H$(r,n)}):!1}function _TD(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(i=>[i.key,i.schema]));return Object.entries(t.properties).every(([i,n])=>{let a=r[i];return a==null?!1:H$(a,n.schema)})}function hM(e){switch(e){case rF.Deprecated:return"deprecated";case rF.Beta:return"pre-release";case rF.GenerallyAvailable:return"generally-available";default:return}}function hTD(e){let t=e.find(i=>typeof i=="object"&&i.type==="namespace"),r=e.filter(i=>typeof i=="string"||i.type!=="namespace");return t?[t,...r]:r}function Jah(e){let t=e?hTD(e):void 0;if(t==null||t.length===0)return Rln;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(nu(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(nu(n.name)):r.push(n.name,Rln);break}default:gt(n.type)}else gt(n);return r.join("/")}function H3t(e){return ns.of(`${Jah(e)}.yml`)}function XLc({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Rln:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,Jah(r))}function $ah({sdkName:e,namespaceOverride:t}){return ns.of(`${XLc({sdkName:e,namespaceOverride:t})}.yml`)}function Yah({location:e,namespaceOverride:t}){return t!=null?PB(ns.of(t),e):e}function mfu(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:gt(e.type)}}function IQi(e){switch(e.type){case"object":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":case"primitive":return e.groupName??void 0;case"oneOf":return e.value.groupName??void 0;case"unknown":return;default:gt(e)}}function Gy(e){return typeof e=="string"?e:e.type}function haa(e){if(typeof e!="string")return e.docs}function VHa(e){if(typeof e!="string")return e.default}function ZLc(e){if(typeof e!="string")return e.validation}function yaa(e){let t=e.match(/^optional<\s*nullable<\s*(.+)\s*>\s*>$/);if(t!=null&&t[1]!=null)return t[1].trim();let r=e.match(/^nullable<\s*(.+)\s*>$/);return r!=null&&r[1]!=null?r[1].trim():e}function Zah(e){let t=Gy(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?Xah(e):{...e,type:Xah(e.type)}}function Xah(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function fbn(e){return Gy(e).startsWith("optional<")?e:typeof e=="string"?kah(e):{...e,type:kah(e.type)}}function kah(e){return e.startsWith("optional<")?e:`optional<${e}>`}var yTD=-2147483648,bTD=2147483647,vTD=-17976931348623157e292,gTD=17976931348623157e292;function Pl({schema:e,fileContainingReference:t,declarationFile:r=t,context:i,namespace:n,declarationDepth:a}){switch(i.shouldMarkSchemaAsReferenced()&&i.markSchemaAsReferenced(e,n),e.type){case"primitive":return Pfu(e);case"array":return tVc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return rVc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return eVc({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return nVc();case"optional":return jfu({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return iVc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return MTD({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,aVc(e);case"object":return DTD({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return BTD({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:gt(e)}}function Pfu(e){switch(e.schema.type){case"string":return mTD({description:e.description,schema:e.schema});case"int":return PTD({description:e.description,schema:e.schema});case"float":return jTD({description:e.description,schema:e.schema});case"double":return wTD({description:e.description,schema:e.schema});case"boolean":return OTD({description:e.description,schema:e.schema});case"int64":return ATD({description:e.description,schema:e.schema})}let t=e.schema._visit({int:()=>"integer",int64:()=>"long",uint:()=>"uint",uint64:()=>"uint64",float:()=>"double",double:()=>"double",string:()=>"string",datetime:()=>"datetime",date:()=>"date",base64:()=>"base64",boolean:()=>"boolean",_other:()=>"unknown"});return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:hM(e.availability)}:{}}}function OTD({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function ATD({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function mTD({description:e,schema:t}){let r="string",i=ETD(t);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function PTD({description:e,schema:t}){let r="integer",i=eoh(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function jTD({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function wTD({description:e,schema:t}){let r="double",i=eoh(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function ETD(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=STD(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function STD(e){switch(e){case"date":case"date-time":case"password":case"byte":case"bytes":case"binary":case"email":case"uuid":case"uri":case"hostname":case"ipv4":case"ipv6":return e;default:return}}function eoh(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:o}=e;if(r=kLc(r,t),i=kLc(i,t),n=kLc(n,t),!(r==null&&i==null&&a==null&&o==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:o,multipleOf:n}}function kLc(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[yTD,bTD]:[vTD,gTD];return e<r||e>i?void 0:e}function eVc({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=ITD(n)??e.schema,o=IQi(n),c=CTD(n),s=wfu({context:r,fileContainingReference:t,declarationFile:H3t(o),type:a});return n.type==="nullable"&&(s=r.options.wrapReferencesToNullableInOptional?`optional<${s}>`:`nullable<${s}>`),n.type==="optional"&&!s.startsWith("optional<")&&(s=`optional<${s}>`),e.description==null&&c==null?s:{type:s,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:hM(e.availability)}:{}}}function tVc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Pl({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=`list<${Gy(o)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:hM(e.availability)}:{},type:c}}function rVc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Pfu(e.key),c=Pl({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),d=e.encoding!=null?mfu(e.encoding):void 0,s=`map<${Gy(o)}, ${Gy(c)}>`;if(e.description==null&&d==null&&e.title==null)return s;let u={type:s};return e.description!=null&&(u.docs=e.description),e.encoding!=null&&(u.encoding=d),e.availability!=null&&(u.availability=hM(e.availability)),u}function iVc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.options.respectNullableSchemas)return jfu({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let o=Pl({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=Gy(o),d=haa(o),s=VHa(o),u=ZLc(o),l=Zah(c);if(i.options.wrapReferencesToNullableInOptional&&(l=fbn(l)),e.availability==null&&e.description==null&&d==null&&s==null&&u==null&&e.title==null)return l;let p=typeof l=="string"?{type:l}:l;return(e.description!=null||d!=null)&&(p.docs=e.description??d),s!=null&&(p.default=s),u!=null&&(p.validation=u),e.availability!=null&&(p.availability=hM(e.availability)),p}function jfu({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Pl({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=Gy(o),d=haa(o),s=VHa(o),u=ZLc(o),l=fbn(c);if(e.availability==null&&e.description==null&&d==null&&s==null&&u==null&&e.title==null)return l;let p=typeof l=="string"?{type:l}:l;return(e.description!=null||d!=null)&&(p.docs=e.description??d),s!=null&&(p.default=s),u!=null&&(p.validation=u),e.availability!=null&&(p.availability=hM(e.availability)),p}function nVc(){return"unknown"}function aVc(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:gt(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:hM(e.availability)}:{}}}function MTD({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=WHa(e,n),o=e.nameOverride??e.generatedName;i.builder.addType(r,{name:o,schema:a.schema});let c=wfu({type:o,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return c;let d={type:c};return e.description!=null&&(d.docs=e.description),e.default!=null&&(d.default=e.default.value),e.availability!=null&&(d.availability=hM(e.availability)),d}function DTD({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=oVc({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:o.schema});let d=wfu({type:c,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:hM(e.availability)}:{}}}function BTD({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=uVc({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:o.schema});let d=wfu({type:c,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{...e.title!=null?{"display-name":e.title}:{},type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:hM(e.availability)}:{}}}function wfu({type:e,fileContainingReference:t,declarationFile:r,context:i}){if(r===t)return e;let n=i.builder.addImport({file:t,fileToImport:r});return n!=null?`${n}.${e}`:e}function ITD(e){return ic._visit(e,{primitive:t=>t.nameOverride??t.generatedName,object:t=>t.nameOverride??t.generatedName,array:t=>t.nameOverride??t.generatedName,map:t=>t.nameOverride??t.generatedName,enum:t=>t.nameOverride??t.generatedName,reference:t=>t.nameOverride??t.generatedName,literal:t=>t.nameOverride??t.generatedName,oneOf:t=>t.nameOverride??t.generatedName,optional:t=>t.nameOverride??t.generatedName,nullable:t=>t.nameOverride??t.generatedName,unknown:t=>t.nameOverride??t.generatedName,_other:()=>{}})}function CTD(e){return ic._visit(e,{primitive:t=>t.title,object:t=>t.title,array:t=>t.title,map:t=>t.title,enum:t=>t.title,reference:t=>t.title,literal:t=>t.title,oneOf:t=>t.title,optional:t=>t.title,nullable:t=>t.title,unknown:t=>{},_other:()=>{}})}var bR;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(bR||(bR={}));function CQi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:gt(e)}}function roh({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=RTD(e);break;case"array":a=qTD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=TTD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=zTD({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=FTD(e.nameOverride,e.generatedName);break;case"optional":a=noh({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=NTD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=WHa(e,n);break;case"literal":a=QTD(e,e.nameOverride,e.generatedName);break;case"object":a=oVc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=uVc({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:gt(e)}return a}function oVc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(bR.Request)&&t.options.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),o=!1,c={},d=new Set;for(let _ of e.properties){if(_.readonly&&(o=!0),a&&_.readonly)continue;if(Object.keys(_.conflict).length>0){if(Object.entries(_.conflict).every(([g,m])=>!m.differentSchema))continue;Object.entries(_.conflict).forEach(([g])=>{sVc({property:_.key,schemaId:g,context:t,namespace:i}).forEach(j=>{d.add(j)})})}let h=Pl({schema:_.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),y=_.audiences,b=_.nameOverride,v=hM(_.availability),O=WTD(_);c[_.key]=VTD({typeReference:h,audiences:y,name:b,availability:v,propertyAccess:O})}let s=new Set;for(let _ of e.allOfPropertyConflicts)_.allOfSchemaIds.forEach(h=>d.add(h)),_.conflictingTypeSignatures&&s.add(_.propertyKey);let u=[];for(let _ of e.allOf){let h=Efu({schema:_.schema,context:t,namespace:i});if(h==null||d.has(_.schema)||d.has(h))continue;let y=Pl({schema:ic.reference(_),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(yaa(Gy(y)))}for(let _ of d){let h=baa(t,_,i);for(let y of h.properties)c[y.key]==null&&(s.has(y.key)&&(c[y.key]="unknown"),c[y.key]=Pl({schema:y.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let y of h.allOf){if(d.has(y.schema))continue;let b=Pl({schema:ic.reference(y),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(yaa(Gy(b)))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([_,h])=>LTD(_)?[_,typeof h=="string"?{type:h,name:`_${_}`}:{...h,name:`_${_}`}]:[_,h]))};u.length>0&&(l.extends=u),e.additionalProperties&&(l["extra-properties"]=!0),e.availability!=null&&(l.availability=hM(e.availability)),e.source!=null&&(l.source=CQi(e.source)),l.inline=cVc(e,n);let p=e.nameOverride??e.generatedName;return{name:o&&t.options.respectReadonlySchemas&&!a?`${p}Read`:p,schema:l}}function sVc({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return sVc({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:o}=baa(r,t,i),c=a.some(s=>s.key===e),d=[...o.flatMap(s=>sVc({property:e,context:r,schemaId:s.schema,namespace:i}))];if(c||d.length>0)return[t,...d]}return[]}function ioh(e,t,r){return t.type==="object"?{properties:t.properties,allOf:t.allOf}:t.type==="reference"?baa(e,t.schema,r):t.type==="nullable"?ioh(e,t.value,r):{properties:[],allOf:[]}}function baa(e,t,r){let i=e.getSchema(t,r);return i==null?{properties:[],allOf:[]}:ioh(e,i,r)}function qTD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:tVc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function TTD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:rVc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function RTD(e){let t=Pfu(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...i}=t;return{name:e.nameOverride??e.generatedName,schema:{...i}}}function toh(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function WHa(e,t){let r={enum:e.values.map(a=>{let o=a.nameOverride??a.generatedName,c=a.value;if(o===c&&a.description==null&&(a.casing==null||toh(a.casing)))return o;let d={value:a.value};if(o!==c&&(d.name=o),a.description!=null&&(d.docs=a.description),a.casing!=null&&!toh(a.casing)){let s={},u=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,u=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,u=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,u=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,u=!0),u&&(d.casing=s)}return d})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=cVc(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?CQi(e.source):void 0};for(let a of r.enum){let o=typeof a=="string"?a:a.name??a.value;i.has(o.toLowerCase())||(n.enum.push(a),i.add(o.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function zTD({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:eVc({schema:e,context:t,fileContainingReference:r,namespace:i})}}function NTD({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.options.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:iVc({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:noh({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function noh({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:jfu({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function FTD(e,t){return{name:e??t,schema:nVc()}}function QTD(e,t,r){return{name:t??r,schema:aVc(e)}}function uVc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?mfu(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=Pl({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let d={};for(let[s,u]of Object.entries(e.schemas))d[s]=Pl({schema:u,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?hM(e.availability):void 0,union:d,encoding:a,source:e.source!=null?CQi(e.source):void 0}}}let o=[];for(let c of e.schemas)o.push(Pl({schema:c,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:o,encoding:a,source:e.source!=null?CQi(e.source):void 0,inline:cVc(e,n)}}}var UTD=/^[0-9]/;function LTD(e){return UTD.test(e)}function Efu({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?Efu({context:t,schema:i.schema,namespace:r}):e}function VTD({typeReference:e,audiences:t,name:r,availability:i,propertyAccess:n}){return t.length===0&&r==null&&i==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{},...n!=null?{access:n}:{}}}function cVc(e,t){return e.inline===!0||t>0?!0:void 0}function WTD(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return WB.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return WB.ObjectPropertyAccess.WriteOnly}}function aoh(e){let t=e.replace(/^x-|^X-/,"");return nu(t)}function ooh(e){if(e.authOverrides!=null){for(let[r,i]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:i});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,i]of Object.entries(e.ir.securitySchemes))if(i.type==="basic"){let n={scheme:"basic"};i.usernameVariableName!=null&&(n.username===void 0?n.username={name:i.usernameVariableName}:n.username.name=i.usernameVariableName),i.usernameEnvVar!=null&&(n.username===void 0?n.username={env:i.usernameEnvVar}:n.username.env=i.usernameEnvVar),i.passwordVariableName!=null&&(n.password===void 0?n.password={name:i.passwordVariableName}:n.password.name=i.passwordVariableName),i.passwordEnvVar!=null&&(n.password===void 0?n.password={env:i.passwordEnvVar}:n.password.env=i.passwordEnvVar),e.builder.addAuthScheme({name:r,schema:n}),t||(e.builder.setAuth(r),t=!0)}else if(i.type==="bearer"){let n={scheme:"bearer"};i.tokenVariableName!=null&&(n.token===void 0?n.token={name:i.tokenVariableName}:n.token.name=i.tokenVariableName),i.tokenEnvVar!=null&&(n.token===void 0?n.token={env:i.tokenEnvVar}:n.token.env=i.tokenEnvVar),e.builder.addAuthScheme({name:r,schema:n}),t||(e.builder.setAuth(r),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??aoh(i.headerName),env:i.headerEnvVar}});else{let n={header:i.headerName,name:i.headerVariableName??"apiKey",type:"string"};i.headerEnvVar!=null&&(n.env=i.headerEnvVar),i.prefix!=null&&(n.prefix=i.prefix),e.builder.addAuthScheme({name:r,schema:n}),e.builder.setAuth(r),t=!0}else if(i.type==="oauth"){let n={scheme:"bearer"};e.builder.addAuthScheme({name:r,schema:n}),t||(e.builder.setAuth(r),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(ns.of("__package__.yml"),{name:"OauthScope",schema:WHa(i.scopesEnum,0).schema})}}function oYt({header:e,context:t,fileContainingReference:r,namespace:i}){let n=Pl({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=Gy(n),o=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:nu(o);if(e.description==null&&e.name===c&&e.env==null&&e.availability==null)return a;let d={type:a};return c!==e.name&&(d.name=c),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=hM(e.availability)),d}function Sfu({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=Pl({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return Gy(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:Gy(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=hM(e.availability)),a}function Dfu({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=lVc({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=Gy(n.value),o=VHa(n.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let c={type:a};return o!=null&&(c.default=o),n.allowMultiple&&(c["allow-multiple"]=!0),e.description!=null&&(c.docs=e.description),e.parameterNameOverride!=null&&(c.name=e.parameterNameOverride),e.availability!=null&&(c.availability=hM(e.availability)),GTD(n.value)&&n.value.validation!==void 0&&(c.validation=n.value.validation),c.default==null&&c["allow-multiple"]==null&&c.docs==null&&c.name==null&&c.availability==null&&c.validation==null?a:c}function lVc({schema:e,context:t,fileContainingReference:r,namespace:i}){if(e.type==="reference"){let n=t.getSchema(e.schema,i);if(n==null)return;if(n.type==="array")return{value:Pl({schema:ic.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:ns.of(Qb),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,d]of Object.entries(n.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(o=!0),d.type==="literal"&&d.value.type==="string"&&(paa.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:_aa(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[c,d]=n.value.schemas;if(c!=null&&d!=null&&Mfu({array:c,primitive:d}))return{value:Pl({schema:ic.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&d!=null&&Mfu({array:c,primitive:d}))return{value:Pl({schema:ic.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[c,d]of Object.entries(n.value.schemas))return lVc({schema:d,context:t,fileContainingReference:r,namespace:i})}else if(t.options.objectQueryParameters)return{value:Pl({schema:e,context:t,fileContainingReference:r,declarationFile:ns.of(Qb),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){let n=e.type==="optional"?ic.optional:ic.nullable;if(e.value.type==="reference"){let a=t.getSchema(e.value.schema,i);if(a==null)return;if(a.type==="array")return{value:Pl({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a.value,description:e.description??a.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:ns.of(Qb),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.options.objectQueryParameters)return{value:Pl({schema:e,context:t,fileContainingReference:r,declarationFile:ns.of(Qb),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:Pl({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,d]of Object.entries(e.value.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(o=!0),d.type==="literal"&&d.value.type==="string"&&(paa.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:_aa(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[c,d]=e.value.value.schemas;if(c!=null&&d!=null&&Mfu({array:c,primitive:d}))return{value:Pl({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&d!=null&&Mfu({array:d,primitive:c}))return{value:Pl({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}if(t.options.objectQueryParameters)return{value:Pl({schema:e,context:t,fileContainingReference:r,declarationFile:ns.of(Qb),namespace:i,declarationDepth:0}),allowMultiple:!1};for(let[c,d]of Object.entries(e.value.value.schemas))return lVc({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.options.objectQueryParameters?{value:Pl({schema:e,context:t,fileContainingReference:r,declarationFile:ns.of(Qb),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:Pl({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:Pl({schema:ic.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:Pl({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function Mfu({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function GTD(e){return typeof e=="object"&&e!==null&&"type"in e}function uoh({websocketExample:e,context:t}){let r={messages:[]};e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=HTD(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=xTD({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=ZKi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function HTD(e){let t={};return e.forEach(r=>{let i=ZKi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function xTD({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=ZKi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function ZKi(e){switch(e.type){case"primitive":return soh(e.value);case"object":return coh(e.properties);case"array":return KTD(e.value);case"map":return JTD(e.value);case"oneOf":return $TD(e.value);case"enum":return e.value;case"literal":return YTD(e.value);case"unknown":return ZKi(e.value);case"null":return null;default:gt(e)}}function soh(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:gt(e)}}function coh(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,ZKi(r)]))}function KTD(e){return e.map(t=>ZKi(t))}function JTD(e){return Object.fromEntries(e.map(t=>[soh(t.key),ZKi(t.value)]))}function $TD(e){return e.type==="discriminated"?coh(e.value):ZKi(e.value)}function YTD(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:gt(e)}}function GHa(e){try{let r=new URL(e).pathname.split("/").filter(i=>i.length>0);if(r.length>0)return r[r.length-1]}catch{}}function Bfu(e){try{return new URL(e).protocol.replace(":","")}catch{return}}function Ifu(e,t,r=!1){let i=GHa(t);return r&&i!=null?i:e!=null&&i!=null?`${e}_${i}`:i??e??"websocket"}function qQi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function Cfu(e,t){return t??(e?.groupName!=null?qQi(e.groupName):void 0)}function loh({channel:e,context:t,declarationFile:r}){let i=e.servers[0],n=i!=null?t.options.groupEnvironmentsByHost?t.getUrlId(i.url)??Ifu(i.name,i.url,!0):i.name:void 0;t.logger.debug(`[buildChannel] Channel path="${e.path}", server name="${i?.name}", server url="${i?.url}", resolved urlId="${n}" (from collision map: ${t.getUrlId(i?.url??"")!=null})`);let a={path:e.path,url:n,auth:!1};e.audiences!=null&&e.audiences.length>0&&(a.audiences=e.audiences),e.summary!=null&&(a["display-name"]=e.summary),e.description!=null&&(a.docs=e.description);let o=qQi(e.groupName),c={};if(e.handshake.pathParameters.length>0)for(let u of e.handshake.pathParameters)c[u.name]=Sfu({pathParameter:u,context:t,fileContainingReference:r,namespace:o});Object.keys(c).length>0&&(a["path-parameters"]=c);let d={};if(e.handshake.queryParameters.length>0)for(let u of e.handshake.queryParameters){let l=Dfu({queryParameter:u,context:t,fileContainingReference:r,namespace:o});l!=null&&(d[u.name]=l)}Object.keys(d).length>0&&(a["query-parameters"]=d);let s={};if(e.handshake.headers.length>0)for(let u of e.handshake.headers){let l=oYt({header:u,context:t,fileContainingReference:r,namespace:o});s[u.name]=l}Object.keys(s).length>0&&(a.headers=s),t.builder.addChannel(r,{channel:a});for(let u of e.messages){let l={origin:u.origin,body:Pl({schema:u.body,context:t,fileContainingReference:r,namespace:o,declarationDepth:0})};u.methodName!=null&&(l["method-name"]=u.methodName),t.builder.addChannelMessage(r,{messageId:u.name,message:l})}for(let u of e.examples){let l=uoh({context:t,websocketExample:u});t.builder.addChannelExample(r,{example:l})}}function fVc(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var PEe="Base",poh="Default";function foh(e){try{return new URL(e).hostname}catch{return}}function doh(e){return e??poh}function XTD(e,t){let r=new Map;for(let i of e){if(fVc(i)||!("url"in i)||!i.url)continue;let n=foh(i.url)??i.url;r.has(n)||r.set(n,{environmentName:doh(i.name),httpServers:[],websocketServers:[]}),r.get(n)?.httpServers.push({name:i.name,url:i.url,audiences:i.audiences})}for(let i of t){let n=foh(i.url)??i.url;r.has(n)||r.set(n,{environmentName:doh(i.name),httpServers:[],websocketServers:[]}),r.get(n)?.websocketServers.push(i)}return r}function dbn(e){return Object.entries(e).reduce((t,[r,i])=>(jve(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function _oh(e){if(e.environmentOverrides!=null){for(let[v,O]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:v,schema:O});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[],i=e.ir.servers.some(v=>fVc(v)),n=e.ir.servers;for(let v of n)if(fVc(v)){let O={urls:{}};for(let[A,g]of Object.entries(v.urls))O.urls[A]=g.url;v.name&&(t[v.name]=O)}else if("url"in v&&v.url){let O=v.audiences?{url:v.url,audiences:v.audiences}:v.url;if(v.name==null){r.push(O);continue}t[v.name]=O}let a={},o={},c=[];for(let v of e.ir.endpoints)for(let O of v.servers){if(O.url==null&&O.name!=null){a[O.name]||(a[O.name]=[]);continue}if(O.url==null)continue;let A=O.audiences?{url:O.url,audiences:O.audiences}:O.url;if(O.name==null){c.push(A);continue}a[O.name]||(a[O.name]=[]),a[O.name]?.push({url:O.url,audiences:O.audiences}),o[O.name]=A}let d={},s=[];for(let v of e.ir.websocketServers){e.logger.debug(`[buildEnvironments] Processing WebSocket server: name="${v.name}", url="${v.url}"`);let O=v.audiences?{url:v.url,audiences:v.audiences}:v.url;if(v.name==null){s.push(O);continue}d[v.name]=O}let u=Object.keys(t).length,l=u>0,p=Object.keys(o).length>0,_=Object.keys(a).some(v=>a[v]?.length===0),h=Object.keys(d).length>0;if(e.options.groupEnvironmentsByHost&&h&&(l||e.ir.servers.length>0)){let v=Object.entries(d).map(([A,g])=>({name:A,url:typeof g=="string"?g:g.url,audiences:typeof g=="string"?void 0:g.audiences})),O=XTD(n,v);if(O.size>0){let A=!0;for(let[g,m]of O.entries()){let j={},S=[...m.httpServers.map(D=>({...D,isHttp:!0})),...m.websocketServers.map(D=>({...D,isHttp:!1}))],w=new Map;for(let D of S){let B=GHa(D.url),R=Bfu(D.url);B&&R&&(w.has(B)||w.set(B,new Set),w.get(B)?.add(R))}if(m.httpServers.length>0){let D=m.httpServers[0];D!=null&&(j[PEe]=D.url,e.setUrlId(D.url,PEe));for(let B=1;B<m.httpServers.length;B++){let R=m.httpServers[B];if(R!=null){let N=GHa(R.url),z=Bfu(R.url),F=N?w.get(N):void 0,U=F&&F.size>1,k=U&&z!=="https"?`${N}_${z}`:N||`Http${B+1}`;e.logger.debug(`[buildEnvironments] HTTP server: url="${R.url}", pathSegment="${N}", protocol="${z}", hasCollision=${U}, urlId="${k}"`),j[k]=R.url,e.setUrlId(R.url,k)}}}for(let D of m.websocketServers){let B=GHa(D.url),R=Bfu(D.url),N=B?w.get(B):void 0,z=N&&N.size>1,F=z?`${B}_${R}`:Ifu(D.name,D.url,!0);e.logger.debug(`[buildEnvironments] WebSocket server: name="${D.name}", url="${D.url}", pathSegment="${B}", protocol="${R}", hasCollision=${z}, urlId="${F}"`),j[F]=D.url,e.setUrlId(D.url,F)}if(Object.keys(j).length>1)e.builder.addEnvironment({name:m.environmentName,schema:{urls:j}});else if(Object.keys(j).length===1){let D=Object.values(j)[0];D!=null&&e.builder.addEnvironment({name:m.environmentName,schema:D})}A&&(e.builder.setDefaultEnvironment(m.environmentName),Object.keys(j).length>1&&e.builder.setDefaultUrl(PEe),A=!1)}return}}if(!l&&!p&&h&&e.ir.servers.length===0){for(let[v,O]of Object.entries(d))e.builder.addEnvironment({name:v,schema:O});e.builder.setDefaultEnvironment(Object.keys(d)[0]),e.builder.setDefaultUrl(PEe);return}if(c.length>0&&e.logger.debug(`Skipping endpoint level servers ${c.map(v=>typeof v=="string"?v:v.url).join(", ")} because x-fern-server-name was not provided.`),!l){let v=e.ir.servers[0]?.url,O=e.ir.servers[0]?.audiences;if(v!=null){let A=O?{url:v,audiences:O}:v;t[poh]=A}}let y=Object.values(t).map(v=>typeof v=="string"?v:jve(v)?Object.values(v.urls)[0]:v.url),b=r.filter(v=>{let O=typeof v=="string"?v:v.url;return!y.includes(O)});if(b.length>0&&e.logger.debug(`Skipping top level servers ${b.map(v=>typeof v=="string"?v:v.url).join(", ")} because x-fern-server-name was not provided.`),i){let v=!0;for(let[O,A]of Object.entries(t))if(e.builder.addEnvironment({name:O,schema:A}),v){if(e.builder.setDefaultEnvironment(O),jve(A)){let g=Object.keys(A.urls)[0];g&&e.builder.setDefaultUrl(g)}v=!1}return}if(!p&&!_){let v=!0;for(let[O,A]of Object.entries(t))if(v){if(h){let g=typeof A=="string"?A:jve(A)?Object.values(A.urls)[0]:A.url;e.builder.addEnvironment({name:O,schema:{urls:{[PEe]:g??"",...dbn(d)}}})}else e.builder.addEnvironment({name:O,schema:A});e.builder.setDefaultEnvironment(O),v=!1}else if(h){let g=typeof A=="string"?A:jve(A)?Object.values(A.urls)[0]:A.url;e.builder.addEnvironment({name:O,schema:{urls:{[PEe]:g??"",...dbn(d)}}})}else e.builder.addEnvironment({name:O,schema:A});h&&e.builder.setDefaultUrl(PEe)}else if(u===1){let v=Object.keys(t)[0],O=Object.values(t)[0],A=typeof O=="string"?O:jve(O)?Object.values(O.urls)[0]:O.url;e.builder.addEnvironment({name:v,schema:{urls:{[PEe]:A??"",...dbn(o),...dbn(d)}}}),e.builder.setDefaultEnvironment(v),e.builder.setDefaultUrl(PEe)}else{let v=new Map;for(let O of e.ir.endpoints)for(let A of O.servers)if(A.url!=null&&A.name!=null){v.has(A.name)||v.set(A.name,new Map);let g=A.url.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",m=v.get(A.name);m&&m.set(g,A.url)}if(v.size>0){let O=!0;for(let[A,g]of Object.entries(t)){let m=typeof g=="string"?g:jve(g)?Object.values(g.urls)[0]:g.url;if(!m)continue;let j=m.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",S={[PEe]:m};for(let[w,D]of v.entries()){let B=D.get(j)||D.get("production")||D.values().next().value;B&&(S[w]=B)}h&&Object.assign(S,dbn(d)),Object.keys(S).length>1?e.builder.addEnvironment({name:A,schema:{urls:S}}):e.builder.addEnvironment({name:A,schema:m}),O&&(e.builder.setDefaultEnvironment(A),O=!1)}v.size>0&&e.builder.setDefaultUrl(PEe)}else{let O=!0;for(let[A,g]of Object.entries(t)){if(h||Object.keys(o).length>0){let m=typeof g=="string"?g:jve(g)?Object.values(g.urls)[0]:g.url;e.builder.addEnvironment({name:A,schema:{urls:{[PEe]:m??"",...dbn(o),...dbn(d)}}})}else e.builder.addEnvironment({name:A,schema:g});O&&(e.builder.setDefaultEnvironment(A),O=!1)}}}}var dVc=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},ZTD=.75,kTD=new Set("authorization");function hoh(e){if(e.globalHeaderOverrides!=null){for(let[r,i]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:i});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,i]of Object.entries(t)){let n="optional<string>";if(i.name==null&&i.env==null&&typeof i.schema=="string")n=i.schema;else if(i!=null){let a=i.schema?IQi(i.schema):void 0,o=a!=null?qQi(a):void 0,c=ns.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?Gy(Pl({schema:i.schema,context:e,fileContainingReference:o?PB(ns.of(nu(o)),c):c,namespace:o,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.options.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(kTD.has(a.name.toLowerCase()))continue;let o=r[a.name];if(o==null){let c=t[a.name],d=oYt({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:ns.of(AB),context:e,namespace:void 0});o=new dVc(d),r[a.name]=o}o.increment()}let i=e.ir.endpoints.length*ZTD;for(let[n,a]of Object.entries(r)){let o=t[n],c=a.count===e.ir.endpoints.length,d=a.count>=i;o==null&&(c?e.builder.addGlobalHeader({name:n,schema:a.schema}):d&&e.builder.addGlobalHeader({name:n,schema:fbn(a.schema)}))}}}function yoh(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?IQi(t.schema):void 0,i=r!=null?qQi(r):void 0,n=oYt({header:{...t,schema:t.schema??ic.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:Th.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0})}),name:t.name??t.header,parameterNameOverride:void 0,description:void 0,availability:void 0,source:void 0},fileContainingReference:ns.of(AB),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:fbn(n)})}}function fW(e){switch(e.type){case"primitive":return voh(e.value);case"object":return goh(e.properties);case"array":return Ooh(e.value);case"map":return tRD(e.value);case"oneOf":return rRD(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return iRD(e.value);case"unknown":return fW(e.value);case"null":return null;default:gt(e)}}function boh(e){switch(e.type){case"withStreaming":return e.sse?{stream:eRD(e.events)}:{stream:Ooh(e.events)};case"withoutStreaming":return{body:fW(e.value)};default:gt(e)}}function voh(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:gt(e)}}function goh(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,fW(r)]))}function eRD(e){return e.map(t=>({event:"",data:fW(t)}))}function Ooh(e){return e.map(t=>fW(t))}function tRD(e){return Object.fromEntries(e.map(t=>[voh(t.key),fW(t.value)]))}function rRD(e){return e.type==="discriminated"?goh(e.value):fW(e.value)}function iRD(e){switch(e.type){case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"boolean":return e.value;default:gt(e)}}function Aoh({endpointExample:e,context:t}){let r={};if(e.type!=="full")return e.value;e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.pathParameters!=null&&e.pathParameters.length>0&&(r["path-parameters"]=nRD(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=aRD(e.queryParameters));let i=e.headers!=null&&e.headers.length>0,n=t.builder.getGlobalHeaders(),a=Object.keys(n).length>0,o=new Set(e.headers?.map(c=>c.name)??[]);if(i||a){let c=[];if(e.headers!=null)for(let d of e.headers)d.name!==t.builder.getAuthHeaderName()&&c.push(d);for(let[d,s]of Object.entries(n))if(!o.has(d))if(s!=null&&typeof s=="object"&&s.type!=null){let u=YI({type:s.type,_default:void 0,validation:void 0,visitor:{primitive:l=>l.toString(),map:l=>l.toString(),list:l=>l,optional:l=>l,nullable:l=>l,set:l=>l,named:l=>l,literal:l=>{if(l.type==="string")return l.string;if(l.type==="boolean")return l.boolean.toString()},unknown:Bt}});u!=null&&c.push({name:d,value:ml.literal(LKi.string(u))})}else c.push({name:d,value:ml.primitive(po.string(d))});r.headers=oRD({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=fW(e.request)),e.response!=null&&(r.response=boh(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(c=>c.type==="language"?{name:c.name??void 0,docs:c.description??void 0,language:c.language,code:c.code,install:c.install??void 0}:{name:c.name??void 0,docs:c.description??void 0,sdk:c.sdk,code:c.code}).filter(As)),r}function nRD(e){let t={};return e.forEach(r=>{let i=fW(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function aRD(e){let t={};return e.forEach(r=>{let i=fW(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function oRD({context:e,namedFullExamples:t}){let r={};return t.forEach(i=>{let n=fW(i.value);n!=null&&(r[i.name]=n)}),r}function moh(e){return nF._visit(e,{get:()=>WB.HttpMethodSchema.Get,post:()=>WB.HttpMethodSchema.Post,put:()=>WB.HttpMethodSchema.Put,patch:()=>WB.HttpMethodSchema.Patch,delete:()=>WB.HttpMethodSchema.Delete,head:()=>WB.HttpMethodSchema.Head,options:()=>{throw new Error("OPTIONS is unsupported")},trace:()=>{throw new Error("TRACE is unsupported")},_other:()=>{throw new Error("Unknown http method is unsupported")}})}function Poh(e){return e==="POST"||e==="PUT"||e==="PATCH"}function joh({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,o=e.path,c=Cfu(e.sdkName,e.namespace),d={};for(let b of e.pathParameters)b.parameterNameOverride&&(o=o.replace(b.name,b.parameterNameOverride)),d[b.parameterNameOverride??b.name]=Sfu({pathParameter:b,context:r,fileContainingReference:t,namespace:c}),a.add(b.name);let s={};for(let b of e.queryParameters){let v=Dfu({queryParameter:b,context:r,fileContainingReference:t,namespace:c});v!=null&&(s[b.name]=v,a.add(b.name))}let u;if(e.pagination!=null)switch(e.pagination.type){case"cursor":u={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":u={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":u={type:"custom",results:e.pagination.results};break;default:gt(e.pagination)}let l={path:o,method:moh(e.method),auth:uRD({endpoint:e,context:r}),docs:e.description??void 0,pagination:u,source:e.source!=null?CQi(e.source):void 0};!fRD({context:r,request:e.request})&&Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let p={},_=r.builder.getGlobalHeaderNames(),h=r.builder.getAuthHeaderName();h!=null&&_.add(h);let y=e.headers.filter(b=>!_.has(b.name));for(let b of y){let v=oYt({header:b,context:r,fileContainingReference:t,namespace:c});p[b.name]=v,a.add(typeof v=="string"?b.name:v.name??b.name)}if(e.request!=null){r.setInState(bR.Request);let b=lRD({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.options.inlinePathParameters&&Object.keys(d).length>0?d:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(i),headers:Object.keys(p).length>0?p:void 0,usedNames:a,namespace:c});l.request=b.value,n=[...n,...b.schemaIdsToExclude??[]],r.unsetInState(bR.Request)}else{let b=r.options.inlinePathParameters&&Object.keys(d).length>0,v=Object.keys(s).length>0,O=Object.keys(p).length>0,A={};(b||v||O)&&(A.name=e.requestNameOverride??e.generatedRequestName),b&&(A["path-parameters"]=d),v&&(A["query-parameters"]=s),O&&(A.headers=p),Object.keys(A).length>0&&(l.request=A)}if(e.response!=null&&e.response._visit({json:b=>{let v=Pl({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:b.description??void 0,type:Gy(v)},b.statusCode!=null&&(l.response["status-code"]=b.statusCode),b.responseProperty!=null&&(l.response.property=b.responseProperty)},streamingJson:b=>{let v=Pl({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:Gy(v),format:"json"}},streamingSse:b=>{let v=Pl({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:Gy(v),format:"sse"}},file:b=>{l.response={docs:b.description??void 0,type:"file","status-code":b.statusCode}},bytes:b=>{l.response={docs:b.description??void 0,type:"bytes","status-code":b.statusCode}},streamingText:b=>{l["response-stream"]={docs:b.description??void 0,type:"text"}},text:b=>{l.response={docs:b.description??void 0,type:"text","status-code":b.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let b=r.getDefaultServerName(),v=e.servers[0];v==null?b!=null&&(l.url=b):l.url=v.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=hM(e.availability)),Object.entries(e.errors).forEach(([b,v])=>{let O=v.generatedName,A=ns.of(Qb);r.builder.enableUniqueErrorsPerEndpoint&&(O=`${e.generatedRequestName}${v.generatedName}`,v.schema!=null&&(v.schema.type!=="reference"&&v.schema.type!=="oneOf"?v.schema.generatedName=`${e.generatedRequestName}${v.schema.generatedName}`:v.schema.type==="oneOf"&&(v.schema.value.generatedName=`${e.generatedRequestName}${v.schema.value.generatedName}`)));let g={"status-code":parseInt(b)},m=Yah({location:woh,namespaceOverride:c});if(v.schema!=null){let w=Pl({schema:v.schema,context:r,fileContainingReference:m,declarationFile:m,namespace:c,declarationDepth:0});g.type=Gy(w),g.docs=v.description}r.builder.addError(m,{name:O,schema:r.isErrorUnknownSchema(parseInt(b))?{...g,type:"unknown"}:g}),l.errors==null&&(l.errors=[]);let j=r.builder.addImport({file:t,fileToImport:m});l.errors.push(j!=null?`${j}.${O}`:O),g.type!=null&&v.examples?.forEach(w=>{let D={value:fW(w.example),name:w.name,docs:w.description};r.builder.addErrorExample(m,{name:O,example:D})})}),e.examples.length>0&&(l.examples=sRD({endpointExamples:e.examples,context:r})),e.retries!=null&&(l.retries=cRD({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[pVc,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:n}}function uRD({endpoint:e,context:t}){if(e.security==null)return t.authOverrides?.auth!=null?!0:t.ir.security==null?void 0:t.ir.security.length>0?!0:void 0;if(e.security.length!==0)return JSON.stringify(e.security)===JSON.stringify(t.ir.security)?!0:e.security}function sRD({endpointExamples:e,context:t}){return e.map(r=>{try{return Aoh({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function cRD({retries:e}){if(e!=null)switch(e.type){case"disabled":return{disabled:e.value??void 0};default:gt(e)}}function lRD({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:o,queryParameters:c,nonRequestReferencedSchemas:d,headers:s,usedNames:u,namespace:l}){if(i.type==="json"||i.type==="formUrlEncoded"){let p=i.schema.type==="reference"?i.schema.schema:void 0,_=i.schema.type==="reference"?r.getSchema(i.schema.schema,l):i.schema;if(_?.type!=="object"||p!=null&&d.includes(p)){let m=Pl({schema:i.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),j={schemaIdsToExclude:[],value:{body:m}},S=Object.keys(o??{}).length>0,w=Object.keys(c??{}).length>0,D=Object.keys(s??{}).length>0;return S&&(j.value["path-parameters"]=o),w&&(j.value["query-parameters"]=c),D&&(j.value.headers=s),(S||w||D)&&(j.value.name=n??a),i.contentType!=null&&(j.value["content-type"]=i.contentType),i.description!=null&&(j.value.docs=i.description),j}let h=new Map;for(let m of _.allOf){let j=r.getSchema(m.schema,l);if(j==null)continue;let S=IQi(j),w=H3t(S),{properties:D}=baa(r,m.schema,l);for(let B of D)h.set(B.key,w)}let y=Object.fromEntries(_.properties.filter(m=>m.readonly==null?!0:!(Poh(e.method)&&m.readonly)).map(m=>{let j=h.get(m.key)??t,S=Pl({schema:m.schema,fileContainingReference:t,declarationFile:j,context:r,namespace:l,declarationDepth:1}),w=m.nameOverride??m.key,D=hM(m.availability);if(!u.has(w)&&m.audiences.length<=0)return u.add(w),m.nameOverride!=null?[m.key,{type:Gy(S),docs:haa(S),name:m.nameOverride,availability:D}]:[m.key,D?{...typeof S=="string"?{type:S}:S,availability:D}:S];let B={type:Gy(S),docs:haa(S)};return u.has(w)&&(B.name=m.generatedName),m.audiences.length>0&&(B.audiences=m.audiences),D!=null&&(B.availability=D),u.add(w),[m.key,B]})),b=new Set,v=new Set;for(let m of _.allOfPropertyConflicts)m.allOfSchemaIds.forEach(j=>b.add(j)),m.conflictingTypeSignatures&&v.add(m.propertyKey);let O=[];for(let m of _.allOf){let j=Efu({schema:m.schema,context:r,namespace:l});if(j==null||b.has(m.schema)||b.has(j))continue;let S=Pl({schema:ic.reference(m),fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),w=yaa(Gy(S));w!=="unknown"&&O.push(w)}for(let m of b){let j=baa(r,m,l),S=r.getSchema(m,l),w=S!=null?H3t(IQi(S)):t;for(let D of j.properties)y[D.key]==null&&(v.has(D.key)?y[D.key]="unknown":y[D.key]=Pl({schema:D.schema,fileContainingReference:t,declarationFile:w,context:r,namespace:l,declarationDepth:1}));for(let D of j.allOf){if(b.has(D.schema))continue;let B=Pl({schema:ic.reference(D),fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),R=yaa(Gy(B));R!=="unknown"&&!O.includes(R)&&O.push(R)}}let A={properties:y};O.length>0&&(A.extends=O),i.additionalProperties&&(A["extra-properties"]=!0);let g={name:n??_.nameOverride??_.generatedName,"path-parameters":o,"query-parameters":c,headers:s,body:A};return i.contentType!=null&&(g["content-type"]=i.contentType),i.description!=null&&(g.docs=i.description),{schemaIdsToExclude:p!=null?[p]:[],value:g}}else if(i.type==="octetStream"){let p={body:"bytes","content-type":i.contentType??xO.APPLICATION_OCTET_STREAM,"query-parameters":c};return c!=null&&(p.name=n??a),i.description!=null&&(p.docs=i.description),{schemaIdsToExclude:[],value:p}}else if(i.type==="multipart"){let p=Object.fromEntries(i.properties.map(_=>{if(_.schema.type==="file"){let h=_.schema.isArray?"list<file>":"file";if(h=_.schema.isOptional?`optional<${h}>`:h,_.description!=null||_.contentType!=null){let y={type:h};if(_.description!=null&&(y.docs=_.description),_.contentType!=null){let b=_.contentType.split(",")[0];y["content-type"]=b}return[_.key,y]}return[_.key,h]}else{let h=Pl({schema:_.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(_.contentType||_.exploded||_.encoding){let y=typeof h=="string"?{type:h}:h;_.contentType!=null&&(y["content-type"]=_.contentType),_.encoding==="form"?y.style="form":_.encoding==="json"?y.style="json":_.exploded&&(y.style="exploded"),h=y}return[_.key,h]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":o,"query-parameters":c,headers:s,body:{properties:p},"content-type":xO.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else gt(i)}function fRD({context:e,request:t}){if(!e.options.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:gt(t)}}function dRD({location:e,namespaceOverride:t}){return t!=null?{...e,file:PB(ns.of(t),e.file)}:e}function pRD(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:ns.of(`${nu(r)}.yml`),endpointId:e.summary!=null?nu(e.summary):nu(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:ns.of(Qb),endpointId:nu(e.summary)}:{file:ns.of(Qb),endpointId:nu(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:ns.of(Qb),endpointId:i};let n=HHa(r),a=HHa(i);if(NT(n,a))return{file:ns.of("__package__.yml"),endpointId:r};let o=yRD({operationId:i,tag:r,path:e.path,method:e.method});if(o!=null)return o;let c=[];for(let d=0;d<n.length;++d){let s=n[d];if(s!=null&&s===a[d])c.push(s);else{let u=nu(r);return{file:ns.of(`${u}.yml`),endpointId:i,tag:r}}}if(c.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:ns.of(nu(c.join("_"))+".yml"),endpointId:nu(a.slice(c.length).join("_")),tag:r}}function xHa(e){let t=e.tags[0];if(e.sdkName!=null){let r=XLc({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:ns.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return dRD({namespaceOverride:e.namespace,location:pRD(e)})}function HHa(e){let t;return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)?t=e.split(/(?=[A-Z])/):t=e.split(/[^a-zA-Z0-9]+/),t=t.map(r=>r.toLowerCase()),t=jje(t),t}var _RD=new RegExp("[^a-zA-Z0-9{}]+"),hRD=new RegExp("[{}]","g");function yRD({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(_RD).join("_").replaceAll(hRD,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:ns.of(nu(t)+".yml"),endpointId:nu(e.slice(0,-1*a.length)),tag:t}}function Eoh(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:o,file:c,tag:d}=xHa(a),s=c.split(".")[0];s!=null&&t.add(s);let u;if(a.sdkName!=null){let _=e.ir.groups;for(let h of a.sdkName.groupName){let y=typeof h=="string"?h:h.name,b=_[y];if(b==null)break;if(b.summary!=null||b.description!=null){u=_[y];break}}}let l=d==null?void 0:i.tagsById[d];e.setInState(bR.Endpoint),e.setEndpointMethod(a.method);let p=joh({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(bR.Endpoint),n=[...n,...p.schemaIdsToExclude],e.builder.addEndpoint(c,{name:o,schema:p.value,source:a.source!=null?CQi(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(c,{"display-name":u?.summary??l?.id,docs:u?.description??l?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function Soh(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?qQi(r.groupName):void 0,n=Pl({schema:ic.primitive(r),context:e,fileContainingReference:ns.of(Qb),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:Gy(n),docs:r.description??void 0}})}}function Moh(e){for(let t of e.ir.webhooks){let r=gRD({webhook:t,context:e});if(r==null)continue;let i=Cfu(t.sdkName,t.namespace),n={};for(let o of t.headers)n[o.name]=oYt({header:o,context:e,fileContainingReference:r.file,namespace:i});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:n,payload:Pl({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(o=>({docs:o.description,name:o.name,payload:fW(o.payload)})):void 0};t.response!=null&&t.response._visit({json:o=>{let c=Pl({schema:o.schema,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0});a.response={docs:o.description??void 0,type:Gy(c)},o.statusCode!=null&&(a.response["status-code"]=o.statusCode)},file:o=>{a.response={docs:o.description??void 0,type:"file","status-code":o.statusCode}},bytes:o=>{a.response={docs:o.description??void 0,type:"bytes","status-code":o.statusCode}},text:o=>{a.response={docs:o.description??void 0,type:"text","status-code":o.statusCode}},streamingJson:o=>{let c=Pl({schema:o.schema,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0});a["response-stream"]={docs:o.description??void 0,type:Gy(c),format:"json"}},streamingSse:o=>{let c=Pl({schema:o.schema,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0});a["response-stream"]={docs:o.description??void 0,type:Gy(c),format:"sse"}},streamingText:o=>{a["response-stream"]={docs:o.description??void 0,type:"text"}},_other:()=>{throw new Error("Unrecognized Response type: "+t.response?.type)}}),e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function bRD({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:PB(ns.of(t),e.file)}:e}function vRD({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:ns.of(Qb),endpointId:i};let n=HHa(r),a=HHa(i);if(NT(n,a))return{file:ns.of("__package__.yml"),endpointId:r};let o=[];for(let c=0;c<n.length;++c){let d=n[c];if(d!=null&&d===a[c])o.push(d);else{let s=nu(r);return{file:ns.of(`${s}.yml`),endpointId:i,tag:r}}}if(o.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:ns.of(nu(o.join("_"))+".yml"),endpointId:nu(a.slice(o.length).join("_")),tag:r}}function gRD({webhook:e,context:t}){return e.sdkName!=null?{file:$ah({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:bRD({namespaceOverride:e.namespace,location:vRD({webhook:e,context:t})})}var ORD=ns.of(Qb);function Boh(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return Doh({namespace:e.namespace,groupName:e.groupName});case"oneOf":return Doh({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return ORD;default:gt(e)}}function Doh({namespace:e,groupName:t}){return e!=null&&t!=null?H3t([{type:"namespace",name:e},...t]):e!=null?H3t([{type:"namespace",name:e}]):H3t(t)}var pVc="external",woh=ns.of(Qb);function Ioh({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let o=Boh(a),c=roh({schema:a,context:i,declarationFile:o,namespace:r,declarationDepth:0});if(SKi(c.schema)){let d=Gy(c.schema);if(d===(c.name??n)||d===`optional<${c.name??n}>`||d===`nullable<${c.name??n}>`||d===`optional<nullable<${c.name??n}>>`)continue}i.builder.addType(o,{name:c.name??n,schema:c.schema})}}function Coh(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),_oh(e),hoh(e),yoh(e),ooh(e),Soh(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(pVc);let t=Eoh(e),r=t.sdkGroups;e.setInState(bR.Webhook),Moh(e),e.unsetInState(bR.Webhook),e.setInState(bR.Channel);for(let n of Object.values(e.ir.channels)){let a=H3t(n.groupName);loh({channel:n,context:e,declarationFile:a})}e.unsetInState(bR.Channel);let i=ARD({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});Ioh({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))Ioh({schemas:a,schemaIdsToExclude:i,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.optimizeServiceAuth(),e.builder.build()}function ARD({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}var KHa=class{context;constructor(t){this.context=t}};var qfu=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[o,c]of Object.entries(i.files)){let d=n!=null?ns.of(`${n}${"/"}${o}`):ns.of(o);t[d]=c}let a=Object.keys(i.directories).sort();for(let o of a){let c=n!=null?`${n}${"/"}${o}`:o,d=i.directories[o];r(d,c)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split("/"))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[ns.of(t[0])]??={};let[r,...i]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(i)}};var pbn=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new qfu,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":i,"display-name":n,docs:a}){let o=this.getOrCreateFile(t);o.service==null&&(o.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(o.service.auth=r),i!=null&&(o.service["base-path"]=i),n!=null&&(o.service["display-name"]=n),a!=null&&(o.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return x$t(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let i of Object.values(this.rootApiFile["auth-schemes"]))qoh(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(qoh(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}getGlobalHeaders(){return this.rootApiFile.headers??{}}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??nu((Lje(r)+"/"+ofn(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===ns.of(AB))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=qzo(Lje(xJn.of(`/${t}`)),xJn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=qzo(Lje(xJn.of(`/${t}`)),xJn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===ns.of(AB))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(c=>NT(c,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=PB(n,r.path))}addChannelExample(t,{example:r}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.examples==null&&(i.channel.examples=[]),i.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:i}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.messages[r]=i}optimizeServiceAuth(){let t=[this.packageMarkerFile,...Object.values(this.root.getAllFiles())];for(let r of t){if(r.service==null)continue;let i=Object.values(r.service.endpoints);if(i.length===0)continue;if(i.every(a=>a.auth===!0)){r.service.auth=!0;for(let a of Object.values(r.service.endpoints))delete a.auth}}}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([n,a])=>[n,{...a,path:PB(r,a.path)}]))});for(let n of Object.values(t))n.service!=null&&(n.service={...n.service,endpoints:Object.fromEntries(Object.entries(n.service.endpoints).map(([a,o])=>[a,{...o,path:PB(r,o.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===Qb?this.packageMarkerFile:this.root.getOrCreateFile(t)}getVersionHeader(){if(this.rootApiFile.version!=null)return typeof this.rootApiFile.version.header=="string"?this.rootApiFile.version.header:this.rootApiFile.version.header.value}};function qoh(e){return e?.header!=null}var Tfu=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;options;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;urlIdMap=new Map;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:o}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=o,this.globalHeaderOverrides=a,this.options=sbn({options:i}),this.enableUniqueErrorsPerEndpoint=this.options.enableUniqueErrorsPerEndpoint,this.referencedSchemaIds=this.options.onlyIncludeReferencedSchemas?new Set:void 0,this.builder=new pbn(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let c={};if(!this.enableUniqueErrorsPerEndpoint)for(let d of r.endpoints)for(let[s,u]of Object.entries(d.errors)){let l=parseInt(s),p=c[l];p==null&&u.schema!=null?c[l]=u.schema:p!=null&&u.schema!=null&&H$(p,u.schema)||this.unknownSchema.add(l)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}setUrlId(t,r){this.urlIdMap.set(t,r)}getUrlId(t){return this.urlIdMap.get(t)}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.options.onlyIncludeReferencedSchemas&&this.isInAnyState(bR.Channel,bR.Endpoint,bR.Webhook)}markSchemaAsReferenced(t,r){switch(t.type){case"primitive":return;case"object":this.markObjectSchemaAsReferenced(t,r);return;case"array":this.markSchemaAsReferenced(t.value,r);return;case"map":this.markSchemaAsReferenced(t.value,r);return;case"optional":this.markSchemaAsReferenced(t.value,r);return;case"reference":this.markSchemaIdAsReferenced(t.schema,r);return;case"oneOf":this.markOneofSchemaAsReferenced(t.value,r);return;case"nullable":this.markSchemaAsReferenced(t.value,r);return;case"enum":return;case"literal":return;case"unknown":return;default:gt(t)}}markObjectSchemaAsReferenced(t,r){for(let i of t.allOf)this.markSchemaIdAsReferenced(i.schema,r);for(let i of t.properties)this.markSchemaAsReferenced(i.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let i of Object.values(t.schemas))this.markSchemaAsReferenced(i,r);return;case"undiscriminated":for(let i of t.schemas)this.markSchemaAsReferenced(i,r);return;default:gt(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let i=this.getSchema(t,r);i!=null&&this.markSchemaAsReferenced(i,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function _Vc(e){let t=new Tfu(e);return Coh(t)}function mRD(e,t){return myn(e,{single:r=>[typeof r=="string"?r:r.scheme],any:r=>r.any.map(i=>typeof i=="string"?i:i.scheme),endpointSecurity:()=>t!=null?Object.keys(t):[]})}function PRD(e,t){if(e==null)return;let r=mRD(t,e),i={};for(let n of r)e[n]!=null&&(i[n]=e[n]);return Object.keys(i).length>0?i:void 0}var Rfu=class{args;constructor(t){this.args=t}buildAuthOverrides(t,r){let i=this.args.generatorsConfiguration?.api?.["auth-schemes"],n=this.args.generatorsConfiguration?.api?.auth,a=t??n;if(a==null)return;let o=r!=null||i!=null?{...i,...r}:void 0,c=PRD(o,a);return{auth:a,"auth-schemes":c}}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=_Vc({taskContext:t,ir:r,options:sbn({options:i,overrides:this.args}),authOverrides:this.buildAuthOverrides(i?.auth,i?.authSchemes),environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:n??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:Bi.dump(a.rootApiFile)},namedDefinitionFiles:{...gn(a.definitionFiles,o=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Bi.dump(o),contents:o})),[ns.of(Qb)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Bi.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var JHa=class extends L3t{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;coerceEnumsToLiterals;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;resolveAliases;groupEnvironmentsByHost;removeDiscriminantsFromSchemas;defaultIntegerFormat;converter;constructor(t){super(t),this.inlinePathParameters=t.inlinePathParameters,this.objectQueryParameters=t.objectQueryParameters,this.onlyIncludeReferencedSchemas=t.onlyIncludeReferencedSchemas,this.respectReadonlySchemas=t.respectReadonlySchemas,this.respectNullableSchemas=t.respectNullableSchemas,this.wrapReferencesToNullableInOptional=t.wrapReferencesToNullableInOptional,this.coerceOptionalSchemasToNullable=t.coerceOptionalSchemasToNullable,this.coerceEnumsToLiterals=t.coerceEnumsToLiterals,this.exampleGeneration=t.exampleGeneration,this.useBytesForBinaryResponse=t.useBytesForBinaryResponse,this.respectForwardCompatibleEnums=t.respectForwardCompatibleEnums,this.inlineAllOfSchemas=t.inlineAllOfSchemas,this.resolveAliases=t.resolveAliases,this.groupEnvironmentsByHost=t.groupEnvironmentsByHost,this.removeDiscriminantsFromSchemas=t.removeDiscriminantsFromSchemas,this.defaultIntegerFormat=t.defaultIntegerFormat,this.converter=new Rfu(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:i},n){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:i},n);return this.converter.convert({context:t,ir:a,settings:n,absoluteFilePath:r})}async toFernWorkspace({context:t},r,i){let n=await this.getDefinition({context:t},r);return new W$({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion})}};var tL={BEARER_FORMAT:"x-bearer-format",ENUM_VAR_NAMES:"x-enum-varnames",INTERNAL:"x-internal",EXAMPLES:"x-examples",TAGS:"x-tags",REDOCLY_CODE_SAMPLES_KEBAB:"x-code-samples",REDOCLY_CODE_SAMPLES_CAMEL:"x-codeSamples"};var vaa={of(e){return e}};var Toh={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},hVc={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:Toh,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},Ki={SOURCE:vaa.of("source"),SDK_NAMESPACE:vaa.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:vaa.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:vaa.of("x-fern-sdk-group-name"),REQUEST_NAME_V1:"x-request-name",REQUEST_NAME_V2:"x-fern-request-name",TYPE_NAME:"x-fern-type-name",BOOLEAN_LITERAL:"x-fern-boolean-literal",SERVER_NAME_V1:"x-name",SERVER_NAME_V2:"x-fern-server-name",BASE_PATH:"x-fern-base-path",GROUPS:vaa.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",RETRIES:"x-fern-retries",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport",IS_DISCRIMINATED:"x-fern-discriminated",EXPLORER_ENABLED:"x-fern-explorer-enabled"};var jRD={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!1,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!1,respectReadonlySchemas:!1,respectNullableSchemas:!0,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!0,preserveSchemaIds:!1,objectQueryParameters:!0,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!0,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!1,preserveSingleSchemaOneOf:!1,inlineAllOfSchemas:!1,resolveAliases:!1,groupMultiApiEnvironments:!1,groupEnvironmentsByHost:!1,wrapReferencesToNullableInOptional:!1,coerceOptionalSchemasToNullable:!1,removeDiscriminantsFromSchemas:_n.RemoveDiscriminantsFromSchemas.Always,defaultIntegerFormat:_n.DefaultIntegerFormat.Int32};function wRD(e){let{defaults:t,options:r,overrides:i,overrideOnly:n=new Set,undefinedIfAbsent:a=new Set}=e,o={};for(let c of Object.keys(t))n.has(c)?o[c]=i?.[c]!==void 0?i[c]:t[c]:a.has(c)?o[c]=i?.[c]!==void 0?i[c]:r?.[c]!==void 0?r[c]:void 0:o[c]=i?.[c]??r?.[c]??t[c];return o}function jEe({options:e,overrides:t}){return wRD({defaults:jRD,options:e,overrides:t,overrideOnly:new Set(["disableExamples","preserveSchemaIds"]),undefinedIfAbsent:new Set(["exampleGeneration","defaultFormParameterEncoding"])})}var Roh={naming:"v1"};function Ci(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function $Ha(e,t,r,i,n=[]){try{let a=Ci(e,t);if(a!=null)return r.parse(a)}catch{let o=jje(n).join(" -> ");i.error(`${o.length>0?`${o}: `:""}Failed to parse ${t}`)}}function _bn(e){let t=Ci(e,"examples");if(t!=null){if(Array.isArray(t))return t;if(typeof t=="object"&&t!==null)return Object.values(t).map(r=>typeof r=="object"&&r!==null&&"value"in r?r.value:r)}return[]}function zoh({schema:e,logger:t}){return Ci(e,Ki.ENCODING)??void 0}function Noh(e){return Ci(e,Ki.FERN_ENUM)}function Foh({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let o=Ci(i,Ki.SDK_NAMESPACE),c=Ci(i,Ki.SDK_GROUP_NAME),d=Ci(i,Ki.TYPE_DEFINITION);if(d!=null)return YHa({fernType:d,nameOverride:e,generatedName:t,title:r,description:n,availability:a,namespace:o,groupName:typeof c=="string"?[c]:c})}function YHa({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c}){return YI({type:e,_default:void 0,validation:void 0,visitor:{primitive:d=>{switch(d.v1){case"BASE_64":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.base64({example:void 0})});case"BOOLEAN":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.boolean({default:void 0,example:void 0})});case"DATE":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.date({example:void 0})});case"DATE_TIME":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.datetime({example:void 0})});case"FLOAT":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.float({example:void 0})});case"DOUBLE":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.double({default:void 0,minimum:void 0,maximum:void 0,exclusiveMinimum:void 0,exclusiveMaximum:void 0,multipleOf:void 0,example:void 0})});case"UINT":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.uint({default:void 0,example:void 0})});case"INTEGER":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.int({default:void 0,minimum:void 0,maximum:void 0,exclusiveMinimum:void 0,exclusiveMaximum:void 0,multipleOf:void 0,example:void 0})});case"UINT_64":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.uint64({default:void 0,example:void 0})});case"LONG":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return ai.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Jn.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:gt(d.v1)}},unknown:()=>ai.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,namespace:o,groupName:c}),map:({keyType:d,valueType:s})=>d?.type==="primitive"&&s!=null?ai.map({nameOverride:t,generatedName:r,title:i,key:d,value:s,description:n,availability:a,namespace:o,groupName:c,encoding:void 0,example:void 0,inline:void 0}):void 0,list:d=>d!=null?ai.array({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,optional:d=>d!=null?ai.optional({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,nullable:d=>d!=null?ai.nullable({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,set:d=>d!=null?ai.array({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,literal:d=>ai.literal({nameOverride:t,generatedName:r,title:i,value:d._visit({string:s=>Ww.string(s),boolean:s=>Ww.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,namespace:o,groupName:c}),named:d=>ai.reference({schema:d,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,source:cW.openapi({file:"<memory>"})})}})}function Qoh(e){let t=Ci(e,Ki.SOURCE);if(t!=null)return t.endsWith(".proto")?cW.protobuf({file:t}):cW.openapi({file:t})}function hbn(e){if(e!=null&&typeof e=="boolean")return e}function wn(e){return e?.$ref!=null}function Uoh({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:d,context:s,namespace:u,groupName:l,example:p,encoding:_,source:h}){return n===void 0&&(n=s.options.additionalPropertiesDefaultsTo),yVc({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:d,description:a,availability:o,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Jn.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:typeof n=="boolean"||XHa(n,s.options)?ai.unknown({...ERD(n),generatedName:`${t}Value`}):Loh(Zl(n,!1,s.options.optionalAdditionalProperties?d:!1,s,[...i,"Value"],h,u,void 0,void 0,void 0)),namespace:u,groupName:l,example:p,encoding:_})}function Loh(e){switch(e.type){case"array":case"enum":case"map":case"object":e.inline=!0;break;case"literal":case"primitive":case"reference":case"unknown":break;case"nullable":case"optional":e.inline=!0,e.value=Loh(e.value);break;case"oneOf":e.value.inline=!0;break;default:gt(e)}return e}function yVc({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsOptional:a,wrapAsNullable:o,description:c,availability:d,namespace:s,groupName:u,example:l,encoding:p}){let _=ai.map({nameOverride:e,generatedName:t,title:r,description:c,availability:d,key:i,value:n,namespace:s,groupName:u,encoding:p,example:l,inline:void 0});return o&&(_=ai.nullable({nameOverride:e,generatedName:t,title:r,value:_,description:c,availability:d,namespace:s,groupName:u,inline:void 0})),a&&(_=ai.optional({nameOverride:e,generatedName:t,title:r,value:_,description:c,availability:d,namespace:s,groupName:u,inline:void 0})),_}function XHa(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:wn(e)||"type"in e&&e.type!=null||"oneOf"in e&&e.oneOf!=null||"anyOf"in e&&e.anyOf!=null?!1:"allOf"in e&&e.allOf!=null?!e.allOf.some(i=>wn(i)?!0:i.type!=null||i.properties!=null||i.allOf!=null||i.oneOf!=null||i.anyOf!=null||i.enum!=null||"items"in i||i.additionalProperties!=null):!("enum"in e&&e.enum!=null)}function ERD(e){let t={nameOverride:void 0,generatedName:"",title:void 0,description:void 0,availability:void 0,example:void 0,namespace:void 0,groupName:void 0};return e==null||typeof e=="boolean"||wn(e)||typeof e!="object"||(e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description)),t}function Voh({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:d,context:s,namespace:u,groupName:l,example:p,source:_}){let h=n==null?ai.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:l}):Zl(n,!1,!1,s,[...i,"Item"],_,u);return SRD({nameOverride:e,generatedName:t,title:r,namespace:u,groupName:l,itemSchema:h,wrapAsOptional:c,wrapAsNullable:d,description:a,availability:o,example:p})}function SRD({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,namespace:d,groupName:s,example:u}){let l=ai.array({nameOverride:e,generatedName:t,title:r,value:i,description:o,availability:c,namespace:d,groupName:s,example:u,inline:void 0});return a&&(l=ai.nullable({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),n&&(l=ai.optional({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),l}function dW(e){switch(Ci(e,Ki.AVAILABILITY)){case"deprecated":return rF.Deprecated;case"beta":return rF.Beta;case"generally-available":return rF.GenerallyAvailable;default:break}if(!wn(e)&&e.deprecated)return rF.Deprecated}function bVc({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:o,required:c,wrapAsOptional:d,wrapAsNullable:s,discriminator:u,context:l,namespace:p,groupName:_,encoding:h,source:y}){let b=u.propertyName,v=Object.fromEntries(Object.entries(u.mapping??{}).map(([A,g])=>{let m=TQi({$ref:g},!1,!1,l,[g],h,y,p);return l.markReferencedByDiscriminatedUnion({$ref:g},b,1),[A,m]})),O=Object.entries(n).filter(([A])=>A!==b).map(([A,g])=>{let m=c!=null&&c.includes(A),[j,S]=l.options.coerceOptionalSchemasToNullable?[!1,!m]:[!m,!1],w=Zl(g,j,S,l,[...i,A],y,p);return{key:A,schema:w}});return Woh({nameOverride:e,generatedName:t,title:r,wrapAsOptional:d,wrapAsNullable:s,properties:O,description:a,availability:o,discriminant:b,subtypes:v,namespace:p,groupName:_,source:y})}function vVc({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:o,required:c,wrapAsOptional:d,wrapAsNullable:s,discriminant:u,variants:l,context:p,namespace:_,groupName:h,encoding:y,source:b}){let v=Object.fromEntries(Object.entries(l).map(([A,g])=>{if(wn(g)){let m=TQi(g,!1,!1,p,[g.$ref],y,b,_);return p.markReferencedByDiscriminatedUnion(g,u,1),[A,m]}else{let m=gaa(g,!1,!1,p,[...i,A],y,b,_,new Set([u]));return[A,m]}})),O=Object.entries(n).filter(([A])=>A!==u).map(([A,g])=>{let m=c!=null&&c.includes(A),[j,S]=p.options.coerceOptionalSchemasToNullable?[!1,!m]:[!m,!1],w=Zl(g,j,S,p,[...i,A],b,_);return{key:A,schema:w}});return Woh({nameOverride:e,generatedName:t,title:r,wrapAsOptional:d,wrapAsNullable:s,properties:O,description:a,availability:o,discriminant:u,subtypes:v,namespace:_,groupName:h,source:b})}function Woh({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,properties:a,description:o,availability:c,discriminant:d,subtypes:s,namespace:u,groupName:l,source:p}){let _=ai.oneOf(Rve.discriminated({description:o,availability:c,discriminantProperty:d,nameOverride:e,generatedName:t,title:r,schemas:s,commonProperties:a,namespace:u,groupName:l,encoding:void 0,source:p,inline:void 0}));return n&&(_=ai.nullable({nameOverride:e,generatedName:t,title:r,value:_,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),i&&(_=ai.optional({nameOverride:e,generatedName:t,title:r,value:_,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),_}function Goh(e){if(e.proto!=null)return Rna.protobuf({typeName:e.proto.type})}function kKi({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:o,description:c,availability:d,wrapAsOptional:s,wrapAsNullable:u,namespace:l,groupName:p,context:_,source:h,inline:y}){let b=DRD(n??[]),v=new Set(a),O=Array.from(v).map((g,m)=>{let j=i?.[g],S=b[m],w=paa.test(g),D=j?.name??S,B=w?g:_aa(g);return D!=null&&!paa.test(D)&&(_?.logger.warn(`Enum name override ${D} is not a valid name. Falling back on ${B}.`),D=void 0),{nameOverride:D,generatedName:B,value:g,description:j?.description,availability:d,casing:{snake:j?.casing?.snake??void 0,pascal:j?.casing?.pascal??void 0,screamingSnake:j?.casing?.screamingSnake??void 0,camel:j?.casing?.camel??void 0}}}),A=o!=null?O.find(g=>g.value===o):void 0;return MRD({wrapAsOptional:s,wrapAsNullable:u,nameOverride:e,generatedName:t,title:r,values:O,_default:A,description:c,availability:d,namespace:l,groupName:p,source:h,inline:y})}function MRD({wrapAsOptional:e,wrapAsNullable:t,nameOverride:r,generatedName:i,title:n,values:a,_default:o,description:c,availability:d,namespace:s,groupName:u,source:l,inline:p}){let _=ai.enum({nameOverride:r,generatedName:i,title:n,values:a,description:c,availability:d,default:o,example:void 0,namespace:s,groupName:u,source:l,inline:p});return t&&(_=ai.nullable({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:d,namespace:s,groupName:u,inline:p})),e&&(_=ai.optional({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:d,namespace:s,groupName:u,inline:p})),_}function DRD(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(i=>i[r]===t[r]);)r++;return e.map(i=>i.substring(r))}function Hoh({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:u,availability:l,wrapAsOptional:p,wrapAsNullable:_,example:h,namespace:y,groupName:b,defaultIntegerFormat:v=_n.DefaultIntegerFormat.Int32}){let O=i??v,A=(()=>{switch(O){case _n.DefaultIntegerFormat.Int64:return Jn.int64({default:n,example:h});case _n.DefaultIntegerFormat.Uint32:return Jn.uint({default:n,example:h});case _n.DefaultIntegerFormat.Uint64:return Jn.uint64({default:n,example:h});default:return Jn.int({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:h})}})();return pW({nameOverride:e,generatedName:t,title:r,primitive:A,wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}function BRD(e){return typeof e=="string"?Ww.string(e):typeof e=="boolean"?Ww.boolean(e):Ww.string(`${e}`)}function xoh({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,value:a,description:o,availability:c,namespace:d,groupName:s}){let u=ai.literal({nameOverride:e,generatedName:t,title:r,value:BRD(a),description:o,availability:c,namespace:d,groupName:s});return n&&(u=ai.nullable({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),i&&(u=ai.optional({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),u}function gVc({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:u,availability:l,wrapAsOptional:p,wrapAsNullable:_,example:h,namespace:y,groupName:b}){return i==null||i==="double"?pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.double({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="float"?pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="int32"?pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.int({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="int64"?pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.int64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint32"?pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.uint({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint64"?pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.uint64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="time-delta"?pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):pW({nameOverride:e,generatedName:t,title:r,primitive:Jn.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}var IRD={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},CRD={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="responses",applyStrategy:e=>{let t=[e[3]??""];return e=e.slice(4),{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},qRD={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="parameters",applyStrategy:e=>{let t=[e[3]??""];return e=e.slice(4),e[0]==="schema"&&(e=e.slice(1)),{refUnderProcessing:e,newBreadcrumbs:t}}},TRD={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},RRD={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},zRD={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},NRD={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},FRD={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function ZHa(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[IRD,CRD,qRD,TRD,RRD,zRD,NRD,FRD],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:o,newBreadcrumbs:c}=a.applyStrategy(t);t=o,r=[...r,...c]}}while(t.join("")!==n.join(""));return r}function f1(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:F0(nu(n))).join("");return/^\d/.test(i)?LHa(i)??i:i}function Koh(e){let t=e.join("_");return nu(t)}function DA(e){switch(e.type){case"object":return ic.object({allOf:e.allOf,properties:e.properties.map(t=>URD(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:e.inline});case"array":return ic.array({description:e.description,availability:e.availability,value:DA(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return ic.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,source:e.source,inline:e.inline});case"literal":return ic.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"nullable":return ic.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:DA(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return ic.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:DA(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return ic.primitive({description:e.description,availability:e.availability,schema:Joh(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return ic.map({description:e.description,availability:e.availability,key:ic.primitive({description:e.key.description,availability:e.key.availability,schema:Joh(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:DA(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return ic.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return ic.oneOf(QRD(e.value));case"unknown":return ic.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:gt(e)}}function QRD(e){switch(e.type){case"discriminated":return tYt.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:DA(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,DA(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return tYt.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>DA(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:gt(e)}}function Joh(e){switch(e.type){case"string":return Th.string(e);case"base64":return Th.base64();case"boolean":return Th.boolean(e);case"date":return Th.date();case"datetime":return Th.datetime();case"double":return Th.double(e);case"float":return Th.float();case"int":return Th.int(e);case"int64":return Th.int64(e);case"uint":return Th.uint();case"uint64":return Th.uint64();default:gt(e)}}function URD(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:DA(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function zfu(e,t){return H$(DA(e),DA(t))}function $oh({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:o,wrapAsOptional:c,wrapAsNullable:d,allOf:s,context:u,propertiesToExclude:l,namespace:p,groupName:_,fullExamples:h,additionalProperties:y,availability:b,source:v}){let O=[...o??[]],A={...Yoh({properties:n,breadcrumbs:i,context:u})},g=[],m=[];for(let B of s)if(!u.options.inlineAllOfSchemas&&wn(B)){let R=u.resolveSchemaReference(B);if(R.discriminator!=null&&R.discriminator.mapping!=null)continue;if(R.oneOf!=null||R.anyOf!=null){let z=R.oneOf??R.anyOf;if(z!=null){for(let F of z){let U=wn(F)?u.resolveSchemaReference(F):F,x=Zl(U,!1,!1,u.DUMMY,i,v,p);x.type==="object"&&g.push(...x.properties.map(k=>k.schema.type!=="optional"&&k.schema.type!=="nullable"?{...k,schema:ai.optional({nameOverride:void 0,generatedName:"",title:void 0,value:k.schema,description:void 0,availability:k.availability,namespace:void 0,groupName:void 0,inline:void 0})}:k))}continue}}let N=eJi(B);if(N==null)continue;m.push({schemaId:N,convertedSchema:OVc(B,[N],v,u.options.preserveSchemaIds),properties:Xoh({schema:B,context:u,breadcrumbs:i,source:v,namespace:p})}),u.markSchemaAsReferencedByNonRequest(N)}else if(wn(B)){let R=u.resolveSchemaReference(B),N=Zl(R,!1,!1,u,i,v,p);N.type==="object"&&g.push(...N.properties)}else{let R=B.required??[];g=g.map(z=>(z.schema.type==="optional"||z.schema.type==="nullable")&&R.includes(z.key)?{...z,schema:z.schema.value}:z);let N=Zl(B,!1,!1,u,i,v,p);N.type==="object"&&g.push(...N.properties)}let j={};for(let B of m)for(let[R,N]of Object.entries(B.properties)){let z=j[R];z!=null?(z.schemaIds.push(B.schemaId),z.schemas.some(U=>zfu(U,N))||z.schemas.push(N)):j[R]={schemaIds:[B.schemaId],schemas:[N]}}let S=[];for(let[B,R]of Object.entries(j))R.schemaIds.length>1&&S.push({propertyKey:B,allOfSchemaIds:R.schemaIds,conflictingTypeSignatures:R.schemas.length>1});let w=Object.fromEntries(Object.entries(A).filter(([B,R])=>!(!wn(R)&&R.type==="null"))),D=Object.entries(w).map(([B,R])=>{let N=Ci(R,Ki.AUDIENCES)??[],z=dW(R),F=wn(R)?!1:R.readOnly,U=wn(R)?!1:R.writeOnly,k=!(O.includes(B)&&!F),je=Ci(R,Ki.FERN_PROPERTY_NAME),ve=[...i,B],H=Koh(ve),G=Zl(R,k,!1,u,ve,v,p),Ee={};for(let ue of m){let Oe=ue.properties[B];Oe!=null&&!zfu(G,Oe)?Ee[ue.schemaId]={differentSchema:!0}:Oe!=null&&(Ee[ue.schemaId]={differentSchema:!1})}return{key:B,schema:G,nameOverride:je,audiences:N,conflict:Ee,generatedName:H,availability:z,readonly:F,writeonly:U}});return D.push(...g.map(B=>{let R=B.conflict;for(let N of m){let z=N.properties[B.key];z!=null&&!zfu(B.schema,z)?R[N.schemaId]={differentSchema:!0}:z!=null&&(R[N.schemaId]={differentSchema:!1})}return{...B,conflict:R}})),LRD({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:d,properties:D.filter(B=>!l.has(B.key)),description:a,allOf:m.map(B=>B.convertedSchema),allOfPropertyConflicts:S,namespace:p,groupName:_,fullExamples:h,additionalProperties:y,availability:b,source:v,context:u})}function LRD({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,properties:a,description:o,allOf:c,allOfPropertyConflicts:d,namespace:s,groupName:u,fullExamples:l,additionalProperties:p,availability:_,source:h,context:y}){let b=ai.object({description:o,properties:a,nameOverride:e,generatedName:t,title:r,allOf:c,allOfPropertyConflicts:d,namespace:s,groupName:u,fullExamples:l,additionalProperties:XHa(p,y.options),availability:_,source:h,inline:void 0});return n&&(b=ai.nullable({nameOverride:e,generatedName:t,title:r,value:b,description:o,availability:_,namespace:s,groupName:u,inline:void 0})),i&&(b=ai.optional({nameOverride:e,generatedName:t,title:r,value:b,description:o,availability:_,namespace:s,groupName:u,inline:void 0})),b}function Yoh({properties:e,breadcrumbs:t,context:r}){return Object.fromEntries(Object.entries(e).filter(([i,n])=>{let a=Ci(n,Ki.IGNORE);return a&&r.logger.debug(`Property ${t.join(".")}.${i} is marked with x-fern-ignore. Skipping.`),!a}))}function Xoh({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[o,c]=wn(e)?[t.resolveSchemaReference(e),ZHa(e.$ref)]:[e,r];for(let d of o.allOf??[])a={...a,...Xoh({schema:d,context:t,breadcrumbs:c,source:i,namespace:n})};for(let[d,s]of Object.entries(Yoh({properties:o.properties??{},breadcrumbs:r,context:t}))){let u=Zl(s,!1,!1,t,[...c,d],i,n);a[d]=u}return a}function tJi({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsOptional:o,wrapAsNullable:c,context:d,subtypes:s,namespace:u,groupName:l,encoding:p,source:_,subtypeSuffixOverrides:h}){let y=GRD({schemas:s}),b=s.flatMap((O,A)=>{if(!wn(O)&&O.enum!=null&&d.options.coerceEnumsToLiterals&&O.type==="string")return O.enum.map(m=>ai.literal({nameOverride:void 0,generatedName:f1([t,m],d.options.preserveSchemaIds),title:void 0,value:Ww.string(String(m)),namespace:u,groupName:void 0,description:void 0,availability:m.availability}));let g=y[A];if(h!=null){let m=h[A];m!=null&&"name"in m&&(g=m.name)}return[Zl(O,!1,!1,d,[...i,g??`${A}`],_,u)]}),v=VRD(b);return WRD({uniqueSubtypes:v,nameOverride:e,generatedName:t,title:r,wrapAsOptional:o,wrapAsNullable:c,description:n,availability:a,namespace:u,groupName:l,context:d,encoding:p,source:_})}function VRD(e){let t=[];for(let r=0;r<e.length;++r){let i=e[r],n=!1;for(let a=r+1;a<e.length;++a){let o=e[a];if(i!=null&&o!=null&&H$(i,o)){n=!0;break}}i!=null&&!n&&t.push(i)}return t}function WRD({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,namespace:d,groupName:s,context:u,encoding:l,source:p}){if(Object.entries(e).every(([h,y])=>y.type==="literal")){let h={},y=[];return Object.entries(e).forEach(([b,v])=>{v.type==="literal"&&v.value.type==="string"&&(y.push(v.value.value),v.description!=null&&(h[v.value.value]={description:v.description}))}),kKi({nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,fernEnum:h,enumVarNames:void 0,enumValues:y,_default:void 0,namespace:d,groupName:s,context:u,source:p,inline:void 0})}if(e.length===1&&e[0]!=null&&!u.options.preserveSingleSchemaOneOf){let h=e[0];return a&&(h=ai.nullable({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),n&&(h=ai.optional({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),h}return Zoh({nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,subtypes:e,namespace:d,groupName:s,encoding:l,source:p})}function AVc({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsOptional:a,wrapAsNullable:o,context:c,namespace:d,groupName:s,discriminator:u,encoding:l,source:p}){let _=Object.entries(u.mapping??{}).map(([b,v],O)=>{let A={$ref:v},g=TQi(A,!1,!1,c,[v],l,p,d);return c.markSchemaWithDiscriminantValue(A,u.propertyName,b),g.type==="object"&&(g.properties={[u.propertyName]:ai.literal({nameOverride:void 0,generatedName:f1([t,b],c.options.preserveSchemaIds),title:void 0,value:Ww.string(b),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...g.properties.filter(m=>m.key!==u.propertyName)}),g}),h=[];for(let b=0;b<_.length;++b){let v=_[b],O=!1;for(let A=b+1;A<_.length;++A){let g=_[A];if(v!=null&&g!=null&&H$(v,g)){O=!0;break}}v!=null&&!O&&h.push(v)}if(Object.entries(h).every(([b,v])=>v.type==="literal")){let b={},v=[];return Object.entries(h).forEach(([O,A])=>{A.type==="literal"&&A.value.type==="string"&&(v.push(A.value.value),A.description!=null&&(b[A.value.value]={description:A.description}))}),kKi({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:i,availability:n,fernEnum:b,enumVarNames:void 0,enumValues:v,_default:void 0,namespace:d,groupName:s,context:c,source:p,inline:void 0})}return h.length===1&&h[0]!=null&&!c.options.preserveSingleSchemaOneOf?h[0]:Zoh({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:i,availability:n,subtypes:h,namespace:d,groupName:s,encoding:l,source:p})}function GRD({schemas:e}){let t={},r=0;for(let n of e){if(!wn(n)){if(n.properties!=null&&Object.entries(n.properties).length>0){let a=Object.keys(n.properties),o={},c=a;for(let[d,s]of Object.entries(t)){let u=LCo(s,a);c=LCo(c,s),o[d]=u}o[r]=c,t=o}}r++}return e.map((n,a)=>{let o=t[a];if(o!=null&&o.length>0){let c=o.sort();if(c[0]!=null)return c[0]}return lbn(a)??`${a}`})}function Zoh({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,description:a,availability:o,subtypes:c,namespace:d,groupName:s,encoding:u,source:l}){let p=ai.oneOf(Rve.undiscriminated({description:a,availability:o,nameOverride:e,generatedName:t,title:r,schemas:c,namespace:d,groupName:s,encoding:u,source:l,inline:void 0}));return n&&(p=ai.nullable({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:d,groupName:s,inline:void 0})),i&&(p=ai.optional({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:d,groupName:s,inline:void 0})),p}function Oaa(e){if(e.default!=null&&typeof e.default=="string")return e.default}function Nfu({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=_bn(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function koh({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=_bn(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function uYt({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=_bn(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function euh({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=_bn(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var ybn="#/components/schemas/";function nuh(e,t){let r=wn(e)?t.resolveSchemaReference(e):e;switch(r.type){case"boolean":case"number":case"integer":return!0;case"string":return r.enum==null;case"array":return nuh(r.items,t);case"object":return!1;case void 0:return!1;default:return t.logger.warn("Unhandled schema type. Will not inline this schema",JSON.stringify(r)),!1}}function HRD(e,t,r){return r.options.resolveAliases?typeof r.options.resolveAliases=="object"&&r.options.resolveAliases.except?.includes(e)?!1:nuh(t,r):!1}function Zl(e,t,r,i,n,a,o,c=!1,d=new Set,s){let u=Qoh(e)??a,l=kRD({schema:e,logger:i.logger}),p=s;if(wn(e)){let _=xRD(e);_!==void 0&&(p=_)}if(wn(e)){let _=eJi(e);return _!=null?HRD(_,e,i)?gaa(i.resolveSchemaReference(e),t,r,i,ZHa(e.$ref),l,u,o,d,c,p):(c?i.markSchemaAsReferencedByRequest(_):i.markSchemaAsReferencedByNonRequest(_),TQi(e,t,r,i,n,l,u,o)):gaa(i.resolveSchemaReference(e),t,r,i,ZHa(e.$ref),l,u,o,d,c,p)}return gaa(e,t,r,i,n,l,u,o,d,c,s)}function xRD(e){if("example"in e&&e.example!==void 0){let t=e.example;if(typeof t=="string"||typeof t=="number"||typeof t=="boolean"||Array.isArray(t))return t}if("examples"in e){let t=e.examples;if(Array.isArray(t)&&t.length>0){let r=t[0];if(typeof r=="string"||typeof r=="number"||typeof r=="boolean"||Array.isArray(r))return r}}}function TQi(e,t,r,i,n,a,o,c){let d=e.$ref.includes("properties")?gaa(i.resolveSchemaReference(e),t,r,i,n,a,o,c,new Set):ai.reference(OVc(e,n,o,i.options.preserveSchemaIds));if(r===!1){let s=i.resolveSchemaReference(e);(s.nullable===!0||Array.isArray(s.type)&&s.type.length>=2&&s.type.includes("null"))&&(r=!0)}return r&&(d=ai.nullable({title:void 0,nameOverride:void 0,generatedName:f1(n,i.options.preserveSchemaIds),value:d,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),t&&(d=ai.optional({title:void 0,nameOverride:void 0,generatedName:f1(n,i.options.preserveSchemaIds),value:d,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),d}function KRD(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function gaa(e,t,r,i,n,a,o,c,d=new Set,s=!1,u){typeof e=="string"&&(e={type:e});let l=Ci(e,Ki.TYPE_NAME)??(i.options.useTitlesAsName?KRD(e.title):void 0),p=Ci(e,Ki.SDK_GROUP_NAME)??Ci(e,tL.TAGS)?.[0],_=(typeof p=="string"?[p]:p)??[];_=i.resolveGroupName(_);let h=f1(n,i.options.preserveSchemaIds),y=e.title,b=e.description,v=dW(e),O=[];e.example!=null&&O.push({name:void 0,value:e.example,description:void 0});let A=Ci(e,tL.EXAMPLES);A!=null&&Object.keys(A).length>0&&O.push(...Object.entries(A).map(([j,S])=>({name:S?.summary??j,value:S.value,description:S.description})));let g=_bn(e);g!=null&&Object.keys(g).length>0&&O.push(...g.map(j=>({name:void 0,value:j,description:void 0})));let m=Foh({schema:e,description:b,title:y,nameOverride:l,generatedName:h,availability:v});if(m!=null){let j=m;return r&&(j=ai.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:j})),t&&(j=ai.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:j})),j}try{if(Array.isArray(e.type)){let w=e.type.indexOf("null"),D=w!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&D)e.type.splice(w,1),e.type=e.type[0],e.nullable=!0;else if(D&&(e.type.splice(w,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let B=new Set([...e.oneOf,...e.type]);e.oneOf=[...B]}}if(r=r||e.nullable===!0,"const"in e&&(e.enum=[e.const]),e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(e.enum=e.enum.filter(D=>D!==null),!Ufu(e.enum))return pW({nameOverride:l,generatedName:h,title:y,primitive:Jn.string({default:Oaa(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:uYt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v});let w=Noh(e);return i.options.coerceEnumsToLiterals&&e.enum.length===1&&e.enum[0]!=null&&w==null?xoh({nameOverride:l,generatedName:h,title:y,wrapAsOptional:t,wrapAsNullable:r,value:e.enum[0],description:b,availability:v,namespace:c,groupName:_}):kKi({nameOverride:l,generatedName:h,title:y,fernEnum:w,enumVarNames:Ci(e,[tL.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:_,context:i,source:o,inline:void 0})}if(Ufu(e.type)&&e.type.length>1){let w=e.type.includes("null"),D=e.type.filter(B=>B!=="null").map(B=>({type:B,nullable:w}));return tJi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:D,namespace:c,groupName:_,encoding:a,source:o})}if(e.type==="boolean"){let w=Ci(e,Ki.BOOLEAN_LITERAL);return w!=null?ruh({nameOverride:l,generatedName:h,title:y,literal:Ww.boolean(w),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):pW({nameOverride:l,generatedName:h,title:y,primitive:Jn.boolean({default:JRD(e.default),example:koh({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_})}if(e.type==="number")return gVc({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:hbn(e.exclusiveMinimum),exclusiveMaximum:hbn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Nfu({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="integer")return Hoh({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:hbn(e.exclusiveMinimum),exclusiveMaximum:hbn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Nfu({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_,defaultIntegerFormat:i.options.defaultIntegerFormat});if(e.type==="float")return gVc({nameOverride:l,generatedName:h,title:y,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:hbn(e.exclusiveMinimum),exclusiveMaximum:hbn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Nfu({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="string"){if(e.format==="date-time")return pW({nameOverride:l,generatedName:h,title:y,primitive:Jn.datetime({example:uYt({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_});if(e.format==="date"&&i.options.typeDatesAsStrings===!1)return pW({nameOverride:l,generatedName:h,title:y,primitive:Jn.date({example:uYt({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_});if(e.format==="json-string"){let D=ai.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:void 0});return r&&(D=ai.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),t&&(D=ai.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),D}let w=ouh(e,"const");return w!=null?ruh({nameOverride:l,generatedName:h,title:y,literal:Ww.string(w),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):pW({nameOverride:l,generatedName:h,title:y,primitive:Jn.string({default:Oaa(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:uYt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v})}if(e.type==="array")return Voh({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,item:e.items,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,example:euh({schema:e,logger:i.logger,fallback:u}),source:o});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&Ffu(e)&&tuh(e))return Uoh({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,additionalProperties:e.additionalProperties,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,example:e.example,source:o});if(e.oneOf!=null&&e.oneOf.length>0&&Ci(e,Ki.IS_DISCRIMINATED)===!1)return tJi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:e.oneOf,namespace:c,groupName:_,encoding:a,source:o});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return i.options.discriminatedUnionV2?AVc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,discriminator:e.discriminator,encoding:a,source:o}):bVc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,source:o});if(e.oneOf!=null&&e.oneOf.length>0){let w=Ci(e,Ki.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return i.options.discriminatedUnionV2||w?AVc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,discriminator:e.discriminator,encoding:a,source:o}):bVc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,source:o});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(i.options.preserveSingleSchemaOneOf)return tJi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:e.oneOf.filter(B=>wn(B)||B.type!=="null"),encoding:a,namespace:c,groupName:_,source:o});let D=Zl(e.oneOf[0],t,r,i,n,o,c,s);return sYt(D,b,c,_)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let N=e.oneOf[0],z=e.oneOf[1];if(!wn(N)&&N.type==="null"){let F=Zl(z,t,!0,i,n,o,c);return sYt(F,b,c,_)}else if(!wn(z)&&z.type==="null"){let F=Zl(N,t,!0,i,n,o,c);return sYt(F,b,c,_)}}let D=YRD({schemas:e.oneOf});if(D!=null)return kKi({nameOverride:l,generatedName:h,title:y,fernEnum:void 0,enumVarNames:void 0,enumValues:D,_default:e.default,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:_,context:i,source:o,inline:void 0});let B=iuh({schemas:e.oneOf,context:i});if(B!=null&&!i.options.discriminatedUnionV2&&!w)return vVc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},required:e.required,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,discriminant:B.discriminant,variants:B.schemas,context:i,namespace:c,groupName:_,encoding:a,source:o});let R=e.oneOf.filter(N=>!wn(N)&&N.type==="null").length>0;return tJi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||R,context:i,subtypes:e.oneOf.filter(N=>wn(N)||N.type!=="null"),encoding:a,namespace:c,groupName:_,source:o})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let B=Zl(e.anyOf[0],t,r,i,n,o,c,s);return sYt(B,b,c,_)}if(e.anyOf.length===2){let[B,R]=e.anyOf;if(B!=null&&R!=null){if(!wn(B)&&B.type==="null"){let N=Zl(R,t,!0,i,n,o,c);return sYt(N,b,c,_)}else if(!wn(R)&&R.type==="null"){let N=Zl(B,t,!0,i,n,o,c);return sYt(N,b,c,_)}}}let w=iuh({schemas:e.anyOf,context:i});if(w!=null&&!i.options.discriminatedUnionV2)return vVc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},required:e.required,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,discriminant:w.discriminant,variants:w.schemas,context:i,namespace:c,groupName:_,encoding:a,source:o});let D=e.anyOf.filter(B=>!wn(B)&&B.type==="null").length>0;return tJi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||D,context:i,subtypes:e.anyOf.filter(B=>wn(B)||B.type!=="null"),encoding:a,namespace:c,groupName:_,source:o})}if(e.allOf!=null||e.properties!=null){let w=[];for(let B of e.allOf??[])(wn(B)||Object.keys(B).length>0)&&w.push(B);if((e.properties==null||Ffu(e))&&w.length===1&&w[0]!=null&&(e.additionalProperties==null||e.additionalProperties===!1)){let B=Zl(w[0],t,r,i,n,o,c,s);return sYt(B,b,c,_)}let D=w.filter(B=>{let R=Qfu(B);return R||i.logger.debug(`Skipping non-object allOf element: ${JSON.stringify(B)}`),R});if((e.properties==null||Ffu(e))&&D.length===1&&D[0]!=null&&(e.additionalProperties==null||e.additionalProperties===!1)){let B=Zl(D[0],t,r,i,n,o,c,s);return sYt(B,b,c,_)}return $oh({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},description:b,required:e.required,wrapAsOptional:t,wrapAsNullable:r,allOf:D,context:i,propertiesToExclude:d,namespace:c,groupName:_,fullExamples:O,additionalProperties:e.additionalProperties,availability:v,encoding:a,source:o})}if(e.type==="object"&&$RD(e)&&tuh(e)&&Ffu(e))return yVc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,keySchema:{nameOverride:void 0,generatedName:`${h}Key`,title:void 0,description:void 0,availability:void 0,schema:Jn.string({default:Oaa(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:uYt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_},valueSchema:ai.unknown({nameOverride:void 0,generatedName:`${h}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:c,groupName:_}),namespace:c,groupName:_,encoding:a,example:e.example});e.type!=null&&i.logger.warn(`Failed to parse an OpenAPI schema at the following location: ${n.join("->")}. Coercing to unknown.`);let j=e.example??e.default,S=ai.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:j});return r&&(S=ai.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:S})),t&&(S=ai.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:S})),S}catch(j){return i.logger.debug(`Error converting schema: ${j.message}
|
|
1410
1410
|
Location: ${n.join("-> ")}`),ai.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:void 0})}}function JRD(e){if(e!=null){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase();if(t==="true")return!0;if(t==="false")return!1}}}function eJi(e){if(e.$ref.startsWith(ybn))return e.$ref.replace(ybn,"")}function OVc(e,t,r,i){let n=Ci(e,Ki.TYPE_NAME),a=f1(t,i),o=e.description,c=dW(e),d=eJi(e);if(d==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return ic.reference({generatedName:a,nameOverride:n,title:void 0,schema:d,description:o??void 0,availability:c,namespace:void 0,groupName:void 0,source:r})}function $RD(e){return e.oneOf==null||e.oneOf.length===0}function tuh(e){return e.allOf==null||e.allOf.length===0}function Ffu(e){return e.properties==null||Dm(e.properties)===0}function Ufu(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function sYt(e,t,r,i){if(e.type==="reference")return ai.reference({...e,description:t,availability:e.availability,namespace:r,groupName:i});if(e.type==="optional"){let n=sYt(e.value,t,r,i);return ai.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0})}else if(e.type==="nullable"){let n=sYt(e.value,t,r,i);return ai.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0})}else if(e.type==="primitive"&&t!=null&&e.description==null)return ai.primitive({...e,description:t});return e}function Qfu(e){return wn(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>Qfu(t)):e.oneOf!=null?e.oneOf.every(t=>Qfu(t)):e.anyOf!=null?e.anyOf.every(t=>Qfu(t)):!1}function ruh({literal:e,wrapAsOptional:t,wrapAsNullable:r,namespace:i,groupName:n,description:a,availability:o,nameOverride:c,generatedName:d,title:s}){let u=ai.literal({nameOverride:c,generatedName:d,title:s,value:e,namespace:i,groupName:n,description:a,availability:o});return r&&(u=ai.nullable({nameOverride:c,generatedName:d,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),t&&(u=ai.optional({nameOverride:c,generatedName:d,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),u}function pW({primitive:e,wrapAsOptional:t,wrapAsNullable:r,namespace:i,groupName:n,description:a,availability:o,generatedName:c,nameOverride:d,title:s}){n=typeof n=="string"?[n]:n;let u=ai.primitive({nameOverride:d,generatedName:c,title:s,schema:e,description:a,availability:o,namespace:i,groupName:n});return r&&(u=ai.nullable({nameOverride:d,generatedName:c,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),t&&(u=ai.optional({nameOverride:d,generatedName:c,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),u}function YRD({schemas:e}){let t=new Set;for(let r of e){if(wn(r))return;if(r.enum!=null&&Ufu(r.enum))r.enum.forEach(i=>t.add(i));else return}return Array.from(t)}function iuh({schemas:e,context:t}){let r={};for(let i of e){let n=auh({schema:i,context:t});for(let[a,o]of Object.entries(n)){let c=r[a];c!=null?c[o]=i:r[a]={[o]:i}}}for(let[i,n]of Object.entries(r))if(Object.keys(n).length===e.length)return{discriminant:i,schemas:n}}function auh({schema:e,context:t}){let r=wn(e)?t.resolveSchemaReference(e):e;return XRD({schema:r,context:t})}function XRD({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let i of e.anyOf){let n=auh({schema:i,context:t});for(let[a,o]of Object.entries(n??{}))r[a]=o}return r}for(let[i,n]of Object.entries(e.properties??{})){let a=wn(n)?t.resolveSchemaReference(n):n;a.type==="string"&&a.enum!=null&&Ufu(a.enum)&&ZRD(a.enum).length===1&&a.enum[0]!=null&&(r[i]=a.enum[0]);let o=ouh(a,"const");a.type==="string"&&o!=null&&(r[i]=o),i==="type"&&a.example!=null&&(r[i]=a.example)}return r}function ZRD(e){if(!e)return[];let t=new Set;return e.forEach(r=>{typeof r=="string"?t.add(r.toLowerCase()):t.add(r)}),Array.from(t)}function ouh(e,t){let r=e[t];if(r!=null)return r}function kRD({schema:e,logger:t}){let r=zoh({schema:e,logger:t});if(r!=null)return Goh(r)}var Aaa=class{document;taskContext;logger;DUMMY;options;namespace;static MESSAGE_REFERENCE_PREFIX="#/components/messages/";constructor({document:t,taskContext:r,options:i,namespace:n}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=i,this.namespace=n}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let i=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};i.push(n)}return i.concat(t??[])}resolveSchemaReference(t){if(!t.$ref.startsWith(ybn))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let i=t.$ref.substring(ybn.length).split("/"),n=this.document.components;if(n==null||n.schemas==null)throw new Error("Document does not have components.schemas.");let[a,o,c]=i;if(a==null||a==="")throw new Error(`${t.$ref} cannot be resolved. No schema key provided.`);let d=n.schemas[a];if(d==null)throw new Error(`Schema "${a}" is undefined in document.components.schemas.`);if(wn(d)&&(d=this.resolveSchemaReference(d)),o==="properties"&&c!=null){let s=d.properties?.[c];if(s==null)throw new Error(`Property "${c}" not found on "${a}". Full ref: ${t.$ref}`);wn(s)?d=this.resolveSchemaReference(s):d=s}return d}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,i){}markSchemaWithDiscriminantValue(t,r,i){}};var Lfu=class extends Aaa{getExampleMessageReference(t){return`#/components/messages/${t.messageId}`}resolveMessageReference(t){let r="#/components/messages/",i=this.document.components;if(i==null||i.messages==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve message reference: ${t.$ref} in v2 components`);let n=t.$ref.substring(r.length),a=i.messages[n];if(a==null)throw new Error(`${t.$ref} is undefined`);return a}};function maa(e,t){let r={};if(e!=null)return{rootSchemas:r,namespacedSchemas:{[e]:t}};let i={};for(let[n,a]of Object.entries(t))switch(a.type){case"object":case"array":case"map":case"optional":case"enum":case"literal":case"reference":case"nullable":case"primitive":{if(a.namespace==null){r[n]=a;continue}let o=a.namespace;i[o]??={},i[o][n]=a;continue}case"oneOf":case"unknown":r[n]=a;continue;default:gt(a)}return{rootSchemas:r,namespacedSchemas:i}}var Paa=ce(require("fs"),1),bbn=ce(require("path"),1);function rJi(e){if(typeof e=="string")return ml.primitive(po.string(e));if(typeof e=="number")return Number.isInteger(e)?ml.primitive(po.int(e)):ml.primitive(po.double(e));if(typeof e=="boolean")return ml.primitive(po.boolean(e));if(Array.isArray(e)){let t=e.map(r=>rJi(r));return t.length===0?void 0:ml.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,i]of Object.entries(e)){let n=rJi(i);n!=null&&t.push({key:po.string(r),value:n})}return ml.map(t)}}function kHa(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function uuh(e){if(e!=null&&Array.isArray(e))return e}var iJi=class{schemas;nonRequestReferencedSchemas;context;constructor(t,r,i){this.schemas=t,this.nonRequestReferencedSchemas=r,this.context=i}buildExample({schema:t,exampleId:r,example:i,options:n,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:i,options:{...n,maxCheckerDepth:n.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:i,depth:n,visitedSchemaIds:a,options:o,skipReadonly:c}){switch(i.type){case"enum":return typeof r=="string"&&suh({schema:i,value:r})?ml.enum(r):i.values[0]!=null?ml.enum(i.values[0]?.value):void 0;case"literal":return ml.literal(i.value);case"nullable":{if(r===null)return ml.null({});if(r==null&&!this.hasExample(i.value,0,a,o)&&this.exceedsMaxDepth(n,o))return ml.null({});let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:o,skipReadonly:c});return d??ml.null({})}case"optional":{if(r==null&&!this.hasExample(i.value,0,a,o)&&(o.ignoreOptionals||this.exceedsMaxDepth(n,o))||Object.is(r,null))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:o,skipReadonly:c});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"primitive":{let d=this.buildExampleFromPrimitive({schema:i.schema,example:r,options:o});return ml.primitive(d)}case"reference":{let d=this.schemas[i.schema];if(d!=null&&!a.has(i.schema)){a.add(i.schema);let s=d?.type==="object"&&!this.nonRequestReferencedSchemas.has(i.schema),u=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:n,options:o,skipReadonly:s||this.context.options.respectReadonlySchemas?c:!1});return a.delete(i.schema),u}return}case"oneOf":switch(i.value.type){case"discriminated":{let d={},s={},u={},l=kHa(r),p=l?.[i.value.discriminantProperty],_=i.value.schemas[p],h=[],y=this.getDiscriminatedUnionVariantSchema(i.value,l);y!=null&&h.push(y),h.push(...Object.entries(i.value.schemas));for(let b of h)if(p!=null&&_!=null&&_.type==="object"){s=this.getAllProperties(_),u=this.getAllRequiredProperties(_),d[i.value.discriminantProperty]=ml.primitive(po.string(p));break}else{let v=this.buildExampleHelper({exampleId:t,schema:b[1],example:void 0,visitedSchemaIds:a,depth:n,options:o,skipReadonly:c});if(v!=null){this.mergeExampleWith(v,d),d[i.value.discriminantProperty]=ml.primitive(po.string(b[0]));break}}for(let b of i.value.commonProperties){s[b.key]={schema:b.schema,readonly:!1};let v=this.getResolvedSchema(b.schema);v.type!=="optional"&&v.type!=="nullable"&&(u[b.key]=b.schema)}for(let[b,v]of Object.entries(s)){let O=b in u;if(O&&l?.[b]!=null){let A=this.buildExampleHelper({schema:v.schema,exampleId:t,example:l[b],visitedSchemaIds:a,depth:n+1,options:o,skipReadonly:c});if(A!=null)d[b]=A;else return}else{let A=this.buildExampleHelper({exampleId:t,schema:v.schema,example:l?.[b],visitedSchemaIds:a,depth:n+1,options:o,skipReadonly:c});if(A!=null)d[b]=A;else if(O)return}}return ml.oneOf(VKi.discriminated(d))}case"undiscriminated":{let d=this.getUnDiscriminatedUnionVariantSchema(i.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:n,options:o,skipReadonly:c});break}}return;case"unknown":if(r!=null){let d=rJi(r);if(d!=null)return ml.unknown(d)}return o.ignoreOptionals||this.exceedsMaxDepth(n,o)?void 0:o.isParameter?ml.primitive(po.string(o.name??"string")):ml.map([{key:po.string("key"),value:ml.primitive(po.string("value"))}]);case"array":{let d=uuh(r),s=[];if(d!=null&&d.length>0)for(let u of d){let l=this.buildExampleHelper({exampleId:t,example:u,schema:i.value,depth:n+1,visitedSchemaIds:a,options:o,skipReadonly:c});l!=null&&s.push(l)}else if(i.example!=null&&i.example.length>0)for(let u of i.example){let l=this.buildExampleHelper({exampleId:t,example:u,schema:i.value,depth:n+1,visitedSchemaIds:a,options:o,skipReadonly:c});l!=null&&s.push(l)}else{let u=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,depth:n+1,visitedSchemaIds:a,options:o,skipReadonly:c});u!=null&&s.push(u)}return ml.array(s)}case"map":{let d=kHa(r??i.example);if(d!=null&&Object.entries(d).length>0){let l=[];for(let[p,_]of Object.entries(d)){let h=this.buildExampleFromPrimitive({schema:i.key.schema,example:p,options:o}),y=this.buildExampleHelper({exampleId:t,example:_,schema:i.value,visitedSchemaIds:a,depth:n+1,options:o,skipReadonly:c});y!=null&&l.push({key:h,value:y})}return ml.map(l)}if(i.key.schema.type==="string"&&i.value.type==="unknown")return ml.map([{key:po.string("key"),value:ml.unknown(ml.primitive(po.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:i.key.schema,example:void 0,options:{...o,name:"key"}}),u=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,visitedSchemaIds:a,depth:n+1,options:{...o,name:"value"},skipReadonly:c});return u!=null&&u.type!=="null"?ml.map([{key:s,value:u}]):ml.map([])}case"object":{let d={},s=i.fullExamples?.find(_=>_.name===t)??i.fullExamples?.find(_=>_.name==null)??i.fullExamples?.[0],u=kHa(r)??(s!=null?kHa(s.value):{})??{},l=this.getAllProperties(i),p=this.getAllRequiredProperties(i);for(let[_,h]of Object.entries(l)){if(c&&h.readonly||h.schema._visit({optional:m=>typeof m.availability=="string"&&m.availability==="Deprecated",primitive:()=>!1,object:()=>!1,array:()=>!1,map:()=>!1,enum:()=>!1,reference:()=>!1,literal:()=>!1,oneOf:()=>!1,nullable:()=>!1,unknown:()=>!1,_other:()=>!1}))continue;let y=_ in p,b=Object.keys(u).includes(_),v=u[_],O=this.getSchemaExample(h.schema),A=b?v:O,g=this.buildExampleHelper({schema:h.schema,exampleId:t,example:A,visitedSchemaIds:a,depth:n+1,options:{...o,name:_},skipReadonly:c});if(y&&g!=null)d[_]=g;else{if(y)return;(b&&g!=null||!o.ignoreOptionals&&g!=null)&&(d[_]=g)}}if(i.additionalProperties){for(let[_,h]of Object.entries(u))if(!(_ in d)){let y=this.buildExampleHelper({schema:ai.unknown({example:h,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0}),exampleId:t,example:h,visitedSchemaIds:a,depth:n+1,options:{...o,name:_},skipReadonly:c});y!=null&&(d[_]=y)}}return ml.object({properties:d})}default:gt(i)}}mergeExampleWith(t,r){t._visit({array:Bt,enum:Bt,literal:Bt,map:i=>{for(let n of i){let a=n.key;a.type==="string"&&(r[a.value]=n.value)}},object:i=>{for(let[n,a]of Object.entries(i.properties))r[n]=a},oneOf:i=>{if(i.type==="discriminated")for(let[n,a]of Object.entries(i.value))r[n]=a;else this.mergeExampleWith(i.value,r)},primitive:Bt,unknown:Bt,null:Bt,_other:Bt})}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let i=r?.[t.discriminantProperty];if(i==null||typeof i!="string")return Object.entries(t.schemas)[0];let n=t.schemas[i];return n==null?Object.entries(t.schemas)[0]:[i,n]}getUnDiscriminatedUnionVariantSchema(t,r){if(r==null){let a=t.schemas.find(c=>this.hasExample(c,0,new Set,{ignoreOptionals:!1,isParameter:!1}));if(a!=null)return a;let o=t.schemas.find(c=>this.hasInherentExample(c));return o??t.schemas[0]}return t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,o)=>o.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return suh({schema:t,value:r})?5:0;case"object":{if(!gl(r))return 0;let i=this.getAllProperties(t),n=0;for(let[a,o]of Object.entries(i))r[a]!=null?(n++,n+=this.calcExampleHeuristic(o.schema,r[a])):n--;return n}case"array":{if(!Array.isArray(r))return 0;let i=0;for(let n of r)i+=this.calcExampleHeuristic(t.value,n);return i}case"map":{if(!gl(r))return 0;let i=0;for(let[,n]of Object.entries(r))i+=this.calcExampleHeuristic(t.value,n);return i}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let i=this.getResolvedSchema(t);return i==null?0:this.calcExampleHeuristic(i,r)}case"oneOf":return Object.values(t.value.schemas).map(n=>this.calcExampleHeuristic(n,r)).sort((n,a)=>a-n)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,i=new Set,n){if(this.exceedsMaxCheckerDepth(r,n))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,i,n);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,i,n);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let o of t.properties)if(this.hasExample(o.schema,r+1,i,n))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!i.has(t.schema)){i.add(t.schema);let o=this.hasExample(a,r,i,n);return i.delete(t.schema),o}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,i,n));default:return!1}}hasInherentExample(t){switch(t.type){case"literal":return!0;case"enum":return t.values.length>0;case"optional":case"nullable":return this.hasInherentExample(t.value);case"reference":{let r=this.schemas[t.schema];return r!=null?this.hasInherentExample(r):!1}default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let i of t.properties)r[i.key]={schema:i.schema,readonly:i.readonly??!1};for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let i of t.properties){let n=this.getResolvedSchema(i.schema);n.type!=="optional"&&n.type!=="nullable"&&(r[i.key]=i.schema)}for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}getSchemaExample(t){return t._visit({primitive:r=>r.schema.example,object:r=>r.fullExamples?.[0]?.value,array:r=>r.example,map:r=>r.example,optional:r=>this.getSchemaExample(r.value),enum:r=>r.example,reference:r=>{let i=this.schemas[r.schema];return i!=null?this.getSchemaExample(i):void 0},literal:()=>{},oneOf:()=>{},nullable:r=>this.getSchemaExample(r.value),unknown:r=>r.example,_other:()=>{}})}buildExampleFromPrimitive({example:t,schema:r,options:i}){switch(r.type){case"string":return t!=null&&typeof t=="string"?po.string(t):r.example!=null?po.string(r.example):po.string(i.name??Un.STRING);case"base64":return t!=null&&typeof t=="string"?po.base64(t):r.example!=null?po.base64(r.example):po.base64(Un.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?po.boolean(t):r.example!=null?po.boolean(r.example):po.boolean(Un.BOOLEAN);case"date":return t!=null&&typeof t=="string"?po.date(t):r.example!=null?po.date(r.example):po.date(Un.DATE);case"datetime":return t!=null&&typeof t=="string"?po.datetime(t):r.example!=null?po.datetime(r.example):po.datetime(Un.DATE_TIME);case"double":return t!=null&&typeof t=="number"?po.double(t):r.example!=null?po.double(r.example):po.double(Un.DOUBLE);case"float":return t!=null&&typeof t=="number"?po.float(t):r.example!=null?po.float(r.example):po.float(Un.FLOAT);case"int":return t!=null&&typeof t=="number"?po.int(t):r.example!=null?po.int(r.example):po.int(Un.INT);case"int64":return t!=null&&typeof t=="number"?po.int64(t):r.example!=null?po.int64(r.example):po.int64(Un.INT64);case"uint":return t!=null&&typeof t=="number"?po.uint(t):r.example!=null?po.uint(r.example):po.uint(Un.UINT);case"uint64":return t!=null&&typeof t=="number"?po.uint64(t):r.example!=null?po.uint64(r.example):po.uint64(Un.UINT64);default:gt(r)}}};function suh({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function x3t(e){switch(e.type){case"object":return ai.object({allOf:e.allOf,properties:e.properties.map(t=>tzD(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:void 0});case"array":return ai.array({description:e.description,availability:e.availability,value:x3t(e.value),generatedName:e.generatedName,title:e.title,namespace:e.namespace,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0});case"enum":return ai.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,example:void 0,source:e.source,inline:void 0});case"literal":return ai.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName});case"nullable":return ai.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:x3t(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"optional":return ai.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:x3t(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"primitive":return ai.primitive({description:e.description,availability:e.availability,schema:cuh(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return ai.map({description:e.description,availability:e.availability,key:ai.primitive({description:e.key.description,availability:e.key.availability,schema:cuh(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,namespace:e.namespace,groupName:e.groupName}),value:x3t(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,example:void 0,inline:void 0});case"reference":return ai.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return ai.oneOf(ezD(e.value));case"unknown":return ai.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,namespace:void 0,groupName:void 0,description:void 0,availability:void 0});default:gt(e)}}function ezD(e){switch(e.type){case"discriminated":return Rve.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:x3t(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,x3t(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return Rve.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>x3t(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:gt(e)}}function cuh(e){switch(e.type){case"string":return Jn.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return Jn.base64({example:void 0});case"boolean":return Jn.boolean({default:e.default,example:void 0});case"date":return Jn.date({example:void 0});case"datetime":return Jn.datetime({example:void 0});case"double":return Jn.double({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"float":return Jn.float({example:void 0});case"int":return Jn.int({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"int64":return Jn.int64({default:e.default,example:void 0});case"uint":return Jn.uint({default:void 0,example:void 0});case"uint64":return Jn.uint64({default:void 0,example:void 0});default:gt(e)}}function tzD(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:x3t(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function Vfu(e){return e.type!=="optional"&&e.type!=="nullable"}function mVc(e){return e==="POST"||e==="PUT"||e==="PATCH"}function e7a(e){if(e.type==="full")return e.request==null&&e.response==null&&e.queryParameters==null&&e.pathParameters==null&&e.headers==null;{let t=e.value;return t.request==null&&t.response==null&&t["query-parameters"]==null&&t["path-parameters"]==null&&t.headers==null}}var Wfu=class{schemas;context;globalHeaders;exampleTypeFactory;logger;missingExamples=[];constructor(t,r,i){this.schemas=t,this.context=r,this.globalHeaders=i,this.schemas=t,this.exampleTypeFactory=new iJi(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}addMissingExampleRecord(t,r,i,n,a={}){this.missingExamples.push({endpoint:t.path,method:t.method.toUpperCase(),type:r,schemaType:i,reason:n,operationSummary:t.summary,operationDescription:t.description,schemaDescription:a.schemaDescription,autoGeneratedExample:a.autoGeneratedExample})}writeMissingExamplesLog(){if(this.missingExamples.length===0)return;let t;if(this.context.source.type==="openapi"){let a=this.context.source.file,o=bbn.dirname(a),c=o;for(;c!==bbn.dirname(c);){let d=bbn.join(c,"fern");if(Paa.existsSync(d)&&Paa.statSync(d).isDirectory()){t=d;break}c=bbn.dirname(c)}t||(t=o)}else t=process.cwd();let r=t??process.cwd(),i=bbn.join(r,"schemas_missing_examples.txt"),n=["# Schemas Missing Examples Report",`# Generated on: ${new Date().toISOString()}`,`# Total missing examples: ${this.missingExamples.length}`,"",...this.missingExamples.flatMap(a=>{let o=[];if(o.push(`${a.method} ${a.endpoint} - ${a.type.toUpperCase()} (${a.schemaType}): ${a.reason}`),a.operationSummary&&o.push(` Operation: ${a.operationSummary}`),a.operationDescription&&a.operationDescription!==a.operationSummary&&o.push(` Description: ${a.operationDescription}`),a.schemaDescription&&o.push(` ${a.type==="request"?"Request":"Response"} Schema: ${a.schemaDescription}`),a.autoGeneratedExample){o.push(" Auto-generated example:");let d=JSON.stringify(a.autoGeneratedExample,null,4).split(`
|
|
1411
1411
|
`).map(s=>` ${s}`).join(`
|
|
1412
1412
|
`);o.push(d)}return o.push(""),o}),""].join(`
|
|
@@ -1781,7 +1781,7 @@ A valid API configuration was not found at the path: fern/apis/${t.apiName}.
|
|
|
1781
1781
|
Learn more about project structure:
|
|
1782
1782
|
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions`:`Failed to load API Definition referenced in docs.
|
|
1783
1783
|
Learn more about project structure:
|
|
1784
|
-
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions`;throw new Error(r)}async toRootNode(){let t=Rt.V1.SlugGenerator.init(Rt.slugjoin(this.getDocsBasePath())),r=this.#e.get("root"),i=await this.toRootChild(t);return{type:"root",version:"v1",id:r,child:i,slug:t.get(),title:this.parsedDocsConfig.title??"Documentation",hidden:!1,icon:void 0,pointsTo:void 0,authed:void 0,viewers:void 0,orphaned:void 0,roles:this.parsedDocsConfig.roles?.map(n=>Rt.RoleId(n)),featureFlags:void 0}}async toRootChild(t){return Tln(this.parsedDocsConfig.navigation)._visit({untabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),tabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),versioned:r=>this.toVersionedNode(r,t),productgroup:r=>this.toProductGroupNode({landingPageConfig:this.parsedDocsConfig.landingPage,productGroup:r,parentSlug:t})})}toLandingPageNode(t,r){let i=Rt.PageId(this.toRelativeFilepath(t.absolutePath)),n=r.apply({urlSlug:t.slug??KE(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{type:"landingPage",id:this.#e.get(i),title:t.title,slug:n.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:i,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags}}async toUnversionedNode({landingPage:t,navigationConfig:r,parentSlug:i}){let n=this.#e.get("unversioned"),a=t!=null?this.toLandingPageNode(t,i):void 0,o=r.type==="tabbed"?await this.convertTabbedNavigation(n,r.items,i):await this.toSidebarRootNode(n,r.items,i);return{type:"unversioned",id:n,landingPage:a,child:o}}async toVersionedNode(t,r){let i=this.#e.get("versioned"),n=t.versions[0];if(n?.hidden===!0)throw new Error(`The default version "${n.version}" cannot be hidden. Please set a non-hidden version as the first version in your versions list, or remove the hidden flag from the default version.`);return{id:i,type:"versioned",children:await Promise.all(t.versions.map((a,o)=>this.toVersionNode(a,r,o===0)))}}async toProductGroupNode({productGroup:t,landingPageConfig:r,parentSlug:i}){let n=this.#e.get("productgroup"),a=r!=null?this.toLandingPageNode(r,i):void 0;return{id:n,type:"productgroup",landingPage:a,children:await Promise.all(t.products.map(o=>this.toProductNode(o,i)))}}async toProductNode(t,r){if(t.type==="internal"){let i=r.setProductSlug(t.slug??KE(t.product)),n;switch(t.navigation.type){case"tabbed":n={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.convertTabbedNavigation(this.#e.get(t.product),t.navigation.items,i)};break;case"untabbed":n={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.toSidebarRootNode(this.#e.get(t.product),t.navigation.items,i)};break;case"versioned":n=await this.toVersionedNode(t.navigation,i);break;default:gt(t.navigation)}return{type:"product",id:this.#e.get(t.product),productId:Rt.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",slug:i.get(),child:n,default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,pointsTo:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,announcement:t.announcement!=null?{text:t.announcement.message}:void 0}}else return{type:"productLink",id:this.#e.get(t.product),productId:Rt.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",href:yG.Url(t.href??""),target:t.target,default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,viewers:t.viewers,orphaned:t.orphaned}}async toVersionNode(t,r,i){let n=this.#e.get(t.version),a=r.setVersionSlug(t.slug??KE(t.version)),o=t.navigation.type==="tabbed"?await this.convertTabbedNavigation(n,t.navigation.items,a):await this.toSidebarRootNode(n,t.navigation.items,a);return{type:"version",id:n,versionId:Rt.VersionId(t.version),title:t.version,slug:a.get(),child:o,default:i,availability:t.availability!=null?tdB(t.availability):void 0,landingPage:t.landingPage?this.toLandingPageNode(t.landingPage,a):void 0,hidden:t.hidden,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,icon:void 0,pointsTo:void 0,featureFlags:t.featureFlags,announcement:t.announcement!=null?{text:t.announcement.message}:void 0}}async toSidebarRootNode(t,r,i){let n=this.#e.get(`${t}/root`),a=await Promise.all(r.map(c=>this.toNavigationChild({prefix:n,item:c,parentSlug:i}))),o=[];return a.forEach(c=>{if(c.type==="apiReference"){o.push(c);return}if(c.type==="section"&&!c.collapsed){o.push(c);return}let d=o.length>0?o[o.length-1]:void 0,s;d?.type==="sidebarGroup"?s=d:(s={id:this.#e.get(`${n}/group`),type:"sidebarGroup",children:[]},o.push(s)),s.children.push(c)}),{type:"sidebarRoot",id:n,children:o}}async toSidebarRootNodeWithVariants(t,r,i){let n=this.#e.get(`${t}/root`);return{type:"sidebarRoot",id:n,children:[{type:"varianted",id:n,children:await Promise.all(r.map(a=>this.toVariantNode(a,n,i)))}]}}async toVariantNode(t,r,i){let n=this.#e.get(`${r}/variant/${t.slug??KE(t.title)}`),a=i.apply({urlSlug:t.slug??KE(t.title),skipUrlSlug:t.skipUrlSlug}),o=await Promise.all(t.layout.map(c=>this.toVariantChild(c,n,a)));return{type:"variant",id:n,variantId:Rt.V1.VariantId(t.title),subtitle:t.subtitle??"",default:t.default??!1,image:void 0,children:o,title:t.title,slug:a.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,pointsTo:void 0}}async toVariantChild(t,r,i){return Tln(t)._visit({page:async n=>this.toPageNode({item:n,parentSlug:i}),apiSection:async n=>this.toApiSectionNode({item:n,parentSlug:i}),section:async n=>this.toSectionNode({prefix:r,item:n,parentSlug:i}),link:async n=>this.toLinkNode(n),changelog:async n=>this.toChangelogNode(n,i)})}async toNavigationChild({prefix:t,item:r,parentSlug:i,hideChildren:n,parentAvailability:a}){return Tln(r)._visit({page:async o=>this.toPageNode({item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),apiSection:async o=>this.toApiSectionNode({item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),section:async o=>this.toSectionNode({prefix:t,item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),link:async o=>this.toLinkNode(o),changelog:async o=>this.toChangelogNode(o,i,n)})}async toApiSectionNode({item:t,parentSlug:r,hideChildren:i,parentAvailability:n}){let a=MMh(t.snippetsConfiguration),o,c=await this.getFernWorkspaceForApiSection(t).toFernWorkspace({context:this.taskContext},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1,objectQueryParameters:!0,preserveSchemaIds:!0}),d=this.parsedDocsConfig.experimental?.openapiParserV3,s=d==null||d;if(s)try{o=await this.getOpenApiWorkspaceForApiSection(t).getIntermediateRepresentation({context:this.taskContext,audiences:t.audiences,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1})}catch{}let u;if(t.tagDescriptionPages&&s)try{let b=await this.getOpenApiWorkspaceForApiSection(t).getOpenAPIIr({context:this.taskContext});b.tags.tagsById&&(u=Object.fromEntries(Object.entries(b.tags.tagsById).filter(([v,O])=>O.description&&O.description.trim().length>0).map(([v,O])=>[v,{id:String(O.id),description:O.description}])))}catch(y){this.taskContext.logger.warn("Failed to extract OpenAPI tags for tag description pages",String(y))}o==null&&(o=lS({workspace:c,audiences:t.audiences,generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!0},readme:void 0,version:void 0,packageName:void 0,context:this.taskContext,sourceResolver:new cS(this.taskContext,c)})),this.docsWorkspace.config.settings?.substituteEnvVars&&(o=FT(o,{onError:y=>this.taskContext.failAndThrow(`Error substituting environment variables in API spec: ${y}`)},{substituteAsEmpty:!1}));let l=await this.registerApi({ir:o,snippetsConfig:a,playgroundConfig:{oauth:t.playground?.oauth},apiName:t.apiName,workspace:c}),p=QKa({ir:o,apiDefinitionId:l,playgroundConfig:{oauth:t.playground?.oauth},context:this.taskContext}),_=new Vgu(t,p,r,this.docsWorkspace,this.taskContext,this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,this.#e,this.collectedFileIds,c,i,n??t.availability,u),h=_.getTagDescriptionContent();for(let[y,b]of h.entries()){let v=y.split("/").pop()||y,O=Ze.of(v),A=b;this.docsWorkspace.config.settings?.substituteEnvVars&&(A=FT(b,{onError:g=>this.taskContext.logger.error(`Error in tag description environment variable substitution: ${g}`)},{substituteAsEmpty:!1})),this.rawMarkdownFiles[O]=A,this.parsedDocsConfig.pages[O]=A}return _.get()}async toChangelogNode(t,r,i){return new Mvn(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,t.changelog,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:r,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:i||t.hidden,slug:t.slug})}async toLinkNode(t){return{type:"link",id:this.#e.get(t.url),title:t.text,url:Rt.V1.Url(t.url),icon:this.resolveIconFileId(t.icon),target:t.target}}async toPageNode({item:t,parentSlug:r,hideChildren:i,parentAvailability:n}){let a=Rt.PageId(this.toRelativeFilepath(t.absolutePath)),o=r.apply({urlSlug:t.slug??KE(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?Rt.PageId(o):void 0,d=this.#e.get(c??`${t}/section`),s=i.apply({urlSlug:r.slug??KE(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 Tln(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 Mvn(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:Rt.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??KE(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??KE(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):yG.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(As),remote:this.parsedDocsConfig.js.remote?.map(t=>({...t,url:yG.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 Tln(t,"type")._visit({filepath:({value:r})=>({type:"fileId",value:this.getFileId(r)}),url:({value:r})=>({type:"url",value:yG.Url(r)}),_other:()=>this.taskContext.failAndThrow("Invalid metadata configuration")})}};function edB(e,t){if(e?.github==null)return;let{owner:r,repo:i,branch:n="main",host:a="https://github.com"}=e.github;return`${mR(a)}/${r}/${i}/blob/${n}/fern/${t}?plain=1`}function tdB(e){switch(e){case"beta":return Rt.V1.NavigationV1Availability.Beta;case"deprecated":return Rt.V1.NavigationV1Availability.Deprecated;case"ga":return Rt.V1.NavigationV1Availability.GenerallyAvailable;case"stable":return Rt.V1.NavigationV1Availability.Stable;default:gt(e)}}async function dL(e){return(await Promise.all(e.apiWorkspaces.map(async t=>t instanceof sS?t:null))).filter(As)}async function Oxc(e,t,r){if(e instanceof LEe){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof sS))return;let i=await e.getIntermediateRepresentation({context:t,audiences:r,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1});return pH({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 oc={};Zt(oc,{AlgoliaSearchIndex:()=>JMh,ApiDefinitionId:()=>hDh,ApiId:()=>gDh,Availability:()=>TDh,DocsConfigId:()=>ODh,EndpointId:()=>mDh,EndpointPathLiteral:()=>CDh,EnvironmentId:()=>ADh,FileId:()=>SDh,HttpMethod:()=>qDh,IndexSegmentId:()=>$Mh,JqString:()=>DDh,OrgId:()=>bDh,PageId:()=>EDh,PayloadLocation:()=>uBh,PropertyKey:()=>BDh,PullRequestState:()=>rBh,RoleId:()=>IDh,TokenId:()=>vDh,TypeId:()=>wDh,Url:()=>MDh,VersionId:()=>yDh,WebSocketId:()=>PDh,WebhookId:()=>jDh,algolia:()=>Axc,api:()=>Ixc,commons:()=>Cxc,diff:()=>RDh,docs:()=>Lxc,generators:()=>Wxc,git:()=>Gxc,navigation:()=>Kxc,sdks:()=>$xc,snippets:()=>aBh,snippetsFactory:()=>oBh,templates:()=>Yxc,tokens:()=>sBh});var Axc={};Zt(Axc,{AlgoliaSearchIndex:()=>JMh,IndexSegmentId:()=>$Mh});function JMh(e){return e}function $Mh(e){return e}var Ixc={};Zt(Ixc,{latest:()=>jxc,v1:()=>Bxc});var jxc={};Zt(jxc,{AuthSchemeId:()=>YMh,WebhookHttpMethod:()=>eDh,auth:()=>mxc,commons:()=>XMh,endpoint:()=>ZMh,type_:()=>kMh,webhook:()=>Pxc,websocket:()=>tDh});var mxc={};Zt(mxc,{AuthSchemeId:()=>YMh});function YMh(e){return e}var XMh={};var ZMh={};var kMh={};var Pxc={};Zt(Pxc,{WebhookHttpMethod:()=>eDh});var eDh={Get:"GET",Post:"POST"};var tDh={};var Bxc={};Zt(Bxc,{SubpackageId:()=>fDh,WebSocketMessageId:()=>dDh,WebSocketMessageOrigin:()=>pDh,WebhookHttpMethod:()=>_Dh,commons:()=>Dxc,db:()=>wxc,read:()=>Sxc,register:()=>Mxc});var wxc={};Zt(wxc,{endpoint:()=>rDh});var rDh={};var Sxc={};Zt(Sxc,{SupportedLanguage:()=>iDh,endpoint:()=>Exc,type_:()=>nDh,webhook:()=>aDh,websocket:()=>oDh});var Exc={};Zt(Exc,{SupportedLanguage:()=>iDh});var iDh={Curl:"curl",Python:"python",Javascript:"javascript",Js:"js",Node:"node",Typescript:"typescript",Ts:"ts",Go:"go",Ruby:"ruby",Csharp:"csharp"};var nDh={};var aDh={};var oDh={};var Mxc={};Zt(Mxc,{SourceId:()=>rdB,endpoint:()=>uDh,type_:()=>sDh,webhook:()=>cDh,websocket:()=>lDh});var uDh={};var sDh={};var cDh={};var lDh={};function rdB(e){return e}var Dxc={};Zt(Dxc,{SubpackageId:()=>fDh,WebSocketMessageId:()=>dDh,WebSocketMessageOrigin:()=>pDh,WebhookHttpMethod:()=>_Dh});function fDh(e){return e}function dDh(e){return e}var pDh={Client:"client",Server:"server"};var _Dh={Get:"GET",Post:"POST"};var Cxc={};Zt(Cxc,{ApiDefinitionId:()=>hDh,ApiId:()=>gDh,Availability:()=>TDh,DocsConfigId:()=>ODh,EndpointId:()=>mDh,EndpointPathLiteral:()=>CDh,EnvironmentId:()=>ADh,FileId:()=>SDh,HttpMethod:()=>qDh,JqString:()=>DDh,OrgId:()=>bDh,PageId:()=>EDh,PropertyKey:()=>BDh,RoleId:()=>IDh,TokenId:()=>vDh,TypeId:()=>wDh,Url:()=>MDh,VersionId:()=>yDh,WebSocketId:()=>PDh,WebhookId:()=>jDh});function hDh(e){return e}function yDh(e){return e}function bDh(e){return e}function vDh(e){return e}function gDh(e){return e}function ODh(e){return e}function ADh(e){return e}function mDh(e){return e}function PDh(e){return e}function jDh(e){return e}function wDh(e){return e}function EDh(e){return e}function SDh(e){return e}function MDh(e){return e}function DDh(e){return e}function BDh(e){return e}function IDh(e){return e}function CDh(e){return e}var qDh={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE"};var TDh={Stable:"Stable",GenerallyAvailable:"GenerallyAvailable",InDevelopment:"InDevelopment",PreRelease:"PreRelease",Deprecated:"Deprecated",Beta:"Beta"};var RDh={};var Lxc={};Zt(Lxc,{latest:()=>Rxc,v1:()=>Qxc,v2:()=>Uxc});var Rxc={};Zt(Rxc,{Layout:()=>NDh,MdxEngine:()=>idB,TwitterCardSetting:()=>FDh,commons:()=>zDh,frontmatter:()=>qxc,seo:()=>Txc});var idB={NextMdxRemote:"next-mdx-remote",MdxBundler:"mdx-bundler"};var zDh={};var qxc={};Zt(qxc,{Layout:()=>NDh});var NDh={Guide:"guide",Overview:"overview",Reference:"reference",Page:"page",Custom:"custom"};var Txc={};Zt(Txc,{TwitterCardSetting:()=>FDh});var FDh={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var Qxc={};Zt(Qxc,{commons:()=>Fxc,db:()=>QDh,read:()=>UDh,write:()=>zxc});var QDh={};var UDh={};var zxc={};Zt(zxc,{DocsRegistrationId:()=>adB,FilePath:()=>ndB});function ndB(e){return e}function adB(e){return e}var Fxc={};Zt(Fxc,{ContentAlignment:()=>GDh,FontDisplay:()=>$Dh,FontStyle:()=>JDh,HeaderPosition:()=>HDh,JsScriptStrategy:()=>KDh,ProgrammingLanguage:()=>LDh,SearchbarPlacement:()=>VDh,TabsPlacement:()=>WDh,TwitterCardSetting:()=>xDh,commons:()=>Nxc});var Nxc={};Zt(Nxc,{ContentAlignment:()=>GDh,FontDisplay:()=>$Dh,FontStyle:()=>JDh,HeaderPosition:()=>HDh,JsScriptStrategy:()=>KDh,ProgrammingLanguage:()=>LDh,SearchbarPlacement:()=>VDh,TabsPlacement:()=>WDh,TwitterCardSetting:()=>xDh});var LDh={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 VDh={Header:"HEADER",HeaderTabs:"HEADER_TABS",Sidebar:"SIDEBAR"};var WDh={Header:"HEADER",Sidebar:"SIDEBAR"};var GDh={Center:"CENTER",Left:"LEFT"};var HDh={Fixed:"FIXED",Absolute:"ABSOLUTE"};var xDh={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var KDh={BeforeInteractive:"beforeInteractive",AfterInteractive:"afterInteractive",LazyOnload:"lazyOnload"};var JDh={Normal:"normal",Italic:"italic"};var $Dh={Auto:"auto",Block:"block",Swap:"swap",Fallback:"fallback",Optional:"optional"};var Uxc={};Zt(Uxc,{read:()=>YDh,write:()=>XDh});var YDh={};var XDh={};var Wxc={};Zt(Wxc,{ChangelogEntryType:()=>kDh,GeneratorId:()=>odB,GeneratorLanguage:()=>udB,ReleaseType:()=>eBh,cli:()=>ZDh,commons:()=>Vxc,versions:()=>tBh});var ZDh={};var Vxc={};Zt(Vxc,{ChangelogEntryType:()=>kDh,ReleaseType:()=>eBh});var kDh={Fix:"fix",Feat:"feat",Chore:"chore",Break:"break",Internal:"internal"};var eBh={Ga:"GA",Rc:"RC"};var tBh={};function odB(e){return e}var udB={Python:"python",Go:"go",Java:"java",Typescript:"typescript",Ruby:"ruby",Csharp:"csharp",Php:"php",Swift:"swift",Rust:"rust"};var Gxc={};Zt(Gxc,{PullRequestState:()=>rBh});var rBh={Open:"open",Closed:"closed",Merged:"merged"};var Kxc={};Zt(Kxc,{latest:()=>Hxc,v1:()=>xxc});var Hxc={};Zt(Hxc,{NodeId:()=>ldB,ProductId:()=>fdB,Slug:()=>sdB,TabId:()=>cdB});function sdB(e){return e}function cdB(e){return e}function ldB(e){return e}function fdB(e){return e}var xxc={};Zt(xxc,{NavigationV1Availability:()=>ydB,NodeId:()=>_dB,ProductId:()=>hdB,Slug:()=>ddB,TabId:()=>pdB});function ddB(e){return e}function pdB(e){return e}function _dB(e){return e}function hdB(e){return e}var ydB={Stable:"stable",GenerallyAvailable:"generally-available",InDevelopment:"in-development",PreRelease:"pre-release",Beta:"beta",Deprecated:"deprecated"};var $xc={};Zt($xc,{Language:()=>iBh,VersionBump:()=>nBh,versions:()=>Jxc});var Jxc={};Zt(Jxc,{Language:()=>iBh,VersionBump:()=>nBh});var iBh={Go:"Go",TypeScript:"TypeScript",Java:"Java",Python:"Python",Csharp:"Csharp",Ruby:"Ruby"};var nBh={Major:"MAJOR",Minor:"MINOR",Patch:"PATCH"};var aBh={};var oBh={};var Yxc={};Zt(Yxc,{PayloadLocation:()=>uBh});var uBh={Body:"BODY",Query:"QUERY",Path:"PATH",Headers:"HEADERS",Relative:"RELATIVE",Auth:"AUTH"};var sBh={};var Xgu=class{warnings=[];errors=[];error(t){this.errors.push(t)}warning(t){this.warnings.push(t)}};function Lo(e){return e!=null}var lBh=ce(eQa(),1);var cBh=["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 QYt(e){return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e=e.replace(/_/g," "),e=e.replace(/-/g," "),(0,lBh.default)(e,{special:cBh}).replace(/V\s(\d)/g,"V$1")}function fBh({endpoints:e,webhookEndpoints:t}){let r={};return Object.values({...e,...t}).forEach(i=>{let n=[];i.namespace?.forEach(a=>{let o=[...n,a],c=oc.api.v1.SubpackageId(o.join("."));r[c]={id:c,name:a,displayName:QYt(a)},n.push(a)})}),r}var Zgu=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 dBh(e){return`#/${e.map(t=>t.replaceAll(/~/g,"~0").replaceAll(/\//g,"~1")).join("/")}`}var ho=class extends Zgu{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 ${dBh(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})}}},pC=class extends ho{},oY=class extends pC{seenSchemas;constructor(t){super(t),this.seenSchemas=new Set(t.seenSchemas)}};var pBh="x-fern-base-path",_Bh="x-fern-availability",kgu="x-fern-sdk-group-name",hBh="x-fern-global-headers",yBh="x-fern-sdk-method-name";var bBh="x-fern-webhook",vBh="x-fern-access-token-locator",gBh="x-fern-basic",OBh="x-fern-username-variable-name",ABh="x-fern-password-variable-name",mBh="x-fern-bearer",PBh="x-fern-token-variable-name",jBh="x-fern-header",wBh="x-fern-header-variable-name",EBh="x-fern-server-name",SBh="x-fern-examples";var eOu=class extends ho{serverName;constructor(t){super(t),this.safeParse()}parse(){this.serverName=this.input[EBh]}convert(){if(this.serverName!=null)return this.serverName}};var tOu=class extends ho{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 eOu({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:oc.EnvironmentId(t),baseUrl:this.url}}};function v$i(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 tOu({input:c,context:r,accessPath:i,pathId:["servers",`${d}`]}));return[...n,...o]}function xv(e){return typeof e=="object"&&Lo(e)&&"$ref"in e&&typeof e.$ref=="string"}function pL(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:(xv(n)&&(n=pL(n,t,r)),n)}function rOu(e,t){let r=t.components?.securitySchemes?.[e];if(r!=null)return xv(r)?pL(r,t,void 0):r}var vIh=ce(ZS());var iOu=class extends ho{username;password;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[gBh];this.username=t?.username,this.password=t?.password}convert(){return{username:this.username,password:this.password}}};var nOu=class extends ho{passwordVariableName;constructor(t){super(t),this.safeParse()}parse(){this.passwordVariableName=this.input[ABh]}convert(){return this.passwordVariableName}};var aOu=class extends ho{usernameVariableName;constructor(t){super(t),this.safeParse()}parse(){this.usernameVariableName=this.input[OBh]}convert(){return this.usernameVariableName}};var oOu=class extends ho{bearerTokenVariableName;bearerTokenEnvVar;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[mBh];this.bearerTokenVariableName=t?.name,this.bearerTokenEnvVar=t?.env}convert(){return{tokenVariableName:this.bearerTokenVariableName,tokenEnvVar:this.bearerTokenEnvVar}}};var uOu=class extends ho{tokenVariableName;constructor(t){super(t),this.safeParse()}parse(){this.tokenVariableName=this.input[PBh]}convert(){return this.tokenVariableName}};function MBh(e){return typeof e=="object"&&e!=null&&"in"in e&&e.in==="header"}var DBh="x-bearer-format",BBh="x-code-samples",IBh="x-codeSamples";var sOu=class extends ho{bearerFormat;constructor(t){super(t),this.safeParse()}parse(){this.bearerFormat=this.input[DBh]}convert(){return this.bearerFormat}};var cOu=class extends ho{headerVariableName;headerEnvVar;headerPrefix;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[jBh];this.headerVariableName=t?.name,this.headerEnvVar=t?.env,this.headerPrefix=t?.prefix}convert(){return{name:this.headerVariableName,env:this.headerEnvVar,prefix:this.headerPrefix}}};var lOu=class extends ho{headerVariableName;constructor(t){super(t),this.safeParse()}parse(){this.headerVariableName=this.input[wBh]}convert(){return this.headerVariableName}};function CBh(e){return e.type==="apiKey"}var Uua=class extends ho{headerName;headerBearerFormatNode;headerAuthNode;headerVariableNameNode;constructor(t){super(t),this.safeParse()}parse(){CBh(this.input)&&(this.headerName=this.input.name),this.headerAuthNode=new cOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerVariableNameNode=new lOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerBearerFormatNode=new sOu({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 fOu(e){return e}function dOu(e){return e==="__proto__"}function pOu(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function Lua(e){return typeof e=="string"||typeof e=="symbol"?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function UKa(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(UKa).join(",");let t=String(e);return t==="0"&&Object.is(Number(e),-0)?"-0":t}function _Ou(e){if(Array.isArray(e))return e.map(Lua);if(typeof e=="symbol")return[e];e=UKa(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 LKa(e,t,r){if(e==null)return r;switch(typeof t){case"string":{if(dOu(t))return r;let i=e[t];return i===void 0?pOu(t)?LKa(e,_Ou(t),r):r:i}case"number":case"symbol":{typeof t=="number"&&(t=Lua(t));let i=e[t];return i===void 0?r:i}default:{if(Array.isArray(t))return bdB(e,t,r);if(Object.is(t?.valueOf(),-0)?t="-0":t=String(t),dOu(t))return r;let i=e[t];return i===void 0?r:i}}}function bdB(e,t,r){if(t.length===0)return r;let i=e;for(let n=0;n<t.length;n++){if(i==null||dOu(t[n]))return r;i=i[t[n]]}return i===void 0?r:i}function qBh(e){return function(t){return LKa(t,e)}}function TBh(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function hOu(e){return e==null||typeof e!="object"&&typeof e!="function"}function Xxc(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function kxc(e,t,r){return typeof r!="function"?kxc(e,t,()=>{}):Zxc(e,t,function i(n,a,o,c,d,s){let u=r(n,a,o,c,d,s);return u!==void 0?!!u:Zxc(n,a,i,s)},new Map)}function Zxc(e,t,r,i){if(t===e)return!0;switch(typeof t){case"object":return vdB(e,t,r,i);case"function":return Object.keys(t).length>0?Zxc(e,{...t},r,i):Xxc(e,t);default:return TBh(e)?typeof t=="string"?t==="":!0:Xxc(e,t)}}function vdB(e,t,r,i){if(t==null)return!0;if(Array.isArray(t))return RBh(e,t,r,i);if(t instanceof Map)return gdB(e,t,r,i);if(t instanceof Set)return OdB(e,t,r,i);let n=Object.keys(t);if(e==null)return n.length===0;if(n.length===0)return!0;if(i?.has(t))return i.get(t)===e;i?.set(t,e);try{for(let a=0;a<n.length;a++){let o=n[a];if(!hOu(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 gdB(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 RBh(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 OdB(e,t,r,i){return t.size===0?!0:e instanceof Set?RBh([...e],[...t],r,i):!1}function yOu(e,t){return kxc(e,t,()=>{})}function zBh(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function bOu(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var NBh="[object RegExp]",vOu="[object String]",gOu="[object Number]",OOu="[object Boolean]",AOu="[object Arguments]",FBh="[object Symbol]",QBh="[object Date]",UBh="[object Map]",LBh="[object Set]",VBh="[object Array]";var WBh="[object ArrayBuffer]",GBh="[object Object]";var HBh="[object DataView]",xBh="[object Uint8Array]",KBh="[object Uint8ClampedArray]",JBh="[object Uint16Array]",$Bh="[object Uint32Array]";var YBh="[object Int8Array]",XBh="[object Int16Array]",ZBh="[object Int32Array]";var kBh="[object Float32Array]",eIh="[object Float64Array]";function tIh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function rIh(e,t){return g$i(e,void 0,e,new Map,t)}function g$i(e,t,r,i=new Map,n=void 0){let a=n?.(e,t,r,i);if(a!==void 0)return a;if(hOu(e))return e;if(i.has(e))return i.get(e);if(Array.isArray(e)){let o=new Array(e.length);i.set(e,o);for(let c=0;c<e.length;c++)o[c]=g$i(e[c],c,r,i,n);return Object.hasOwn(e,"index")&&(o.index=e.index),Object.hasOwn(e,"input")&&(o.input=e.input),o}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let o=new RegExp(e.source,e.flags);return o.lastIndex=e.lastIndex,o}if(e instanceof Map){let o=new Map;i.set(e,o);for(let[c,d]of e)o.set(c,g$i(d,c,r,i,n));return o}if(e instanceof Set){let o=new Set;i.set(e,o);for(let c of e)o.add(g$i(c,void 0,r,i,n));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(e))return e.subarray();if(tIh(e)){let o=new(Object.getPrototypeOf(e)).constructor(e.length);i.set(e,o);for(let c=0;c<e.length;c++)o[c]=g$i(e[c],c,r,i,n);return o}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){let o=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return i.set(e,o),v8t(o,e,r,i,n),o}if(typeof File<"u"&&e instanceof File){let o=new File([e],e.name,{type:e.type});return i.set(e,o),v8t(o,e,r,i,n),o}if(typeof Blob<"u"&&e instanceof Blob){let o=new Blob([e],{type:e.type});return i.set(e,o),v8t(o,e,r,i,n),o}if(e instanceof Error){let o=new e.constructor;return i.set(e,o),o.message=e.message,o.name=e.name,o.stack=e.stack,o.cause=e.cause,v8t(o,e,r,i,n),o}if(e instanceof Boolean){let o=new Boolean(e.valueOf());return i.set(e,o),v8t(o,e,r,i,n),o}if(e instanceof Number){let o=new Number(e.valueOf());return i.set(e,o),v8t(o,e,r,i,n),o}if(e instanceof String){let o=new String(e.valueOf());return i.set(e,o),v8t(o,e,r,i,n),o}if(typeof e=="object"&&AdB(e)){let o=Object.create(Object.getPrototypeOf(e));return i.set(e,o),v8t(o,e,r,i,n),o}return e}function v8t(e,t,r=e,i,n){let a=[...Object.keys(t),...zBh(t)];for(let o=0;o<a.length;o++){let c=a[o],d=Object.getOwnPropertyDescriptor(e,c);(d==null||d.writable)&&(e[c]=g$i(t[c],c,r,i,n))}}function AdB(e){switch(bOu(e)){case AOu:case VBh:case WBh:case HBh:case OOu:case QBh:case kBh:case eIh:case YBh:case XBh:case ZBh:case UBh:case gOu:case GBh:case NBh:case LBh:case vOu:case FBh:case xBh:case KBh:case JBh:case $Bh:return!0;default:return!1}}function iIh(e){return g$i(e,void 0,e,new Map,void 0)}function nIh(e){return e=iIh(e),t=>yOu(t,e)}function aIh(e,t){return rIh(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 gOu:case vOu:case OOu:{let c=new e.constructor(e?.valueOf());return v8t(c,e),c}case AOu:{let c={};return v8t(c,e),c.length=e.length,c[Symbol.iterator]=e[Symbol.iterator],c}default:return}})}function oIh(e){return aIh(e)}var mdB=/^(?:0|[1-9]\d*)$/;function uIh(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 mdB.test(e)}}function sIh(e){return e!==null&&typeof e=="object"&&bOu(e)==="[object Arguments]"}function cIh(e,t){let r;if(Array.isArray(t)?r=t:typeof t=="string"&&pOu(t)&&e?.[t]==null?r=_Ou(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)||sIh(i))&&uIh(a)&&a<i.length))return!1;i=i[a]}return!0}function lIh(e,t){switch(typeof e){case"object":{Object.is(e?.valueOf(),-0)&&(e="-0");break}case"number":{e=Lua(e);break}}return t=oIh(t),function(r){let i=LKa(r,e);return i===void 0?cIh(r,e):t===void 0?i===void 0:yOu(i,t)}}function fIh(e){if(e==null)return fOu;switch(typeof e){case"function":return e;case"object":return Array.isArray(e)&&e.length===2?lIh(e[0],e[1]):nIh(e);case"string":case"symbol":case"number":return qBh(e)}}function dIh(e,t){let r={},i=Object.keys(e);for(let n=0;n<i.length;n++){let a=i[n],o=e[a];r[a]=t(o,a,e)}return r}function mOu(e,t=fOu){return e==null?{}:dIh(e,fIh(t))}function pIh(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}var PdB=new RegExp("\\p{Lu}?\\p{Ll}+|[0-9]+|\\p{Lu}+(?!\\p{Ll})|\\p{Emoji_Presentation}|\\p{Extended_Pictographic}|\\p{L}+","gu");function _Ih(e){return Array.from(e.match(PdB)??[])}function hIh(e){let t=_Ih(e);if(t.length===0)return"";let[r,...i]=t;return`${r.toLowerCase()}${i.map(n=>pIh(n)).join("")}`}function yIh(e){return typeof e!="string"&&(e=UKa(e)),e.replace(/['\u2019]/g,"")}function g8t(e){return hIh(yIh(e))}function HP(e){if(e!=null)return Array.isArray(e)?e:[e]}function POu({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`${jdB(o)}${wdB(e)}.${EdB(i,n,a,c)}`}function jdB(e){return e?"webhook_":"endpoint_"}function wdB(e){return e!=null?HP(e)?.map(t=>g8t(t)).join("/"):""}function EdB(e,t,r,i){return e||t||g8t(r??"")||g8t(i??"")}function bIh(e){return e.length===0?!1:/^\$?(\.[\w*]+|\[['"][\w*]+['"]?\]|\[['"]?[\d*]+['"]?\]|\[[\d:]+\])*$/.test(e)}var jOu=class extends ho{accessTokenLocator;constructor(t){super(t),this.safeParse()}parse(){this.accessTokenLocator=this.input[vBh],this.accessTokenLocator!=null&&(bIh(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 wOu=class extends ho{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 Uua({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.accessTokenLocatorNode=new jOu({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=POu({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:oc.EndpointId(r),accessTokenLocator:oc.JqString(t),headerName:this.headerAuthNode?.convert()?.headerWireValue,tokenPrefix:this.headerAuthNode?.convert()?.prefix}}}}};var Vua=class extends ho{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 iOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicUsernameVariableNameNode=new aOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicPasswordVariableNameNode=new nOu({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 oOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.bearerTokenVariableNameNode=new uOu({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":{MBh(this.input)?(this.authScheme="header",this.headerAuthNode=new Uua({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 wOu({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 vIh.UnreachableCaseError(this.authScheme);return}}};var Wua=class extends ho{authNodesMap;constructor(t){super(t),this.safeParse()}parse(){this.input.map((t,r)=>Object.keys(t).map(i=>{let n=rOu(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 Vua({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(Lo))}};var EOu=class extends ho{basePath;constructor(t){super(t),this.safeParse()}parse(){this.basePath=this.input[pBh],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 gIh(e){return"required"in e&&typeof e.required=="boolean"?e.required:!1}function OIh(e,t){return{type:"alias",value:{type:"optional",shape:e,default:t}}}function Gua(e,t){return e==null?void 0:Object.entries(e).map(([i,n])=>HP(n.convert())?.map(o=>((t!=null&&!t.includes(i)||t==null&&!gIh(n))&&(o=OIh(o,o.type==="enum"?o.default:void 0)),{key:oc.PropertyKey(i),valueShape:o,description:n.description,availability:n.availability?.convert()})).filter(Lo)).filter(Lo).reduce((i,n)=>i.flatMap(a=>n.length>0?n.map(o=>[...a,o]):[[...a]]),[[]])}function SOu(e,t){return xv(e)?pL(e,t,void 0):e}function O$i(e,t){return e!=null&&e!==""?e:t!=null&&t!==""?t:void 0}function AIh(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 mIh(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 PIh=ce(ZS());var eKc=["decimal","decimal128","double-int","double","float","sf-decimal"],tKc=["int16","int32","int64","int8","sf-integer","uint8"],rKc=["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"],iKc=["beta","pre-release","in-development","generally-available","deprecated"];function _C(e,t){return xv(e)?pL(e,t,{type:"unknown","x-fern-type":"unknown",additionalProperties:!1}):e}var ZEe=class extends ho{availability;constructor(t){super(t),this.safeParse()}parse(){if(_C(this.input,this.context.document)?.deprecated)this.availability="deprecated";else{let r=this.input[_Bh];r!=null&&(iKc.includes(r)?this.availability=r:(this.context.errors.warning({message:`Expected one of: ${iKc.join(", ")}. Received: ${r}`,path:this.accessPath}),this.availability=void 0))}}convert(){switch(this.availability){case"beta":case"pre-release":return oc.Availability.Beta;case"in-development":return oc.Availability.InDevelopment;case"generally-available":return oc.Availability.GenerallyAvailable;case"deprecated":return oc.Availability.Deprecated;case void 0:return;default:new PIh.UnreachableCaseError(this.availability);return}}};var DOu=ce(ZS());function jIh(e){return typeof e=="object"&&e!=null&&"language"in e}function wIh(e){return typeof e=="object"&&e!=null&&"sdk"in e}function EIh(e){return typeof e=="object"&&e!=null&&("error"in e||"body"in e)}function SIh(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)}function MOu(e){return typeof e=="object"&&e!=null&&"event"in e}function nKc(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)&&e.stream.every(MOu)}function A$i(e){return typeof e=="object"&&e!=null&&"filename"in e&&"data"in e&&typeof e.filename=="string"&&typeof e.data=="string"}function MIh(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}var BOu=class extends ho{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[SBh]}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 A$i(o)?[n,{type:"filenameWithData",filename:o.filename,data:oc.FileId(o.data)}]:o!=null?[n,{type:"filename",value:o}]:void 0;case"files":{if(Array.isArray(o)){if(o.every(c=>A$i(c)))return[n,{type:"filenamesWithData",value:o.map(c=>({filename:c.filename,data:oc.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 DOu.UnreachableCaseError(a.multipartType);return}}).filter(Lo))};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=MIh(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 DOu.UnreachableCaseError(n.contentType);break}let o;switch(i.contentType){case"application/json":{EIh(r.response)&&(o={type:"json",value:r.response.body});break}case"text/event-stream":{nKc(r.response)&&(o={type:"sse",value:r.response.stream.map(l=>({event:l.event,data:l.data}))});break}case"application/octet-stream":!nKc(r.response)&&SIh(r.response)&&(o={type:"stream",value:r.response.stream});break;case void 0:break;default:new DOu.UnreachableCaseError(i.contentType);break}let c={};r["code-samples"]?.forEach(l=>{jIh(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})):wIh(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])=>[oc.PropertyKey(l),p])),s=Object.fromEntries(Object.entries(r["query-parameters"]??{}).map(([l,p])=>[oc.PropertyKey(l),p])),u=Object.fromEntries(Object.entries(r.headers??{}).map(([l,p])=>[oc.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 VKa=class extends ho{groupName;constructor(t){super(t),this.safeParse()}parse(){this.groupName=this.input[kgu]}convert(){if(this.groupName==null)return;let t;return Array.isArray(this.groupName)?t=this.groupName:t=[this.groupName],t.map(r=>oc.api.v1.SubpackageId(g8t(r)))}};var IOu=class extends ho{sdkMethodName;constructor(t){super(t),this.safeParse()}parse(){this.sdkMethodName=this.input[yBh]}convert(){return this.sdkMethodName}};var COu=class extends ho{isWebhook;constructor(t){super(t),this.safeParse()}parse(){this.isWebhook=this.input[bBh]}convert(){return this.isWebhook}};var qOu=class extends ho{codeSamples;constructor(t){super(t),this.safeParse()}parse(){this.codeSamples=[...this.input[BBh]??[],...this.input[IBh]??[]],this.codeSamples.forEach(t=>{[...Object.values(oc.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 Dvn=ce(ZS());function aKc(e,t){return xv(e)?pL(e,t,void 0):e}function DIh(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 yF="",UYt=class extends ho{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&&(A$i(n)||typeof n=="string");case"files":return t&&Array.isArray(n)&&n.every(a=>A$i(a)||typeof a=="string");case"property":return t;case void 0:return t&&!1;default:return new Dvn.UnreachableCaseError(i.multipartType),t}},!0)}parse(){let t=this.shapes.requestBody?.schema?.example({includeOptionals:!1,override:void 0});this.resolvedRequestInput=aKc(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=aKc(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 Dvn.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(MOu)){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 Dvn.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 A$i(n)?[r,{type:"filenameWithData",filename:n.filename,data:oc.FileId(n.data)}]:[r,{type:"filename",value:n}];case"files":{if(Array.isArray(n)){if(n.every(a=>A$i(a)))return[r,{type:"filenamesWithData",value:n.map(a=>({filename:a.filename,data:oc.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 Dvn.UnreachableCaseError(i.multipartType);return}}).filter(Lo))};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 Dvn.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 Dvn.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(Lo));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(Lo));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:DIh(this.path,i??{}),responseStatusCode:this.responseStatusCode,name:this.name!=null?QYt(this.name):this.summary!=null?QYt(this.summary):void 0,description:this.convertDescription(),pathParameters:i,queryParameters:n,headers:a,requestBody:t,responseBody:r,snippets:void 0}}};function BIh(e,t){return xv(e)?pL(e,t,void 0):e}var WIh=ce(ZS());var IIh="#/components/schemas/";function Hua(e){if(e.$ref.startsWith(IIh))return e.$ref.replace(IIh,"")}function BUi(e){if(e!=null)return{type:"alias",value:{type:"nullable",shape:e}}}function m$i(e){return typeof e.type=="string"&&e.type==="array"}function CIh(e){return e.type==="boolean"}function qIh(e){return e.type==="integer"}function P$i(e){return!Array.isArray(e.type)&&!m$i(e)}function TIh(e){return e!=null&&Array.isArray(e)&&e.every(t=>t.type==="null"||P$i(t)||m$i(t))}function RIh(e){return"nullable"in e&&typeof e.nullable=="boolean"}function zIh(e){return e.type==="null"}function NIh(e){return e.type==="number"}function oKc(e){return e.type==null||typeof e.type=="string"&&e.type==="object"}function FIh(e){return e.type==="string"}var TOu=class extends oY{item;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.item=new ew({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 HP(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 ROu=class extends pC{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 ZEe({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 zOu=class extends oY{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 ew({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName})}).filter(Lo)}convert(){if(this.typeNodes==null)return;let i=this.typeNodes.map(n=>HP(n.convert())?.map(o=>({displayName:n.name,shape:o,description:n.description,availability:n.availability?.convert()}))).filter(Lo).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(BUi).filter(Lo):i}example(t){return this.nullable?null:this.typeNodes?.[0]?.example(t)}};function NOu(e){return e!=null&&e.length>0?e:[void 0]}var xua=class extends oY{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 ew({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 ew({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(xv(t))return Hua(t);this.properties={...this.properties,...Object.fromEntries(Object.entries(t.properties??{}).map(([i,n])=>[i,new ew({input:n,context:this.context,accessPath:this.accessPath,pathId:["allOf",r.toString(),"properties",i],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))}}).filter(Lo))),this.description=this.input.description}convertProperties(){if(this.properties!=null)return Gua(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}}}]:HP(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(Lo)}convert(){let t=this.convertProperties();if(t==null)return;let r=this.convertExtraProperties();return t.flatMap(i=>NOu(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=>oc.TypeId(a)),properties:i,extraProperties:n}))}example({includeOptionals:t}){let r={...this.properties};return this.input.allOf?.forEach(i=>{let n=_C(i,this.context.document);n!=null&&(r={...r,...Object.fromEntries(Object.entries(n.properties??{}).map(([a,o])=>[a,new ew({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 FOu=class extends oY{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=>_C(t,this.context.document)?.type==="null"),this.input.discriminator==null)this.discriminated=!1,this.undiscriminatedMapping=(this.input.oneOf??this.input.anyOf)?.map(t=>_C(t,this.context.document)?.type!=="null"?new ew({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0).filter(Lo);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=_C({$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 ew({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(Lo);return this.isNullable&&n!=null?n.map(BUi).filter(Lo):n}let t=0,r=this.discriminated&&this.discriminant!=null&&this.discriminatedMapping!=null?{type:"discriminatedUnion",discriminant:oc.PropertyKey(this.discriminant),variants:Object.entries(this.discriminatedMapping).flatMap(([n,a])=>HP(a.convert())?.map(c=>{if(!(c==null||c.type!=="object"))return{discriminantValue:n,displayName:a.name??QYt(n),availability:a.availability?.convert(),description:a.description,...c}}).filter(Lo)).filter(Lo)}:this.undiscriminatedMapping!=null?{type:"undiscriminatedUnion",variants:this.undiscriminatedMapping.flatMap(n=>HP(n.convert())?.map(o=>{if(o==null)return;t+=1;let c=o.type==="object"?QYt(`${this.schemaName??"Variant"} ${t}`):void 0;return{displayName:n.name??(o.type==="alias"&&o.value.type==="id"?QYt(o.value.id):c),shape:o,description:n.description,availability:n.availability?.convert()}}).filter(Lo)).filter(Lo)}:void 0,i=this.isNullable?BUi(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 QOu=class extends pC{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 j$i=class extends pC{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(xv(r)){let n=_C(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(Lo),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 QIh=ce(ZS());function SdB(e){return tKc.includes(e)}var UOu=class extends pC{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&&(SdB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${tKc.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 QIh.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 LOu=class extends pC{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){this.displayName=this.input.title}convert(){return BUi({type:"alias",value:{type:"unknown",displayName:this.displayName}})}example(){return null}};var UIh=ce(ZS());function MdB(e){return eKc.includes(e)}var VOu=class extends pC{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&&(MdB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${eKc.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 UIh.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 LIh=ce(ZS());function DdB(e){return rKc.includes(e)}var WOu=class extends pC{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 LIh.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&&(DdB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${rKc.join(", ")}. Received ${this.input.format}`,path:this.accessPath})),this.input.enum!=null&&(this.enum=new j$i({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 VIh=ce(ZS());var GOu=class extends pC{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){(0,VIh.noop)()}convert(){return{type:"alias",value:{type:"unknown",displayName:void 0}}}example(){}};var Bvn=class extends oY{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=Hua(this.input);let t=_C(this.input,this.context.document);t?.enum!=null&&P$i(t)&&(this.maybeEnumConverterNode=new j$i({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:oc.TypeId(this.schemaId),default:this.maybeEnumConverterNode?.default!=null?{type:"enum",value:this.maybeEnumConverterNode.default}:void 0}}}example(t){let r=_C(this.input,this.context.document);if(r!=null)return new ew({input:r,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName}).example(t)}};var ew=class e extends oY{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 ZEe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),P$i(this.input)&&RIh(this.input)&&(this.nullable=this.input.nullable!=null?this.input.nullable:this.nullable),xv(this.input)){let t=Hua(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 Bvn({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 ROu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});else if(TIh(this.input))this.typeShapeNode=new zOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(P$i(this.input)&&(this.input.oneOf!=null||this.input.anyOf!=null))this.typeShapeNode=new FOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(oKc(this.input)&&this.input.allOf!=null)this.typeShapeNode=new xua({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(P$i(this.input)&&this.input.enum!=null)this.typeShapeNode=new j$i({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":oKc(this.input)&&(this.typeShapeNode=new xua({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"array":m$i(this.input)&&(this.typeShapeNode=new TOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"boolean":CIh(this.input)&&(this.typeShapeNode=new QOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"integer":qIh(this.input)&&(this.typeShapeNode=new UOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"number":NIh(this.input)&&(this.typeShapeNode=new VOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"string":FIh(this.input)&&(this.typeShapeNode=new WOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"null":zIh(this.input)&&(this.typeShapeNode=new LOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}));break;case void 0:break;default:new WIh.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 xua({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 GOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),!xv(this.input)&&(!m$i(this.input)&&this.input==null||m$i(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=HP(t)?.map(i=>this.nullable?BUi(i):i).filter(Lo);return Array.isArray(t)&&t.length>1?r:r?.[0]}example(t){return this.availability?.availability!=="deprecated"?this.typeShapeNode?.example(t):void 0}};function w$i(e){if(e!=null)return Gua(e,Object.entries(e??{}).map(([t,r])=>r.required?t:void 0).filter(Lo))}var LYt=class extends pC{availability;required;schema;description;inputExample;constructor(t){super(t),this.safeParse(t.parameterName)}parse(t){this.description=this.input.description;let r;xv(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 ZEe({input:r,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=new ew({input:r,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:t});let i=BIh(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 GIh(e,t){return xv(e)?pL(e,t,void 0):e}var uKc=ce(ZS());function HOu(e){let{uniqueId:t,type:r,contextTypes:i,description:n,availability:a}=e;i[oc.TypeId(t)]={name:t,shape:r,description:n,availability:a}}var HIh=ce(p2s(),1),Kua=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=HIh.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 BdB(e){return typeof e.securitySchemes=="object"&&e.securitySchemes!=null}var xOu=class extends ho{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 ew({input:r,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:new Set,nullable:void 0,schemaName:t})]))),BdB(this.input)&&this.input.securitySchemes!=null&&(this.securitySchemes=Object.fromEntries(Object.entries(this.input.securitySchemes??{}).map(([t,r],i)=>{let n;if(xv(r)?n=rOu(r.$ref,this.context.document):n=r,n!=null)return[t,new Vua({input:n,context:this.context,accessPath:this.accessPath,pathId:["securitySchemes",`${i}`]})]}).filter(Lo)))}convert(){return{auths:this.securitySchemes!=null?Object.fromEntries(Object.entries(this.securitySchemes??{}).map(([t,r])=>{let i=r.convert();if(i!=null)return[oc.api.latest.AuthSchemeId(t),i]}).filter(Lo)):void 0,types:this.typeSchemas!=null?Object.fromEntries(Object.entries(this.typeSchemas).map(([t,r])=>{let i=r.name??t,n=HP(r.convert());return n==null?[t,void 0]:[oc.TypeId(t),{name:i,shape:n[0],description:r.description,availability:void 0}]}).filter(([t,r])=>Lo(r))):void 0}}};var KOu=class extends ew{multipartType;contentType;constructor(t){super(t),this.safeParse()}parse(){super.parse();let t=_C(this.input,this.context.document);if(t==null){this.context.errors.error({message:`Expected multipart form data property definition. ${xv(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=_C(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 JOu=class extends ho{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=_C(this.input.schema,this.context.document);this.availability=new ZEe({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=xv(this.input.schema)?new Bvn({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=Kua.parse(t);n?.containsJSON()?(this.contentType="json",this.schema=this.schema??new ew({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 KOu({input:o,context:this.context,accessPath:this.accessPath,pathId:`schema.${a}`,seenSchemas:new Set,nullable:void 0,schemaName:a})]}).filter(Lo))):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?{[yF]:{value:this.input.example}}:{},...this.input.examples},r!=null&&Object.keys(this.examples).length===0&&(this.examples={[yF]:{value:r}})}convertJsonLike(){let t=this.schema?.convert();return t==null?void 0:HP(t)?.map(i=>{let n=i.type;switch(n){case"object":case"alias":return i;case"enum":case"undiscriminatedUnion":case"discriminatedUnion":{let a=g8t([this.method,this.path,this.contentType,"request"].join("_"));return HOu({uniqueId:a,type:i,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:oc.TypeId(a),default:i.type==="enum"&&i.default!=null?{type:"enum",value:i.default}:void 0}}}case void 0:return;default:new uKc.UnreachableCaseError(n);return}}).filter(Lo)}convert(){if(this.schema instanceof Bvn)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:oc.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:oc.PropertyKey(i),isOptional:this.requiredFields?.includes(i)==null,contentType:n.contentType,description:n.description,availability:n.availability?.convert()}];case"property":{let a=HP(n.convert()),o=n.multipartType;return a?.map(c=>({type:o,key:oc.PropertyKey(i),contentType:n.contentType,exploded:void 0,valueShape:c,description:n.description,availability:n.availability?.convert()}))}case void 0:return[];default:return new uKc.UnreachableCaseError(n.multipartType),[]}}).filter(Lo).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 $Ou=class extends ho{description;requestBodiesByContentType;constructor(t){super(t),this.safeParse(t)}parse({method:t,path:r}){let i=GIh(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 JOu({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])=>HP(r.convert())?.map(n=>({description:this.description,contentType:t,body:n}))).filter(Lo)}convertToWebhookPayload(){return Object.values(this.requestBodiesByContentType??{}).flatMap(t=>HP(t.convert())?.map(i=>{if(!(i.type!=="alias"&&i.type!=="object"))return{description:this.description,shape:i}})).filter(Lo)}webhookExample(){return{payload:this.requestBodiesByContentType?.["application/json"]?.schema?.example({includeOptionals:!0,override:void 0})}}};var xIh={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 KIh(e,t){if(xv(e)){let r=pL(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var YOu=ce(ZS());var JIh="application/json";var $Ih="application/octet-stream";function YIh(e,t){return e===t||t===yF||e===yF}var WKa=class extends ho{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)YIh(c,a)&&(i.add(c),this.examples?.push(new UYt({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,O$i(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 UYt({input:{requestExample:u,responseExample:l},context:this.context,accessPath:this.accessPath,pathId:s!=null&&s!==""?["examples",s]:"examples"},this.path,this.statusCode,O$i(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 UYt({input:{requestExample:s,responseExample:u},context:this.context,accessPath:this.accessPath,pathId:d!=null&&d!==""?["examples",d]:"examples"},this.path,this.statusCode,O$i(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 UYt({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,O$i(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[yF];if(a!=null)for(let o of a)this.examples?.push(new UYt({input:{requestExample:n,responseExample:o},context:this.context,accessPath:this.accessPath,pathId:i!=null&&i!==""?["examples",i]:"examples"},this.path,this.statusCode,O$i(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=Kua.parse(t);if(c?.isJSON()||c?.isEventStream())this.contentType=JIh,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 ew({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=$Ih,this.contentSubtype=_C(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 ew({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=mOu(this.input.examples,c=>[c])),this.input.example!=null&&Object.keys(r).length===0&&(r[yF]??=[],r[yF]=[{value:this.input.example}]);let i=_C(this.input.schema,this.context.document);if(i!=null&&(i.examples!=null&&Object.keys(r).length===0&&(r=mOu(i.examples,c=>[c])),i.example!=null&&Object.keys(r).length===0&&(r[yF]??=[],r[yF]?.push({value:i.example}))),Object.keys(r).length===0){let c=this.schema?.example({includeOptionals:!0,override:void 0});r[yF]??=[],r[yF]?.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!==yF).map(([d,s])=>[c,d,s]));let o=Object.entries(r).filter(([c,d])=>!n.has(c)&&Lo(d)&&c!==yF);Object.keys(r).every(c=>c===yF)||this.matchExamplesByIndex(a,o),!n.has(yF)&&this.examples.length===0&&this.addGlobalFallbackExample(this.requests,r),this.examples.length===0&&(this.examples=void 0)}convertStreamingFormat(){switch(this.streamingFormat){case"json":return HP(this.schema?.convert())?.map(r=>({type:"stream",terminator:"[DATA]",shape:r}));case"sse":return{type:"streamingText"};case void 0:return;default:new YOu.UnreachableCaseError(this.streamingFormat);return}}convertJsonLike(){return HP(this.schema?.convert())?.map(r=>{let i=r.type;switch(i){case"alias":return r;case"discriminatedUnion":case"undiscriminatedUnion":case"enum":{let n=g8t([this.method,this.path,this.statusCode,"response"].join("_"));return HOu({uniqueId:n,type:r,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:oc.TypeId(n),default:r.type==="enum"&&r.default!=null?{type:"enum",value:r.default}:void 0}}}case"object":return r;default:new YOu.UnreachableCaseError(i);return}}).filter(Lo)}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 YOu.UnreachableCaseError(this.contentType);return}else return this.unsupportedContentType!=null?this.convertJsonLike():void 0}};var GKa=class extends ho{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=KIh(this.input,this.context.document);if(r==null){this.context.errors.error({message:xv(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 LYt({input:n,context:this.context,accessPath:this.accessPath,pathId:"headers",parameterName:i})}),r.content==null?(this.responses??=[],this.responses.push(new WKa({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 WKa({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(Lo)}};var XOu=class extends ho{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 GKa({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 GKa({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 NOu(w$i(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(Lo))})))}).filter(Lo)}convertResponseObjectToErrors(){return Object.entries(this.errorsByStatusCode??{}).flatMap(([t,r])=>r.responses?.flatMap(i=>{let n=i.schema,a=HP(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??xIh[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(Lo)})).filter(Lo)})).filter(Lo)}convert(){return{responses:this.convertResponseObjectToHttpResponses(),errors:this.convertResponseObjectToErrors()}}};var E$i=class extends ho{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 UYt({input:{requestExample:t,responseExample:void 0},context:this.context,accessPath:this.accessPath,pathId:"examples"},this.path,200,O$i(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 ZEe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),this.servers=v$i(this.servers,this.input.servers,this.context,this.accessPath),this.isWebhook=new COu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}).isWebhook||this.isWebhook,this.input.parameters?.map((i,n)=>{if(xv(i)){let a=SOu(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 LYt({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 LYt({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 LYt({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 qOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-code-samples"}),this.requests=this.input.requestBody!=null?new $Ou({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 XOu({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 Wua({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"})),this.namespaces=[new VKa({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 VKa({input:{[kgu]:i},context:this.context,accessPath:this.accessPath,pathId:["tags",`${n}`]})));let r=new IOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-sdk-method-name"});this.endpointIds=this.namespaces.map(i=>POu({namespace:HP(i?.groupName),path:this.path,method:this.method,sdkMethodName:r.sdkMethodName,operationId:this.input.operationId,displayName:this.displayName,isWebhook:this.isWebhook})).filter(Lo),this.xFernExamplesNode=new BOu({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(Lo)}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:oc.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(Lo),n=mIh(this.xFernExamplesNode?.convert(),[...i??[],...t?.flatMap(u=>u.examples)??[]])?.map(u=>({...u,snippets:AIh(u.snippets,this.redocExamplesNode?.convert())}));if(this.isWebhook)return this.endpointIds.map((u,l)=>{if(!(this.method!=="POST"&&this.method!=="GET"))return{id:oc.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:w$i(this.queryParameters)?.flat(),headers:w$i(this.requestHeaders)?.flat(),payloads:this.requests?.convertToWebhookPayload(),examples:[this.requests?.webhookExample()].filter(Lo)}}).filter(Lo);let a=this.servers?.map(u=>u.convert()).filter(Lo),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(Lo);return this.endpointIds.map((u,l)=>({id:oc.EndpointId(u),description:this.description,availability:this.availability?.convert(),namespace:this.namespaces?.[l]?.convert()?.map(p=>oc.api.v1.SubpackageId(p)),displayName:this.displayName,operationId:this.operationId,method:this.method,path:o,auth:c?.map(p=>oc.api.latest.AuthSchemeId(p)),defaultEnvironment:a?.[0]?.id,environments:a,pathParameters:w$i(this.pathParameters)?.flat(),queryParameters:w$i(this.queryParameters)?.flat(),requestHeaders:w$i(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 Jua=class extends ho{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=v$i(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 E$i({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 E$i({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 E$i({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 E$i({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 E$i({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(Lo)}};function ZOu(e){return"payloads"in e}var kOu=class extends ho{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 Jua({input:a,context:this.context,accessPath:this.accessPath,pathId:n,servers:v$i(t,a.servers,this.context,this.accessPath),globalAuth:r,basePath:i,isWebhook:void 0})}).filter(Lo)}convert(){if(this.paths==null)return;let t={},r={};return this.paths.forEach(i=>{let n=i.convert();n?.forEach(a=>{ZOu(a)?r[oc.WebhookId(a.id)]=a:t[oc.EndpointId(a.id)]=a})}),{endpoints:t,webhookEndpoints:r}}};var eAu=class extends ho{globalHeaders;requiredProperties;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[hBh]?.map(r=>{let{header:i,...n}=r;return(n.optional!=null&&!n.optional||SOu(n,this.context.document)?.required)&&(this.requiredProperties??=[],this.requiredProperties?.push(i)),[i,new LYt({input:n,context:this.context,accessPath:this.accessPath,pathId:this.pathId,parameterName:i})]});t!=null&&(this.globalHeaders=Object.fromEntries(t))}convert(){return Gua(this.globalHeaders,this.requiredProperties)?.flat()}};function XIh(e,t){if(xv(e)){let r=pL(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var tAu=class extends ho{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=XIh(a,this.context.document);if(o!=null)return new Jua({input:o,context:this.context,accessPath:this.accessPath,pathId:n,servers:t,globalAuth:r,basePath:i,isWebhook:!0})}).filter(Lo)}convert(){return this.webhooks?.reduce((t,r)=>(r.convert()?.forEach(i=>{ZOu(i)&&(t[oc.WebhookId(i.id)]=i)}),t),{})}};var rAu=class extends ho{paths;webhooks;components;auth;globalHeaders;constructor(t){super(t),this.safeParse()}parse(){let t=v$i(void 0,this.input.servers,this.context,this.accessPath);this.input.security!=null&&(this.auth=new Wua({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"}));let r=new EOu({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 kOu({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 tAu({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 xOu({input:this.input.components,context:this.context,accessPath:this.accessPath,pathId:"components"})),this.globalHeaders=new eAu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-global-headers"})}convert(){let t=ave(),{webhookEndpoints:r,endpoints:i}=this.paths?.convert()??{},n={...this.webhooks?.convert()??{},...r??{}},a=fBh({endpoints:i,webhookEndpoints:n}),{types:o,auths:c}=this.components?.convert()??{};return{id:oc.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 sKc(e,t){if(e instanceof LEe){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof sS))return;let r=new u8t(e.absoluteFilePath),i=await WEe({context:t,specs:e.specs}),n=await r.loadDocuments({context:t,specs:i}),a;for(let o of n){if(o.type!=="openapi")continue;let c={document:o.value,logger:t.logger,errors:new Xgu,generatedTypes:{}},d=new rAu({input:o.value,context:c,accessPath:[],pathId:e.workspaceName??"openapi parser"});a=D2s(a,d.convert())}return a}var hLh=ce(fKc(),1),yLh=ce(GAu(),1),_Pu=require("fs/promises"),bLh=ce(require("http"),1),vLh=ce(require("path"),1);var tzh=require("events"),$Au=ce(require("fs"),1),Uvn=ce(require("path"),1);var NRh=ce(require("os"),1),FRh=300,q$i=20,pJa=1e7,QRh=NRh.default.platform();var ZgB=QRh==="darwin",IJc=QRh==="win32",T$i=ZgB||IJc,URh=3e3,LRh=2e4,CJc=1250;var HYt;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(HYt||(HYt={}));var Qvn;(function(e){e.CHANGE="change",e.RENAME="rename"})(Qvn||(Qvn={}));var _Ja;(function(e){e.CHANGE="change",e.ERROR="error"})(_Ja||(_Ja={}));var tf;(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"})(tf||(tf={}));var yH;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(yH||(yH={}));var kgB=(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(),m=g-d,j=g-s,S=m>=t||j>=a;return[g,S]},l=g=>{if(s=g,!o)return;let m=o;o=void 0,e.apply(void 0,m)},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,m]=u();return m?y(g):v(g)},v=g=>{let m=g-d,j=g-s,S=t-m,w=a-j,D=Math.min(S,w);return O(D)},O=g=>{c&&clearTimeout(c),!(g<=0)&&(c=setTimeout(b,g))},A=(...g)=>{let[m,j]=u(),S=!!c;if(o=g,d=m,(j||!c)&&O(t),j)return S?l(m):h(m)};return A.cancel=p,A.flush=_,A},HAu=kgB;var zJc=ce(require("fs"),1),KAu=ce(require("path"),1);var iA=ce(require("fs"),1),_L=require("util");var CUi=(e,t)=>function(...i){return e.apply(void 0,i).catch(t)},xYt=(e,t)=>function(...i){try{return e.apply(void 0,i)}catch(n){return t(n)}};var qJc=ce(require("process"),1),VRh=qJc.default.getuid?!qJc.default.getuid():!1,WRh=1e4,lY=()=>{};var hJa={isChangeErrorOk:e=>{if(!hJa.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!VRh&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!hJa.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(!hJa.isNodeError(e))throw e;if(!hJa.isChangeErrorOk(e))throw e}},hC=hJa;var TJc=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=WRh,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()}}}}},GRh=new TJc;var qUi=(e,t)=>function(i){return function n(...a){return GRh.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)})}},TUi=(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 eOB={attempt:{chmod:CUi((0,_L.promisify)(iA.default.chmod),hC.onChangeError),chown:CUi((0,_L.promisify)(iA.default.chown),hC.onChangeError),close:CUi((0,_L.promisify)(iA.default.close),lY),fsync:CUi((0,_L.promisify)(iA.default.fsync),lY),mkdir:CUi((0,_L.promisify)(iA.default.mkdir),lY),realpath:CUi((0,_L.promisify)(iA.default.realpath),lY),stat:CUi((0,_L.promisify)(iA.default.stat),lY),unlink:CUi((0,_L.promisify)(iA.default.unlink),lY),chmodSync:xYt(iA.default.chmodSync,hC.onChangeError),chownSync:xYt(iA.default.chownSync,hC.onChangeError),closeSync:xYt(iA.default.closeSync,lY),existsSync:xYt(iA.default.existsSync,lY),fsyncSync:xYt(iA.default.fsync,lY),mkdirSync:xYt(iA.default.mkdirSync,lY),realpathSync:xYt(iA.default.realpathSync,lY),statSync:xYt(iA.default.statSync,lY),unlinkSync:xYt(iA.default.unlinkSync,lY)},retry:{close:qUi((0,_L.promisify)(iA.default.close),hC.isRetriableError),fsync:qUi((0,_L.promisify)(iA.default.fsync),hC.isRetriableError),open:qUi((0,_L.promisify)(iA.default.open),hC.isRetriableError),readFile:qUi((0,_L.promisify)(iA.default.readFile),hC.isRetriableError),rename:qUi((0,_L.promisify)(iA.default.rename),hC.isRetriableError),stat:qUi((0,_L.promisify)(iA.default.stat),hC.isRetriableError),write:qUi((0,_L.promisify)(iA.default.write),hC.isRetriableError),writeFile:qUi((0,_L.promisify)(iA.default.writeFile),hC.isRetriableError),closeSync:TUi(iA.default.closeSync,hC.isRetriableError),fsyncSync:TUi(iA.default.fsyncSync,hC.isRetriableError),openSync:TUi(iA.default.openSync,hC.isRetriableError),readFileSync:TUi(iA.default.readFileSync,hC.isRetriableError),renameSync:TUi(iA.default.renameSync,hC.isRetriableError),statSync:TUi(iA.default.statSync,hC.isRetriableError),writeSync:TUi(iA.default.writeSync,hC.isRetriableError),writeFileSync:TUi(iA.default.writeFileSync,hC.isRetriableError)}},HRh=eOB;var xAu=ce(require("fs"),1),yJa=ce(require("path"),1);var RJc=()=>{};var tOB=()=>{let e=RJc,t=RJc,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}},xRh=tOB;var rOB=()=>{let{promise:e,resolve:t,isPending:r}=xRh(),i=0,n=()=>{i+=1},a=()=>{i-=1,!i&&t()};return(()=>{n(),queueMicrotask(a)})(),{promise:e,isPending:r,increment:n,decrement:a}},KRh=rOB;var JRh={then:e=>{e()}};var $Rh=e=>Array.isArray(e)?e:[e],YRh=e=>typeof e=="function";var iOB=(e,t)=>{let r=t?.followSymlinks??!1,i=t?.depth??1/0,n=t?.limit??1/0,a=t?.ignore??[],o=$Rh(a).map(H=>YRh(H)?H:G=>H.test(G)),c=H=>o.some(G=>G(H)),d=t?.signal??{aborted:!1},s=t?.onDirents||(()=>{}),u=[],l=new Set,p={},_=[],h=new Set,y={},b=[],v=new Set,O={},A={},g=new Set,m={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:A},{promise:S,increment:w,decrement:D}=KRh(),B=0,R=(H,G,Ee,ue)=>{g.has(G)||B>=n||(B+=1,H.directories.push(G),H.directoriesNames.add(Ee),u.push(G),l.add(Ee),p.propertyIsEnumerable(Ee)||(p[Ee]=[]),p[Ee].push(G),g.add(G),!(ue>=i)&&(B>=n||k(G,ue+1)))},N=(H,G,Ee)=>{g.has(G)||B>=n||(B+=1,H.files.push(G),H.filesNames.add(Ee),_.push(G),h.add(Ee),y.propertyIsEnumerable(Ee)||(y[Ee]=[]),y[Ee].push(G),g.add(G))},z=(H,G,Ee,ue)=>{g.has(G)||B>=n||(B+=1,H.symlinks.push(G),H.symlinksNames.add(Ee),b.push(G),v.add(Ee),O.propertyIsEnumerable(Ee)||(O[Ee]=[]),O[Ee].push(G),g.add(G),r&&(ue>=i||B>=n||je(G,ue+1)))},F=(H,G,Ee,ue,Oe)=>{d.aborted||c(G)||(ue.isDirectory()?R(H,G,Ee,Oe):ue.isFile()?N(H,G,Ee):ue.isSymbolicLink()&&z(H,G,Ee,Oe))},U=(H,G,Ee,ue)=>{if(d.aborted)return;let Oe=G===yJa.default.sep?"":yJa.default.sep,Qe=Ee.name,se=`${G}${Oe}${Qe}`;c(se)||(Ee.isDirectory()?R(H,se,Qe,ue):Ee.isFile()?N(H,se,Qe):Ee.isSymbolicLink()&&z(H,se,Qe,ue))},x=(H,G,Ee,ue)=>{for(let Oe=0,Qe=Ee.length;Oe<Qe;Oe++)U(H,G,Ee[Oe],ue)},k=(H,G)=>{d.aborted||G>i||B>=n||(w(),xAu.default.readdir(H,{withFileTypes:!0},(Ee,ue)=>{if(Ee||d.aborted||!ue.length)return D();(s(ue)||JRh).then(()=>{let Qe=A[H]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};x(Qe,H,ue,G),D()})}))},je=(H,G)=>{w(),xAu.default.realpath(H,(Ee,ue)=>{if(Ee||d.aborted)return D();xAu.default.stat(ue,(Oe,Qe)=>{if(Oe||d.aborted)return D();let se=yJa.default.basename(ue),ne=A[H]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};F(ne,ue,se,Qe,G),D()})})};return(async(H,G=1)=>(H=yJa.default.normalize(H),g.add(H),k(H,G),await S,d.aborted?m:j))(e)},XRh=iOB;var KYt={lang:{debounce:HAu,attempt:e=>{try{return e()}catch(t){return KYt.lang.castError(t)}},castArray:e=>KYt.lang.isArray(e)?e:[e],castError:e=>KYt.lang.isError(e)?e:KYt.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(KYt.lang.isNaN(e))return KYt.lang.isNaN(t);if(KYt.lang.isPrimitive(e)||KYt.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(KAu.default.sep).length-1),getRealPath:(e,t)=>{try{return t?zJc.default.realpathSync.native(e):zJc.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===KAu.default.sep&&t.length-e.length>KAu.default.sep.length,poll:(e,t=LRh)=>HRh.retry.stat(t)(e,{bigint:!0}).catch(KYt.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 XRh(e,{depth:r,limit:i,ignore:t,signal:n});return[o.directories,o.files]}}}},Fp=KYt;var JAu=ce(require("path"),1);var NJc=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||Fp.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=FRh){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=Fp.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===tf.CHANGE&&c===tf.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===tf.ADD_DIR?await this.eventsPopulateAddDir(t,n,r,i):o===tf.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??q$i:Math.min(1,this.options.depth??q$i),o=this.options.limit??pJa,[c,d]=await Fp.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())Fp.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(tf.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!T$i&&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(tf.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(tf.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(JAu.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(tf.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(JAu.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(tf.UNLINK_DIR,t))}onTargetEvent(t){let[r,i]=t;r===tf.ADD?this.onTargetAdd(i):r===tf.ADD_DIR?this.onTargetAddDir(i):r===tf.CHANGE?this.onTargetChange(i):r===tf.UNLINK?this.onTargetUnlink(i):r===tf.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=Qvn.CHANGE,r){if(this.watcher.isClosed())return;let i=JAu.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){IJc&&t.code==="EPERM"?this.onWatcherChange(Qvn.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(_Ja.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(_Ja.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(Qvn.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&T$i&&this.options.native!==!1?this.options.depth??q$i:Math.min(1,this.options.depth??q$i),i=this.options.limit??pJa,[n,a]=await Fp.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(Qvn.CHANGE,c,t)}))}}},ZRh=NJc;var bH={interval:100,intervalId:void 0,fns:new Map,init:()=>{bH.intervalId||(bH.intervalId=setInterval(bH.resolve,bH.interval))},reset:()=>{bH.intervalId&&(clearInterval(bH.intervalId),delete bH.intervalId)},add:(e,t)=>{bH.fns.set(e,Date.now()+t),bH.init()},remove:e=>{bH.fns.delete(e)},resolve:()=>{if(!bH.fns.size)return bH.reset();let e=Date.now();for(let[t,r]of bH.fns)r>=e||(bH.remove(t),t())}},bJa=bH;var vJa=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=CJc){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(Fp.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),bJa.remove(s)},s=()=>{d(),c()};bJa.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=CJc){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),bJa.remove(s)},s=()=>{d(),c()};bJa.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,tf.ADD,HYt.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,tf.ADD_DIR,HYt.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,tf.UNLINK,HYt.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,tf.UNLINK_DIR,HYt.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}}};vJa.DIR_EVENTS={add:tf.ADD_DIR,rename:tf.RENAME_DIR,unlink:tf.UNLINK_DIR};vJa.FILE_EVENTS={add:tf.ADD,change:tf.CHANGE,rename:tf.RENAME,unlink:tf.UNLINK};var kRh=vJa;var FJc=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(Fp.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let i=this.map.get(t);if(Fp.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(Fp.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(Fp.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let i=this.map.get(t);return Fp.lang.isSet(i)?i.has(r):i===r}return!1}set(t,r){if(this.map.has(t)){let i=this.map.get(t);Fp.lang.isSet(i)?i.add(r):i!==r&&this.map.set(t,new Set([i,r]))}else this.map.set(t,r);return this}},QJc=FJc;var UJc=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}},ezh=UJc;var LJc=class{constructor(){this.inos={},this.paths=new QJc,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 Fp.fs.poll(t,r);if(!(!i||!(i.isFile()||i.isDirectory())))return new ezh(i)}reset(){this.inos={},this.paths=new QJc,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,tf.ADD,n),[tf.ADD];if(n.isDirectory())return this.updateIno(t,tf.ADD_DIR,n),[tf.ADD_DIR]}else if(i&&!n){if(i.isFile())return this.updateIno(t,tf.UNLINK,i),[tf.UNLINK];if(i.isDirectory())return this.updateIno(t,tf.UNLINK_DIR,i),[tf.UNLINK_DIR]}else if(i&&n){if(i.isFile()){if(n.isFile())return i.ino===n.ino&&!i.size&&!n.size?[]:(this.updateIno(t,tf.CHANGE,n),[tf.CHANGE]);if(n.isDirectory())return this.updateIno(t,tf.UNLINK,i),this.updateIno(t,tf.ADD_DIR,n),[tf.UNLINK,tf.ADD_DIR]}else if(i.isDirectory()){if(n.isFile())return this.updateIno(t,tf.UNLINK_DIR,i),this.updateIno(t,tf.ADD,n),[tf.UNLINK_DIR,tf.ADD];if(n.isDirectory())return i.ino===n.ino?[]:(this.updateIno(t,tf.UNLINK_DIR,i),this.updateIno(t,tf.ADD_DIR,n),[tf.UNLINK_DIR,tf.ADD_DIR])}}return[]}updateIno(t,r,i){let n=this.inos[r]=this.inos[r]||(this.inos[r]={}),a=i.isFile()?HYt.FILE:HYt.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)}}},VJc=LJc;var WJc=class e extends tzh.EventEmitter{constructor(t,r,i){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(yH.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(n=>this.on(yH.CLOSE,n)),this._readyWait=new Promise(n=>this.on(yH.READY,n)),this._locker=new kRh(this),this._roots=new Set,this._poller=new VJc,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&&(Fp.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(yH.CLOSE))}error(t){if(this.isClosed())return!1;let r=Fp.lang.castError(t);return this.emit(yH.ERROR,r)}event(t,r,i){return this.isClosed()?!1:(this.emit(yH.ALL,t,r,i),this.emit(t,r,i))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(yH.READY))}pollerExists(t,r){for(let i of this._pollers)if(i.targetPath===t&&Fp.lang.isShallowEqual(i.options,r))return!0;return!1}subwatcherExists(t,r){for(let i of this._subwatchers)if(i.targetPath===t&&Fp.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)Fp.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 ZRh(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=Fp.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=Uvn.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??q$i))&&u.handler===i&&(!u.filePath||u.filePath===n)&&u.options.ignore===r.ignore&&!!u.options.native==!!r.native&&(!r.recursive||u.options.recursive&&T$i&&u.options.native!==!1)))return!0;if(!T$i)break;let s=Uvn.default.dirname(t);if(o===s)break;o=s}return!1}async watchDirectories(t,r,i,n,a){if(this.isClosed())return;t=Fp.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||T$i&&r.native!==!1?r:{...r,recursive:!1},u={watcher:$Au.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=Uvn.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||T$i&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,i,n,a));{r={...r,recursive:!0};let o=r.depth??q$i,c=r.limit??pJa,[d]=await Fp.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=Fp.fs.getDepth(t);for(let l of d){let p=Fp.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(yH.CLOSE,d),o.watchFile(t,r,a)},d=()=>{this._subwatchers.delete(n),this.removeListener(yH.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=Uvn.default.dirname(t);return this.watchDirectory(n,r,i,t)}async watchPollingOnce(t,r,i){if(this.isClosed())return;let n=!1,a=new VJc,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 Fp.lang.noop;if(this.pollerExists(t,r))return Fp.lang.noop;let n={...r,interval:r.pollingInterval??URh},a={targetPath:t,options:r},o=()=>{this._pollers.add(a),this.on(yH.CLOSE,c),$Au.default.watchFile(t,n,i)},c=()=>{this._pollers.delete(a),this.removeListener(yH.CLOSE,c),$Au.default.unwatchFile(t,i)};return Fp.lang.attempt(o),()=>Fp.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=Fp.lang.uniq(t).sort(),t.every((a,o)=>t.every((c,d)=>d===o||!Fp.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=Uvn.default.resolve(t),this.isIgnored(t,r.ignore)))return;let n=await Fp.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=Uvn.default.dirname(t);return(await Fp.fs.poll(a,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,i):this.watchUnknownTarget(t,r,i)}}async watch(t,r,i=Fp.lang.noop){if(Fp.lang.isFunction(t))return this.watch([],{},t);if(Fp.lang.isUndefined(t))return this.watch([],r,i);if(Fp.lang.isFunction(r))return this.watch(t,{},r);if(Fp.lang.isUndefined(r))return this.watch(t,{},i);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let n=Fp.lang.castArray(t);n.forEach(a=>this._roots.add(a)),await this.watchPaths(n,r,i),!this.isClosed()&&(i!==Fp.lang.noop&&this.on(yH.ALL,i),r.readdirMap=void 0,this.ready())}},YAu=WJc;TXo();var lsa=require("fs/promises"),rzh=require("os"),izh=ce(require("path"),1),nOB=".fern",aOB="logs";function oOB(){return"cli@3.30.1"}var gJa=class{logFilePath=null;initialized=!1;sessionStartTime;constructor(){this.sessionStartTime=Date.now()}async initialize(){if(this.initialized)return;let t=Ct(Cr.of((0,rzh.homedir)()),Ze.of(nOB)),r=Ct(t,Ze.of(aOB));await ji(r)||await(0,lsa.mkdir)(r,{recursive:!0});let n=`${new Date().toISOString().replace(/[:.]/g,"-")}.debug.log`;this.logFilePath=Ct(r,Ze.of(n));let a=["================================================================================","Fern Docs Dev Debug Log",`Session started: ${new Date().toISOString()}`,`Log file: ${izh.default.basename(this.logFilePath)}`,"================================================================================",""].join(`
|
|
1784
|
+
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions`;throw new Error(r)}async toRootNode(){let t=Rt.V1.SlugGenerator.init(Rt.slugjoin(this.getDocsBasePath())),r=this.#e.get("root"),i=await this.toRootChild(t);return{type:"root",version:"v1",id:r,child:i,slug:t.get(),title:this.parsedDocsConfig.title??"Documentation",hidden:!1,icon:void 0,pointsTo:void 0,authed:void 0,viewers:void 0,orphaned:void 0,roles:this.parsedDocsConfig.roles?.map(n=>Rt.RoleId(n)),featureFlags:void 0}}async toRootChild(t){return Tln(this.parsedDocsConfig.navigation)._visit({untabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),tabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),versioned:r=>this.toVersionedNode(r,t),productgroup:r=>this.toProductGroupNode({landingPageConfig:this.parsedDocsConfig.landingPage,productGroup:r,parentSlug:t})})}toLandingPageNode(t,r){let i=Rt.PageId(this.toRelativeFilepath(t.absolutePath)),n=r.apply({urlSlug:t.slug??KE(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{type:"landingPage",id:this.#e.get(i),title:t.title,slug:n.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:i,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags}}async toUnversionedNode({landingPage:t,navigationConfig:r,parentSlug:i}){let n=this.#e.get("unversioned"),a=t!=null?this.toLandingPageNode(t,i):void 0,o=r.type==="tabbed"?await this.convertTabbedNavigation(n,r.items,i):await this.toSidebarRootNode(n,r.items,i);return{type:"unversioned",id:n,landingPage:a,child:o}}async toVersionedNode(t,r){let i=this.#e.get("versioned"),n=t.versions[0];if(n?.hidden===!0)throw new Error(`The default version "${n.version}" cannot be hidden. Please set a non-hidden version as the first version in your versions list, or remove the hidden flag from the default version.`);return{id:i,type:"versioned",children:await Promise.all(t.versions.map((a,o)=>this.toVersionNode(a,r,o===0)))}}async toProductGroupNode({productGroup:t,landingPageConfig:r,parentSlug:i}){let n=this.#e.get("productgroup"),a=r!=null?this.toLandingPageNode(r,i):void 0;return{id:n,type:"productgroup",landingPage:a,children:await Promise.all(t.products.map(o=>this.toProductNode(o,i)))}}async toProductNode(t,r){if(t.type==="internal"){let i=r.setProductSlug(t.slug??KE(t.product)),n;switch(t.navigation.type){case"tabbed":n={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.convertTabbedNavigation(this.#e.get(t.product),t.navigation.items,i)};break;case"untabbed":n={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.toSidebarRootNode(this.#e.get(t.product),t.navigation.items,i)};break;case"versioned":n=await this.toVersionedNode(t.navigation,i);break;default:gt(t.navigation)}return{type:"product",id:this.#e.get(t.product),productId:Rt.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",slug:i.get(),child:n,default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,pointsTo:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,announcement:t.announcement!=null?{text:t.announcement.message}:void 0}}else return{type:"productLink",id:this.#e.get(t.product),productId:Rt.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",href:yG.Url(t.href??""),target:t.target,default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,viewers:t.viewers,orphaned:t.orphaned}}async toVersionNode(t,r,i){let n=this.#e.get(t.version),a=r.setVersionSlug(t.slug??KE(t.version)),o=t.navigation.type==="tabbed"?await this.convertTabbedNavigation(n,t.navigation.items,a):await this.toSidebarRootNode(n,t.navigation.items,a);return{type:"version",id:n,versionId:Rt.VersionId(t.version),title:t.version,slug:a.get(),child:o,default:i,availability:t.availability!=null?tdB(t.availability):void 0,landingPage:t.landingPage?this.toLandingPageNode(t.landingPage,a):void 0,hidden:t.hidden,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,icon:void 0,pointsTo:void 0,featureFlags:t.featureFlags,announcement:t.announcement!=null?{text:t.announcement.message}:void 0}}async toSidebarRootNode(t,r,i){let n=this.#e.get(`${t}/root`),a=await Promise.all(r.map(c=>this.toNavigationChild({prefix:n,item:c,parentSlug:i}))),o=[];return a.forEach(c=>{if(c.type==="apiReference"){o.push(c);return}if(c.type==="section"&&!c.collapsed){o.push(c);return}let d=o.length>0?o[o.length-1]:void 0,s;d?.type==="sidebarGroup"?s=d:(s={id:this.#e.get(`${n}/group`),type:"sidebarGroup",children:[]},o.push(s)),s.children.push(c)}),{type:"sidebarRoot",id:n,children:o}}async toSidebarRootNodeWithVariants(t,r,i){let n=this.#e.get(`${t}/root`);return{type:"sidebarRoot",id:n,children:[{type:"varianted",id:n,children:await Promise.all(r.map(a=>this.toVariantNode(a,n,i)))}]}}async toVariantNode(t,r,i){let n=this.#e.get(`${r}/variant/${t.slug??KE(t.title)}`),a=i.apply({urlSlug:t.slug??KE(t.title),skipUrlSlug:t.skipUrlSlug}),o=await Promise.all(t.layout.map(c=>this.toVariantChild(c,n,a)));return{type:"variant",id:n,variantId:Rt.V1.VariantId(t.title),subtitle:t.subtitle??"",default:t.default??!1,image:void 0,children:o,title:t.title,slug:a.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,pointsTo:void 0}}async toVariantChild(t,r,i){return Tln(t)._visit({page:async n=>this.toPageNode({item:n,parentSlug:i}),apiSection:async n=>this.toApiSectionNode({item:n,parentSlug:i}),section:async n=>this.toSectionNode({prefix:r,item:n,parentSlug:i}),link:async n=>this.toLinkNode(n),changelog:async n=>this.toChangelogNode(n,i)})}async toNavigationChild({prefix:t,item:r,parentSlug:i,hideChildren:n,parentAvailability:a}){return Tln(r)._visit({page:async o=>this.toPageNode({item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),apiSection:async o=>this.toApiSectionNode({item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),section:async o=>this.toSectionNode({prefix:t,item:o,parentSlug:i,hideChildren:n,parentAvailability:a}),link:async o=>this.toLinkNode(o),changelog:async o=>this.toChangelogNode(o,i,n)})}async toApiSectionNode({item:t,parentSlug:r,hideChildren:i,parentAvailability:n}){let a=MMh(t.snippetsConfiguration),o,c=await this.getFernWorkspaceForApiSection(t).toFernWorkspace({context:this.taskContext},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1,objectQueryParameters:!0,preserveSchemaIds:!0}),d=this.parsedDocsConfig.experimental?.openapiParserV3,s=d==null||d;if(s)try{o=await this.getOpenApiWorkspaceForApiSection(t).getIntermediateRepresentation({context:this.taskContext,audiences:t.audiences,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1})}catch{}let u;if(t.tagDescriptionPages&&s)try{let b=await this.getOpenApiWorkspaceForApiSection(t).getOpenAPIIr({context:this.taskContext});b.tags.tagsById&&(u=Object.fromEntries(Object.entries(b.tags.tagsById).filter(([v,O])=>O.description&&O.description.trim().length>0).map(([v,O])=>[v,{id:String(O.id),description:O.description}])))}catch(y){this.taskContext.logger.warn("Failed to extract OpenAPI tags for tag description pages",String(y))}o==null&&(o=lS({workspace:c,audiences:t.audiences,generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!0},readme:void 0,version:void 0,packageName:void 0,context:this.taskContext,sourceResolver:new cS(this.taskContext,c)})),this.docsWorkspace.config.settings?.substituteEnvVars&&(o=FT(o,{onError:y=>this.taskContext.failAndThrow(`Error substituting environment variables in API spec: ${y}`)},{substituteAsEmpty:!1}));let l=await this.registerApi({ir:o,snippetsConfig:a,playgroundConfig:{oauth:t.playground?.oauth},apiName:t.apiName,workspace:c}),p=QKa({ir:o,apiDefinitionId:l,playgroundConfig:{oauth:t.playground?.oauth},context:this.taskContext}),_=new Vgu(t,p,r,this.docsWorkspace,this.taskContext,this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,this.#e,this.collectedFileIds,c,i,n??t.availability,u),h=_.getTagDescriptionContent();for(let[y,b]of h.entries()){let v=y.split("/").pop()||y,O=Ze.of(v),A=b;this.docsWorkspace.config.settings?.substituteEnvVars&&(A=FT(b,{onError:g=>this.taskContext.logger.error(`Error in tag description environment variable substitution: ${g}`)},{substituteAsEmpty:!1})),this.rawMarkdownFiles[O]=A,this.parsedDocsConfig.pages[O]=A}return _.get()}async toChangelogNode(t,r,i){return new Mvn(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,t.changelog,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:r,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:i||t.hidden,slug:t.slug})}async toLinkNode(t){return{type:"link",id:this.#e.get(t.url),title:t.text,url:Rt.V1.Url(t.url),icon:this.resolveIconFileId(t.icon),target:t.target}}async toPageNode({item:t,parentSlug:r,hideChildren:i,parentAvailability:n}){let a=Rt.PageId(this.toRelativeFilepath(t.absolutePath)),o=r.apply({urlSlug:t.slug??KE(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?Rt.PageId(o):void 0,d=this.#e.get(c??`${t}/section`),s=i.apply({urlSlug:r.slug??KE(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 Tln(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 Mvn(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:Rt.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??KE(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??KE(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):yG.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(As),remote:this.parsedDocsConfig.js.remote?.map(t=>({...t,url:yG.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 Tln(t,"type")._visit({filepath:({value:r})=>({type:"fileId",value:this.getFileId(r)}),url:({value:r})=>({type:"url",value:yG.Url(r)}),_other:()=>this.taskContext.failAndThrow("Invalid metadata configuration")})}};function edB(e,t){if(e?.github==null)return;let{owner:r,repo:i,branch:n="main",host:a="https://github.com"}=e.github;return`${mR(a)}/${r}/${i}/blob/${n}/fern/${t}?plain=1`}function tdB(e){switch(e){case"beta":return Rt.V1.NavigationV1Availability.Beta;case"deprecated":return Rt.V1.NavigationV1Availability.Deprecated;case"ga":return Rt.V1.NavigationV1Availability.GenerallyAvailable;case"stable":return Rt.V1.NavigationV1Availability.Stable;default:gt(e)}}async function dL(e){return(await Promise.all(e.apiWorkspaces.map(async t=>t instanceof sS?t:null))).filter(As)}async function Oxc(e,t,r){if(e instanceof LEe){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof sS))return;let i=await e.getIntermediateRepresentation({context:t,audiences:r,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1});return pH({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 oc={};Zt(oc,{AlgoliaSearchIndex:()=>JMh,ApiDefinitionId:()=>hDh,ApiId:()=>gDh,Availability:()=>TDh,DocsConfigId:()=>ODh,EndpointId:()=>mDh,EndpointPathLiteral:()=>CDh,EnvironmentId:()=>ADh,FileId:()=>SDh,HttpMethod:()=>qDh,IndexSegmentId:()=>$Mh,JqString:()=>DDh,OrgId:()=>bDh,PageId:()=>EDh,PayloadLocation:()=>uBh,PropertyKey:()=>BDh,PullRequestState:()=>rBh,RoleId:()=>IDh,TokenId:()=>vDh,TypeId:()=>wDh,Url:()=>MDh,VersionId:()=>yDh,WebSocketId:()=>PDh,WebhookId:()=>jDh,algolia:()=>Axc,api:()=>Ixc,commons:()=>Cxc,diff:()=>RDh,docs:()=>Lxc,generators:()=>Wxc,git:()=>Gxc,navigation:()=>Kxc,sdks:()=>$xc,snippets:()=>aBh,snippetsFactory:()=>oBh,templates:()=>Yxc,tokens:()=>sBh});var Axc={};Zt(Axc,{AlgoliaSearchIndex:()=>JMh,IndexSegmentId:()=>$Mh});function JMh(e){return e}function $Mh(e){return e}var Ixc={};Zt(Ixc,{latest:()=>jxc,v1:()=>Bxc});var jxc={};Zt(jxc,{AuthSchemeId:()=>YMh,WebhookHttpMethod:()=>eDh,auth:()=>mxc,commons:()=>XMh,endpoint:()=>ZMh,type_:()=>kMh,webhook:()=>Pxc,websocket:()=>tDh});var mxc={};Zt(mxc,{AuthSchemeId:()=>YMh});function YMh(e){return e}var XMh={};var ZMh={};var kMh={};var Pxc={};Zt(Pxc,{WebhookHttpMethod:()=>eDh});var eDh={Get:"GET",Post:"POST"};var tDh={};var Bxc={};Zt(Bxc,{SubpackageId:()=>fDh,WebSocketMessageId:()=>dDh,WebSocketMessageOrigin:()=>pDh,WebhookHttpMethod:()=>_Dh,commons:()=>Dxc,db:()=>wxc,read:()=>Sxc,register:()=>Mxc});var wxc={};Zt(wxc,{endpoint:()=>rDh});var rDh={};var Sxc={};Zt(Sxc,{SupportedLanguage:()=>iDh,endpoint:()=>Exc,type_:()=>nDh,webhook:()=>aDh,websocket:()=>oDh});var Exc={};Zt(Exc,{SupportedLanguage:()=>iDh});var iDh={Curl:"curl",Python:"python",Javascript:"javascript",Js:"js",Node:"node",Typescript:"typescript",Ts:"ts",Go:"go",Ruby:"ruby",Csharp:"csharp"};var nDh={};var aDh={};var oDh={};var Mxc={};Zt(Mxc,{SourceId:()=>rdB,endpoint:()=>uDh,type_:()=>sDh,webhook:()=>cDh,websocket:()=>lDh});var uDh={};var sDh={};var cDh={};var lDh={};function rdB(e){return e}var Dxc={};Zt(Dxc,{SubpackageId:()=>fDh,WebSocketMessageId:()=>dDh,WebSocketMessageOrigin:()=>pDh,WebhookHttpMethod:()=>_Dh});function fDh(e){return e}function dDh(e){return e}var pDh={Client:"client",Server:"server"};var _Dh={Get:"GET",Post:"POST"};var Cxc={};Zt(Cxc,{ApiDefinitionId:()=>hDh,ApiId:()=>gDh,Availability:()=>TDh,DocsConfigId:()=>ODh,EndpointId:()=>mDh,EndpointPathLiteral:()=>CDh,EnvironmentId:()=>ADh,FileId:()=>SDh,HttpMethod:()=>qDh,JqString:()=>DDh,OrgId:()=>bDh,PageId:()=>EDh,PropertyKey:()=>BDh,RoleId:()=>IDh,TokenId:()=>vDh,TypeId:()=>wDh,Url:()=>MDh,VersionId:()=>yDh,WebSocketId:()=>PDh,WebhookId:()=>jDh});function hDh(e){return e}function yDh(e){return e}function bDh(e){return e}function vDh(e){return e}function gDh(e){return e}function ODh(e){return e}function ADh(e){return e}function mDh(e){return e}function PDh(e){return e}function jDh(e){return e}function wDh(e){return e}function EDh(e){return e}function SDh(e){return e}function MDh(e){return e}function DDh(e){return e}function BDh(e){return e}function IDh(e){return e}function CDh(e){return e}var qDh={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE"};var TDh={Stable:"Stable",GenerallyAvailable:"GenerallyAvailable",InDevelopment:"InDevelopment",PreRelease:"PreRelease",Deprecated:"Deprecated",Beta:"Beta"};var RDh={};var Lxc={};Zt(Lxc,{latest:()=>Rxc,v1:()=>Qxc,v2:()=>Uxc});var Rxc={};Zt(Rxc,{Layout:()=>NDh,MdxEngine:()=>idB,TwitterCardSetting:()=>FDh,commons:()=>zDh,frontmatter:()=>qxc,seo:()=>Txc});var idB={NextMdxRemote:"next-mdx-remote",MdxBundler:"mdx-bundler"};var zDh={};var qxc={};Zt(qxc,{Layout:()=>NDh});var NDh={Guide:"guide",Overview:"overview",Reference:"reference",Page:"page",Custom:"custom"};var Txc={};Zt(Txc,{TwitterCardSetting:()=>FDh});var FDh={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var Qxc={};Zt(Qxc,{commons:()=>Fxc,db:()=>QDh,read:()=>UDh,write:()=>zxc});var QDh={};var UDh={};var zxc={};Zt(zxc,{DocsRegistrationId:()=>adB,FilePath:()=>ndB});function ndB(e){return e}function adB(e){return e}var Fxc={};Zt(Fxc,{ContentAlignment:()=>GDh,FontDisplay:()=>$Dh,FontStyle:()=>JDh,HeaderPosition:()=>HDh,JsScriptStrategy:()=>KDh,ProgrammingLanguage:()=>LDh,SearchbarPlacement:()=>VDh,TabsPlacement:()=>WDh,TwitterCardSetting:()=>xDh,commons:()=>Nxc});var Nxc={};Zt(Nxc,{ContentAlignment:()=>GDh,FontDisplay:()=>$Dh,FontStyle:()=>JDh,HeaderPosition:()=>HDh,JsScriptStrategy:()=>KDh,ProgrammingLanguage:()=>LDh,SearchbarPlacement:()=>VDh,TabsPlacement:()=>WDh,TwitterCardSetting:()=>xDh});var LDh={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 VDh={Header:"HEADER",HeaderTabs:"HEADER_TABS",Sidebar:"SIDEBAR"};var WDh={Header:"HEADER",Sidebar:"SIDEBAR"};var GDh={Center:"CENTER",Left:"LEFT"};var HDh={Fixed:"FIXED",Absolute:"ABSOLUTE"};var xDh={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var KDh={BeforeInteractive:"beforeInteractive",AfterInteractive:"afterInteractive",LazyOnload:"lazyOnload"};var JDh={Normal:"normal",Italic:"italic"};var $Dh={Auto:"auto",Block:"block",Swap:"swap",Fallback:"fallback",Optional:"optional"};var Uxc={};Zt(Uxc,{read:()=>YDh,write:()=>XDh});var YDh={};var XDh={};var Wxc={};Zt(Wxc,{ChangelogEntryType:()=>kDh,GeneratorId:()=>odB,GeneratorLanguage:()=>udB,ReleaseType:()=>eBh,cli:()=>ZDh,commons:()=>Vxc,versions:()=>tBh});var ZDh={};var Vxc={};Zt(Vxc,{ChangelogEntryType:()=>kDh,ReleaseType:()=>eBh});var kDh={Fix:"fix",Feat:"feat",Chore:"chore",Break:"break",Internal:"internal"};var eBh={Ga:"GA",Rc:"RC"};var tBh={};function odB(e){return e}var udB={Python:"python",Go:"go",Java:"java",Typescript:"typescript",Ruby:"ruby",Csharp:"csharp",Php:"php",Swift:"swift",Rust:"rust"};var Gxc={};Zt(Gxc,{PullRequestState:()=>rBh});var rBh={Open:"open",Closed:"closed",Merged:"merged"};var Kxc={};Zt(Kxc,{latest:()=>Hxc,v1:()=>xxc});var Hxc={};Zt(Hxc,{NodeId:()=>ldB,ProductId:()=>fdB,Slug:()=>sdB,TabId:()=>cdB});function sdB(e){return e}function cdB(e){return e}function ldB(e){return e}function fdB(e){return e}var xxc={};Zt(xxc,{NavigationV1Availability:()=>ydB,NodeId:()=>_dB,ProductId:()=>hdB,Slug:()=>ddB,TabId:()=>pdB});function ddB(e){return e}function pdB(e){return e}function _dB(e){return e}function hdB(e){return e}var ydB={Stable:"stable",GenerallyAvailable:"generally-available",InDevelopment:"in-development",PreRelease:"pre-release",Beta:"beta",Deprecated:"deprecated"};var $xc={};Zt($xc,{Language:()=>iBh,VersionBump:()=>nBh,versions:()=>Jxc});var Jxc={};Zt(Jxc,{Language:()=>iBh,VersionBump:()=>nBh});var iBh={Go:"Go",TypeScript:"TypeScript",Java:"Java",Python:"Python",Csharp:"Csharp",Ruby:"Ruby"};var nBh={Major:"MAJOR",Minor:"MINOR",Patch:"PATCH"};var aBh={};var oBh={};var Yxc={};Zt(Yxc,{PayloadLocation:()=>uBh});var uBh={Body:"BODY",Query:"QUERY",Path:"PATH",Headers:"HEADERS",Relative:"RELATIVE",Auth:"AUTH"};var sBh={};var Xgu=class{warnings=[];errors=[];error(t){this.errors.push(t)}warning(t){this.warnings.push(t)}};function Lo(e){return e!=null}var lBh=ce(eQa(),1);var cBh=["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 QYt(e){return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e=e.replace(/_/g," "),e=e.replace(/-/g," "),(0,lBh.default)(e,{special:cBh}).replace(/V\s(\d)/g,"V$1")}function fBh({endpoints:e,webhookEndpoints:t}){let r={};return Object.values({...e,...t}).forEach(i=>{let n=[];i.namespace?.forEach(a=>{let o=[...n,a],c=oc.api.v1.SubpackageId(o.join("."));r[c]={id:c,name:a,displayName:QYt(a)},n.push(a)})}),r}var Zgu=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 dBh(e){return`#/${e.map(t=>t.replaceAll(/~/g,"~0").replaceAll(/\//g,"~1")).join("/")}`}var ho=class extends Zgu{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 ${dBh(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})}}},pC=class extends ho{},oY=class extends pC{seenSchemas;constructor(t){super(t),this.seenSchemas=new Set(t.seenSchemas)}};var pBh="x-fern-base-path",_Bh="x-fern-availability",kgu="x-fern-sdk-group-name",hBh="x-fern-global-headers",yBh="x-fern-sdk-method-name";var bBh="x-fern-webhook",vBh="x-fern-access-token-locator",gBh="x-fern-basic",OBh="x-fern-username-variable-name",ABh="x-fern-password-variable-name",mBh="x-fern-bearer",PBh="x-fern-token-variable-name",jBh="x-fern-header",wBh="x-fern-header-variable-name",EBh="x-fern-server-name",SBh="x-fern-examples";var eOu=class extends ho{serverName;constructor(t){super(t),this.safeParse()}parse(){this.serverName=this.input[EBh]}convert(){if(this.serverName!=null)return this.serverName}};var tOu=class extends ho{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 eOu({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:oc.EnvironmentId(t),baseUrl:this.url}}};function v$i(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 tOu({input:c,context:r,accessPath:i,pathId:["servers",`${d}`]}));return[...n,...o]}function xv(e){return typeof e=="object"&&Lo(e)&&"$ref"in e&&typeof e.$ref=="string"}function pL(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:(xv(n)&&(n=pL(n,t,r)),n)}function rOu(e,t){let r=t.components?.securitySchemes?.[e];if(r!=null)return xv(r)?pL(r,t,void 0):r}var vIh=ce(ZS());var iOu=class extends ho{username;password;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[gBh];this.username=t?.username,this.password=t?.password}convert(){return{username:this.username,password:this.password}}};var nOu=class extends ho{passwordVariableName;constructor(t){super(t),this.safeParse()}parse(){this.passwordVariableName=this.input[ABh]}convert(){return this.passwordVariableName}};var aOu=class extends ho{usernameVariableName;constructor(t){super(t),this.safeParse()}parse(){this.usernameVariableName=this.input[OBh]}convert(){return this.usernameVariableName}};var oOu=class extends ho{bearerTokenVariableName;bearerTokenEnvVar;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[mBh];this.bearerTokenVariableName=t?.name,this.bearerTokenEnvVar=t?.env}convert(){return{tokenVariableName:this.bearerTokenVariableName,tokenEnvVar:this.bearerTokenEnvVar}}};var uOu=class extends ho{tokenVariableName;constructor(t){super(t),this.safeParse()}parse(){this.tokenVariableName=this.input[PBh]}convert(){return this.tokenVariableName}};function MBh(e){return typeof e=="object"&&e!=null&&"in"in e&&e.in==="header"}var DBh="x-bearer-format",BBh="x-code-samples",IBh="x-codeSamples";var sOu=class extends ho{bearerFormat;constructor(t){super(t),this.safeParse()}parse(){this.bearerFormat=this.input[DBh]}convert(){return this.bearerFormat}};var cOu=class extends ho{headerVariableName;headerEnvVar;headerPrefix;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[jBh];this.headerVariableName=t?.name,this.headerEnvVar=t?.env,this.headerPrefix=t?.prefix}convert(){return{name:this.headerVariableName,env:this.headerEnvVar,prefix:this.headerPrefix}}};var lOu=class extends ho{headerVariableName;constructor(t){super(t),this.safeParse()}parse(){this.headerVariableName=this.input[wBh]}convert(){return this.headerVariableName}};function CBh(e){return e.type==="apiKey"}var Uua=class extends ho{headerName;headerBearerFormatNode;headerAuthNode;headerVariableNameNode;constructor(t){super(t),this.safeParse()}parse(){CBh(this.input)&&(this.headerName=this.input.name),this.headerAuthNode=new cOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerVariableNameNode=new lOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerBearerFormatNode=new sOu({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 fOu(e){return e}function dOu(e){return e==="__proto__"}function pOu(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function Lua(e){return typeof e=="string"||typeof e=="symbol"?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function UKa(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(UKa).join(",");let t=String(e);return t==="0"&&Object.is(Number(e),-0)?"-0":t}function _Ou(e){if(Array.isArray(e))return e.map(Lua);if(typeof e=="symbol")return[e];e=UKa(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 LKa(e,t,r){if(e==null)return r;switch(typeof t){case"string":{if(dOu(t))return r;let i=e[t];return i===void 0?pOu(t)?LKa(e,_Ou(t),r):r:i}case"number":case"symbol":{typeof t=="number"&&(t=Lua(t));let i=e[t];return i===void 0?r:i}default:{if(Array.isArray(t))return bdB(e,t,r);if(Object.is(t?.valueOf(),-0)?t="-0":t=String(t),dOu(t))return r;let i=e[t];return i===void 0?r:i}}}function bdB(e,t,r){if(t.length===0)return r;let i=e;for(let n=0;n<t.length;n++){if(i==null||dOu(t[n]))return r;i=i[t[n]]}return i===void 0?r:i}function qBh(e){return function(t){return LKa(t,e)}}function TBh(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function hOu(e){return e==null||typeof e!="object"&&typeof e!="function"}function Xxc(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function kxc(e,t,r){return typeof r!="function"?kxc(e,t,()=>{}):Zxc(e,t,function i(n,a,o,c,d,s){let u=r(n,a,o,c,d,s);return u!==void 0?!!u:Zxc(n,a,i,s)},new Map)}function Zxc(e,t,r,i){if(t===e)return!0;switch(typeof t){case"object":return vdB(e,t,r,i);case"function":return Object.keys(t).length>0?Zxc(e,{...t},r,i):Xxc(e,t);default:return TBh(e)?typeof t=="string"?t==="":!0:Xxc(e,t)}}function vdB(e,t,r,i){if(t==null)return!0;if(Array.isArray(t))return RBh(e,t,r,i);if(t instanceof Map)return gdB(e,t,r,i);if(t instanceof Set)return OdB(e,t,r,i);let n=Object.keys(t);if(e==null)return n.length===0;if(n.length===0)return!0;if(i?.has(t))return i.get(t)===e;i?.set(t,e);try{for(let a=0;a<n.length;a++){let o=n[a];if(!hOu(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 gdB(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 RBh(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 OdB(e,t,r,i){return t.size===0?!0:e instanceof Set?RBh([...e],[...t],r,i):!1}function yOu(e,t){return kxc(e,t,()=>{})}function zBh(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function bOu(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var NBh="[object RegExp]",vOu="[object String]",gOu="[object Number]",OOu="[object Boolean]",AOu="[object Arguments]",FBh="[object Symbol]",QBh="[object Date]",UBh="[object Map]",LBh="[object Set]",VBh="[object Array]";var WBh="[object ArrayBuffer]",GBh="[object Object]";var HBh="[object DataView]",xBh="[object Uint8Array]",KBh="[object Uint8ClampedArray]",JBh="[object Uint16Array]",$Bh="[object Uint32Array]";var YBh="[object Int8Array]",XBh="[object Int16Array]",ZBh="[object Int32Array]";var kBh="[object Float32Array]",eIh="[object Float64Array]";function tIh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function rIh(e,t){return g$i(e,void 0,e,new Map,t)}function g$i(e,t,r,i=new Map,n=void 0){let a=n?.(e,t,r,i);if(a!==void 0)return a;if(hOu(e))return e;if(i.has(e))return i.get(e);if(Array.isArray(e)){let o=new Array(e.length);i.set(e,o);for(let c=0;c<e.length;c++)o[c]=g$i(e[c],c,r,i,n);return Object.hasOwn(e,"index")&&(o.index=e.index),Object.hasOwn(e,"input")&&(o.input=e.input),o}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let o=new RegExp(e.source,e.flags);return o.lastIndex=e.lastIndex,o}if(e instanceof Map){let o=new Map;i.set(e,o);for(let[c,d]of e)o.set(c,g$i(d,c,r,i,n));return o}if(e instanceof Set){let o=new Set;i.set(e,o);for(let c of e)o.add(g$i(c,void 0,r,i,n));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(e))return e.subarray();if(tIh(e)){let o=new(Object.getPrototypeOf(e)).constructor(e.length);i.set(e,o);for(let c=0;c<e.length;c++)o[c]=g$i(e[c],c,r,i,n);return o}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){let o=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return i.set(e,o),v8t(o,e,r,i,n),o}if(typeof File<"u"&&e instanceof File){let o=new File([e],e.name,{type:e.type});return i.set(e,o),v8t(o,e,r,i,n),o}if(typeof Blob<"u"&&e instanceof Blob){let o=new Blob([e],{type:e.type});return i.set(e,o),v8t(o,e,r,i,n),o}if(e instanceof Error){let o=new e.constructor;return i.set(e,o),o.message=e.message,o.name=e.name,o.stack=e.stack,o.cause=e.cause,v8t(o,e,r,i,n),o}if(e instanceof Boolean){let o=new Boolean(e.valueOf());return i.set(e,o),v8t(o,e,r,i,n),o}if(e instanceof Number){let o=new Number(e.valueOf());return i.set(e,o),v8t(o,e,r,i,n),o}if(e instanceof String){let o=new String(e.valueOf());return i.set(e,o),v8t(o,e,r,i,n),o}if(typeof e=="object"&&AdB(e)){let o=Object.create(Object.getPrototypeOf(e));return i.set(e,o),v8t(o,e,r,i,n),o}return e}function v8t(e,t,r=e,i,n){let a=[...Object.keys(t),...zBh(t)];for(let o=0;o<a.length;o++){let c=a[o],d=Object.getOwnPropertyDescriptor(e,c);(d==null||d.writable)&&(e[c]=g$i(t[c],c,r,i,n))}}function AdB(e){switch(bOu(e)){case AOu:case VBh:case WBh:case HBh:case OOu:case QBh:case kBh:case eIh:case YBh:case XBh:case ZBh:case UBh:case gOu:case GBh:case NBh:case LBh:case vOu:case FBh:case xBh:case KBh:case JBh:case $Bh:return!0;default:return!1}}function iIh(e){return g$i(e,void 0,e,new Map,void 0)}function nIh(e){return e=iIh(e),t=>yOu(t,e)}function aIh(e,t){return rIh(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 gOu:case vOu:case OOu:{let c=new e.constructor(e?.valueOf());return v8t(c,e),c}case AOu:{let c={};return v8t(c,e),c.length=e.length,c[Symbol.iterator]=e[Symbol.iterator],c}default:return}})}function oIh(e){return aIh(e)}var mdB=/^(?:0|[1-9]\d*)$/;function uIh(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 mdB.test(e)}}function sIh(e){return e!==null&&typeof e=="object"&&bOu(e)==="[object Arguments]"}function cIh(e,t){let r;if(Array.isArray(t)?r=t:typeof t=="string"&&pOu(t)&&e?.[t]==null?r=_Ou(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)||sIh(i))&&uIh(a)&&a<i.length))return!1;i=i[a]}return!0}function lIh(e,t){switch(typeof e){case"object":{Object.is(e?.valueOf(),-0)&&(e="-0");break}case"number":{e=Lua(e);break}}return t=oIh(t),function(r){let i=LKa(r,e);return i===void 0?cIh(r,e):t===void 0?i===void 0:yOu(i,t)}}function fIh(e){if(e==null)return fOu;switch(typeof e){case"function":return e;case"object":return Array.isArray(e)&&e.length===2?lIh(e[0],e[1]):nIh(e);case"string":case"symbol":case"number":return qBh(e)}}function dIh(e,t){let r={},i=Object.keys(e);for(let n=0;n<i.length;n++){let a=i[n],o=e[a];r[a]=t(o,a,e)}return r}function mOu(e,t=fOu){return e==null?{}:dIh(e,fIh(t))}function pIh(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}var PdB=new RegExp("\\p{Lu}?\\p{Ll}+|[0-9]+|\\p{Lu}+(?!\\p{Ll})|\\p{Emoji_Presentation}|\\p{Extended_Pictographic}|\\p{L}+","gu");function _Ih(e){return Array.from(e.match(PdB)??[])}function hIh(e){let t=_Ih(e);if(t.length===0)return"";let[r,...i]=t;return`${r.toLowerCase()}${i.map(n=>pIh(n)).join("")}`}function yIh(e){return typeof e!="string"&&(e=UKa(e)),e.replace(/['\u2019]/g,"")}function g8t(e){return hIh(yIh(e))}function HP(e){if(e!=null)return Array.isArray(e)?e:[e]}function POu({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`${jdB(o)}${wdB(e)}.${EdB(i,n,a,c)}`}function jdB(e){return e?"webhook_":"endpoint_"}function wdB(e){return e!=null?HP(e)?.map(t=>g8t(t)).join("/"):""}function EdB(e,t,r,i){return e||t||g8t(r??"")||g8t(i??"")}function bIh(e){return e.length===0?!1:/^\$?(\.[\w*]+|\[['"][\w*]+['"]?\]|\[['"]?[\d*]+['"]?\]|\[[\d:]+\])*$/.test(e)}var jOu=class extends ho{accessTokenLocator;constructor(t){super(t),this.safeParse()}parse(){this.accessTokenLocator=this.input[vBh],this.accessTokenLocator!=null&&(bIh(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 wOu=class extends ho{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 Uua({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.accessTokenLocatorNode=new jOu({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=POu({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:oc.EndpointId(r),accessTokenLocator:oc.JqString(t),headerName:this.headerAuthNode?.convert()?.headerWireValue,tokenPrefix:this.headerAuthNode?.convert()?.prefix}}}}};var Vua=class extends ho{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 iOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicUsernameVariableNameNode=new aOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicPasswordVariableNameNode=new nOu({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 oOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.bearerTokenVariableNameNode=new uOu({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":{MBh(this.input)?(this.authScheme="header",this.headerAuthNode=new Uua({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 wOu({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 vIh.UnreachableCaseError(this.authScheme);return}}};var Wua=class extends ho{authNodesMap;constructor(t){super(t),this.safeParse()}parse(){this.input.map((t,r)=>Object.keys(t).map(i=>{let n=rOu(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 Vua({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(Lo))}};var EOu=class extends ho{basePath;constructor(t){super(t),this.safeParse()}parse(){this.basePath=this.input[pBh],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 gIh(e){return"required"in e&&typeof e.required=="boolean"?e.required:!1}function OIh(e,t){return{type:"alias",value:{type:"optional",shape:e,default:t}}}function Gua(e,t){return e==null?void 0:Object.entries(e).map(([i,n])=>HP(n.convert())?.map(o=>((t!=null&&!t.includes(i)||t==null&&!gIh(n))&&(o=OIh(o,o.type==="enum"?o.default:void 0)),{key:oc.PropertyKey(i),valueShape:o,description:n.description,availability:n.availability?.convert()})).filter(Lo)).filter(Lo).reduce((i,n)=>i.flatMap(a=>n.length>0?n.map(o=>[...a,o]):[[...a]]),[[]])}function SOu(e,t){return xv(e)?pL(e,t,void 0):e}function O$i(e,t){return e!=null&&e!==""?e:t!=null&&t!==""?t:void 0}function AIh(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 mIh(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 PIh=ce(ZS());var eKc=["decimal","decimal128","double-int","double","float","sf-decimal"],tKc=["int16","int32","int64","int8","sf-integer","uint8"],rKc=["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"],iKc=["beta","pre-release","in-development","generally-available","deprecated"];function _C(e,t){return xv(e)?pL(e,t,{type:"unknown","x-fern-type":"unknown",additionalProperties:!1}):e}var ZEe=class extends ho{availability;constructor(t){super(t),this.safeParse()}parse(){if(_C(this.input,this.context.document)?.deprecated)this.availability="deprecated";else{let r=this.input[_Bh];r!=null&&(iKc.includes(r)?this.availability=r:(this.context.errors.warning({message:`Expected one of: ${iKc.join(", ")}. Received: ${r}`,path:this.accessPath}),this.availability=void 0))}}convert(){switch(this.availability){case"beta":case"pre-release":return oc.Availability.Beta;case"in-development":return oc.Availability.InDevelopment;case"generally-available":return oc.Availability.GenerallyAvailable;case"deprecated":return oc.Availability.Deprecated;case void 0:return;default:new PIh.UnreachableCaseError(this.availability);return}}};var DOu=ce(ZS());function jIh(e){return typeof e=="object"&&e!=null&&"language"in e}function wIh(e){return typeof e=="object"&&e!=null&&"sdk"in e}function EIh(e){return typeof e=="object"&&e!=null&&("error"in e||"body"in e)}function SIh(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)}function MOu(e){return typeof e=="object"&&e!=null&&"event"in e}function nKc(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)&&e.stream.every(MOu)}function A$i(e){return typeof e=="object"&&e!=null&&"filename"in e&&"data"in e&&typeof e.filename=="string"&&typeof e.data=="string"}function MIh(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}var BOu=class extends ho{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[SBh]}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 A$i(o)?[n,{type:"filenameWithData",filename:o.filename,data:oc.FileId(o.data)}]:o!=null?[n,{type:"filename",value:o}]:void 0;case"files":{if(Array.isArray(o)){if(o.every(c=>A$i(c)))return[n,{type:"filenamesWithData",value:o.map(c=>({filename:c.filename,data:oc.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 DOu.UnreachableCaseError(a.multipartType);return}}).filter(Lo))};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=MIh(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 DOu.UnreachableCaseError(n.contentType);break}let o;switch(i.contentType){case"application/json":{EIh(r.response)&&(o={type:"json",value:r.response.body});break}case"text/event-stream":{nKc(r.response)&&(o={type:"sse",value:r.response.stream.map(l=>({event:l.event,data:l.data}))});break}case"application/octet-stream":!nKc(r.response)&&SIh(r.response)&&(o={type:"stream",value:r.response.stream});break;case void 0:break;default:new DOu.UnreachableCaseError(i.contentType);break}let c={};r["code-samples"]?.forEach(l=>{jIh(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})):wIh(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])=>[oc.PropertyKey(l),p])),s=Object.fromEntries(Object.entries(r["query-parameters"]??{}).map(([l,p])=>[oc.PropertyKey(l),p])),u=Object.fromEntries(Object.entries(r.headers??{}).map(([l,p])=>[oc.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 VKa=class extends ho{groupName;constructor(t){super(t),this.safeParse()}parse(){this.groupName=this.input[kgu]}convert(){if(this.groupName==null)return;let t;return Array.isArray(this.groupName)?t=this.groupName:t=[this.groupName],t.map(r=>oc.api.v1.SubpackageId(g8t(r)))}};var IOu=class extends ho{sdkMethodName;constructor(t){super(t),this.safeParse()}parse(){this.sdkMethodName=this.input[yBh]}convert(){return this.sdkMethodName}};var COu=class extends ho{isWebhook;constructor(t){super(t),this.safeParse()}parse(){this.isWebhook=this.input[bBh]}convert(){return this.isWebhook}};var qOu=class extends ho{codeSamples;constructor(t){super(t),this.safeParse()}parse(){this.codeSamples=[...this.input[BBh]??[],...this.input[IBh]??[]],this.codeSamples.forEach(t=>{[...Object.values(oc.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 Dvn=ce(ZS());function aKc(e,t){return xv(e)?pL(e,t,void 0):e}function DIh(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 yF="",UYt=class extends ho{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&&(A$i(n)||typeof n=="string");case"files":return t&&Array.isArray(n)&&n.every(a=>A$i(a)||typeof a=="string");case"property":return t;case void 0:return t&&!1;default:return new Dvn.UnreachableCaseError(i.multipartType),t}},!0)}parse(){let t=this.shapes.requestBody?.schema?.example({includeOptionals:!1,override:void 0});this.resolvedRequestInput=aKc(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=aKc(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 Dvn.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(MOu)){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 Dvn.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 A$i(n)?[r,{type:"filenameWithData",filename:n.filename,data:oc.FileId(n.data)}]:[r,{type:"filename",value:n}];case"files":{if(Array.isArray(n)){if(n.every(a=>A$i(a)))return[r,{type:"filenamesWithData",value:n.map(a=>({filename:a.filename,data:oc.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 Dvn.UnreachableCaseError(i.multipartType);return}}).filter(Lo))};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 Dvn.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 Dvn.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(Lo));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(Lo));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:DIh(this.path,i??{}),responseStatusCode:this.responseStatusCode,name:this.name!=null?QYt(this.name):this.summary!=null?QYt(this.summary):void 0,description:this.convertDescription(),pathParameters:i,queryParameters:n,headers:a,requestBody:t,responseBody:r,snippets:void 0}}};function BIh(e,t){return xv(e)?pL(e,t,void 0):e}var WIh=ce(ZS());var IIh="#/components/schemas/";function Hua(e){if(e.$ref.startsWith(IIh))return e.$ref.replace(IIh,"")}function BUi(e){if(e!=null)return{type:"alias",value:{type:"nullable",shape:e}}}function m$i(e){return typeof e.type=="string"&&e.type==="array"}function CIh(e){return e.type==="boolean"}function qIh(e){return e.type==="integer"}function P$i(e){return!Array.isArray(e.type)&&!m$i(e)}function TIh(e){return e!=null&&Array.isArray(e)&&e.every(t=>t.type==="null"||P$i(t)||m$i(t))}function RIh(e){return"nullable"in e&&typeof e.nullable=="boolean"}function zIh(e){return e.type==="null"}function NIh(e){return e.type==="number"}function oKc(e){return e.type==null||typeof e.type=="string"&&e.type==="object"}function FIh(e){return e.type==="string"}var TOu=class extends oY{item;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.item=new ew({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 HP(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 ROu=class extends pC{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 ZEe({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 zOu=class extends oY{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 ew({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName})}).filter(Lo)}convert(){if(this.typeNodes==null)return;let i=this.typeNodes.map(n=>HP(n.convert())?.map(o=>({displayName:n.name,shape:o,description:n.description,availability:n.availability?.convert()}))).filter(Lo).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(BUi).filter(Lo):i}example(t){return this.nullable?null:this.typeNodes?.[0]?.example(t)}};function NOu(e){return e!=null&&e.length>0?e:[void 0]}var xua=class extends oY{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 ew({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 ew({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(xv(t))return Hua(t);this.properties={...this.properties,...Object.fromEntries(Object.entries(t.properties??{}).map(([i,n])=>[i,new ew({input:n,context:this.context,accessPath:this.accessPath,pathId:["allOf",r.toString(),"properties",i],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))}}).filter(Lo))),this.description=this.input.description}convertProperties(){if(this.properties!=null)return Gua(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}}}]:HP(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(Lo)}convert(){let t=this.convertProperties();if(t==null)return;let r=this.convertExtraProperties();return t.flatMap(i=>NOu(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=>oc.TypeId(a)),properties:i,extraProperties:n}))}example({includeOptionals:t}){let r={...this.properties};return this.input.allOf?.forEach(i=>{let n=_C(i,this.context.document);n!=null&&(r={...r,...Object.fromEntries(Object.entries(n.properties??{}).map(([a,o])=>[a,new ew({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 FOu=class extends oY{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=>_C(t,this.context.document)?.type==="null"),this.input.discriminator==null)this.discriminated=!1,this.undiscriminatedMapping=(this.input.oneOf??this.input.anyOf)?.map(t=>_C(t,this.context.document)?.type!=="null"?new ew({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0).filter(Lo);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=_C({$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 ew({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(Lo);return this.isNullable&&n!=null?n.map(BUi).filter(Lo):n}let t=0,r=this.discriminated&&this.discriminant!=null&&this.discriminatedMapping!=null?{type:"discriminatedUnion",discriminant:oc.PropertyKey(this.discriminant),variants:Object.entries(this.discriminatedMapping).flatMap(([n,a])=>HP(a.convert())?.map(c=>{if(!(c==null||c.type!=="object"))return{discriminantValue:n,displayName:a.name??QYt(n),availability:a.availability?.convert(),description:a.description,...c}}).filter(Lo)).filter(Lo)}:this.undiscriminatedMapping!=null?{type:"undiscriminatedUnion",variants:this.undiscriminatedMapping.flatMap(n=>HP(n.convert())?.map(o=>{if(o==null)return;t+=1;let c=o.type==="object"?QYt(`${this.schemaName??"Variant"} ${t}`):void 0;return{displayName:n.name??(o.type==="alias"&&o.value.type==="id"?QYt(o.value.id):c),shape:o,description:n.description,availability:n.availability?.convert()}}).filter(Lo)).filter(Lo)}:void 0,i=this.isNullable?BUi(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 QOu=class extends pC{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 j$i=class extends pC{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(xv(r)){let n=_C(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(Lo),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 QIh=ce(ZS());function SdB(e){return tKc.includes(e)}var UOu=class extends pC{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&&(SdB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${tKc.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 QIh.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 LOu=class extends pC{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){this.displayName=this.input.title}convert(){return BUi({type:"alias",value:{type:"unknown",displayName:this.displayName}})}example(){return null}};var UIh=ce(ZS());function MdB(e){return eKc.includes(e)}var VOu=class extends pC{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&&(MdB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${eKc.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 UIh.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 LIh=ce(ZS());function DdB(e){return rKc.includes(e)}var WOu=class extends pC{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 LIh.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&&(DdB(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${rKc.join(", ")}. Received ${this.input.format}`,path:this.accessPath})),this.input.enum!=null&&(this.enum=new j$i({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 VIh=ce(ZS());var GOu=class extends pC{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){(0,VIh.noop)()}convert(){return{type:"alias",value:{type:"unknown",displayName:void 0}}}example(){}};var Bvn=class extends oY{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=Hua(this.input);let t=_C(this.input,this.context.document);t?.enum!=null&&P$i(t)&&(this.maybeEnumConverterNode=new j$i({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:oc.TypeId(this.schemaId),default:this.maybeEnumConverterNode?.default!=null?{type:"enum",value:this.maybeEnumConverterNode.default}:void 0}}}example(t){let r=_C(this.input,this.context.document);if(r!=null)return new ew({input:r,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName}).example(t)}};var ew=class e extends oY{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 ZEe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),P$i(this.input)&&RIh(this.input)&&(this.nullable=this.input.nullable!=null?this.input.nullable:this.nullable),xv(this.input)){let t=Hua(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 Bvn({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 ROu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});else if(TIh(this.input))this.typeShapeNode=new zOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(P$i(this.input)&&(this.input.oneOf!=null||this.input.anyOf!=null))this.typeShapeNode=new FOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(oKc(this.input)&&this.input.allOf!=null)this.typeShapeNode=new xua({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(P$i(this.input)&&this.input.enum!=null)this.typeShapeNode=new j$i({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":oKc(this.input)&&(this.typeShapeNode=new xua({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"array":m$i(this.input)&&(this.typeShapeNode=new TOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"boolean":CIh(this.input)&&(this.typeShapeNode=new QOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"integer":qIh(this.input)&&(this.typeShapeNode=new UOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"number":NIh(this.input)&&(this.typeShapeNode=new VOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"string":FIh(this.input)&&(this.typeShapeNode=new WOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"null":zIh(this.input)&&(this.typeShapeNode=new LOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}));break;case void 0:break;default:new WIh.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 xua({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 GOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),!xv(this.input)&&(!m$i(this.input)&&this.input==null||m$i(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=HP(t)?.map(i=>this.nullable?BUi(i):i).filter(Lo);return Array.isArray(t)&&t.length>1?r:r?.[0]}example(t){return this.availability?.availability!=="deprecated"?this.typeShapeNode?.example(t):void 0}};function w$i(e){if(e!=null)return Gua(e,Object.entries(e??{}).map(([t,r])=>r.required?t:void 0).filter(Lo))}var LYt=class extends pC{availability;required;schema;description;inputExample;constructor(t){super(t),this.safeParse(t.parameterName)}parse(t){this.description=this.input.description;let r;xv(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 ZEe({input:r,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=new ew({input:r,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:t});let i=BIh(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 GIh(e,t){return xv(e)?pL(e,t,void 0):e}var uKc=ce(ZS());function HOu(e){let{uniqueId:t,type:r,contextTypes:i,description:n,availability:a}=e;i[oc.TypeId(t)]={name:t,shape:r,description:n,availability:a}}var HIh=ce(p2s(),1),Kua=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=HIh.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 BdB(e){return typeof e.securitySchemes=="object"&&e.securitySchemes!=null}var xOu=class extends ho{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 ew({input:r,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:new Set,nullable:void 0,schemaName:t})]))),BdB(this.input)&&this.input.securitySchemes!=null&&(this.securitySchemes=Object.fromEntries(Object.entries(this.input.securitySchemes??{}).map(([t,r],i)=>{let n;if(xv(r)?n=rOu(r.$ref,this.context.document):n=r,n!=null)return[t,new Vua({input:n,context:this.context,accessPath:this.accessPath,pathId:["securitySchemes",`${i}`]})]}).filter(Lo)))}convert(){return{auths:this.securitySchemes!=null?Object.fromEntries(Object.entries(this.securitySchemes??{}).map(([t,r])=>{let i=r.convert();if(i!=null)return[oc.api.latest.AuthSchemeId(t),i]}).filter(Lo)):void 0,types:this.typeSchemas!=null?Object.fromEntries(Object.entries(this.typeSchemas).map(([t,r])=>{let i=r.name??t,n=HP(r.convert());return n==null?[t,void 0]:[oc.TypeId(t),{name:i,shape:n[0],description:r.description,availability:void 0}]}).filter(([t,r])=>Lo(r))):void 0}}};var KOu=class extends ew{multipartType;contentType;constructor(t){super(t),this.safeParse()}parse(){super.parse();let t=_C(this.input,this.context.document);if(t==null){this.context.errors.error({message:`Expected multipart form data property definition. ${xv(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=_C(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 JOu=class extends ho{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=_C(this.input.schema,this.context.document);this.availability=new ZEe({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=xv(this.input.schema)?new Bvn({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=Kua.parse(t);n?.containsJSON()?(this.contentType="json",this.schema=this.schema??new ew({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 KOu({input:o,context:this.context,accessPath:this.accessPath,pathId:`schema.${a}`,seenSchemas:new Set,nullable:void 0,schemaName:a})]}).filter(Lo))):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?{[yF]:{value:this.input.example}}:{},...this.input.examples},r!=null&&Object.keys(this.examples).length===0&&(this.examples={[yF]:{value:r}})}convertJsonLike(){let t=this.schema?.convert();return t==null?void 0:HP(t)?.map(i=>{let n=i.type;switch(n){case"object":case"alias":return i;case"enum":case"undiscriminatedUnion":case"discriminatedUnion":{let a=g8t([this.method,this.path,this.contentType,"request"].join("_"));return HOu({uniqueId:a,type:i,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:oc.TypeId(a),default:i.type==="enum"&&i.default!=null?{type:"enum",value:i.default}:void 0}}}case void 0:return;default:new uKc.UnreachableCaseError(n);return}}).filter(Lo)}convert(){if(this.schema instanceof Bvn)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:oc.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:oc.PropertyKey(i),isOptional:this.requiredFields?.includes(i)==null,contentType:n.contentType,description:n.description,availability:n.availability?.convert()}];case"property":{let a=HP(n.convert()),o=n.multipartType;return a?.map(c=>({type:o,key:oc.PropertyKey(i),contentType:n.contentType,exploded:void 0,valueShape:c,description:n.description,availability:n.availability?.convert()}))}case void 0:return[];default:return new uKc.UnreachableCaseError(n.multipartType),[]}}).filter(Lo).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 $Ou=class extends ho{description;requestBodiesByContentType;constructor(t){super(t),this.safeParse(t)}parse({method:t,path:r}){let i=GIh(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 JOu({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])=>HP(r.convert())?.map(n=>({description:this.description,contentType:t,body:n}))).filter(Lo)}convertToWebhookPayload(){return Object.values(this.requestBodiesByContentType??{}).flatMap(t=>HP(t.convert())?.map(i=>{if(!(i.type!=="alias"&&i.type!=="object"))return{description:this.description,shape:i}})).filter(Lo)}webhookExample(){return{payload:this.requestBodiesByContentType?.["application/json"]?.schema?.example({includeOptionals:!0,override:void 0})}}};var xIh={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 KIh(e,t){if(xv(e)){let r=pL(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var YOu=ce(ZS());var JIh="application/json";var $Ih="application/octet-stream";function YIh(e,t){return e===t||t===yF||e===yF}var WKa=class extends ho{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)YIh(c,a)&&(i.add(c),this.examples?.push(new UYt({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,O$i(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 UYt({input:{requestExample:u,responseExample:l},context:this.context,accessPath:this.accessPath,pathId:s!=null&&s!==""?["examples",s]:"examples"},this.path,this.statusCode,O$i(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 UYt({input:{requestExample:s,responseExample:u},context:this.context,accessPath:this.accessPath,pathId:d!=null&&d!==""?["examples",d]:"examples"},this.path,this.statusCode,O$i(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 UYt({input:{requestExample:o,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,O$i(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[yF];if(a!=null)for(let o of a)this.examples?.push(new UYt({input:{requestExample:n,responseExample:o},context:this.context,accessPath:this.accessPath,pathId:i!=null&&i!==""?["examples",i]:"examples"},this.path,this.statusCode,O$i(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=Kua.parse(t);if(c?.isJSON()||c?.isEventStream())this.contentType=JIh,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 ew({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=$Ih,this.contentSubtype=_C(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 ew({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=mOu(this.input.examples,c=>[c])),this.input.example!=null&&Object.keys(r).length===0&&(r[yF]??=[],r[yF]=[{value:this.input.example}]);let i=_C(this.input.schema,this.context.document);if(i!=null&&(i.examples!=null&&Object.keys(r).length===0&&(r=mOu(i.examples,c=>[c])),i.example!=null&&Object.keys(r).length===0&&(r[yF]??=[],r[yF]?.push({value:i.example}))),Object.keys(r).length===0){let c=this.schema?.example({includeOptionals:!0,override:void 0});r[yF]??=[],r[yF]?.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!==yF).map(([d,s])=>[c,d,s]));let o=Object.entries(r).filter(([c,d])=>!n.has(c)&&Lo(d)&&c!==yF);Object.keys(r).every(c=>c===yF)||this.matchExamplesByIndex(a,o),!n.has(yF)&&this.examples.length===0&&this.addGlobalFallbackExample(this.requests,r),this.examples.length===0&&(this.examples=void 0)}convertStreamingFormat(){switch(this.streamingFormat){case"json":return HP(this.schema?.convert())?.map(r=>({type:"stream",terminator:"[DATA]",shape:r}));case"sse":return{type:"streamingText"};case void 0:return;default:new YOu.UnreachableCaseError(this.streamingFormat);return}}convertJsonLike(){return HP(this.schema?.convert())?.map(r=>{let i=r.type;switch(i){case"alias":return r;case"discriminatedUnion":case"undiscriminatedUnion":case"enum":{let n=g8t([this.method,this.path,this.statusCode,"response"].join("_"));return HOu({uniqueId:n,type:r,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:oc.TypeId(n),default:r.type==="enum"&&r.default!=null?{type:"enum",value:r.default}:void 0}}}case"object":return r;default:new YOu.UnreachableCaseError(i);return}}).filter(Lo)}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 YOu.UnreachableCaseError(this.contentType);return}else return this.unsupportedContentType!=null?this.convertJsonLike():void 0}};var GKa=class extends ho{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=KIh(this.input,this.context.document);if(r==null){this.context.errors.error({message:xv(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 LYt({input:n,context:this.context,accessPath:this.accessPath,pathId:"headers",parameterName:i})}),r.content==null?(this.responses??=[],this.responses.push(new WKa({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 WKa({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(Lo)}};var XOu=class extends ho{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 GKa({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 GKa({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 NOu(w$i(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(Lo))})))}).filter(Lo)}convertResponseObjectToErrors(){return Object.entries(this.errorsByStatusCode??{}).flatMap(([t,r])=>r.responses?.flatMap(i=>{let n=i.schema,a=HP(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??xIh[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(Lo)})).filter(Lo)})).filter(Lo)}convert(){return{responses:this.convertResponseObjectToHttpResponses(),errors:this.convertResponseObjectToErrors()}}};var E$i=class extends ho{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 UYt({input:{requestExample:t,responseExample:void 0},context:this.context,accessPath:this.accessPath,pathId:"examples"},this.path,200,O$i(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 ZEe({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),this.servers=v$i(this.servers,this.input.servers,this.context,this.accessPath),this.isWebhook=new COu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}).isWebhook||this.isWebhook,this.input.parameters?.map((i,n)=>{if(xv(i)){let a=SOu(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 LYt({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 LYt({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 LYt({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 qOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-code-samples"}),this.requests=this.input.requestBody!=null?new $Ou({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 XOu({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 Wua({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"})),this.namespaces=[new VKa({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 VKa({input:{[kgu]:i},context:this.context,accessPath:this.accessPath,pathId:["tags",`${n}`]})));let r=new IOu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-sdk-method-name"});this.endpointIds=this.namespaces.map(i=>POu({namespace:HP(i?.groupName),path:this.path,method:this.method,sdkMethodName:r.sdkMethodName,operationId:this.input.operationId,displayName:this.displayName,isWebhook:this.isWebhook})).filter(Lo),this.xFernExamplesNode=new BOu({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(Lo)}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:oc.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(Lo),n=mIh(this.xFernExamplesNode?.convert(),[...i??[],...t?.flatMap(u=>u.examples)??[]])?.map(u=>({...u,snippets:AIh(u.snippets,this.redocExamplesNode?.convert())}));if(this.isWebhook)return this.endpointIds.map((u,l)=>{if(!(this.method!=="POST"&&this.method!=="GET"))return{id:oc.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:w$i(this.queryParameters)?.flat(),headers:w$i(this.requestHeaders)?.flat(),payloads:this.requests?.convertToWebhookPayload(),examples:[this.requests?.webhookExample()].filter(Lo)}}).filter(Lo);let a=this.servers?.map(u=>u.convert()).filter(Lo),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(Lo);return this.endpointIds.map((u,l)=>({id:oc.EndpointId(u),description:this.description,availability:this.availability?.convert(),namespace:this.namespaces?.[l]?.convert()?.map(p=>oc.api.v1.SubpackageId(p)),displayName:this.displayName,operationId:this.operationId,method:this.method,path:o,auth:c?.map(p=>oc.api.latest.AuthSchemeId(p)),defaultEnvironment:a?.[0]?.id,environments:a,pathParameters:w$i(this.pathParameters)?.flat(),queryParameters:w$i(this.queryParameters)?.flat(),requestHeaders:w$i(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 Jua=class extends ho{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=v$i(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 E$i({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 E$i({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 E$i({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 E$i({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 E$i({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(Lo)}};function ZOu(e){return"payloads"in e}var kOu=class extends ho{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 Jua({input:a,context:this.context,accessPath:this.accessPath,pathId:n,servers:v$i(t,a.servers,this.context,this.accessPath),globalAuth:r,basePath:i,isWebhook:void 0})}).filter(Lo)}convert(){if(this.paths==null)return;let t={},r={};return this.paths.forEach(i=>{let n=i.convert();n?.forEach(a=>{ZOu(a)?r[oc.WebhookId(a.id)]=a:t[oc.EndpointId(a.id)]=a})}),{endpoints:t,webhookEndpoints:r}}};var eAu=class extends ho{globalHeaders;requiredProperties;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[hBh]?.map(r=>{let{header:i,...n}=r;return(n.optional!=null&&!n.optional||SOu(n,this.context.document)?.required)&&(this.requiredProperties??=[],this.requiredProperties?.push(i)),[i,new LYt({input:n,context:this.context,accessPath:this.accessPath,pathId:this.pathId,parameterName:i})]});t!=null&&(this.globalHeaders=Object.fromEntries(t))}convert(){return Gua(this.globalHeaders,this.requiredProperties)?.flat()}};function XIh(e,t){if(xv(e)){let r=pL(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var tAu=class extends ho{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=XIh(a,this.context.document);if(o!=null)return new Jua({input:o,context:this.context,accessPath:this.accessPath,pathId:n,servers:t,globalAuth:r,basePath:i,isWebhook:!0})}).filter(Lo)}convert(){return this.webhooks?.reduce((t,r)=>(r.convert()?.forEach(i=>{ZOu(i)&&(t[oc.WebhookId(i.id)]=i)}),t),{})}};var rAu=class extends ho{paths;webhooks;components;auth;globalHeaders;constructor(t){super(t),this.safeParse()}parse(){let t=v$i(void 0,this.input.servers,this.context,this.accessPath);this.input.security!=null&&(this.auth=new Wua({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"}));let r=new EOu({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 kOu({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 tAu({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 xOu({input:this.input.components,context:this.context,accessPath:this.accessPath,pathId:"components"})),this.globalHeaders=new eAu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-global-headers"})}convert(){let t=ave(),{webhookEndpoints:r,endpoints:i}=this.paths?.convert()??{},n={...this.webhooks?.convert()??{},...r??{}},a=fBh({endpoints:i,webhookEndpoints:n}),{types:o,auths:c}=this.components?.convert()??{};return{id:oc.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 sKc(e,t){if(e instanceof LEe){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof sS))return;let r=new u8t(e.absoluteFilePath),i=await WEe({context:t,specs:e.specs}),n=await r.loadDocuments({context:t,specs:i}),a;for(let o of n){if(o.type!=="openapi")continue;let c={document:o.value,logger:t.logger,errors:new Xgu,generatedTypes:{}},d=new rAu({input:o.value,context:c,accessPath:[],pathId:e.workspaceName??"openapi parser"});a=D2s(a,d.convert())}return a}var hLh=ce(fKc(),1),yLh=ce(GAu(),1),_Pu=require("fs/promises"),bLh=ce(require("http"),1),vLh=ce(require("path"),1);var tzh=require("events"),$Au=ce(require("fs"),1),Uvn=ce(require("path"),1);var NRh=ce(require("os"),1),FRh=300,q$i=20,pJa=1e7,QRh=NRh.default.platform();var ZgB=QRh==="darwin",IJc=QRh==="win32",T$i=ZgB||IJc,URh=3e3,LRh=2e4,CJc=1250;var HYt;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(HYt||(HYt={}));var Qvn;(function(e){e.CHANGE="change",e.RENAME="rename"})(Qvn||(Qvn={}));var _Ja;(function(e){e.CHANGE="change",e.ERROR="error"})(_Ja||(_Ja={}));var tf;(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"})(tf||(tf={}));var yH;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(yH||(yH={}));var kgB=(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(),m=g-d,j=g-s,S=m>=t||j>=a;return[g,S]},l=g=>{if(s=g,!o)return;let m=o;o=void 0,e.apply(void 0,m)},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,m]=u();return m?y(g):v(g)},v=g=>{let m=g-d,j=g-s,S=t-m,w=a-j,D=Math.min(S,w);return O(D)},O=g=>{c&&clearTimeout(c),!(g<=0)&&(c=setTimeout(b,g))},A=(...g)=>{let[m,j]=u(),S=!!c;if(o=g,d=m,(j||!c)&&O(t),j)return S?l(m):h(m)};return A.cancel=p,A.flush=_,A},HAu=kgB;var zJc=ce(require("fs"),1),KAu=ce(require("path"),1);var iA=ce(require("fs"),1),_L=require("util");var CUi=(e,t)=>function(...i){return e.apply(void 0,i).catch(t)},xYt=(e,t)=>function(...i){try{return e.apply(void 0,i)}catch(n){return t(n)}};var qJc=ce(require("process"),1),VRh=qJc.default.getuid?!qJc.default.getuid():!1,WRh=1e4,lY=()=>{};var hJa={isChangeErrorOk:e=>{if(!hJa.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!VRh&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!hJa.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(!hJa.isNodeError(e))throw e;if(!hJa.isChangeErrorOk(e))throw e}},hC=hJa;var TJc=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=WRh,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()}}}}},GRh=new TJc;var qUi=(e,t)=>function(i){return function n(...a){return GRh.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)})}},TUi=(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 eOB={attempt:{chmod:CUi((0,_L.promisify)(iA.default.chmod),hC.onChangeError),chown:CUi((0,_L.promisify)(iA.default.chown),hC.onChangeError),close:CUi((0,_L.promisify)(iA.default.close),lY),fsync:CUi((0,_L.promisify)(iA.default.fsync),lY),mkdir:CUi((0,_L.promisify)(iA.default.mkdir),lY),realpath:CUi((0,_L.promisify)(iA.default.realpath),lY),stat:CUi((0,_L.promisify)(iA.default.stat),lY),unlink:CUi((0,_L.promisify)(iA.default.unlink),lY),chmodSync:xYt(iA.default.chmodSync,hC.onChangeError),chownSync:xYt(iA.default.chownSync,hC.onChangeError),closeSync:xYt(iA.default.closeSync,lY),existsSync:xYt(iA.default.existsSync,lY),fsyncSync:xYt(iA.default.fsync,lY),mkdirSync:xYt(iA.default.mkdirSync,lY),realpathSync:xYt(iA.default.realpathSync,lY),statSync:xYt(iA.default.statSync,lY),unlinkSync:xYt(iA.default.unlinkSync,lY)},retry:{close:qUi((0,_L.promisify)(iA.default.close),hC.isRetriableError),fsync:qUi((0,_L.promisify)(iA.default.fsync),hC.isRetriableError),open:qUi((0,_L.promisify)(iA.default.open),hC.isRetriableError),readFile:qUi((0,_L.promisify)(iA.default.readFile),hC.isRetriableError),rename:qUi((0,_L.promisify)(iA.default.rename),hC.isRetriableError),stat:qUi((0,_L.promisify)(iA.default.stat),hC.isRetriableError),write:qUi((0,_L.promisify)(iA.default.write),hC.isRetriableError),writeFile:qUi((0,_L.promisify)(iA.default.writeFile),hC.isRetriableError),closeSync:TUi(iA.default.closeSync,hC.isRetriableError),fsyncSync:TUi(iA.default.fsyncSync,hC.isRetriableError),openSync:TUi(iA.default.openSync,hC.isRetriableError),readFileSync:TUi(iA.default.readFileSync,hC.isRetriableError),renameSync:TUi(iA.default.renameSync,hC.isRetriableError),statSync:TUi(iA.default.statSync,hC.isRetriableError),writeSync:TUi(iA.default.writeSync,hC.isRetriableError),writeFileSync:TUi(iA.default.writeFileSync,hC.isRetriableError)}},HRh=eOB;var xAu=ce(require("fs"),1),yJa=ce(require("path"),1);var RJc=()=>{};var tOB=()=>{let e=RJc,t=RJc,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}},xRh=tOB;var rOB=()=>{let{promise:e,resolve:t,isPending:r}=xRh(),i=0,n=()=>{i+=1},a=()=>{i-=1,!i&&t()};return(()=>{n(),queueMicrotask(a)})(),{promise:e,isPending:r,increment:n,decrement:a}},KRh=rOB;var JRh={then:e=>{e()}};var $Rh=e=>Array.isArray(e)?e:[e],YRh=e=>typeof e=="function";var iOB=(e,t)=>{let r=t?.followSymlinks??!1,i=t?.depth??1/0,n=t?.limit??1/0,a=t?.ignore??[],o=$Rh(a).map(H=>YRh(H)?H:G=>H.test(G)),c=H=>o.some(G=>G(H)),d=t?.signal??{aborted:!1},s=t?.onDirents||(()=>{}),u=[],l=new Set,p={},_=[],h=new Set,y={},b=[],v=new Set,O={},A={},g=new Set,m={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:A},{promise:S,increment:w,decrement:D}=KRh(),B=0,R=(H,G,Ee,ue)=>{g.has(G)||B>=n||(B+=1,H.directories.push(G),H.directoriesNames.add(Ee),u.push(G),l.add(Ee),p.propertyIsEnumerable(Ee)||(p[Ee]=[]),p[Ee].push(G),g.add(G),!(ue>=i)&&(B>=n||k(G,ue+1)))},N=(H,G,Ee)=>{g.has(G)||B>=n||(B+=1,H.files.push(G),H.filesNames.add(Ee),_.push(G),h.add(Ee),y.propertyIsEnumerable(Ee)||(y[Ee]=[]),y[Ee].push(G),g.add(G))},z=(H,G,Ee,ue)=>{g.has(G)||B>=n||(B+=1,H.symlinks.push(G),H.symlinksNames.add(Ee),b.push(G),v.add(Ee),O.propertyIsEnumerable(Ee)||(O[Ee]=[]),O[Ee].push(G),g.add(G),r&&(ue>=i||B>=n||je(G,ue+1)))},F=(H,G,Ee,ue,Oe)=>{d.aborted||c(G)||(ue.isDirectory()?R(H,G,Ee,Oe):ue.isFile()?N(H,G,Ee):ue.isSymbolicLink()&&z(H,G,Ee,Oe))},U=(H,G,Ee,ue)=>{if(d.aborted)return;let Oe=G===yJa.default.sep?"":yJa.default.sep,Qe=Ee.name,se=`${G}${Oe}${Qe}`;c(se)||(Ee.isDirectory()?R(H,se,Qe,ue):Ee.isFile()?N(H,se,Qe):Ee.isSymbolicLink()&&z(H,se,Qe,ue))},x=(H,G,Ee,ue)=>{for(let Oe=0,Qe=Ee.length;Oe<Qe;Oe++)U(H,G,Ee[Oe],ue)},k=(H,G)=>{d.aborted||G>i||B>=n||(w(),xAu.default.readdir(H,{withFileTypes:!0},(Ee,ue)=>{if(Ee||d.aborted||!ue.length)return D();(s(ue)||JRh).then(()=>{let Qe=A[H]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};x(Qe,H,ue,G),D()})}))},je=(H,G)=>{w(),xAu.default.realpath(H,(Ee,ue)=>{if(Ee||d.aborted)return D();xAu.default.stat(ue,(Oe,Qe)=>{if(Oe||d.aborted)return D();let se=yJa.default.basename(ue),ne=A[H]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};F(ne,ue,se,Qe,G),D()})})};return(async(H,G=1)=>(H=yJa.default.normalize(H),g.add(H),k(H,G),await S,d.aborted?m:j))(e)},XRh=iOB;var KYt={lang:{debounce:HAu,attempt:e=>{try{return e()}catch(t){return KYt.lang.castError(t)}},castArray:e=>KYt.lang.isArray(e)?e:[e],castError:e=>KYt.lang.isError(e)?e:KYt.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(KYt.lang.isNaN(e))return KYt.lang.isNaN(t);if(KYt.lang.isPrimitive(e)||KYt.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(KAu.default.sep).length-1),getRealPath:(e,t)=>{try{return t?zJc.default.realpathSync.native(e):zJc.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===KAu.default.sep&&t.length-e.length>KAu.default.sep.length,poll:(e,t=LRh)=>HRh.retry.stat(t)(e,{bigint:!0}).catch(KYt.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 XRh(e,{depth:r,limit:i,ignore:t,signal:n});return[o.directories,o.files]}}}},Fp=KYt;var JAu=ce(require("path"),1);var NJc=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||Fp.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=FRh){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=Fp.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===tf.CHANGE&&c===tf.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===tf.ADD_DIR?await this.eventsPopulateAddDir(t,n,r,i):o===tf.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??q$i:Math.min(1,this.options.depth??q$i),o=this.options.limit??pJa,[c,d]=await Fp.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())Fp.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(tf.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!T$i&&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(tf.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(tf.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(JAu.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(tf.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(JAu.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(tf.UNLINK_DIR,t))}onTargetEvent(t){let[r,i]=t;r===tf.ADD?this.onTargetAdd(i):r===tf.ADD_DIR?this.onTargetAddDir(i):r===tf.CHANGE?this.onTargetChange(i):r===tf.UNLINK?this.onTargetUnlink(i):r===tf.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=Qvn.CHANGE,r){if(this.watcher.isClosed())return;let i=JAu.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){IJc&&t.code==="EPERM"?this.onWatcherChange(Qvn.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(_Ja.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(_Ja.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(Qvn.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&T$i&&this.options.native!==!1?this.options.depth??q$i:Math.min(1,this.options.depth??q$i),i=this.options.limit??pJa,[n,a]=await Fp.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(Qvn.CHANGE,c,t)}))}}},ZRh=NJc;var bH={interval:100,intervalId:void 0,fns:new Map,init:()=>{bH.intervalId||(bH.intervalId=setInterval(bH.resolve,bH.interval))},reset:()=>{bH.intervalId&&(clearInterval(bH.intervalId),delete bH.intervalId)},add:(e,t)=>{bH.fns.set(e,Date.now()+t),bH.init()},remove:e=>{bH.fns.delete(e)},resolve:()=>{if(!bH.fns.size)return bH.reset();let e=Date.now();for(let[t,r]of bH.fns)r>=e||(bH.remove(t),t())}},bJa=bH;var vJa=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=CJc){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(Fp.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),bJa.remove(s)},s=()=>{d(),c()};bJa.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=CJc){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),bJa.remove(s)},s=()=>{d(),c()};bJa.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,tf.ADD,HYt.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,tf.ADD_DIR,HYt.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,tf.UNLINK,HYt.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,tf.UNLINK_DIR,HYt.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}}};vJa.DIR_EVENTS={add:tf.ADD_DIR,rename:tf.RENAME_DIR,unlink:tf.UNLINK_DIR};vJa.FILE_EVENTS={add:tf.ADD,change:tf.CHANGE,rename:tf.RENAME,unlink:tf.UNLINK};var kRh=vJa;var FJc=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(Fp.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let i=this.map.get(t);if(Fp.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(Fp.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(Fp.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let i=this.map.get(t);return Fp.lang.isSet(i)?i.has(r):i===r}return!1}set(t,r){if(this.map.has(t)){let i=this.map.get(t);Fp.lang.isSet(i)?i.add(r):i!==r&&this.map.set(t,new Set([i,r]))}else this.map.set(t,r);return this}},QJc=FJc;var UJc=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}},ezh=UJc;var LJc=class{constructor(){this.inos={},this.paths=new QJc,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 Fp.fs.poll(t,r);if(!(!i||!(i.isFile()||i.isDirectory())))return new ezh(i)}reset(){this.inos={},this.paths=new QJc,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,tf.ADD,n),[tf.ADD];if(n.isDirectory())return this.updateIno(t,tf.ADD_DIR,n),[tf.ADD_DIR]}else if(i&&!n){if(i.isFile())return this.updateIno(t,tf.UNLINK,i),[tf.UNLINK];if(i.isDirectory())return this.updateIno(t,tf.UNLINK_DIR,i),[tf.UNLINK_DIR]}else if(i&&n){if(i.isFile()){if(n.isFile())return i.ino===n.ino&&!i.size&&!n.size?[]:(this.updateIno(t,tf.CHANGE,n),[tf.CHANGE]);if(n.isDirectory())return this.updateIno(t,tf.UNLINK,i),this.updateIno(t,tf.ADD_DIR,n),[tf.UNLINK,tf.ADD_DIR]}else if(i.isDirectory()){if(n.isFile())return this.updateIno(t,tf.UNLINK_DIR,i),this.updateIno(t,tf.ADD,n),[tf.UNLINK_DIR,tf.ADD];if(n.isDirectory())return i.ino===n.ino?[]:(this.updateIno(t,tf.UNLINK_DIR,i),this.updateIno(t,tf.ADD_DIR,n),[tf.UNLINK_DIR,tf.ADD_DIR])}}return[]}updateIno(t,r,i){let n=this.inos[r]=this.inos[r]||(this.inos[r]={}),a=i.isFile()?HYt.FILE:HYt.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)}}},VJc=LJc;var WJc=class e extends tzh.EventEmitter{constructor(t,r,i){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(yH.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(n=>this.on(yH.CLOSE,n)),this._readyWait=new Promise(n=>this.on(yH.READY,n)),this._locker=new kRh(this),this._roots=new Set,this._poller=new VJc,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&&(Fp.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(yH.CLOSE))}error(t){if(this.isClosed())return!1;let r=Fp.lang.castError(t);return this.emit(yH.ERROR,r)}event(t,r,i){return this.isClosed()?!1:(this.emit(yH.ALL,t,r,i),this.emit(t,r,i))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(yH.READY))}pollerExists(t,r){for(let i of this._pollers)if(i.targetPath===t&&Fp.lang.isShallowEqual(i.options,r))return!0;return!1}subwatcherExists(t,r){for(let i of this._subwatchers)if(i.targetPath===t&&Fp.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)Fp.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 ZRh(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=Fp.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=Uvn.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??q$i))&&u.handler===i&&(!u.filePath||u.filePath===n)&&u.options.ignore===r.ignore&&!!u.options.native==!!r.native&&(!r.recursive||u.options.recursive&&T$i&&u.options.native!==!1)))return!0;if(!T$i)break;let s=Uvn.default.dirname(t);if(o===s)break;o=s}return!1}async watchDirectories(t,r,i,n,a){if(this.isClosed())return;t=Fp.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||T$i&&r.native!==!1?r:{...r,recursive:!1},u={watcher:$Au.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=Uvn.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||T$i&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,i,n,a));{r={...r,recursive:!0};let o=r.depth??q$i,c=r.limit??pJa,[d]=await Fp.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=Fp.fs.getDepth(t);for(let l of d){let p=Fp.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(yH.CLOSE,d),o.watchFile(t,r,a)},d=()=>{this._subwatchers.delete(n),this.removeListener(yH.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=Uvn.default.dirname(t);return this.watchDirectory(n,r,i,t)}async watchPollingOnce(t,r,i){if(this.isClosed())return;let n=!1,a=new VJc,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 Fp.lang.noop;if(this.pollerExists(t,r))return Fp.lang.noop;let n={...r,interval:r.pollingInterval??URh},a={targetPath:t,options:r},o=()=>{this._pollers.add(a),this.on(yH.CLOSE,c),$Au.default.watchFile(t,n,i)},c=()=>{this._pollers.delete(a),this.removeListener(yH.CLOSE,c),$Au.default.unwatchFile(t,i)};return Fp.lang.attempt(o),()=>Fp.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=Fp.lang.uniq(t).sort(),t.every((a,o)=>t.every((c,d)=>d===o||!Fp.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=Uvn.default.resolve(t),this.isIgnored(t,r.ignore)))return;let n=await Fp.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=Uvn.default.dirname(t);return(await Fp.fs.poll(a,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,i):this.watchUnknownTarget(t,r,i)}}async watch(t,r,i=Fp.lang.noop){if(Fp.lang.isFunction(t))return this.watch([],{},t);if(Fp.lang.isUndefined(t))return this.watch([],r,i);if(Fp.lang.isFunction(r))return this.watch(t,{},r);if(Fp.lang.isUndefined(r))return this.watch(t,{},i);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let n=Fp.lang.castArray(t);n.forEach(a=>this._roots.add(a)),await this.watchPaths(n,r,i),!this.isClosed()&&(i!==Fp.lang.noop&&this.on(yH.ALL,i),r.readdirMap=void 0,this.ready())}},YAu=WJc;TXo();var lsa=require("fs/promises"),rzh=require("os"),izh=ce(require("path"),1),nOB=".fern",aOB="logs";function oOB(){return"cli@3.30.2"}var gJa=class{logFilePath=null;initialized=!1;sessionStartTime;constructor(){this.sessionStartTime=Date.now()}async initialize(){if(this.initialized)return;let t=Ct(Cr.of((0,rzh.homedir)()),Ze.of(nOB)),r=Ct(t,Ze.of(aOB));await ji(r)||await(0,lsa.mkdir)(r,{recursive:!0});let n=`${new Date().toISOString().replace(/[:.]/g,"-")}.debug.log`;this.logFilePath=Ct(r,Ze.of(n));let a=["================================================================================","Fern Docs Dev Debug Log",`Session started: ${new Date().toISOString()}`,`Log file: ${izh.default.basename(this.logFilePath)}`,"================================================================================",""].join(`
|
|
1785
1785
|
`);await(0,lsa.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)+`
|
|
1786
1786
|
`;try{await(0,lsa.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:oOB(),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 yYc=ce(ZJc(),1),$4h=ce(Lmu(),1),fY=require("fs/promises"),Y4h=require("os"),X4h=ce(fG(),1),Z4h=ce(K4h(),1),nPu=process.platform==="win32",hYc=It.cyan("[docs]:"),EjB="etag",SjB=23,J4h=e=>e.padEnd(SjB," "),MjB="preview",DjB="app-preview",BjB="bundle",IjB=".next",CjB="standalone",qjB=".fern",TjB="packages/fern-docs/bundle/.next/server/instrumentation.js",RjB=".npmrc",zjB=".pnpmfile.cjs",NjB="pnpm-workspace.yaml",FjB='Cannot find matching keyid: {"signatures":';function QjB(){return Ct(Cr.of((0,Y4h.homedir)()),Ze.of(qjB))}function Ssa({app:e=!1}){return Ct(QjB(),Ze.of(e?DjB:MjB))}function W$i({app:e=!1}){return Ct(Ssa({app:e}),Ze.of(e?IjB:BjB))}function WJa({app:e=!1}){return Ct(W$i({app:e}),Ze.of(CjB))}function UjB({app:e=!1}){return Ct(WJa({app:e}),Ze.of(TjB))}function LjB({app:e=!1}){return Ct(WJa({app:e}),Ze.of(NjB))}function VjB({app:e=!1}){return Ct(WJa({app:e}),Ze.of(zjB))}function WjB({app:e=!1}){return Ct(WJa({app:e}),Ze.of(RjB))}function Kvn(e){return new Error(`${e}. Please reach out to support@buildwithfern.com.`)}function GjB({app:e=!1}){return Ct(Ssa({app:e}),Ze.of(EjB))}var HjB=`module.exports = {
|
|
1787
1787
|
hooks: {
|